Ocean Update #5

I wanted to find a way to do better intersection than I was getting through depth testing. I decided to look at rendering out the rocks to a buffer, from a top-down, orthographic camera sitting just above the water surface. It would simply render out the rocks as a mask to a RenderTexture, which I could then blur to give me a nice mask texture around the rocks.

This meant the scene needed some more work (and if I ever release this formally, I’ll need some further scripts to make it usable for others), setting up the camera, getting out a sane render I could use, etc. 

This worked remarkably well, and means I can switch off/on outline on any object just by adding it to a render layer that the ortho camera sees. It also meant I could use this to drive the wave position offset of waves around the rocks a bit – this really helped the outlying rocks, as when waves pass through the rocks, it looks wrong…

See how the waves intersect poorly
See how the waves intersect much more nicely

I also added in refraction and fog, using the methods described in catlikecoding’s blog. I tweaked the fog calculation slightly as the depth fog was calculating based on distance between surface and background, I also need this to fog out at a general distance to camera. Its not a final implementation yet, but it works for now.

Oh, I implemented the “wet surface” shader seen an in earlier blog post – minus the rain water buildup and ripples – just to make use of the porosity and smoothness controls for now.

Next I plan on spray/splashes, followed by an adjustment to the wet surface shader to support water running down after a wave hit – for this I’ll need some triplanar projection – I’ve already got some shaders I’ve created to help for that, so I’ll possibly blog about those separately.

Leave a Reply

Your email address will not be published. Required fields are marked *