From 144d7bc5cc999b9c5f84a9a7fc2a86dafe276df1 Mon Sep 17 00:00:00 2001 From: yum Date: Sat, 5 Oct 2024 17:32:47 -0700 Subject: Fix SSR --- pbr.cginc | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'pbr.cginc') diff --git a/pbr.cginc b/pbr.cginc index 9955d0d..0da16dc 100644 --- a/pbr.cginc +++ b/pbr.cginc @@ -285,7 +285,7 @@ float4 getLitColor( // Do this to avoid division by 0. If both light sources are black, // sum_brightness could be 0; #if defined(_BRIGHTNESS_CLAMP) - brightnesses = max(brightnesses, min(_Min_Brightness, .001)); + brightnesses = max(brightnesses, _Min_Brightness); #endif float sum_brightness = brightnesses[0] + brightnesses[1]; float2 brightness_proportions = brightnesses / sum_brightness; @@ -336,10 +336,23 @@ float4 getLitColor( float2 screenUVs = 0; float4 screenPos = 0; + #if SSR_ENABLED + screenUVs = i.screenPos.xy / (i.screenPos.w+0.0000000001); + #if UNITY_SINGLE_PASS_STEREO || defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED ) + screenUVs.x *= 2; + #endif + screenPos = i.screenPos; + #endif + #if 1 float reflection_strength = _ReflectionStrength; #if defined(_REFLECTION_STRENGTH_TEX) reflection_strength *= _ReflectionStrengthTex.SampleLevel(linear_repeat_s, i.uv0, 0); +#endif +#if defined(SSR_MASK) + float ssr_mask = _SSR_Mask.SampleLevel(linear_repeat_s, i.uv0, 0); +#else + float ssr_mask = 1; #endif float4 pbr = BRDF1_Mochie_PBS( albedo, @@ -359,7 +372,8 @@ float4 getLitColor( vertexLightColor, direct_light, indirect_light, - reflection_strength); + reflection_strength, + ssr_mask); #else float3 pbr = UNITY_BRDF_PBS( albedo, -- cgit v1.2.3