From c3812dd54e60762408e7479b79562df46150c6ba Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Fri, 9 Feb 2024 16:09:40 +0100 Subject: [PATCH] Added water movement --- client/world/water/Water.gdshader | 6 +++++- client/world/water/Water.tres | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/client/world/water/Water.gdshader b/client/world/water/Water.gdshader index 3494fe3..daff1be 100644 --- a/client/world/water/Water.gdshader +++ b/client/world/water/Water.gdshader @@ -1,6 +1,7 @@ shader_type spatial; render_mode cull_disabled; render_mode specular_toon; +// render_mode shadows_disabled; // render_mode wireframe; uniform vec3 color : source_color = vec3(0.055, 0.286, 0.62); @@ -11,6 +12,8 @@ uniform sampler2D height_map; uniform sampler2D normal_map; uniform float height_scale = 0.0; uniform float noise_scale = 0.5; +uniform vec2 wave_direction = vec2(1.0, 1.0); +uniform float time_scale : hint_range(0.0, 1.0) = 0.1; varying vec2 noise_position; @@ -19,7 +22,8 @@ float get_fresnel(float power, vec3 normal, vec3 view) { } void vertex() { - noise_position = VERTEX.xz * noise_scale + 0.5; + vec2 wave = TIME * time_scale * wave_direction; + noise_position = (wave + VERTEX.xz) * noise_scale + 0.5; float height = texture(height_map, noise_position).x - 0.5; VERTEX.y += height * height_scale; } diff --git a/client/world/water/Water.tres b/client/world/water/Water.tres index 98ea1a0..16510aa 100644 --- a/client/world/water/Water.tres +++ b/client/world/water/Water.tres @@ -21,11 +21,13 @@ noise = SubResource("FastNoiseLite_d0hd3") [resource] render_priority = 0 shader = ExtResource("1_uj7oj") -shader_parameter/color = Color(0.054902, 0.286275, 0.619608, 1) -shader_parameter/fresnel_color = Color(0.141176, 0.447059, 0.901961, 1) +shader_parameter/color = Color(0.055, 0.286, 0.62, 1) +shader_parameter/fresnel_color = Color(0.141, 0.447, 0.902, 1) shader_parameter/fresnel_reduction = 5.0 shader_parameter/roughness = 0.02 shader_parameter/height_scale = 0.0 shader_parameter/noise_scale = 0.5 +shader_parameter/wave_direction = Vector2(1, 1) +shader_parameter/time_scale = 0.1 shader_parameter/height_map = SubResource("NoiseTexture2D_7t3c8") shader_parameter/normal_map = SubResource("NoiseTexture2D_rcc52")