Search Unity

Shaders not working in VR/first person?

Discussion in 'Shaders' started by justin_kasowski, Mar 31, 2020.

  1. justin_kasowski

    justin_kasowski

    Joined:
    Jan 14, 2020
    Posts:
    45
    Hello all, I have a set of shaders that take an image, and highlight the edges and then choose certain pixels to stay on. ie:
    Original Image:
    upload_2020-3-30_21-54-39.png


    First Shader:
    upload_2020-3-30_21-54-26.png

    Second shader:
    upload_2020-3-30_21-55-26.png

    It works fine when the camera has a set position, but when the camera moves it does weird stuff and I don't know why. It seems to run both shaders but the second one ends up getting flipped and displayed over the first one. Any ideas why this is happening?

    upload_2020-3-30_22-1-9.png
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    The frame buffer can get flipped for all sorts of reasons. Most of this gets handled if you're using the built in
    ComputeScreenPos
    function, but sometimes it seems like Unity gets it wrong too.
    https://docs.unity3d.com/Manual/SL-PlatformDifferences.html

    Specifically that
    UNITY_UV_STARTS_AT_TOP
    stuff isn't implemented in any of the built in shaders, so you'll want to add that to your shader code manually.