Conflicting shaders: Changing alpha and reading the screen
Asked Answered
D

3

0

hello!! i'm trying to modify the alpha channel of an on-screen mesh in one shader, and then read the screen and alter it in another shader. when i do this, though, the second shader does not produce the correct effect for the mesh with the first shader.

first shader:

shader_type spatial;

render_mode unshaded;

void fragment() {
	ALBEDO = vec3(1.0f, 0.0f, 0.0f); // red
	ALPHA = 0.5f;                               // make it half-transparent
}

second shader:

shader_type spatial;
render_mode unshaded;

void fragment() {
	ALBEDO = vec3(1.0f, 1.0f, 1.0f);
	ALPHA = 1.0f;
}

here's an image of the problem:

in this case, i'm just trying to make the red-tinted area completely white, like the rest of the screen. am i missing something really simple?

Daven answered 13/2 at 5:2 Comment(0)
H
0

Your render_mode has no flags.
It's THAT simple.
I don't know what you are trying to do, but godot allows for some control over transparent objects, you can do mix, add, multiply, or different types of alpha, and you define this in render_mode.

Hiro answered 13/2 at 5:51 Comment(0)
Y
0

Daven There's no screen reading in your shader code. How is the second shader assigned?

Yalu answered 13/2 at 14:36 Comment(0)
D
0

turns out it was some render order shenanigans lol

Daven answered 13/2 at 21:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.