This commit is contained in:
2025-09-05 22:56:48 +03:00
parent 25816c5658
commit 92ec3e9497
17 changed files with 1320 additions and 453 deletions

View File

@@ -8,6 +8,21 @@ uniform float renderTargetFlipping;
uniform vec4 viewportSize;
uniform f32vec4 cameraPosition;
)
float rand(float n){return fract(sin(n) * 43758.5453123);}
float rand2(vec2 n) {
return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
}
float noise(vec2 n) {
const vec2 d = vec2(0.0, 1.0);
vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));
float fx = f.x;
vec2 e = b + d.yx;
float m = mix(rand2(b), rand2(e), fx);
vec2 p = b + d.xy;
vec2 q = b + d.yy;
float r = mix(rand2(p), rand2(q), f.y);
return mix(m, r, fx);
}
MAIN_PARAMETERS
IN(f32vec3 positionWS, TEXCOORD0)
IN(f32vec3 vnormal, TEXCOORD1)
@@ -21,9 +36,12 @@ MAIN_DECLARATION
#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));
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 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;