Hi,
From what i read about the Render method in builtin you needed to disable the camera Unity - Scripting API: Camera.Render, i did the same with RenderSingleCamera for URP but i see the method just executes in case i have the camera component active, i am not sure if having the camera active is fine or can have any problem, cause i am using two rendersinglecamera, one for each eye, but i camera doesn’t actually render the objects belonging to the culling mask it has. I am applying to each camera stereo matrix for each eye, like this for left eye currentCamera.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left);. Seems the projection matrix is wrong as if i don’t change the camera matrix i can see the objects for each eye but wrong when i see with both eyes
I also noticed that objects look nearer than they should be, tried col = tex2D(_LeftTex, UnityStereoScreenSpaceUVAdjust(i.uv, _LeftTex_ST)); in shader instead col = tex2D(_LeftTex, screenUV); using float2 screenUV = i.screenPos.xy / i.screenPos.w; but doesn’t work, just show the objects smaller
Also rotation is wrong, seems camera projectionmatrix is not correct
This is my code
private void OnEnable()
{
//UnityEngine.XR.XRSettings.gameViewRenderMode = UnityEngine.XR.GameViewRenderMode.BothEyes;
RenderPipelineManager.beginCameraRendering += UpdateCurrentCam;
}
private void OnDisable()
{
RenderPipelineManager.beginCameraRendering -= UpdateCurrentCam;
}
void Start()
{
meshRenderer = GetComponent<MeshRenderer>();
}
void UpdateCurrentCam(ScriptableRenderContext context, Camera currentCamera)
{
if (meshRenderer != null && currentCamera.gameObject.name == "PortalCamera")
{
currentCamera.projectionMatrix = currentCamera.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left);
UniversalRenderPipeline.RenderSingleCamera(context, currentCamera);
meshRenderer.material.SetTexture("_LeftTex", currentCamera.targetTexture);
currentCamera.projectionMatrix = currentCamera.GetStereoProjectionMatrix(Camera.StereoscopicEye.Right);
UniversalRenderPipeline.RenderSingleCamera(context, currentCamera);
meshRenderer.material.SetTexture("_RightTex", currentCamera.targetTexture);
}
}
I have seen code from other projects and they use obliquematrix but don’t know why, what does obliquematrix? If i transform matrix with obliquematrix and it renders the box column in front of the camera but wrong. I have set the same models for both dimensions but the portal camera renders wrong scale and rotation, i have set the portal camera as child of main camera but render just the culling mask for objects in the other dimension