@@ -6,6 +6,7 @@ float4 main(PS_INPUT input) : COLOR
66 float3 view = normalize (Constants1.xyz - input.localPosition);
77 float facing = abs (dot (normal, view));
88 float grazing = 1.0 - smoothstep (0.08 , 0.55 , facing);
9+ // pillars drive me mad
910 float pillar = step (0.5 , Constants2.y);
1011 float radialLength = max (length (normal.xy), 0.0001 );
1112 float3 pillarTangentU = float3 (-normal.y / radialLength,
@@ -40,24 +41,27 @@ float4 main(PS_INPUT input) : COLOR
4041 matrixAngle * 0.2 );
4142 screenColor = lerp (screenColor, float3 (0.17 , 0.18 , 0.2 ),
4243 matrixAngle * 0.12 );
44+ float3 modulation = input.color.rgb * Constants0.x;
45+
46+ // if backlit, return early. if not backlit, leave hope here
47+ if (Constants0.y < 0.5 )
48+ return float4 (screenColor * modulation, albedo.a);
4349
4450 float inverseW = 1.0 / max (abs (input.projected.w), 0.0001 );
4551 float2 lightUV = float2 (
4652 input.projected.x * inverseW * 0.5 + 0.5 ,
4753 -input.projected.y * inverseW * 0.5 + 0.5
4854 );
49- float3 light = lerp (float3 (1.0 , 1.0 , 1.0 ),
50- saturate (tex2D (Tex1, lightUV).rgb), Constants0.w);
55+ float3 light = saturate (tex2D (Tex1, lightUV).rgb);
5156 float lightMaximum = max (light.r, max (light.g, light.b));
5257 float lightMinimum = min (light.r, min (light.g, light.b));
53- float lightRange = lightMaximum - lightMinimum;
54- float lightSaturation = lightRange / max (lightMaximum, 0.0001 );
55- float lightEnergy = smoothstep (0.0005 , 0.004 , lightMaximum);
56- float coloredLight = smoothstep (0.12 , 0.58 , lightSaturation) *
57- lightEnergy * Constants0.w;
58+ float lightSaturation = 1.0 - lightMinimum / max (lightMaximum, 0.0001 );
59+ float spectralMix = smoothstep (0.12 , 0.58 , lightSaturation) *
60+ smoothstep (0.0005 , 0.004 , lightMaximum);
5861
59- // The sampled Witness response preserves tiny non-zero lamp values and
60- // approaches a square-root curve before its highlight shoulder.
62+ // this took an unreasonable amount of staring at witness panels
63+ // (like 580 screenshots from the game, ask me about them)
64+ // what do they mean mason
6165 float3 curvedLight = pow (light, float3 (0.45 , 0.45 , 0.45 ));
6266 curvedLight = saturate (curvedLight * (2.4 - 1.4 * curvedLight));
6367
@@ -66,29 +70,27 @@ float4 main(PS_INPUT input) : COLOR
6670
6771 float sourceMaximum = max (screenColor.r,
6872 max (screenColor.g, screenColor.b));
69- float stark = smoothstep (0.58 , 0.82 , sourceMaximum);
70- float3 membership = step (sourceMaximum * 0.38 , screenColor);
73+ float clueWeight = smoothstep (0.58 , 0.82 , sourceMaximum);
74+ float3 spectralMask = step (sourceMaximum * 0.38 , screenColor);
7175 float3 normalizedColor = screenColor / max (sourceMaximum, 0.0001 );
72- float3 clueReflectance = normalizedColor * membership ;
76+ float3 clueReflectance = normalizedColor * spectralMask ;
7377 float3 clueLit = curvedLight * clueReflectance;
7478 float3 neutralClueLit = screenColor * neutralLight;
75- float3 drivenClueLit = lerp (neutralClueLit, clueLit, coloredLight );
79+ float3 drivenClueLit = lerp (neutralClueLit, clueLit, spectralMix );
7680
77- // Dark panel materials use a much straighter response than clue pixels.
81+ // clue special case doohickery
7882 float surfaceGamma = lerp (0.95 , 0.62 ,
7983 smoothstep (0.12 , 0.72 , sourceMaximum));
8084 float3 surfaceLight = pow (light,
8185 float3 (surfaceGamma, surfaceGamma, surfaceGamma));
8286 float3 surfaceLit = screenColor * surfaceLight;
83- float3 lightDrivenResult = lerp (surfaceLit, drivenClueLit, stark);
84- float3 reflected = lerp (screenColor, lightDrivenResult, Constants0.y);
85- reflected *= input.color.rgb * Constants0.x;
87+ float3 lightDrivenResult = lerp (surfaceLit, drivenClueLit, clueWeight);
88+ float3 reflected = lightDrivenResult * modulation;
8689
87- // HDR overbright values feed Source's normal bloom pass. Backlit panels
88- // keep their authored emission in gamut; their glare is a separate pass.
90+ // the source bloom/hdr just turns this into soup
8991 float visibleMaximum = max (reflected.r, max (reflected.g, reflected.b));
9092 float bloom = smoothstep (0.72 , 0.96 , sourceMaximum) *
91- smoothstep (0.58 , 0.92 , visibleMaximum) * Constants0.z * Constants0.y ;
93+ smoothstep (0.58 , 0.92 , visibleMaximum) * Constants0.z;
9294 reflected *= 1.0 + bloom;
9395
9496 return float4 (reflected, albedo.a);
0 commit comments