Spent a few lunchbreaks looking at improving the intersection – I’m not 100% happy with it, still, but its better.
I’ve simply world-space-projected (with asymmetric triplanar blending) the foam texture (which is still a temporary one) across the rocks, based on a z-depth and height-based masking function to allow me to reproject the foam texture on to the rocks, too.
This will also feed into a better cascading-foam technique I want to put on the rocks at a later date.
I’ve also replicated the Gerstner wave functions into C#, with a dampener and offset. This means I can start to make things look like they’re floating on the water.
I need to refactor some of the code – I’m currently duplicating a lot of the wave values, so changing them means I have to change the values in many places. I’ll make these static soon to make my life easier.
I’ve also fixed transparency by using two passes for the water the writes to the depth buffer. Less efficient as I’m now duplicating the Gerstner waves in the shader, but there’s no other easy way I’ve yet found around this.
- Using INTERNAL_DATA in surface shaders, with worldNormals is a pain. You have to set your o.Normal first, then call float3 worldNormal = WorldNormalVector(IN, o.Normal); for things to work. This isn’t well-documented
- Although you can query _Time property in C#, so your scripts match up – you don’t get the value every frame. This is a problem – instead I used _Time.y (for CG) and Time.timeSinceLevelLoad (for C#) as the timers seem to be concurrent.
- Depth testing on transparent objects is hard – to do efficiently anyway.
Splashes got delayed, but they’re next on the list. Unfortunately, I’m at the gym all next week on my Physio’s orders to help fix my neck, so may not get updates next week.