7

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!

water alpha

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
xfxsworld
  • 283
  • 1
  • 10

1 Answers1

1

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);
fishfood
  • 4,092
  • 4
  • 28
  • 35