浏览代码

Merge pull request #1811 from Unity-Technologies/lw/fix-shadowcascadewarning

Fixed _WorldToShadow warning.
/main
GitHub 6 年前
当前提交
b094e6ea
共有 3 个文件被更改,包括 4 次插入10 次删除
  1. 2
      com.unity.render-pipelines.lightweight/CHANGELOG.md
  2. 5
      com.unity.render-pipelines.lightweight/LWRP/Passes/DirectionalShadowsPass.cs
  3. 7
      com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Shadows.hlsl

2
com.unity.render-pipelines.lightweight/CHANGELOG.md


and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [3.2.0-preview]
### Fixed
- When you change a Shadow Cascade option in the Pipeline Asset, this no longer warns you that you've exceeded the array size for the _WorldToShadow property.
## [3.1.0-preview]

5
com.unity.render-pipelines.lightweight/LWRP/Passes/DirectionalShadowsPass.cs


float invHalfShadowAtlasWidth = 0.5f * invShadowAtlasWidth;
float invHalfShadowAtlasHeight = 0.5f * invShadowAtlasHeight;
cmd.SetGlobalTexture(destination.id, m_DirectionalShadowmapTexture);
if (shadowData.directionalLightCascadeCount > 1)
cmd.SetGlobalMatrixArray(DirectionalShadowConstantBuffer._WorldToShadow, m_DirectionalShadowMatrices);
else
cmd.SetGlobalMatrix(DirectionalShadowConstantBuffer._WorldToShadow, m_DirectionalShadowMatrices[0]);
cmd.SetGlobalMatrixArray(DirectionalShadowConstantBuffer._WorldToShadow, m_DirectionalShadowMatrices);
cmd.SetGlobalVector(DirectionalShadowConstantBuffer._ShadowData, new Vector4(light.shadowStrength, 0.0f, 0.0f, 0.0f));
cmd.SetGlobalVector(DirectionalShadowConstantBuffer._DirShadowSplitSpheres0, m_CascadeSplitDistances[0]);
cmd.SetGlobalVector(DirectionalShadowConstantBuffer._DirShadowSplitSpheres1, m_CascadeSplitDistances[1]);

7
com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Shadows.hlsl


// Last cascade is initialized with a no-op matrix. It always transforms
// shadow coord to half(0, 0, NEAR_PLANE). We use this trick to avoid
// branching since ComputeCascadeIndex can return cascade index = MAX_SHADOW_CASCADES
#ifdef _SHADOWS_CASCADE
#else
float4x4 _WorldToShadow;
#endif
float4 _DirShadowSplitSpheres0;
float4 _DirShadowSplitSpheres1;
float4 _DirShadowSplitSpheres2;

half ComputeCascadeIndex(float3 positionWS)
{
// TODO: profile if there's a performance improvement if we avoid indexing here
float3 fromCenter0 = positionWS - _DirShadowSplitSpheres0.xyz;
float3 fromCenter1 = positionWS - _DirShadowSplitSpheres1.xyz;
float3 fromCenter2 = positionWS - _DirShadowSplitSpheres2.xyz;

half cascadeIndex = ComputeCascadeIndex(positionWS);
return mul(_WorldToShadow[cascadeIndex], float4(positionWS, 1.0));
#else
return mul(_WorldToShadow, float4(positionWS, 1.0));
return mul(_WorldToShadow[0], float4(positionWS, 1.0));
#endif
}

正在加载...
取消
保存