Added water movement

This commit is contained in:
Eduard Urbach 2024-02-09 16:09:40 +01:00
parent ea7e813546
commit c3812dd54e
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
2 changed files with 9 additions and 3 deletions

View File

@ -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;
}

View File

@ -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")