87 lines
3.3 KiB
GLSL
87 lines
3.3 KiB
GLSL
#version 330
|
|
// FBC: NIGHT SHIFT — actor lighting (S9 look-dev).
|
|
// Risk of Rain 2's gradient-map diffuse and two-tone rim, in Control's graphite
|
|
// palette: cool shadows, warm highlights, faction-coloured fresnel edge,
|
|
// atmospheric haze and corruption bleed. actor_ramp.png is generated in Blender
|
|
// by tools/blender/build_lut.py. uOutline renders the back-face ink silhouette.
|
|
|
|
in vec2 fragTexCoord;
|
|
in vec4 fragColor;
|
|
in vec3 vNormal;
|
|
in vec3 vWorld;
|
|
|
|
out vec4 finalColor;
|
|
|
|
uniform sampler2D texture0;
|
|
uniform sampler2D actorRamp;
|
|
uniform vec4 colDiffuse;
|
|
uniform vec3 uCameraPos;
|
|
|
|
uniform float uTime = 0.0;
|
|
uniform float uFlash = 0.0;
|
|
uniform float uCorruption = 0.0;
|
|
uniform float uOutline = 0.0;
|
|
uniform float uGlow = 0.0;
|
|
|
|
void main()
|
|
{
|
|
vec3 n = normalize(vNormal);
|
|
// glTF base factors are linear and uploaded as plain bytes: undo the curve.
|
|
vec3 base = pow(colDiffuse.rgb * fragColor.rgb, vec3(1.0 / 2.2));
|
|
|
|
if (uOutline > 0.5) {
|
|
vec3 ink = vec3(0.018, 0.020, 0.026)
|
|
+ vec3(0.055, 0.0, 0.0) * uCorruption;
|
|
finalColor = vec4(ink, 1.0);
|
|
return;
|
|
}
|
|
|
|
float sat = max(base.r, max(base.g, base.b))
|
|
- min(base.r, min(base.g, base.b));
|
|
|
|
vec3 keyDir = normalize(vec3(-0.42, 0.86, 0.30));
|
|
vec3 fillDir = normalize(vec3(0.55, 0.25, -0.70));
|
|
float ndl = dot(n, keyDir) * 0.5 + 0.5; // half-Lambert
|
|
vec3 ramp = texture(actorRamp, vec2(clamp(ndl, 0.0, 1.0), 0.5)).rgb * 1.7;
|
|
float fill = max(dot(n, fillDir), 0.0);
|
|
float hemi = 0.5 + 0.5 * n.y;
|
|
|
|
vec3 lit = base * ramp * (0.88 + 0.12 * hemi);
|
|
lit += base * fill * 0.13;
|
|
|
|
// Two-tone rim: cold fluorescent in the House, faction hue on corrupted
|
|
// actors (red Hiss, sickly Mold) with no extra textures or draw calls.
|
|
vec3 viewDir = normalize(uCameraPos - vWorld);
|
|
float fresnel = pow(1.0 - max(dot(n, viewDir), 0.0), 3.0);
|
|
float ceiling = pow(1.0 - max(dot(n, normalize(vec3(0.0, 0.7, 0.7))), 0.0), 3.0);
|
|
float rim = max(fresnel * 0.85, ceiling * 0.55);
|
|
vec3 cold = vec3(0.40, 0.53, 0.66);
|
|
vec3 accent = normalize(base + vec3(1e-4)) * 0.55;
|
|
lit += mix(cold, accent, smoothstep(0.16, 0.45, sat)) * rim
|
|
* (0.75 + 0.25 * uCorruption);
|
|
|
|
// Saturated palette entries read as emissive resin.
|
|
float bright = max(base.r, max(base.g, base.b));
|
|
float pulse = 0.88 + 0.12 * sin(uTime * 2.6 + vWorld.x * 1.7 + vWorld.z * 0.9);
|
|
lit += base * smoothstep(0.42, 0.88, bright) * 0.20 * pulse;
|
|
lit += base * uGlow * pulse;
|
|
|
|
// Tight sheen so bevels catch the fluorescent key.
|
|
vec3 halfDir = normalize(keyDir + viewDir);
|
|
float spec = pow(max(dot(n, halfDir), 0.0), 42.0)
|
|
* (0.06 + 0.10 * smoothstep(0.35, 0.8, bright));
|
|
lit += vec3(0.90, 0.88, 0.82) * spec;
|
|
|
|
// The House bleeds red into unlit faces as containment fails.
|
|
lit += vec3(0.26, 0.012, 0.018) * (1.0 - ndl) * uCorruption * 0.30;
|
|
|
|
// Hit flash washes the silhouette toward hot white-red.
|
|
lit = mix(lit, vec3(1.0, 0.62, 0.56) * (0.75 + 0.25 * bright), uFlash);
|
|
|
|
// Haze pulls distant actors into the room instead of floating on top.
|
|
float dist = length(uCameraPos - vWorld);
|
|
float fog = (1.0 - exp(-dist * 0.014)) * 0.55;
|
|
lit = mix(lit, vec3(0.055, 0.058, 0.070), fog);
|
|
|
|
finalColor = vec4(lit, 1.0);
|
|
}
|