Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

# include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowContext.hlsl"

// Normal light loop is guaranteed to be scalar, but not always we sample shadows with said guarantee. In those cases we define SHADOW_DATA_NOT_GUARANTEED_SCALAR to skip the forcing into scalar.
#define FORCE_SHADOW_SCALAR_READ !defined(SHADOW_DATA_NOT_GUARANTEED_SCALAR) && !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE) && (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER))


// normalWS is the vertex normal if available or shading normal use to bias the shadow position
float GetDirectionalShadowAttenuation(HDShadowContext shadowContext, float2 positionSS, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 L)
{
Expand All @@ -32,7 +36,7 @@ float GetDirectionalShadowAttenuation(HDShadowContext shadowContext, float2 posi

float GetPunctualShadowAttenuation(HDShadowContext shadowContext, float2 positionSS, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 L, float L_dist, bool pointLight, bool perspecive)
{
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE) && (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER))
#if FORCE_SHADOW_SCALAR_READ
shadowDataIndex = WaveReadLaneFirst(shadowDataIndex);
#endif

Expand Down Expand Up @@ -63,7 +67,7 @@ float GetPunctualShadowAttenuation(HDShadowContext shadowContext, float2 positio

float GetPunctualShadowClosestDistance(HDShadowContext shadowContext, SamplerState sampl, real3 positionWS, int shadowDataIndex, float3 L, float3 lightPositionWS, bool pointLight)
{
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE) && (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER))
#if FORCE_SHADOW_SCALAR_READ
shadowDataIndex = WaveReadLaneFirst(shadowDataIndex);
#endif

Expand Down Expand Up @@ -94,7 +98,7 @@ float GetRectAreaShadowAttenuation(HDShadowContext shadowContext, float2 positio
{
// We need to disable the scalarization here on xbox due to bad code generated by FXC for the eye shader.
// This shouldn't have an enormous impact since with Area lights we are already exploded in VGPR by this point.
#if !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_GAMECORE) && (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER))
#if FORCE_SHADOW_SCALAR_READ
shadowDataIndex = WaveReadLaneFirst(shadowDataIndex);
#endif
HDShadowData sd = shadowContext.shadowDatas[shadowDataIndex];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
// which might be lower than the max number of lights that might be in the big tile.
#define PRE_FILTER_LIGHT_LIST 1 && defined(USE_BIG_TILE_LIGHTLIST)


#define SHADOW_DATA_NOT_GUARANTEED_SCALAR // We are not looping over shadows in a scalarized fashion. If we will at some point, remove this define.

//--------------------------------------------------------------------------------------------------
// Included headers
//--------------------------------------------------------------------------------------------------
Expand Down