浏览代码

Limited per face information to matrices and atlas offsets to cut down on register usage.

/main
uygar 7 年前
当前提交
f5518a7e
共有 2 个文件被更改,包括 17 次插入8 次删除
  1. 13
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl
  2. 12
      ScriptableRenderPipeline/Core/CoreRP/Shadow/Shadow.cs

13
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl


return (asint( flag ) & 1) ? 1.0 : 0.0;
}
float2 EvalShadow_SampleBias_Persp( ShadowData sd, float3 positionWS, float3 normalWS, float3 tcs )
{
float3 e1, e2;

// load the right shadow data for the current face
[branch]
if( shadowType == GPUSHADOWTYPE_POINT )
sd = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1];
{
sd.worldToShadow = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].worldToShadow;
sd.shadowToWorld = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].shadowToWorld;
sd.scaleOffset.zw = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].scaleOffset.zw;
}
uint texIdx, sampIdx;
float slice;

/* load the right shadow data for the current face */ \
[branch] \
if( shadowType == GPUSHADOWTYPE_POINT ) \
sd = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1]; \
{ \
sd.worldToShadow = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].worldToShadow; \
sd.shadowToWorld = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].shadowToWorld; \
sd.scaleOffset.zw = shadowContext.shadowDatas[index + EvalShadow_GetCubeFaceID( L ) + 1].scaleOffset.zw; \
} \
\
float slice; \
UnpackShadowmapId( sd.id, slice ); \

12
ScriptableRenderPipeline/Core/CoreRP/Shadow/Shadow.cs


}
uint multiFaceIdx = key.shadowDataIdx;
// For lights with multiple faces, the first shadow data contains
// per light information, so not all fields contain valid data.
// Shader code must make sure to read per face data from per face entries.
sd.texelSizeRcp = new Vector4( m_WidthRcp, m_HeightRcp, 1.0f / widths[0], 1.0f / heights[0] );
sd.PackShadowType( sr.shadowType, sanitizedAlgo );
sd.payloadOffset = payload.Count();
entries.AddUnchecked( sd );
key.shadowDataIdx++;
}

sd.payloadOffset = originalPayloadCount;
entries.AddUnchecked( sd );
if( multiFace )
{
entries[multiFaceIdx] = sd;
multiFace = false;
}
resIdx++;
facecnt--;
key.shadowDataIdx++;

正在加载...
取消
保存