By P Web Design Company



RenderMan - Light Shader

Water Caustics

Caustics is when light shines through a reflected or refracted object and thus casting bright light rays on the surfaces surrounding the object. In this assignment we were able to mimic the animation of water caustics with the use of a custom Light Shader. We will have control over the width, amplitude, and frequency attributes of the caustics as it animates over time in an underwater environment.

Reference and Reserach

water-caustics

fish caustics

In looking at images of water caustics we can tell that the brightness of the caustics is not consistant throughout. There are some areas that are not as bright as other and it varies. The pattern of the caustics form almost a circular shape.

Custom Light Shader

Coding the Interface for the Caustics Shader

light
caustics(float intensity = 1;
color lightcolor = (0.0,0.6,1.0);
color whitepoint = (1,1,1);
color contrast = 2;
color waterlevel = 0;
color maxdepth = 20;
string shadowname = "[passinfo [subst $OBJNAME]_DeepShadow filename]"; // assigns a default value to save the lighter time in entering a TCL expression in the "shadowname" parameter
float width = 1;
float samples = 16;
float freq = 1;
float amp = 0.1;
float xshift = 0;
float yshift = 0;
float zshift = 0;
)
{
vector direction = vector "shader"(0,0,1);
solar(direction, 0.0) {

point ps = Ps + vector(xshift,yshift,zshift);
float ns = abs(noise(transform("shader",ps) + freq) - 0.5);

// The contrast will depend on the distance from the micro-polygon to the top of the water. The
// water is in world-space so we must convert "Ps" to world-space in order to figure out how depth
// below the suface of the water

point p = transform ("world", Ps);
float depth = abs(p[1] + waterlevel;
float depthFactor = depth/maxdepth;

ns = ns * contrast;

// invert the values
ns = 1 - ns;

// increase the contrast
ns = ns * ns * ns * ns

// re-define the black as a light gray
float grayness = 0.3;
ns = ns + grayness;

float blochy = ns;//+ amp;

// ramp color
color causticcolor = mix(lightcolor, whitepoint, blochy);
Cl = intensity * causticcolor * blochy);

// Attenuate the output light color by the value
// returned from a shadow (texture) map

if(shadowname != "")<br /> <span class="style4">Cl *= 1 <span class="style7">shadow(shadowname, <span class="style4">Ps, "samples", samples, "width", width);<br /> }<br /> }</p>

Caustics Test Render

Maya Settings

After coding our shader we can then bring it into maya and test how it works then make any necessary adjustments in order to get it took look better. Once in Maya we will need to create a light, for the purpose of this assignment we will use a Directional Light and apply the shader to it.

 

 

shader maya

Final Thoughts

In conclusion, Light Shaders are a very powerful and effective way of creating one shader that has a lot of control. It is usefull and saves on rendering time because it only uses one file to create the look of caustics. Whereas if you were to generate caustics through a series of maps it takes up a lot of space to store all the information and will take longer for the renderer to read in a different file every frame. As a result of using a light shader it gives the user control over a variety of parameters and time saving.

connect
- - - - - - - - - - - - - - - - - - -

linkedin twitter flickr

- - - - - - - - - - - - - - - - - - -