CommonShadow.hlsl 591 B

1234567891011121314
  1. #ifndef UNITY_COMMON_SHADOW_INCLUDED
  2. #define UNITY_COMMON_SHADOW_INCLUDED
  3. // Ref: https://mynameismjp.wordpress.com/2015/02/18/shadow-sample-update/
  4. // Calculates the offset to use for sampling the shadow map, based on the surface normal
  5. real3 GetShadowPosOffset(real NdotL, real3 normalWS, real2 invShadowMapSize)
  6. {
  7. real texelSize = 2.0 * invShadowMapSize.x;
  8. real offsetScaleNormalize = saturate(1.0 - NdotL);
  9. // return texelSize * OffsetScale * offsetScaleNormalize * normalWS;
  10. return texelSize * offsetScaleNormalize * normalWS;
  11. }
  12. #endif // UNITY_COMMON_SHADOW_INCLUDED