diff --git a/assets/fs/shaders/lava.f.glsl b/assets/fs/shaders/lava.f.glsl index 12ca677..ba4ef8c 100644 --- a/assets/fs/shaders/lava.f.glsl +++ b/assets/fs/shaders/lava.f.glsl @@ -1,9 +1,11 @@ uniform sampler2D tex; +uniform float shift; varying vec2 tex_coord_i; void main(void) { - gl_FragColor = texture2D(tex, tex_coord_i); + vec2 tex_coord = vec2(tex_coord_i.s + shift, tex_coord_i.t); + gl_FragColor = texture2D(tex, tex_coord); } diff --git a/src/client/Client-gl.cc b/src/client/Client-gl.cc index 02e04bf..4a06287 100644 --- a/src/client/Client-gl.cc +++ b/src/client/Client-gl.cc @@ -119,7 +119,8 @@ bool Client::initgl() const char *lava_uniforms[] = { "projection", "modelview", - "tex" + "tex", + "shift" }; const char *obj_v_source = (const char *) CFS.get_file("shaders/obj.v.glsl", NULL); @@ -473,7 +474,11 @@ void Client::draw_lava() glEnableVertexAttribArray(1); m_projection.to_uniform(m_lava_program.uniform("projection")); m_lava_texture.bind(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glUniform1i(m_lava_program.uniform("tex"), 0); + double shift = m_clock.getElapsedTime().asSeconds() / 40; + glUniform1f(m_lava_program.uniform("shift"), shift); const int n_lavas = 2 * SKY_DIST / LAVA_SIZE; glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), NULL);