Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLES2 Error with custom shader code for fade in effect #24084

Closed
Tobi-La opened this issue Nov 30, 2018 · 1 comment · Fixed by #24089
Closed

GLES2 Error with custom shader code for fade in effect #24084

Tobi-La opened this issue Nov 30, 2018 · 1 comment · Fixed by #24089

Comments

@Tobi-La
Copy link

Tobi-La commented Nov 30, 2018

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

@clayjohn
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants