浏览代码

Fixed hardcoded shadow resource path incorrectly handling out of bounds cases.

Fixed directional lights being subject to shadow distance calculations.
Fixed errors when having empty cascades.
/Branch_Batching2
uygar 7 年前
当前提交
1996704d
共有 2 个文件被更改,包括 7 次插入4 次删除
  1. 6
      Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs
  2. 5
      Assets/ScriptableRenderPipeline/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl

6
Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs


{
vp = ShadowUtils.ExtractDirectionalLightMatrix( lights[sr.index], key.faceIdx, m_CascadeCount, m_CascadeRatios, nearPlaneOffset, width, height, out ce.current.view, out ce.current.proj, out ce.current.lightDir, out ce.current.splitData, m_CullResults, (int) sr.index );
m_TmpSplits[key.faceIdx] = ce.current.splitData.cullingSphere;
m_TmpSplits[key.faceIdx].w *= ce.current.splitData.cullingSphere.w;
if( ce.current.splitData.cullingSphere.w != float.NegativeInfinity )
m_TmpSplits[key.faceIdx].w *= ce.current.splitData.cullingSphere.w;
}
else
vp = Matrix4x4.identity; // should never happen, though

AdditionalLightData ald = vl.light.GetComponent<AdditionalLightData>();
Vector3 lpos = vl.light.transform.position;
float distToCam = (campos - lpos).magnitude;
// TODO: Directional light (not projector), should not test shadowFadeDistance
bool add = distToCam < ald.shadowFadeDistance && m_ShadowSettings.enabled;
bool add = (distToCam < ald.shadowFadeDistance || vl.lightType == LightType.Directional) && m_ShadowSettings.enabled;
if( add )
{

5
Assets/ScriptableRenderPipeline/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl


/* load the right shadow data for the current face */ \
float4 dirShadowSplitSpheres[4]; \
uint payloadOffset = EvalShadow_LoadSplitSpheres( shadowContext, index, dirShadowSplitSpheres ); \
uint shadowSplitIndex = EvalShadow_GetSplitSphereIndexForDirshadows( positionWS, dirShadowSplitSpheres ); \
int shadowSplitIndex = EvalShadow_GetSplitSphereIndexForDirshadows( positionWS, dirShadowSplitSpheres ); \
if( shadowSplitIndex < 0 ) \
return 1.0; \
\
ShadowData sd = shadowContext.shadowDatas[index + 1 + shadowSplitIndex]; \
/* normal based bias */ \
positionWS += EvalShadow_NormalBias( normalWS, saturate( dot( normalWS, L ) ), sd.texelSizeRcp.zw, sd.normalBias ); \

正在加载...
取消
保存