From 36bd33d973f54f91f881cee87a234994d3fbd4eb Mon Sep 17 00:00:00 2001 From: yum Date: Thu, 20 Feb 2025 17:37:54 -0800 Subject: Add specular quantization --- filamented.cginc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'filamented.cginc') diff --git a/filamented.cginc b/filamented.cginc index 9edfca5..9895361 100644 --- a/filamented.cginc +++ b/filamented.cginc @@ -343,7 +343,12 @@ half3 Unity_GlossyEnvironment_local (UNITY_ARGS_TEXCUBE(tex), half4 hdr, Unity_G half3 R = glossIn.reflUVW; half4 rgbm = UNITY_SAMPLE_TEXCUBE_LOD(tex, R, mip); - return DecodeHDR(rgbm, hdr); + half3 color = DecodeHDR(rgbm, hdr); +#if defined(_QUANTIZE_SPECULAR) + float luminance = dot(color, float3(0.2126, 0.7152, 0.0722)); // convert to luminance + color = color * floor(luminance * _Quantize_Specular_Steps) / _Quantize_Specular_Steps; +#endif + return color; } inline half3 UnityGI_prefilteredRadiance(const UnityGIInput data, -- cgit v1.2.3