![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | akoutsoulelos |
I’m using the low poly water shader to have some water effects in a voxel terrain. I am also using a camera with orthogonal perspective.
The problem is that, when in orthogonal perspective, the water is not visible. After some debuging it was clear that inside the fragment() function the division:
depth = PROJECTION_MATRIX[3][2] / (depth + PROJECTION_MATRIX[2][2]);
results always to 0.0, thus making the ALPHA also 0.0 and the water invisible.
So I do understand that I have to change the projection matrix, but not so clearly what and how.
Do you have any hints?
OK, it seems that the 0.0 value comes from
float depth = texture(DEPTH_TEXTURE, SCREEN_UV).r;
I should check how the DEPTH_TEXTURE is displayed in orthogonal perspective.
akoutsoulelos | 2023-03-22 13:57
Well, after more testing, it seems that indeed the projection matrix is used incorrectly, since it leads to a very big negative depth that exponentiately leads to a negative value that clamps to 0.0, thus giving ALPHA a zero value…
akoutsoulelos | 2023-03-22 22:38