I need some help with distorting a water quad using a DuDv map. I have been following ThinMatrix's Water tutorials, for the most part successfully. For my particular problem, I followed this tutorial: https://www.youtube.com/watch?v=6B7IF6GOu7s.
Upon using a DuDv map to distort my water quad, all seems fine, except that there is a small problem. There are line seams across the water quad.
The attached image illustrates the issue.
This is my code:
// The coordinates to sample the dudv map with
layout(location = 0) in vec3 vertex;
texCoords = vec2(vertex.x/2.0 + 0.5, vertex.z/2.0 + 0.5) * 0.24; // vertex is a read-in coordinate from a blender exported mesh file
uniform sampler2D waterDuDv;
uniform float in_time;
vec2 distortion = texture(waterDuDv, vec2(texCoords.x + in_time, texCoords.y)).rg * 0.1;
distortion = texCoords + vec2(distortion.x, distortion.y + in_time);
vec2 totalDistortion = (texture(waterDuDv, distortion).rg * 2.0 - 1.0) * 0.02;
// Projectively map the reflection texture
vec2 clipProj = ((clipSpace.xy / clipSpace.w) / 2.0 + 0.5);
clipProj.y *= -1.0f;
// Distort sampled texture with dudv map
clipProj += totalDistortion;
clipProj.x = clamp(clipProj.x, 0.001, 0.999);
clipProj.y = clamp(clipProj.y, -0.999, -0.001);
finalVec = vec4(texture(waterTexture, clipProj).rgb, 1.0); // waterTexture is a Render to Texture reflection image of the scene
If anyone could point out what's wrong or point me in the right direction, I would appreciate it.
Thank you in advance!