02-02-2024 04:34 PM - edited 02-02-2024 05:33 PM
So I have a fairly simple RenderPass and shader, and on Quest 2, it renders fine, but on Quest 3, the eyes don't line up properly. With the below code, I get the same image displayed, but vastly offset in space for each eye. I'm using the Oculus SDK and not OpenXR.
Render Pass:
public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
{
RenderTextureDescriptor blitTargetDescriptor = renderingData.cameraData.cameraTargetDescriptor;
blitTargetDescriptor.depthBufferBits = 0;
_source = renderingData.cameraData.renderer.cameraColorTargetHandle;
RenderingUtils.ReAllocateIfNeeded(ref _destination, blitTargetDescriptor, FilterMode.Bilinear,
TextureWrapMode.Clamp, name: "MagnifierTexture");
}
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
CommandBuffer cmd = CommandBufferPool.Get(_profilerTag);
Blitter.BlitCameraTexture(cmd, _source, _destination);
cmd.SetGlobalTexture(magnificationTexturePropertyID, _destination);
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
Shader:
struct appdata
{
float4 vertex : POSITION;
float2 uv0 : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv0 : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};
TEXTURE2D_X(MagnifierTexture);
SAMPLER(samplerMagnifierTexture);
v2f vert(appdata v)
{
v2f o = (v2f)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = TransformObjectToHClip(v.vertex.xyz);
o.uv0 = v.uv0;
return o;
}
half4 frag(v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
half4 output = SAMPLE_TEXTURE2D_X(MagnifierTexture, samplerMagnifierTexture, UnityStereoTransformScreenSpaceTex(i.uv0));
return output;
}
ENDHLSL