Search Unity

Question Apply Stereo Rendering to Camera Render Texture in VR and URP

Discussion in 'Shader Graph' started by RedGirafeGames, Jul 23, 2021.

  1. RedGirafeGames

    RedGirafeGames

    Joined:
    Sep 30, 2016
    Posts:
    32
    Hi,

    I'm trying to achieve a portal effect in VR using Camera Render Texture and URP.

    It's almost working, but the Render Texture when viewed in the Headset is blurry, I guess it's because the Single Pass Stereo Rendering is not applied to the screen position and left and right eyes are not rendered as it should.

    I found a reddit thread explaining how to apply in shader graph the code from the Unity documentation on stereo rendering.

    But as soon as I do it, the render texture is just plain white.

    Here is the custom function that should do the job :
    Code (CSharp):
    1. void PixelShaderFunction_float(float2 uv, out float2 vruv)
    2. {
    3.  
    4. float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
    5.  
    6. vruv.xy = uv.xy * (scaleOffset.xy + scaleOffset.zw);
    7.  
    8. }
    The sub graph using it :
    Portal_subGraph.png

    The Shader displaying the Render Texture by using the subgraph instead of the classic Screen Position :
    Portal_shaderGraph.png

    Would you have an idea on why it fails?

    Thanks,
    Thomas