Watergit push!
This commit is contained in:
@@ -1,12 +1,29 @@
|
||||
OGRE_NATIVE_GLSL_VERSION_DIRECTIVE
|
||||
#include <OgreUnifiedShader.h>
|
||||
// SAMPLER2D(noiseMap, 0);
|
||||
SAMPLER2D(reflectMap, 0);
|
||||
SAMPLER2D(noiseMap, 1);
|
||||
// SAMPLER2D(refractMap, 1);
|
||||
#if NEW_WATER_SHADER
|
||||
MAIN_PARAMETERS
|
||||
IN(vec4 clipSpace, TEXCOORD0)
|
||||
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);
|
||||
gl_FragColor = mix(reflectionColour, refractionColour, 0.5);
|
||||
}
|
||||
#else
|
||||
OGRE_UNIFORMS(
|
||||
uniform float renderTargetFlipping;
|
||||
uniform vec4 viewportSize;
|
||||
uniform f32vec4 cameraPosition;
|
||||
uniform mat4 viewProj2;
|
||||
uniform float time2;
|
||||
uniform vec4 materialVariables;
|
||||
)
|
||||
float rand(float n){return fract(sin(n) * 43758.5453123);}
|
||||
float rand2(vec2 n) {
|
||||
@@ -26,6 +43,11 @@ float noise(vec2 n) {
|
||||
MAIN_PARAMETERS
|
||||
IN(f32vec3 positionWS, TEXCOORD0)
|
||||
IN(f32vec3 vnormal, TEXCOORD1)
|
||||
IN(f32vec3 viewDirection, TEXCOORD2)
|
||||
IN(f32vec3 viewDirectionTS, TEXCOORD3)
|
||||
IN(f32vec3 olightDirection, TEXCOORD4)
|
||||
IN(f32vec3 lightDirectionTS, TEXCOORD5)
|
||||
IN(vec2 bumpCoord0, TEXCOORD6)
|
||||
MAIN_DECLARATION
|
||||
{
|
||||
float flip = -renderTargetFlipping;
|
||||
@@ -37,14 +59,68 @@ MAIN_DECLARATION
|
||||
screenUV.y = screenUV.y * 0.6 + 0.2;
|
||||
#endif
|
||||
|
||||
vec2 texCoord = 0.001 * positionWS.xz;
|
||||
vec3 normal = vec3_splat(0.0);
|
||||
float time = time2 * 0.01;
|
||||
f32vec2 muv = screenUV * 1.1 + vec2(-0.1, -0.1);
|
||||
normal += normalize(2.0 * texture2D(noiseMap, vec2(texCoord.x, texCoord.y - 5.0 * time)).rgb - 1.0);
|
||||
normal += normalize(2.0 * texture2D(noiseMap, vec2(texCoord.y, 1.0 - texCoord.x - 5.0 * time)).rgb - 1.0);
|
||||
normal += normalize(2.0 * texture2D(noiseMap, vec2(1.0 - texCoord.x, 1.0 - texCoord.y - 5.0 * time)).rgb - 1.0);
|
||||
normal += normalize(2.0 * texture2D(noiseMap, vec2(1.0 - texCoord.y, texCoord.x - 5.0 * time)).rgb - 1.0);
|
||||
normal = normalize(normal);
|
||||
float reflectionDepth = 0.08;
|
||||
float refractionDepth = 1.05;
|
||||
|
||||
vec2 reflectionTexCoord = screenUV + (normal.xy * reflectionDepth) / length(positionWS - cameraPosition.xyz);
|
||||
vec2 refractionTexCoord = screenUV + normal.xy * refractionDepth;
|
||||
|
||||
float depth = saturate(length(positionWS - cameraPosition.xyz) * 0.01);
|
||||
float nx = sin(noise(vec2(1300.0 + screenUV.x * 48.11, 1100.0 + screenUV.y)));
|
||||
float ny = sin(noise(vec2(100.0 + screenUV.y * 72.2, 1500.0 + screenUV.x)));
|
||||
vec4 reflectionColour = texture2D(reflectMap, vec2(nx, ny) + screenUV * vec2(0.5, 1.0));
|
||||
vec4 refractionColour = texture2D(reflectMap, vec2(nx, ny) + screenUV * vec2(0.5, 1.0) + vec2(0.5, 0.0));
|
||||
vec4 t0 = texture2D(noiseMap, bumpCoord0) * 2.0 - 1.0;
|
||||
vec4 t1 = texture2D(noiseMap, bumpCoord0 + vec2(0.75, 0.02)) * 2.0 - 1.0;
|
||||
vec4 t2 = texture2D(noiseMap, bumpCoord0 + vec2(0.33, 0.11)) * 2.0 - 1.0;
|
||||
vec4 N = vec4(t0.xyz + t1.xyz + t2.xyz, 1);
|
||||
N = normalize(viewProj2 * N) * 0.1;
|
||||
vec4 mrow = vec4(screenUV.x, 0, screenUV.y, 1);
|
||||
vec4 mrowt = mul(viewProj2, mrow);
|
||||
f32vec2 e = vec2(0, 0);
|
||||
float min_speed = 16.0;
|
||||
float max_ax = 0.01;
|
||||
float max_ay = 0.005;
|
||||
float px = noise(vec2(screenUV.x * 13123.0, screenUV.y * 1121.0));
|
||||
float py = noise(vec2(screenUV.y * 15123.0, screenUV.x * 1421.0));
|
||||
float offsetx = 0.0;
|
||||
float offsety = 0.0;
|
||||
float l = length(positionWS - cameraPosition.xyz);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
e.x += sin(mrow.z * min_speed + offsetx + time2 * 0.01) * max_ax * (1.0 + 1.0 / (1.0 + l * 30.0));
|
||||
e.y += cos(mrow.x * min_speed + offsety + time2 * 0.01) * max_ay;
|
||||
offsetx += 113.0;
|
||||
offsety += 78.0;
|
||||
min_speed *= 2.45;
|
||||
max_ax *= 0.9;
|
||||
max_ay *= 0.9;
|
||||
}
|
||||
f32vec2 reflectUV = /* screenUV + e */ reflectionTexCoord;
|
||||
f32vec2 refractUV = /* screenUV + e */ refractionTexCoord;
|
||||
reflectUV.x = (reflectUV.x < 0.05 ) ? 0.05 : reflectUV.x;
|
||||
reflectUV.x = (reflectUV.x > 0.95 ) ? 0.95 : reflectUV.x;
|
||||
f32vec2 uv_mul = vec2(0.5, 1.0);
|
||||
f32vec2 uv_offset = vec2(0.5, 0.0);
|
||||
vec4 reflectionColour = texture2D(reflectMap, reflectUV * uv_mul);
|
||||
vec4 refractionColour = texture2D(reflectMap, refractUV * uv_mul + uv_offset);
|
||||
if (reflectionColour.a == 0.0) {
|
||||
reflectionColour = texture2D(reflectMap, screenUV * uv_mul);
|
||||
}
|
||||
if (refractionColour.a == 0.0) {
|
||||
refractionColour = texture2D(reflectMap, screenUV * uv_mul + uv_offset);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user