#SCREEN_UV I think causing text shader to stop working depending on window zoom
1 messages · Page 1 of 1 (latest)
Here is the shader applied to the text:
shader_type canvas_item;
uniform sampler2D back_texture: hint_screen_texture, filter_linear_mipmap;
uniform sampler2D gradient: source_color;
uniform vec4 background_color: source_color;
uniform vec4 shadow_color: source_color;
vec2 rotateUV(vec2 u_v, vec2 center, float angle) {
mat2 rm = mat2(
vec2(cos(angle), -sin(angle)),
vec2(sin(angle), cos(angle))
);
u_v -= center;
u_v = rm * u_v;
u_v += center;
return u_v;
}
void fragment() {
// Called for every pixel the material is visible on.
vec2 rotated_uv = rotateUV(UV, vec2(0.5), PI/2.0);
vec4 back_color = textureLod(back_texture, SCREEN_UV, 0.0);
vec4 gradientTex = texture(gradient, rotated_uv);
if (COLOR == vec4(1.0)) {
COLOR = vec4(0.0);
}
if (distance(back_color, shadow_color) > 0.5){
if (distance(back_color, background_color) > 0.01) {
COLOR.a = distance(background_color, back_color);
COLOR.rgb = gradientTex.rgb;
}
}
and then in gdscript this is what I do to my shader node
shader_node = $Gradient_Shader.duplicate()
shader_node.visible = true
$'.'.add_child(shader_node)
SCREEN_UV I think causing text shader to stop working depending on window zoom
and this is the scene above the word scene
Try setting the local_to_scene property of the material to true.