浏览代码

LWRP XR Single Pass Instancing Shadow Fixes

After the LWRP refactor, both directional and local shadows were broken for XR when using Single Pass Instancing.  This commit fixes those issues.
/main
Brandon Fogerty 7 年前
当前提交
5677b4e8
共有 2 个文件被更改,包括 4 次插入5 次删除
  1. 6
      com.unity.render-pipelines.lightweight/LWRP/LightweightForwardRenderer.cs
  2. 3
      com.unity.render-pipelines.lightweight/LWRP/Shaders/LightweightScreenSpaceShadows.shader

6
com.unity.render-pipelines.lightweight/LWRP/LightweightForwardRenderer.cs


SetupPerObjectLightIndices(ref cullResults, ref renderingData.lightData);
RenderTextureDescriptor baseDescriptor = CreateRTDesc(ref renderingData.cameraData);
RenderTextureDescriptor shadowDescriptor = baseDescriptor;
shadowDescriptor.dimension = TextureDimension.Tex2D;
bool requiresCameraDepth = renderingData.cameraData.requiresDepthTexture;
bool requiresDepthPrepass = renderingData.shadowData.requiresScreenSpaceShadowResolve ||

if (renderingData.shadowData.renderDirectionalShadows)
{
EnqueuePass(cmd, RenderPassHandles.DirectionalShadows, baseDescriptor);
EnqueuePass(cmd, RenderPassHandles.DirectionalShadows, shadowDescriptor);
EnqueuePass(cmd, RenderPassHandles.LocalShadows, baseDescriptor);
EnqueuePass(cmd, RenderPassHandles.LocalShadows, shadowDescriptor);
bool requiresDepthAttachment = requiresCameraDepth && !requiresDepthPrepass;
bool requiresColorAttachment = RequiresColorAttachment(ref renderingData.cameraData, baseDescriptor) || requiresDepthAttachment;

3
com.unity.render-pipelines.lightweight/LWRP/Shaders/LightweightScreenSpaceShadows.shader


{
half4 pos : SV_POSITION;
half4 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};

UNITY_SETUP_INSTANCE_ID(i);
UNITY_TRANSFER_INSTANCE_ID(i, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = TransformObjectToHClip(i.vertex.xyz);

half4 Fragment(Interpolators i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)

正在加载...
取消
保存