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

OpenGL: Shader render mode blend_mul not working correctly in (and alpha effecting blend modes that shouldn't use alpha) #72873

Open
Tracked by #66458
TheRektafire opened this issue Feb 8, 2023 · 1 comment

Comments

@TheRektafire
Copy link

TheRektafire commented Feb 8, 2023

Godot version

4.0 beta 17

System information

Windows 10, gl_compatibility, Intel UHD 600

Issue description

I was working on a basic water caustic shader that I wanted to apply as sort of an overlay on top of other geometry under the water, and for it I wanted to use blend_mul to brighten up the parts of the surface the caustics are effecting, and since I'm using the same device from issue #43891 I also wanted to use the gl_compatibility renderer since it would provide the best performance for me. But my shader doesn't seem to work correctly in the compatibility renderer, only in mobile and forward+. In those two it looks as expected, but in gl_compatibility it looks completely white.

Example of the shader in forward+/mobile:
Untitled_073828

Example of the shader in gl_compatibility:
Untitledb_073830

Not only that, but setting ALPHA in the shader effects the outcome as well which I wouldn't really expect for multiply blending. If I set the ALPHA to basically any value the effect just doesn't work, as you can see here
Untitledc_073832

Here is the shader code itself

shader_type spatial;
render_mode blend_mul;

uniform sampler2D layer1;
uniform sampler2D layer2;

uniform float s1; uniform float s2; //layer shift speeds
uniform vec2 d1; uniform vec2 d2; //layer shift directions

void fragment() {
	// Place fragment code here.
	vec2 l1offset = UV + (normalize(d1) * (TIME * s1));
	vec2 l2offset = UV + (normalize(d2) * (TIME * s2));
	vec3 l1p = texture(layer1, l1offset).rgb;
	vec3 l2p = texture(layer2, l2offset).rgb;
	
	ALBEDO = min(l1p, l2p);
	ALBEDO = ALBEDO + vec3(1.0);
	//ALPHA = 0.5;
}

FWIW I think this might have something to do with the difference between 3.x and 4.0 fragment representation as discussed in #66978 but I'm not sure

Steps to reproduce

  1. Open example project
  2. Open testing.tscn
  3. Set renderer to compatibility

Minimal reproduction project

blendmul_073824.zip

@clayjohn
Copy link
Member

clayjohn commented Feb 8, 2023

Related to #72488

@clayjohn clayjohn added this to the 4.x milestone Feb 8, 2023
@Calinou Calinou changed the title (Godot 4 beta 17) Shader render mode blend_mul not working correctly in gl_compatibility renderer (and alpha effecting blend modes that shouldn't use alpha) OpenGL: Shader render mode blend_mul not working correctly in (and alpha effecting blend modes that shouldn't use alpha) Feb 8, 2023
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