Why do I get lighter colors in Godot 4.0 using the same simple shader?
Asked Answered
P

1

0

First of all: I'm new to shaders, but not new to coding.

I'm porting a "portal effect" prototype, and I'm having different results (in light) in Godot 3.5.1 and Godot 4.0 beta 15.
This portal works like a mirror but using a camera in another place.
This difference is breaking the illusion of "naturally teleport by just walking through a door" and is more like "touch the mirror and get teleported immediately" :S

This is the shader (took it from a youtube video, sorry can't remember the source)

render_mode unshaded;

uniform sampler2D refl_tx;

void fragment() {
	ALBEDO = texture(refl_tx, vec2(SCREEN_UV.x, SCREEN_UV.y)).rgb;
}

I use it as the Material Override in a MeshInstance (PlaneMesh), and for the refl_tx variable I set a SubViewport which has a camera child which has no Environment set.

Render from Godot 3.5.1

Render from Godot 4.0 beta 15

So, is it a bug in new Godot 4.0? If not, how can I solve it?

Thanks!

Pola answered 25/1, 2023 at 14:25 Comment(0)
E
0

refl_tx is in the sRGB color space. Change the line to:
uniform sampler2D refl_tx : source_color
which will convert it to an albedo color.

Emelia answered 28/6, 2023 at 17:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.