浏览代码

Added macro to control usage of clip space depth biasing.

Disabled clip space depth biasing for HDRP.
/main
uygar 6 年前
当前提交
1c570293
共有 3 个文件被更改,包括 31 次插入6 次删除
  1. 4
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/Shadow.hlsl
  2. 32
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/ShadowSampling.hlsl
  3. 1
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/Shadow.hlsl

4
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/Shadow.hlsl


#define SHADOW_USE_VIEW_BIAS_SCALING 0 // Enable view bias scaling to mitigate light leaking across edges. Uses the light vector if SHADOW_USE_ONLY_VIEW_BASED_BIASING is defined, otherwise uses the normal.
#define SHADOW_USE_ONLY_VIEW_BASED_BIASING 0 // Enable only light view vector based biasing. If undefined, biasing will be based on the normal and calling code must provide a valid normal.
#define SHADOW_USE_SAMPLE_BIASING 0 // Enable per sample biasing for wide multi-tap PCF filters. Incompatible with SHADOW_USE_ONLY_VIEW_BASED_BIASING.
#define SHADOW_USE_DEPTH_BIAS 0 // Enable clip space z biasing
// #define SHADOW_DISPATCH_USE_CUSTOM_PUNCTUAL // Enable custom implementations of GetPunctualShadowAttenuation. If not defined, a default implementation will be used.
// #define SHADOW_DISPATCH_USE_CUSTOM_DIRECTIONAL // Enable custom implementations of GetDirectionalShadowAttenuation. If not defined, a default implementation will be used.
*/

#endif
#ifndef SHADOW_USE_SAMPLE_BIAS
# define SHADOW_USE_SAMPLE_BIAS 0
#endif
#ifndef SHADOW_USE_DEPTH_BIAS
# define SHADOW_USE_DEPTH_BIAS 0
#endif
#if SHADOW_USE_ONLY_VIEW_BASED_BIASING != 0

32
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/ShadowSampling.hlsl


//
// 1 tap PCF sampling
//
real SampleShadow_PCF_1tap( ShadowContext shadowContext, inout uint payloadOffset, real3 tcs, float slice, uint texIdx, uint sampIdx )
real SampleShadow_PCF_1tap( ShadowContext shadowContext, inout uint payloadOffset, real3 coord, float slice, uint texIdx, uint sampIdx )
#if SHADOW_USE_DEPTH_BIAS == 1
tcs.z += depthBias;
coord.z += depthBias;
#endif
return SampleCompShadow_T2DA( shadowContext, texIdx, sampIdx, tcs, slice ).x;
return SampleCompShadow_T2DA( shadowContext, texIdx, sampIdx, coord, slice ).x;
real SampleShadow_PCF_1tap( ShadowContext shadowContext, inout uint payloadOffset, real3 tcs, float slice, Texture2DArray tex, SamplerComparisonState compSamp )
real SampleShadow_PCF_1tap( ShadowContext shadowContext, inout uint payloadOffset, real3 coord, float slice, Texture2DArray tex, SamplerComparisonState compSamp )
#if SHADOW_USE_DEPTH_BIAS == 1
tcs.z += depthBias;
coord.z += depthBias;
#endif
return SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, tcs, slice );
return SAMPLE_TEXTURE2D_ARRAY_SHADOW( tex, compSamp, coord, slice );
}
//

real4 shadowMapTexture_TexelSize = real4( texelSizeRcp.xy, textureSize.xy );
#if SHADOW_USE_DEPTH_BIAS == 1
#endif
real shadow = 0.0;
real fetchesWeights[4];

real4 shadowMapTexture_TexelSize = real4( texelSizeRcp.xy, textureSize.xy );
#if SHADOW_USE_DEPTH_BIAS == 1
#endif
real shadow = 0.0;
real fetchesWeights[4];

real4 shadowMapTexture_TexelSize = real4( texelSizeRcp.xy, textureSize.xy );
#if SHADOW_USE_DEPTH_BIAS == 1
#endif
real shadow = 0.0;
real fetchesWeights[9];

real4 shadowMapTexture_TexelSize = real4( texelSizeRcp.xy, textureSize.xy );
#if SHADOW_USE_DEPTH_BIAS == 1
#endif
real shadow = 0.0;
real fetchesWeights[9];

real4 shadowMapTexture_TexelSize = real4( texelSizeRcp.xy, textureSize.xy );
#if SHADOW_USE_DEPTH_BIAS == 1
#endif
real shadow = 0.0;
real fetchesWeights[16];

real4 shadowMapTexture_TexelSize = real4( texelSizeRcp.xy, textureSize.xy );
#if SHADOW_USE_DEPTH_BIAS == 1
#endif
real shadow = 0.0;
real fetchesWeights[16];

texelSizeRcp *= filterSize;
#if SHADOW_USE_DEPTH_BIAS == 1
#endif
// Terms0 are weights for the individual samples, the other terms are offsets in texel space
real4 vShadow3x3PCFTerms0 = real4( 20.0 / 267.0, 33.0 / 267.0, 55.0 / 267.0, 0.0 );

texelSizeRcp *= filterSize;
#if SHADOW_USE_DEPTH_BIAS == 1
#endif
// Terms0 are weights for the individual samples, the other terms are offsets in texel space
real4 vShadow3x3PCFTerms0 = real4(20.0 / 267.0, 33.0 / 267.0, 55.0 / 267.0, 0.0);

1
ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/LightLoop/Shadow.hlsl


#define SHADOW_USE_VIEW_BIAS_SCALING 1 // Enable view bias scaling to mitigate light leaking across edges. Uses the light vector if SHADOW_USE_ONLY_VIEW_BASED_BIASING is defined, otherwise uses the normal.
#define SHADOW_USE_SAMPLE_BIASING 1 // Enable per sample biasing for wide multi-tap PCF filters. Incompatible with SHADOW_USE_ONLY_VIEW_BASED_BIASING.
#define SHADOW_USE_DEPTH_BIAS 0 // Enable clip space z biasing
#include "ShadowContext.hlsl"

正在加载...
取消
保存