Is there a way for shader to get if it's rendering for left/right eye in XR

i am currently working on some advanced effect for VR.

one of it is to use camera’s RenderTexture and render it to the background on a VR view. but the problem is i don’t know how to make the shader to get if it’s rendering for left/right eye in XR. Do you have suggestion for me?

Engine sets camera projection matrices, but nothing extra (no extra uniform that could identify a view): https://github.com/playcanvas/engine/blob/9a0697c6b2cd521db510df49f90028f414006696/src/scene/renderer/forward-renderer.js#L1475

You could modify the engine, to set uniform with a view index in the code provided above.

4 Likes