Water Shader does not work ingame only in the editor (Outdated Tutorial?)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PlamAtom

Used code from the following Tutorial:

Result:

Code on Sprite:

tool
extends Sprite

func _ready():
pass

func _process(delta):
zoom_changed()

func zoom_changed():
#material.set_shader_param(“y_zoom”, get_viewport().global_canvas_transform.y.y)
material.set_shader_param(“y_zoom”, get_viewport_transform().get_scale().y)

func _on_Shaderbase_item_rect_changed():
material.set_shader_param(“scale”, scale)

Code on Shader:

shader_type canvas_item;

uniform vec2 scale;
uniform float yzoom;

void fragment() {
float uv_height = SCREEN_PIXEL_SIZE.y / TEXTURE_PIXEL_SIZE.y;
vec2 reflected_screen_uv = vec2(SCREEN_UV.x, SCREEN_UV.y + uv_height *yzoom *scale.y * UV.y *2.0); //
//vec2 reflected_screen_uv = vec2(SCREEN_UV.x, SCREEN_UV.y + uv_height *scale.y * UV.y *2.0);
COLOR = texture(SCREEN_TEXTURE, reflected_screen_uv);
}

Signal connected:

item_rect_changed / Connects with itself

It seems only passing uniform is causing problems. What happens if You comment out whole zoomchanged() in process ?

Inces | 2022-03-10 16:43

I deleted that part but nothing changed…

PlamAtom | 2022-03-10 22:54