Water: distortions
This commit is contained in:
@@ -6,14 +6,21 @@ SAMPLER2D(noiseMap, 1);
|
||||
#if NEW_WATER_SHADER
|
||||
MAIN_PARAMETERS
|
||||
IN(vec4 clipSpace, TEXCOORD0)
|
||||
IN(vec2 textureCoords, TEXCOORD1)
|
||||
MAIN_DECLARATION
|
||||
{
|
||||
// vec2 ndc = gl_FragCoord.xy / viewportSize.xy;
|
||||
vec2 ndc = clipSpace.xy / clipSpace.w / 2.0 + vec2(0.5, 0.5);
|
||||
vec2 reflectionUV = vec2(ndc.x, 1.0 - ndc.y) * 0.5;
|
||||
vec2 refractionUV = vec2(ndc.x, 1.0 - ndc.y) * 0.5 + vec2(0.5, 0.0);
|
||||
vec4 reflectionColour = texture2D(reflectMap, reflectionUV);
|
||||
vec4 refractionColour = texture2D(reflectMap, refractionUV);
|
||||
vec2 distortion1 = texture2D(noiseMap, textureCoords).rg * 2.0 - vec2(1.0, 1.0);
|
||||
vec2 distortion2 = texture2D(noiseMap, textureCoords * 5.0 + vec2(10202.0, 221.0)).rg * 2.0 - vec2(1.0, 1.0);
|
||||
vec2 distortion3 = texture2D(noiseMap, textureCoords * 10.0 + vec2(1302.0, 721.0)).rg * 2.0 - vec2(1.0, 1.0);
|
||||
vec2 reflectionUV = (vec2(ndc.x, 1.0 - ndc.y) + distortion1 * 0.035 + distortion2 * 0.02 + distortion3 * 0.01);
|
||||
vec2 refractionUV = (vec2(ndc.x, 1.0 - ndc.y) + distortion1 * 0.035 + distortion2 * 0.02 + distortion3 * 0.01);
|
||||
reflectionUV.x = clamp(reflectionUV.x, 0.001, 0.999);
|
||||
reflectionUV.y = clamp(reflectionUV.y, 0.001, 0.999);
|
||||
refractionUV.x = clamp(refractionUV.x, 0.001, 0.999);
|
||||
refractionUV.y = clamp(refractionUV.y, 0.001, 0.999);
|
||||
vec4 reflectionColour = texture2D(reflectMap, reflectionUV * 0.5);
|
||||
vec4 refractionColour = texture2D(reflectMap, refractionUV * 0.5 + vec2(0.5, 0.0));
|
||||
gl_FragColor = mix(reflectionColour, refractionColour, 0.5);
|
||||
}
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user