浏览代码

Workaround unity_StereoEyeIndex issue with stereo instancing

Basically, something is going wrong with UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX or stereoTargetEyeIndex in stereo instancing. We can work around it by not calling it, because UNITY_SETUP_INSTANCE_ID sets up unity_StereoEyeIndex for us, if instancing is enabled.
/lwrp-xr-sssm-DrawProc
Robert Srinivasiah 7 年前
当前提交
6365f8fb
共有 1 个文件被更改,包括 5 次插入14 次删除
  1. 19
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightScreenSpaceShadows.shader

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


SAMPLER(sampler_CameraDepthTexture);
#endif
struct VertexInput
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct FullScreenInput
{
uint vertexID : SV_VertexID;

UNITY_VERTEX_OUTPUT_STEREO
};
//Interpolators Vertex(VertexInput i)
Interpolators Vertex(FullScreenInput i)
{
Interpolators o;

//o.pos = TransformObjectToHClip(i.vertex.xyz);
//o.texcoord.xy = i.texcoord;
//o.texcoord.xy = UnityStereoTransformScreenSpaceTex(i.texcoord.xy);
o.texcoord.xy = GetFullScreenTriangleTexCoord(i.vertexID);
o.texcoord.zw = projPos.xy;

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
// 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
unity_StereoEyeIndex = i.instanceID;
float deviceDepth = SAMPLE_TEXTURE2D_ARRAY(_CameraDepthTexture, sampler_CameraDepthTexture, adjTexCoords, unity_StereoEyeIndex).r;
#else
float deviceDepth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, adjTexCoords);

正在加载...
取消
保存