浏览代码

Fixed UNITY_REVERSED_Z check. It's always defines in SRP shader library to either 0 or 1. Fixed shadow pancaking on OGL.

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

6
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassShadow.hlsl


// _ShadowBias.x sign depens on if platform has reversed z buffer
clipPos.z += _ShadowBias.x;
#if defined(UNITY_REVERSED_Z)
clipPos.z = min(clipPos.z, 1.0);
#if UNITY_REVERSED_Z
clipPos.z = min(clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE);
clipPos.z = max(clipPos.z, 0.0);
clipPos.z = max(clipPos.z, clipPos.w * UNITY_NEAR_CLIP_VALUE);
#endif
return clipPos;
}

2
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightScreenSpaceShadows.shader


float zDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.uv);
float depth = Linear01Depth(zDepth, _ZBufferParams);
#ifdef UNITY_REVERSED_Z
#if UNITY_REVERSED_Z
zDepth = 1 - zDepth;
#endif

正在加载...
取消
保存