home

[ Ocean Surface And Distance To Camera ]

 

To create a neat ocean shader for shot with scatic camera is easy, but the things are getting tricky when the camera is animated and flies all over the place.

 

If the distance between the point of view and the ocean surface is constant value ( or the change is small ), we can get the desired results easy.
The left image is rendered from camera placed 4 units above the ocean.

 
The same shader, but this time the camera is placed 250 units above the surface. The ocean is not beautiful anymore !
 

To make the things looking nicely again, we need a small workaround.

   
Let's create another oceanShader ( name it BigWaves ). At first sight it looks ugly - especially from close-up. But we dont care so mutch about that, because we need this one only to add better look to our far camera plane frames.
   
The same shader from our camera placed 250 units above the surface. We cant recognize the fractal pattern and this is exactly what we need.
 
Now we need a layeredShader to blend between the outputs of our two oceanShaders.
 

In this simple tutorial i'm using only two oceanShaders, but in most cases you will need more, why that is a good idea to organize their order inside the layeredShader.

The transparency attribute of the BigWave one controls how both shaders will be blended. Most likelly we will need to animate this attribute based on the distance between camera and surface - drivenKeys or expressions are doing good job here.

And here is the first result of this little test.
Click on the left image to get some animated eyecandy.
 

Here is the test scene: oceanSurface.zip

Here is updated scene with added displecement. Because the layeredShader does not operate with displacement maps we need to use blendColors node to mix togather the displacement channels of the oceanShaders. Here is the file: oceanShader_displaced.zip.

Here is a scene designed for high resolution rendering: oceanSurface_highres.zip