Jump to content

[SOLVED] ObjectWater.getHeight(); doesn't take into account shader falloff.


photo

Recommended Posts

I created an expression that uses ObjectWater.getHeight() to make objects appear to be floating in the water. It looks great up close but at a distance the objects appear above the waterline.

Link to comment

We know the reason, though we cannot find the fix.

 

To elaborate:

This error / or visual bug we have, is to do with the absence of a relationship between the rendered wave falloff  (re:wave_radius  in the shader) versus the actual vertex deformation of the non-rendered wave function called by ObjectWater.getHeight() not having the falloff.

 

(We looked at the shaders but appear to be to stupid to work out the maths to make this correction for the ObjectWater.getHeight() to respect the falloff in the shader)

 

Our question is:

How do we (urgently) compensate for the difference listed above so the the expression using ObjectWater.getHeight() returns the height including the rendered wave falloff?

 

Thanks in advance.

Nat.

Link to comment

ok we managed to compensate for this using linear interpolation

 

float ratio = 1 - ( clamp( abs( length(p-player.getWorldPosition()) ), 0.f, radius ) / radius );
pos.z = (pos.z - water.getHeight()) * ratio;

normal = lerp(vec3(0.f,0.f,1.f),normal,ratio);
Link to comment
  • 2 weeks later...
×
×
  • Create New...