Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

VR Mobile fog?

Discussion in 'AR/VR (XR) Discussion' started by FingerInd, Jul 21, 2016.

  1. FingerInd

    FingerInd

    Joined:
    Apr 5, 2016
    Posts:
    38
    Any thoughts on the best way to simulate depth on mobile VR? Looking at some of the Google cardboard demo's it looks like Unity's built in fog, but that's not going to work on mobile platforms..
    I've tried cheating it with textures which kind of works, but it'd be interesting to see how other people are achieving this!
     
  2. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,134
    I've successfully faked it by using a hollow cylinder with a shader that utilizes depth blending to control its opacity. It turns transparent the closer it gets to a solid object.

     
    eduardoalvara2 and FingerInd like this.
  3. bart_the_13th

    bart_the_13th

    Joined:
    Jan 16, 2012
    Posts:
    485
    Projector?
    BTW, afaik, built in fog does work on mobile..
     
    FingerInd likes this.
  4. FingerInd

    FingerInd

    Joined:
    Apr 5, 2016
    Posts:
    38
    you're right, mobile fog DOES work.. I assumed it was causing a lag, but that might have been down to my poly count..

    nice trick with the cylinder and the shader! i was going to try something like that next ;)
     
  5. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    Much thanks Jonny10, very cool! Is the script from this shader available?
     
  6. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,134
    Sure thing! I've attached a package.
     

    Attached Files:

  7. Selzier

    Selzier

    Joined:
    Sep 23, 2014
    Posts:
    652
    Amazing work here Jonny10, very much appreciated!!! :)
     
  8. FingerInd

    FingerInd

    Joined:
    Apr 5, 2016
    Posts:
    38
    NIce! thanks for sharing dude.
     
  9. FingerInd

    FingerInd

    Joined:
    Apr 5, 2016
    Posts:
    38
    Hmmm.. that prefab isn't working, is there something obvious that I'm totally missing?
    Dragged it into a scene and it's just transparent...
     
  10. Mischief_Cody

    Mischief_Cody

    Joined:
    Nov 24, 2012
    Posts:
    8
    Thank you Jonny10! I am having difficulty getting it to work though. It works fine when the target platform in pc, but not when target platform is android.
     
    Last edited: Aug 10, 2016
  11. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,134
    On Android the camera doesn't enable the depth buffer by default, at least not in forward rendering.

    Attach this script to your camera, and it should work ;) Your camera component should say: "Info: Renders depth texture" at the bottom.
     

    Attached Files:

    eduardoalvara2 and Mischief_Cody like this.
  12. eduardoalvara2

    eduardoalvara2

    Joined:
    Mar 13, 2015
    Posts:
    2
    OOOH MAAAN,

    YOU'RE AWESOME,

    THANK YOU VERY MUCH,

    very much appreciated!!!

    God yes, I needed that 3D model and you gave me,

    Thank you
     
    StaggartCreations likes this.