Search Unity

Graphics.Blit not aligning content in VR?

Discussion in 'Image Effects' started by harperAtustwo, Aug 28, 2018.

  1. harperAtustwo

    harperAtustwo

    Joined:
    Nov 15, 2016
    Posts:
    25
    Hey, I have this on a camera to blend two RenderTextures together using adaptive blending.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class AdativeCamera : MonoBehaviour {
    6.     public Material addativeMat;
    7.     public RenderTexture contentRT;
    8.     void OnRenderImage(RenderTexture source, RenderTexture destination)
    9.     {
    10.         Graphics.Blit(source, destination);
    11.         Graphics.Blit(contentRT, destination, addativeMat);
    12.        
    13.     }
    14.  
    15. }
    16.  
    The shader looks like this.

    Code (CSharp):
    1. Shader "blend" {
    2.     Properties{
    3.         _MainTex("Texture to blend", 2D) = "black" {}
    4.     }
    5.         SubShader{
    6.             Tags { "Queue" = "Transparent" }
    7.             Pass {
    8.                 Blend One One
    9.                 SetTexture[_MainTex] { combine texture }
    10.             }
    11.  
    12.     }
    13. }
    This all works as intended outside of VR but when I use it in a VR setup, the Blit appears to render only one eye even if the camera is set to both. As a result, the "content" appears double as the 2 eyes do not align.

    Any idea what direction I should go to resolve the issue? Thank you.