Skip to content

Commit

Permalink
added specular occlusion from realtime shadows
Browse files Browse the repository at this point in the history
disabled by default, #define SPECULAR_OCCLUSION_REALTIME_SHADOWS in the config to enable
  • Loading branch information
z3y committed Feb 4, 2024
1 parent a76a59c commit 2105ac8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Editor/Importer/LitImporterDefaultProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ [ToggleGroupEnd] [UnIndent] [ToggleOff] _OpaqueLights(""Opaque Lights"", Float)
// #define NONLINEAR_LIGHTPROBESH // enable non linear lightprobe sh
// #define DISABLE_LIGHT_PROBE_PROXY_VOLUME // disable LPPV
// #undef UNITY_SPECCUBE_BLENDING // disable blending of 2 reflection probes
// #define SPECULAR_OCCLUSION_REALTIME_SHADOWS // allow realtime directional shadows to affect specular occlusion and subtract from the indirect diffuse light
DEFINES_END
";
Expand Down
4 changes: 4 additions & 0 deletions ShaderLibrary/ForwardLighting.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,10 @@ namespace CustomLighting
half3 bentLight = giData.IndirectDiffuse;
#endif

#if defined(SHADOWS_SCREEN) && defined(SPECULAR_OCCLUSION_REALTIME_SHADOWS)
half NoL = saturate(dot(sd.normalWS, mainLightData.direction));
bentLight *= NoL * mainLightData.attenuation;
#endif
half bentLightGrayscale = sqrt(dot(bentLight + giData.Light, 1.0));
half bentLightGrayscaleRemap = saturate(lerp(1.0, bentLightGrayscale, surfaceDescription.SpecularOcclusion));
reflections *= bentLightGrayscaleRemap;
Expand Down

0 comments on commit 2105ac8

Please sign in to comment.