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 shader with multiple texture parameters fails. #20033

Closed
pgregory opened this issue Jul 8, 2018 · 5 comments
Closed

GLES2 shader with multiple texture parameters fails. #20033

pgregory opened this issue Jul 8, 2018 · 5 comments

Comments

@pgregory
Copy link

pgregory commented Jul 8, 2018

Godot version:
Custom Build @ c45a8a5 on the GLES2 fork https://github.com/karroffel/godot/tree/gles2. Also shown to be an issue on the official master @ 02372bf

OS/device including version:
Macbook Pro, macOS 10.13.6 Beta (17G62a)

Issue description:
I have a simple shader that mixes the alpha channel from 4 additional sampler2D parameters, and uses that as the alpha for the final colour which comes from the primary TEXTURE. On GLES3 this works fine and masks off the primary texture as expected, on GLES2 the alpha seems to come back as 0 all the time. Oddly, if I change the mask generation line to:

float alpha = (texture(mask_texture_ul, UV).r + texture(mask_texture_ur, UV).r + texture(mask_texture_ll, UV).r + texture(mask_texture_lr, UV).r);

and the colour calculation to:

COLOR = vec4(1, 0, 0, alpha);

I get an image, but it looks like it's getting the alpha from the primary TEXTURE sampler, not the specified additional ones, as it shows the animated water as the alpha.

Steps to reproduce:

  1. Load the attached project.
  2. You can see the sprite is completely invisible, the blue-ish square is the collision shape.
  3. Change the renderer in Project-->Project Settings-->Rendering:Quality to GLES3, save and close.
  4. Re-open with the same project and you'll see that in GLES3 the result is as expected, with parts of the water masked off.
  5. Switch back to GLES2, save & close, and reload.
  6. Change the shader as described in the description, to see that it appears to be getting the alpha from the primary channel, and moreover, seems to dislike the 'a' member of the colour.

For reference, I see the following errors printed to the shell when making any changes, successful or otherwise, to the shader:

type is: canvas_item
ERROR: complete: Failed to parse shader
   At: servers/visual/shader_language.cpp:4128.
ERROR: _code_complete_script: Shaderlang complete failed
   At: editor/plugins/shader_editor_plugin.cpp:196.

Minimal reproduction project:
gles2_shader_issue.zip

@karroffel
Copy link
Contributor

Using specific commits on my fork is a bit of a problem, since I rebase regularly and the latest changes are all applied on top. Can you try the latest version of the fork?

@pgregory
Copy link
Author

pgregory commented Jul 8, 2018

Sorry, my mistake, I thought I'd checked out the branch, turns out I was building master. Rebuilding the gles2 branch now, will report status momentarily.

@pgregory
Copy link
Author

pgregory commented Jul 8, 2018

Unfortunately, can't seem to build the latest one on macOS.

[ 52%] Compiling ==> drivers/gles2/rasterizer_scene_gles2.cpp
drivers/gles2/rasterizer_scene_gles2.cpp:630:45: error: expected expression
        light_instance->shadow_transform[p_pass] = {
                                                   ^
1 error generated.
scons: *** [drivers/gles2/rasterizer_scene_gles2.osx.tools.64.o] Error 1
scons: building terminated because of errors.

@karroffel
Copy link
Contributor

@pgregory oh okay, I fixed the error and pushed to my fork. Can you test again?

@pgregory
Copy link
Author

pgregory commented Jul 8, 2018

@karroffel Confirmed, latest code on the gles2 branch works fine for both GLES3 and GLES2 with this technique. Thanks.

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

No branches or pull requests

2 participants