Maya Shader Animation



(The only element not created in Maya was the black silhouetted figure)









Project Overview

Coding the shading network was a new challenge that was an overwhelming process initially that required some practice for the shader to work appropriately but became intuitive in time.






shader wavelock(color fcolor = color(1,0,0),
                color fcolor2 = color(1,1,1),
                    float frequency = 2,
                    float amptitude = .25,
                    float offset = 3,
                    float pi= 3.14,
                    float mid= 0.5,
                    float u_cutoff=.5,
                    float toggle = 0,
                    float radius = .5,
                    string spacename = "world",    
                    float s = 0 [[int lockgeom = 0]],
                    float t = 0 [[int lockgeom = 0]],
                    output color resultRGB = 0,
                    output float Pres = 1)
{
point p = transform(spacename, P);
point origin = point (0, 0, 0);
  
float dist = distance(p, origin);
if(dist <= radius) {
    Pres = (toggle == 0) ? 1 : 0;
    }
else
    {
    Pres = (toggle == 0) ? 0 : 1;
    }
  
if (s >= mid + sin (frequency * pi * t + offset) * amptitude) {
    resultRGB = fcolor;
    }
else
    {
    resultRGB = fcolor2;
    }
  
}




shader ripple(color fcolor = color(1,0,0),
              color fcolor2 = color(1,1,1),
              //color fcolor3 = color(1,1,1),     
                float radius = .2,
                //float radius2 = .1, 
                float s = 0 [[int lockgeom = 0]],
                float t = 0 [[int lockgeom = 0]],
                output color resultRGB = 0,
                output float Pres=1)
{
if (((s - .5) * (s - .5) + (t - .5) * (t - .5)) <= radius) {
    resultRGB=fcolor;
    Pres=1;
    }
else
    {
    resultRGB = fcolor2;
    Pres = 0;
    }
}




shader circle2(color fcolor = color(1,0,0),
               color fcolor2 = color(1,1,1),    
                float radius = .2, 
                float s = 0 [[int lockgeom = 0]],
                float t = 0 [[int lockgeom = 0]],
                output color resultRGB = 0)
{
if (((s - .5) * (s - .5) + (t - .5) * (t - .5)) <= radius) {
    resultRGB=fcolor;
    }
else
    {
    resultRGB= fcolor2;
    }
}


Challenges of the Project



The largest difficulty was trying to accomplish a combination of shader effects in one shader. I wanted to have a sin wave that would move across an object while have the presence of the object dictated by a coordinate system. With the help of some of the other students in the class with allowing me to see the two separate shaders working by themselves I was able to create my desired effect while keeping everything in one .osl. Timing the expanding circle at the end was also a little tricky but that was more of a time consuming process rather than a technical problem.