Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Yoirgl's avatar
Yoirgl
Start Partner
9 years ago

Unity - portals discussion and rendertexture help needed.

Hello everyone.

I'm currently doing a small clone of portal (on Unity) for the kicks of it while waiting for Music Box to be released and get some feedback.
Here you can see the progress on my portal clone

https://youtu.be/zRj8HomsCYA

For the moment for the portals I'm using a render depth shader allowing me to see straight trough my current camera's to see the "portal camera". It works quite nice and fast but it can end up having some glitches i cannot solve because they are caused by render depth issues.
I made a few tests to have it work with rendertextures. But rendertextures seems to be updating too late (rotating my head makes the texture "shift" to one side for a split second until it's back at the right place) it's very quick but it makes it feel "wrong".
Is there a way to make sure "portal camera" +  rendertextures are always updated before an image is sent to the headset (ASW included ?)
Any help is welcome.

Yoirgl.

5 Replies

  • Yoirgl's avatar
    Yoirgl
    Start Partner
    Hello Impereativity.

    Thanks for the reply who is well thought out.
    This is indeed what I do and what can be seen on the video.
    However there is still an issue.
    I made a small schematic here to explain my issue.

    The issue here is that -if you can see both portals-, one of them is always going to have its image in front of the other one if, indeed, its camera is oriented towards terrain. . In this case, the blue 1 camera image always appears on top of the red 1 camera, causing the issue we see on the screenshot. I drastically limited the issue by deactivating a portal's camera(s) if you don't look at it but I still get this issue. 
    Is there a way to have a shader render only one specific camera instead of having to resort to render order ?
    I'm still very new to rendering issues and I haven't had the chance to find a decent free tutorial on shaders that I could understand properly :neutral:
    Maybe there's something I'm doing wrong or I'm not using the right technique ?
    Cheers.

    Yoirgl.
  • Yoirgl's avatar
    Yoirgl
    Start Partner
    @imperativity
    *erm*
    Well you lost me at "directed acyclic graph
    of cameras" :#
    I'm trying to read wikipedia articles and try to understand what you mean :)
    (as I said i'm still quite new to this ^^)
    brb.

  • Yoirgl's avatar
    Yoirgl
    Start Partner
    @imperativity
    Hello again.
    I think I understood what you meant but in this case, recursivity is not really the issue.
    The issue happens even with recursivity set to 0 (I made it dynamic). -0 meaning only one camera per portal-
    I'm just not entirely certain what you meant by "clear the depth". If you mean set the camera's clear flags to depth only, yes that is the case and that is also part of what's causing me so much troubles. .
    The problem I have, as you can see in the small screen capture below, is that I cannot render both camera on 2 different depths without them "polluting" one another in certain cases. (check the depth modification on 2nd portal camera) .

    https://youtu.be/Yl_WvTZq_LE

    In the video if i change the depth on the camera to a value between 0 and -0.5 it'll seems OK but it won't be because then my blue portal will suffer the same issue as the red one. (although not visible on the current angle.)
    I tried scissoring the screen to only render what was around the portal
    per camera but that doesn't seem to work with a VR camera
    Did I understand you correctly or is my problem a bit clearer ?
    It's quite tricky to explain precisely.

    Yoirgl.

  • Yoirgl's avatar
    Yoirgl
    Start Partner


    @Yoirgl

    To further clarify: you will need to depth clear after each
    portal render. You will also need to mask the region of UserCamera's view where
    Portal1 appears before rendering Portal2.

    Hope this helps you!



    Hello.

    Well, unfortunately it doesn't. :'(
    I think you have a different vision of mine but i can't quite grasp your idea.
    Could you try and explain it to me o:) ? 
    Thank you for your replies.

    Yoirgl.

    PS : is there no way to hack the view bypass to get the rendertextures to behave properly ?
    Using a rendertextures removes a whole bunch of other issues at once.


    edit : I was able to achieve some level of success using stencil buffers+depth
    masks but the result is quite unstable and i sometimes get some degree
    of "judder" (not 100% reproducible)