w a t e r  s h a d e r

Using a combination of renderman shaders and MTOR the following images were produced to recreate a water effect.



 

Sine Wave Displacement Testing
|_________________________________________________________________________________________________<back
A renderman shader was written and applied to a polygonal plane in Maya.  60 frames were rendered in Renderman and also in
Maya MTOR.  Notice that in Maya the settings will have to be modifide to get the same level of detail that you can accomplish
within renderman.

 

 
PRMAN:

Maya MTOR:

 



Shader Settings in Maya MTOR:
Using the lerp function the frequency of the waves was animated.

Shader Code:

displacement
basic_wave(float Km = -0.3,
sfreq = 1,
tfreq = 1,
phase = 1,
offset = 0,
turb = .3 )
{
float hump = 0;
normal n;

n = normalize(N);

float waviness = noise(P) * turb;
hump = sin((s + phase + waviness) * 2 * PI * sfreq) + offset;

/*hump = hump + sin((t + phase) * 2 * PI * tfreq) + offset;*/

P = P - n * hump * Km;

N = calculatenormal(P);
}

 

 

Adding More Detail - Rendered in Maya MTOR
|__________________________________________________________________________________________________^top
Lights were added along with the modification of the shader to add multiple levels of detail in the ripples of the water.
 Additionally, two separate coordinate systems are used to generate movement through the water.
To Do: I am still troubleshooting the flashes of light that appear on the surface.....

 


Adding multiple levels of noise



Adding a glass shader and animating the coordinate systems

 

Modifying Lighting and Fixing Errors:
I had to recreate the original plane because it was causing the light artifacts that you see in the above version.

 

Shader Settings in Maya:
The lerp function was used to modify the frequency of the waves
and the movement of the sine curve.  Two separate coordinate systems
were used to effect the movement of the turbulence and waves
over time .

 

Shader Code

#include "H:/rman/shaders/wave/getWaveHt.h"

displacement
basic_wave(float 
	Km = -0.3,		/* height of the entire wave */
	tKm = 1, 		/* height of the turb ONLY */
	wKm = 1,		/* height of the wave ONLY */
	sfreq = 1,		/* number of waves in the s direction */
	phase01 = 1,	/* movement of the wave in the s dir */
	phase02 = 1,
	offset = 0,		
	waviness = .3, 	/* curviness of the crest of the wave */	
	nfreq = 3,		/* freq of the turb */
	detail = 3;		/* richness of the details of the turb */
string	wavesys = "object",
	turbsys = "object")		
{
float	hump = 0;
normal	n;
point	pp = transform(wavesys, P);
point	ppp = transform(turbsys, P);


n = normalize(N);


hump = getWaveHt(pp, s, sfreq, phase01, waviness) * wKm;
hump = hump + turbulence(ppp, detail, nfreq) * tKm;

P = P - n * hump * Km;


N = calculatenormal(P);
}

View Final Water Shader :
A high resolution 150 frame movie and explanation of final shader.
 
  |__________________________________________________________________________________________________^top