diff options
| -rw-r--r-- | globals.cginc | 1 | ||||
| -rw-r--r-- | pbr.cginc | 34 |
2 files changed, 18 insertions, 17 deletions
diff --git a/globals.cginc b/globals.cginc index 5271e64..b4b0c84 100644 --- a/globals.cginc +++ b/globals.cginc @@ -85,7 +85,6 @@ float _Clearcoat_Mask2_Invert; #endif #if defined(SSR_ENABLED) -UNITY_DECLARE_DEPTH_TEXTURE(_CameraDepthTexture); sampler2D _GrabTexture; sampler2D _NoiseTexSSR; float4 _GrabTexture_TexelSize; @@ -254,6 +254,21 @@ float4 getLitColor( direct_light.color *= (1 - e); } +#if defined(_LTCGI) + ltcgi_acc acc = (ltcgi_acc) 0; + if ((bool) round(_LTCGI_Enabled)) { + LTCGI_Contribution( + acc, + i.worldPos, + normal, + view_dir, + GetRoughness(smoothness), + 0); + indirect_light.diffuse += acc.diffuse; + indirect_light.specular += acc.specular; + } +#endif + direct_light.color = RGBtoHSV(direct_light.color); indirect_light.specular = RGBtoHSV(indirect_light.specular); indirect_light.diffuse = RGBtoHSV(indirect_light.diffuse); @@ -322,11 +337,12 @@ float4 getLitColor( float2 screenUVs = 0; float4 screenPos = 0; #if SSR_ENABLED - screenUVs = i.screenPos.xy / (i.screenPos.w+0.0000000001); + float perspective_divide = rcp(i.pos.w+0.0000000001); + screenUVs = i.screenPos.xy * perspective_divide; #if UNITY_SINGLE_PASS_STEREO || defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED ) screenUVs.x *= 2; #endif - screenPos = i.screenPos; + screenPos = float4(i.screenPos, 0, i.pos.w); #endif #if 1 @@ -445,20 +461,6 @@ float4 getLitColor( #endif #endif -#if defined(_LTCGI) - ltcgi_acc acc = (ltcgi_acc) 0; - if ((bool) round(_LTCGI_Enabled)) { - LTCGI_Contribution( - acc, - i.worldPos, - normal, - view_dir, - GetRoughness(smoothness), - 0); - pbr.rgb += acc.diffuse + acc.specular; - } -#endif - UNITY_APPLY_FOG(i.fogCoord, pbr.rgb); return float4(pbr.rgb, albedo.a); |
