cntrl/assets/shaders/post_fx.fs
dandovlatov db0fd64f39 FBC: NIGHT SHIFT - S5: wired sprites, the diorama scene and corruption post FX into the game
- render/presenter.cpp: loads assets/sprites/*.png (guard, hiss_staff, hiss_brute,\n  mold_spore, shard, glow) as DrawBillboardRec standees at card aspect; hit-flash\n  tint; missing art degrades to the soft-disc standee.\n- presenter scene dressing: polished-concrete palette (#2b2b2f), red carpet\n  runners, pillar red bands, threshold door with Hiss glow + hazard stripes,\n  EXIT signs, curb light strip, painted walkway lines.\n- assets/shaders/post_fx.fs (new): corruption-keyed VHS scanlines/noise, chromatic\n  aberration, red Hiss tint, vignette, damage flash.\n- main.cpp: frame renders to RenderTexture then the post shader blits it; uniforms\n  fed from game.corruption.value() + presenter.damage_flash().\n- Validated via --bot --screenshot: sprite orientation correct, post FX active\n  and scaling with corruption, red-dominant 18%, clip 0.1%.
2026-10-24 11:19:37 +04:00

57 lines
2 KiB
GLSL

#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;
}