Godot version:
v3.1.alpha.calinou.5b8dde4
OS/device including version:
Windows 10 and Android devices tested
Issue description:
I have written a custom shader code, which basically makes the object fade out at a given clip_height. It can be used to just render the bottom 50% of an object and so on. It works on GLES3, but not on GLES2.
I have created an example project to make the issue clear.
Here is how it looks on GLES3
And here is how it looks on GLES2
Steps to reproduce:
I was able to break down the problem to basically these two lines of shader code:
vec4 world_vertex = camera_matrix * vec4(VERTEX, 1.0);
ALPHA = smoothstep(1, 0, (world_vertex.y - clip_height)/fade_offset);
The camera Matrix is passed from the vertex shader. Unfortunately, I have no idea how to further investigate what exactly is causing the error.
Minimal reproduction project:
AlphaIssue.zip
Good catch! I found the bug. It is an issue with the gles2 shader compiler. It swaps INV_CAMERA_MATRIX
and CAMERA_MATRIX
in the user defined code. Ill submit a PR to fix this in a few minutes. In the meantime, use INV_CAMERA_MATRIX
in the fragment function if you want to use CAMERA_MATRIX
.
Most helpful comment
Good catch! I found the bug. It is an issue with the gles2 shader compiler. It swaps
INV_CAMERA_MATRIX
andCAMERA_MATRIX
in the user defined code. Ill submit a PR to fix this in a few minutes. In the meantime, useINV_CAMERA_MATRIX
in the fragment function if you want to useCAMERA_MATRIX
.