The Wave Displacement project has to do with the creation of creating a realistic water by using a displacement shader. The difficulties of the project will come from trying to keep the waves from being patternistic (if that's really a word). I am not trying to create a flag but rather an orangic free moving animation.



The First step has to do with creating a sine wave. This look something like:

float s_shift = s +offset

s_shift refers to the waves moving along the s value and offset will be a user controled number for where the wave is at any given time.
This paired with

hump = (sin(s_shift * 2 * PI * number_of_waves)

Hump represents our bump.. bump would have been used if it wasn't already taken.. and we'll call number_of_waves "num_waves" for short.
Now let's add some randomness to the wave.

 

I added:

s_shift = s_shift + noise(pp * 5) * 0.05

I also lowerd the Km value from 0.1 to 0.03 to lower the waves



So things are beginning to roll on this shader. My next step was to add a second wave. I created new arguements bum_waves (the number of waves of the second wave) and boffset (the offset for the second wave). I then created a new s_shift I called this one a_shift.

a_shift = ((s + boffset) + (s + boffset) +
(t + boffset)) / 3

This is to make the wave come in at a different angle. now:

hump = hump + (sin(a_shift * 2 * PI * bum_waves)

Now that's starting to look good... In case you lost here's my full script. Also you're going to want to lower the Km agian since you're adding the waves together. I put it back down to 0.01

Cool now let's animate it by setting up a .rib then a .key. To get the waves moving I will be changing the offset and boffset. I'm also going to animate things like num_waves slightly so it looks like the waves disapate.
.




So I tweak my numbers some more and this is my new result. It's starting to look much better than it did above. Also it should be noted that I forgot to mention the pp1 and the pp2. I created a string argument called spacename this is used so I can offset the wave so it doesn't repeat itself. It should be noted that I also created another for my second wave. Next I am going to attempt to put froth on my waves.


I hope to accomplish this by telling my shader to be a different color based it's height. This seems like this will be good but we need to add a smoothstep. Playing with the values will be the hard part. It's been tough to get it looking right. I think I will ignore it for now and move onto creating an enviroment map for my waves.

This really helps the waves start to look really good. First let's get a texture file I choose a simple sky pattern I got online. I used a simple command in my terminal window to turn the jpeg into a tex file. Then it was a simple input of an argument to create a texture map and a few lines of code to make it work.

A placement a tranlation in my rib file to get it in the right spot and that's all she wrote. The wave displacement shader. I think the next step would be to try and get something bobbing in the wave or make color shift move throughout the waves. My criticism for myself is that I couldn't get the seafoam to look good. Perhaps though my waves were moving to slowly and I wouldn't have been able to accomplish this anyways. I also wish I would have found a way to make the code easier to change and alter. There were too many steps if I wanted to make a slight change... Perhaps this will be the next thing I fix but for now it's onto Mental Ray. I thought for fun I put up another water project I did. This is a particle sim done in Houdini.

contact@joshwood.net