I want to make soft edged water. so i make a render target to hold the depth of the scene, and then i render water geometry.
And let water alpha = ( SceneDepth - WaterDepth ) * Scale
looking at the results of the following chart, the edge of water is softed, but it seem strange, like a ladder.
so how to deal with?
Thanks very much!
I've been working on a similar issue recently.
I use transparency to soften the edges of the water.
In order to utilize the water's depth to determine the alpha value, I use the HLSL smoothstep and clamp functions to return an opacity value between 0.75f and 1.0f:
// colour can be whatever your lighting equations compute
float3 colour = (r, g, b);
if ( SeaDepth <= 0.2f )
discard;
float opacity = clamp(
smoothstep( 0.f, 12.f, SeaDepth ),
.75f, 1.f
);
return float4(colour.xyz, opacity);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With