Godot: GLES2 Error with custom shader code for fade in effect

Created on 30 Nov 2018  ·  1Comment  ·  Source: godotengine/godot

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
gles3

And here is how it looks on GLES2
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

bug rendering

Most helpful comment

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.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SleepProgger picture SleepProgger  ·  3Comments

ndee85 picture ndee85  ·  3Comments

bojidar-bg picture bojidar-bg  ·  3Comments

RebelliousX picture RebelliousX  ·  3Comments

nunodonato picture nunodonato  ·  3Comments