Skip to content
Snippets Groups Projects
Commit 31c2d495 authored by Fabian Keßler's avatar Fabian Keßler
Browse files

Enhance water

parent 4e6edc22
No related branches found
No related tags found
No related merge requests found
......@@ -34,9 +34,9 @@ script = ExtResource("1_ij3xc")
[node name="Water" parent="." instance=ExtResource("2_hycu0")]
offset_left = -160.0
offset_top = -145.0
offset_right = 1752.0
offset_bottom = 979.0
scale = Vector2(0.8, 0.8)
offset_right = 522.0
offset_bottom = 302.0
scale = Vector2(2, 2)
[node name="IceFloe" parent="." instance=ExtResource("2_ij3xc")]
position = Vector2(559, 304)
......
shader_type canvas_item;
uniform vec2 center = vec2(50.0, 50.0); // Set this to your polygon's center in local space.
uniform float amplitude : hint_range(0.0, 1.0) = 0.1;
uniform float frequency = 1.0;
uniform float tile_factor = 10.0;
uniform float aspect_ratio = 0.5;
void vertex() {
// Translate vertex position so the center is at (0, 0).
vec2 pos = VERTEX - center;
uniform vec2 time_factor = vec2(2.0, 3.0);
uniform vec2 offset_factor = vec2(5.0, 2.0);
uniform vec2 amplitude = vec2(0.05, 0.05);
// Compute the angle of the vertex relative to the center.
// This angle will be used to offset the sine wave phase.
float angle = atan(pos.y, pos.x);
void fragment() {
vec2 tiled_uvs = UV * tile_factor;
tiled_uvs.y *= aspect_ratio;
vec2 wave_uv_offset;
wave_uv_offset.x += sin(TIME * time_factor.x + (tiled_uvs.x + tiled_uvs.y) * offset_factor.x);
wave_uv_offset.y += cos(TIME * time_factor.y + (tiled_uvs.x + tiled_uvs.y) * offset_factor.y);
// Create a sine wave where each vertex is offset by its angle.
// You can adjust the formula as desired.
float wave = sin(TIME * frequency - angle);
COLOR = texture(TEXTURE, tiled_uvs + wave_uv_offset * amplitude);
// Use the wave value to scale the vertex's distance from the center.
pos *= 1.0 + amplitude * wave;
// Move the vertex back to the original coordinate space.
VERTEX = pos + center;
}
}
\ No newline at end of file
......@@ -5,9 +5,11 @@
[sub_resource type="ShaderMaterial" id="ShaderMaterial_doghl"]
shader = ExtResource("1_wjap7")
shader_parameter/center = Vector2(50, 50)
shader_parameter/amplitude = 0.005
shader_parameter/frequency = 2.0
shader_parameter/tile_factor = 7.51
shader_parameter/aspect_ratio = 0.975
shader_parameter/time_factor = Vector2(1, 1.5)
shader_parameter/offset_factor = Vector2(2.5, 1)
shader_parameter/amplitude = Vector2(0.05, 0.05)
[node name="Water" type="TextureRect"]
material = SubResource("ShaderMaterial_doghl")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment