Files
ogre-prototype/water/water.frag
2025-07-04 01:10:08 +03:00

25 lines
816 B
GLSL

OGRE_NATIVE_GLSL_VERSION_DIRECTIVE
#include <OgreUnifiedShader.h>
// SAMPLER2D(noiseMap, 0);
SAMPLER2D(reflectMap, 0);
SAMPLER2D(refractMap, 1);
OGRE_UNIFORMS(
uniform vec4 viewportSize;
uniform f32vec4 cameraPosition;
)
MAIN_PARAMETERS
IN(highp vec4 projectionCoord, TEXCOORD4)
IN(f32vec3 positionWS, TEXCOORD7)
MAIN_DECLARATION
{
vec2 screenUV = gl_FragCoord.xy / viewportSize.xy;
screenUV.y = 1.0 - screenUV.y * 0.6 - 0.2;
// vec2 final = projectionCoord.xy / projectionCoord.w;
float depth = saturate(length(positionWS - cameraPosition.xyz) * 0.01);
vec4 reflectionColour = texture2D(reflectMap, screenUV);
vec4 refractionColour = texture2D(refractMap, screenUV);
vec4 result = mix(mix(reflectionColour, refractionColour, 0.5), vec4(0.0, 1.0, 1.0, 1.0), depth);
result.a = 1.0;
gl_FragColor = result;
}