#version 330 // FBC: NIGHT SHIFT — corruption-keyed post FX (docs/ART_DIRECTION.md "Post FX"). // VHS scanlines + noise, chromatic aberration, red Hiss tint, vignette. // Strength scales with the corruption coefficient — the House decays in // real time and so does the image. Drawn over the whole frame by main.cpp. in vec2 fragTexCoord; in vec4 fragColor; out vec4 finalColor; uniform sampler2D texture0; uniform vec4 colDiffuse; uniform float uTime = 0.0; uniform float uCorruption = 0.05; // ~0.05 .. 2.0 (see game/corruption.hpp) uniform float uDamage = 0.0; // 0..1 player hit flash float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); } void main() { vec2 uv = fragTexCoord; // Chromatic aberration: subtle, grows with corruption + on damage. float aberr = 0.0012 + 0.0035 * uCorruption + 0.010 * uDamage; vec2 dir = uv - vec2(0.5); float dist = length(dir); vec2 off = dir * dist * aberr * 6.0; vec3 col = vec3( texture(texture0, uv + off).r, texture(texture0, uv).g, texture(texture0, uv - off).b); // VHS scanlines + rolling noise (intensity keys to corruption). float scan = sin(uv.y * 720.0) * 0.5 + 0.5; col *= 1.0 - 0.06 * scan * (0.5 + 0.5 * clamp(uCorruption, 0.0, 1.5)); float n = hash(uv * vec2(1024.0, 1024.0) + fract(uTime) * 61.7); col += (n - 0.5) * (0.02 + 0.05 * clamp(uCorruption, 0.0, 1.5)); // Red Hiss tint breathing with corruption. float hiss = clamp(uCorruption * 0.12, 0.0, 0.45); col = mix(col, col * vec3(1.08, 0.93, 0.93) + vec3(0.05, 0.0, 0.0), hiss); // Damage flash: red bloom. col = mix(col, vec3(0.8, 0.05, 0.07), uDamage * 0.35); // Vignette (tightens as the House decays). float vig = 1.0 - smoothstep(0.45, 1.05, dist) * (0.42 + 0.12 * uCorruption); col *= vig; // Mild exposure lift to keep the night scene readable under the vignette. col *= 1.12; finalColor = vec4(col, 1.0) * colDiffuse * fragColor; }