Better water
This commit is contained in:
@@ -4,21 +4,29 @@ OGRE_NATIVE_GLSL_VERSION_DIRECTIVE
|
||||
SAMPLER2D(reflectMap, 0);
|
||||
// SAMPLER2D(refractMap, 1);
|
||||
OGRE_UNIFORMS(
|
||||
uniform float renderTargetFlipping;
|
||||
uniform vec4 viewportSize;
|
||||
uniform f32vec4 cameraPosition;
|
||||
)
|
||||
MAIN_PARAMETERS
|
||||
IN(highp vec4 projectionCoord, TEXCOORD4)
|
||||
IN(f32vec3 positionWS, TEXCOORD7)
|
||||
IN(f32vec3 positionWS, TEXCOORD0)
|
||||
IN(f32vec3 vnormal, TEXCOORD1)
|
||||
MAIN_DECLARATION
|
||||
{
|
||||
float flip = -renderTargetFlipping;
|
||||
vec2 screenUV = gl_FragCoord.xy / viewportSize.xy;
|
||||
|
||||
#if !defined(OGRE_HLSL) && !defined(VULKAN)
|
||||
screenUV.y = 1.0 - screenUV.y * 0.6 - 0.2;
|
||||
// vec2 final = projectionCoord.xy / projectionCoord.w;
|
||||
#else
|
||||
screenUV.y = screenUV.y * 0.6 + 0.2;
|
||||
#endif
|
||||
float depth = saturate(length(positionWS - cameraPosition.xyz) * 0.01);
|
||||
vec4 reflectionColour = texture2D(reflectMap, screenUV * vec2(0.5, 1.0));
|
||||
vec4 refractionColour = texture2D(reflectMap, screenUV * vec2(0.5, 1.0) + vec2(0.5, 0.0));
|
||||
vec4 result = mix(mix(reflectionColour, refractionColour, 0.5), vec4(0.0, 1.0, 1.0, 1.0), depth);
|
||||
float mul = dot(vec3(0.0, 1.0, 0.0), vnormal);
|
||||
result = result * mul;
|
||||
result.a = 1.0;
|
||||
gl_FragColor = result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user