summaryrefslogtreecommitdiffstats
path: root/water/Wave.gdshader
diff options
context:
space:
mode:
authordusoleil <howcansocksbereal@gmail.com>2022-09-22 07:18:03 -0400
committerdusoleil <howcansocksbereal@gmail.com>2022-09-22 07:18:03 -0400
commitdf3557dc3b04b1fa2f399ea319d8810f37931035 (patch)
treeb9db26cbeff5ef5ea0079b87fff6f24c2dc4a463 /water/Wave.gdshader
parent12943209f25236a06f0a1c3ddcb62c83f7172827 (diff)
downloadgodot_wildjam_49-df3557dc3b04b1fa2f399ea319d8810f37931035.tar.gz
godot_wildjam_49-df3557dc3b04b1fa2f399ea319d8810f37931035.zip
Only update the time uniform for the shader each frame
Diffstat (limited to 'water/Wave.gdshader')
-rw-r--r--water/Wave.gdshader18
1 files changed, 10 insertions, 8 deletions
diff --git a/water/Wave.gdshader b/water/Wave.gdshader
index ee06fe0..95d064e 100644
--- a/water/Wave.gdshader
+++ b/water/Wave.gdshader
@@ -1,14 +1,17 @@
shader_type spatial;
render_mode cull_disabled, depth_draw_always;
-uniform vec4 wave1 = vec4(0.5,0.5,0.5,1.0);
+uniform vec3 wave1 = vec3(0.5,0.5,0.5);
uniform vec2 wave1_dir = vec2(1.0,0.0);
+uniform float wave1_t = 0.0;
-uniform vec4 wave2 = vec4(0.5,0.5,0.5,1.0);
+uniform vec3 wave2 = vec3(0.5,0.5,0.5);
uniform vec2 wave2_dir = vec2(1.0,0.0);
+uniform float wave2_t = 0.0;
-uniform vec4 wave3 = vec4(0.5,0.5,0.5,1.0);
+uniform vec3 wave3 = vec3(0.5,0.5,0.5);
uniform vec2 wave3_dir = vec2(1.0,0.0);
+uniform float wave3_t = 0.0;
uniform vec4 water_colour: hint_color;
uniform vec4 deep_water_colour : hint_color;
@@ -20,12 +23,11 @@ uniform float refraction_amount = 0.01;
varying float vertex_y;
-vec3 gerstner_wave(vec4 wave, vec2 wave_dir, vec3 pos, inout vec3 tangent, inout vec3 binormal)
+vec3 gerstner_wave(vec3 wave, vec2 wave_dir, float t, vec3 pos, inout vec3 tangent, inout vec3 binormal)
{
float steepness = wave.x;
float k = wave.y;
float a = wave.z;
- float t = wave.w;
vec2 d = normalize(wave_dir);
float f = k * (dot(d,pos.xz) - t);
@@ -60,9 +62,9 @@ void vertex()
vec3 global_vertex = (WORLD_MATRIX * vec4(VERTEX,1.0)).xyz;
TANGENT = vec3(1.0,0.0,0.0);
BINORMAL = vec3(0.0,0.0,1.0);
- VERTEX += gerstner_wave(wave1,wave1_dir,global_vertex,TANGENT,BINORMAL);
- VERTEX += gerstner_wave(wave2,wave2_dir,global_vertex,TANGENT,BINORMAL);
- VERTEX += gerstner_wave(wave3,wave3_dir,global_vertex,TANGENT,BINORMAL);
+ VERTEX += gerstner_wave(wave1,wave1_dir,wave1_t,global_vertex,TANGENT,BINORMAL);
+ VERTEX += gerstner_wave(wave2,wave2_dir,wave2_t,global_vertex,TANGENT,BINORMAL);
+ VERTEX += gerstner_wave(wave3,wave3_dir,wave3_t,global_vertex,TANGENT,BINORMAL);
vertex_y = VERTEX.y;
NORMAL = normalize(cross(BINORMAL,TANGENT));
}