Hello again!
I’m trying to apply a DuDv Map effect (distorsions) on my water.
My texture is 512x512 in size.
I’m using the following code:
(Vertex Shader)
out vec2 texCoord0;
void main()...
{
texCoord0 = vec2(position.x / 2.0 + 0.5, position.y / 2.0 + 0.5) * 6.0;
}
(Fragment Shader)
in vec2 texCoord0;
void main()
{
...
vec3 ndc = (clipSpace.xyz / clipSpace.w)/ 2.0 + 0.5;
vec2 reflectTexCoords = vec2(ndc.x, -ndc.y);
vec2 refractTexCoords = vec2(ndc.x, ndc.y);
vec2 distorsion1 = (texture(dudvMap, vec2(texCoord0.x, texCoord0.y)).rg * 2.0 - 1.0) * waveStrength; // waveStrength = 0.02;
refractTexCoords += distorsion1;
reflectTexCoords += distorsion1;
vec4 reflectColor = texture(reflectionTexture, reflectTexCoords);
vec4 refractionColor = texture(refractionTexture, refractTexCoords);
outColor = mix(reflectColor, refractionColor, 0.5);
}
As you can see when I add my distorsion to my reflection and refraction texture coordinates, it seems that something is wrong and can’t figure what, because I get this effect:
Do any of you have any idea how can I fix this? Thanks for your time!