Search Unity

Unity projection matrix calculation affects shader

Discussion in 'Shaders' started by hknylt, Jul 3, 2019.

  1. hknylt

    hknylt

    Joined:
    Sep 13, 2014
    Posts:
    16
    I'm working on a portal game with Unity. For the portal camera to see the world correctly, I do a matrix calculation like the one I see in github.

    https://github.com/pr0g/unity-porta...alsWithRenderTargets/Assets/Scripts/Portal.cs

    But when I do, the distortion effect of unity's "Glass Refractive" material deteriorates.

    The main camera is rendering correctly.
    1.jpg

    However, the portal camera does not show the distortion effect when I use the projection matrix calculation.

    3.jpg

    If I do not calculate the projection matrix, the distortion effect is visible, but this time, objects such as walls in front of the camera pass. Because the projection matrix does not calculate the back of the portal does not cut.

    2.jpg

    When I use the matrix calculation in unity's water script for projection matrix calculation, the result does not change again.

    Since I don't understand the cause of this problem, I can't predict what kind of problem it can cause on different shaders.

    Does anyone have any idea about this?
     
    Last edited: Jul 3, 2019
  2. hknylt

    hknylt

    Joined:
    Sep 13, 2014
    Posts:
    16
    Problems occur with cameras using projection matrix. For example, unity's water script does not run toon shaders and glass refraction shaders properly.

    21.jpg

    The problem with the Water script is also present in the portal camera. Why does this problem occur with cameras using a projection matrix? How can I solve it? I have no idea and my project has stopped. :(

    22.jpg
     
    Last edited: Jul 3, 2019
  3. hknylt

    hknylt

    Joined:
    Sep 13, 2014
    Posts:
    16
    I still haven't found a solution.
     
  4. hknylt

    hknylt

    Joined:
    Sep 13, 2014
    Posts:
    16
  5. hknylt

    hknylt

    Joined:
    Sep 13, 2014
    Posts:
    16
    Also, the projection matrix is reset when I use a post processing stack. I have learned that there is no solution yet. So my question is: how can I set up the F***ing portal camera with these restrictions? How will the portal camera work without using a projection matrix?
     
    deus0 likes this.