Low poly water shader with orthogonal perspective
Asked Answered
R

2

0

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?

Godot 3.5

Rosabelle answered 22/3, 2023 at 10:31 Comment(0)
R
0

Rosabelle
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.

Rosabelle answered 22/3, 2023 at 13:57 Comment(0)
R
0

Rosabelle 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...

Rosabelle answered 22/3, 2023 at 22:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.