浏览代码

Workaround stereo instancing issue with unity_StereoEyeIndex

Usually, in the stereo instancing path, we source unity_StereoEyeIndex from the fragment input structure's stereoTargetEyeIndex member. In fact, stereoTargetEyeIndex is needed as it is bound to the SV_RenderTargetArrayIndex semantic, which dictates which render target array slice is rasterized to.

However, for whatever reason, reading stereoTargetEyeIndex is not reliable in the fragment shader.  However, if I use the raw instance ID passed into the fragment shader, that works correctly.  More work probably needs to be done, but this is fine for now.
/lwrp-xr-sssm-DrawProc
Robert Srinivasiah 7 年前
当前提交
142882bf
共有 1 个文件被更改,包括 5 次插入4 次删除
  1. 9
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightScreenSpaceShadows.shader

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


half Fragment(Interpolators i) : SV_Target
{
UNITY_SETUP_INSTANCE_ID(i);
#if !defined(UNITY_STEREO_INSTANCING_ENABLED)
// Completely unclear why i.stereoTargetEyeIndex doesn't work here, considering
// this has to be correct in order for the texture array slices to be rasterized to
// We can limit this workaround to stereo instancing for now.
#endif
// TODO
// declare texture correctly as tex2darray
// pass in stereo eye index in correctly so it can sample texture
// Fix up sampling from a depth texture array
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
float deviceDepth = SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord.xy, unity_StereoEyeIndex).r;
#else

正在加载...
取消
保存