Search Unity

Tree / Billboard solution yet?

Discussion in 'AR/VR (XR) Discussion' started by Gibbonuk, Mar 23, 2017.

  1. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    175
    Hi, i was just wondering if there is any solution or workaround yet for using billboard trees in VR? (other than not using billboards)

    Thanks
     
  2. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,536
    I'm also curious about this and there seem to be several other posts about it on the web.

    If nothing else, does anyone have the particulars about why this happens and/or what a possible solution might be?
     
  3. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    You could synthesize some: instantiate quad prefab with script to make it always look at cam with Y-up. Being CPU calculated though; for many trees it will get costlier than using a few more tris per tree.

    If you're going after semi realistic and are on a tight tri budget: I'm using trees made of 3 quads (6 tris) with a fast double sided alpha cutoff shader, they look OK from any viewpoint and even have a bit of volume in VR.
    For connifer types you can even get away with 3 tris per tree and those tris can share the same apex vert, so just 7 vertex per tree.
     
    Selzier likes this.
  4. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,536
    That's one way to do it but it seems like that makes a lot of sacrifices in terms of quality.
     
  5. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    I'm not sure about that, billboards look pretty bad IMO, certainly when as close as the trees in my screenshot if you're moving past them they are obviously flat planes swinging around their y axis. And at a distance, I'll bet you wouldn't be able to tell the difference, unless you moved past them really quick and then billboards look totally fake as they swing around.

    But yeah if you really want billboards, you'll have to wait for unity to fix it or synthesize them as I mention.
     
  6. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,536
    That's my point, at that distance quality that low isn't an option for everyone. For the majority, I would imagine.

    Billboards serve a clear purpose, and we're interested in making them work in VR.
     
  7. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    I think my trees look pretty nice considering I only have a 50k triangle budget to build a city and 8 mech robots with.:p

    You got my point backward though... I'm saying billboards look obviously fake up close; certainly when the camera is translating.

    Don't get me wrong: I'm not saying billboards don't need to work or that they serve no purpose.

    For those that really want billboards... you have one option until unity fixes them: Make your own batched billboards, just make sure you cache all vars at class scope (even cam and object transform) and have tiny script in onUpdate to make quad face cam. Should be able to instantiate many with no worse performance than standard unity billboard and exactly the same visual quality.

    EDIT: or write your own optimized billboard shader as @Gibbonuk alludes to below.
     
    Last edited: Mar 27, 2017
  8. Gibbonuk

    Gibbonuk

    Joined:
    Dec 10, 2013
    Posts:
    175
    Thanks for the replies, assuming not as it would have been done by now but is the rotate to face camera a shader program? Could it modified to face something else? (that is near the camera?) (I read its due to VR having 2 cameras)
     
  9. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    I'm not sure how unity implements billboards, but yes indeed you can do them with a shader. You can do flat, cylindrical and spherically mapped billboards with shader.

    Having each shader grab it's corresponding camera gxl3d_ProjectionMatrix would only work for billboards >20m away in stereo. Any closer and you would need to have all shader instances share some global per frame stored gxl3d_ProjectionMatrix, ideally one that is the vectorSum/2 of both cams.

    But the saving a shader would give over optimized script rotated quads would probably only be benificial for very large billboard count. You're gonna need seperate transform for each billboard no way around that even with shader.
     
    Last edited: Mar 27, 2017
  10. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,536
  11. graphicDNA

    graphicDNA

    Joined:
    Jun 26, 2017
    Posts:
    47