浏览代码

Fixed shadows on OpenGL

/main
Felipe Lira 7 年前
当前提交
f8249fa0
共有 2 个文件被更改,包括 4 次插入7 次删除
  1. 7
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
  2. 4
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightPassShadow.hlsl

7
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


float atlasWidth = (float)m_ShadowSettings.shadowAtlasWidth;
float atlasHeight = (float)m_ShadowSettings.shadowAtlasHeight;
float deviceZRangeScale = 1.0f;
// Currently CullResults ComputeDirectionalShadowMatricesAndCullingPrimitives doesn't
// apply z reversal to projection matrix. We need to do it manually here.
if (SystemInfo.usesReversedZBuffer)

proj.m22 = -proj.m22;
proj.m23 = -proj.m23;
deviceZRangeScale = 0.5f;
}
Matrix4x4 worldToShadow = proj * view;

textureScaleAndBias.m11 = 0.5f;
textureScaleAndBias.m22 = deviceZRangeScale;
textureScaleAndBias.m22 = 0.5f;
textureScaleAndBias.m23 = deviceZRangeScale;
textureScaleAndBias.m23 = 0.5f;
textureScaleAndBias.m13 = 0.5f;
// Apply texture scale and offset to save a MAD in shader.

4
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightPassShadow.hlsl


clipPos.z += _ShadowBias.x;
#if defined(UNITY_REVERSED_Z)
clipPos.z = min(clipPos.z, UNITY_NEAR_CLIP_VALUE);
clipPos.z = min(clipPos.z, 1.0);
clipPos.z = max(clipPos.z, UNITY_NEAR_CLIP_VALUE);
clipPos.z = max(clipPos.z, 0.0);
#endif
return clipPos;
}

正在加载...
取消
保存