summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scene.cpp4
-rw-r--r--shaders/water_fragment.glsl3
2 files changed, 6 insertions, 1 deletions
diff --git a/scene.cpp b/scene.cpp
index 491ec67..e981295 100644
--- a/scene.cpp
+++ b/scene.cpp
@@ -440,6 +440,10 @@ void Scene::render() {
chunk_pos = glGetUniformLocation(water_program.get_program(), "chunk_pos");
player_pos = glGetUniformLocation(water_program.get_program(), "player_pos");
glUniform3f(player_pos, pos.x, pos.y, pos.z);
+ GLint t_pos = glGetUniformLocation(water_program.get_program(), "t");
+ static float t = 0.0;
+ t += 0.00002 * steps;
+ glUniform1f(t_pos, t);
for(std::list<Terrain::Chunk*>::iterator it = terrain->chunks.begin(); it != terrain->chunks.end(); it++) {
Terrain::Chunk *chunk = *it;
diff --git a/shaders/water_fragment.glsl b/shaders/water_fragment.glsl
index 857a500..150f071 100644
--- a/shaders/water_fragment.glsl
+++ b/shaders/water_fragment.glsl
@@ -3,9 +3,10 @@
varying vec3 pos;
uniform vec3 player_pos;
uniform sampler2D tex;
+uniform float t;
void main() {
- gl_FragColor = texture2D(tex, gl_TexCoord[0].st) - vec4(.2, .2, 0, 0);
+ gl_FragColor = texture2D(tex, gl_TexCoord[0].st + vec2(t, t)) - vec4(.2, .2, 0, 0);
gl_FragColor = mix(gl_FragColor, gl_Fog.color, pow(length(player_pos - pos)/100, 5));
gl_FragColor.a = 0.7;
}