Step 1

 

Create a plain polygon or a nurbs plain surface

Step 2

 

In order to create a wave like pattern, we can use the sin or cos function., these are the closest functions to a repeating wave pattern. the function depends on the s and t values. It can be written as such:

 

hump = sin((s)*2*PI*freq)*amp;

 

Where hump is the amount of displacement and ferq and amp, declared variables that will be controllable after importing the shader in SLIM.

Step 3

 

If we use the same function we used above and add the same variables to the t value we get the following result

 

float wave = amp * (sin(s*freq));
float wiggle =namp * (sin(t*nfreq));

hump = wave + wiggle;

Step 4

 

At this stage we can animate the waves using the lerp function but the sin and cos functions are too regular to give a realistic water effect. In order to remove the pattern like effect, we can use the noise function. But we can't use s and t since the noise function requires 3 parameters and since we want more control over the waves. Instead, we will assign a parenting string. This will allow us to create a renderman coordinate system and get full control over speed and velocity with 2 layers of control.

 

string parent = "object";

point pp = transform (parent, P);

float wave = amp * (noise(pp*freq));

 

 

Step 5

 

Now that the concept is there, we can add as many layers as we want but sometimes less is more so I've restricted myself to 3 layers and added a phase variable and a plastic shader , here's the result

 

float wave = amp * (noise(pp*freq));
float wiggle = phase + noise(w*wfreq)*wamp;
float micro = microamp * cos(noise(ss*microfreq));

 

hump = wave + wiggle + micro;

Step 6

 

At this stage the waves are done and are animatable, now a texture is needed. I did this texture in photoshop and made it a bit dark since it is a night scene. After applying the texture I created a renderman coordinate system for the texture and attached it to the shader so that I can move the texture along the displacement. Here's what it looks like with the texture applied.

Step 7

 

To apply a reflection map it's always good to have a reference map to know exactly what is going to show on the surface. I've created this map with different colors and numbering. Then I've selected the appropriate angle for the final rendering and removed the displacement to get a clear view of the reflection map. I've rendered the image to see the map portion that will show and that was the result. I've added a sphere in the background as well and applied a texture to it.

Step 8

 

Using the reference we had we can create a texture without worrying too much about the whole region but only the part that is showing in the reflection. Now since I've used a plane with no displacement to see the reference, I have to make my region larger because once displaced, the reflection will show more of the texture. I've colored the rest of the texture with an intermediate sky color to stay on the safe side in case some parts get displaced more than the usual and end up reflecting other parts of the map.

Step 9

 

The rest is tweaking the animation and adding a few details. I've added the moon to give a sense of what's going on because there is a highlight from the light source and the scene was not convincing. After adding the moon I added a glow effect by duplicating the sphere that the moon is made of and applying a blinn shader and assigning a facing_forward to the opacity. That's it.

s h a d e r  w r i t i n g:     w a t e r


The purpose of this project was to write a displacement shader, using Pixar's Shading Language, that when applied to rigid square polygon would give the illusion of water in motion. This assignment emphasises the use of procedural shading techniques to generate visual complexity.



final render with reflection map. Double click to play

 

 

Process

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Previous tests

 

 

 

first attempt to get the speed right

(double-click to play)

 

 

 

second attempt for the small waves

 

 

 

third attempt with fixed small waves