Search Unity

Unity Tree Billboard Bug!!! with Oculus UNITY WHAT IS GOING ON??

Discussion in 'AR/VR (XR) Discussion' started by superjayman, May 23, 2016.

  1. kritoa

    kritoa

    Joined:
    Apr 21, 2017
    Posts:
    60
    Oops, I should have written a while ago but I forgot - regarding the trees having a few clumps of leaves which you can rotate by moving your head around: I tried to get the billboarded leaf clumps in the trees to point towards the camera position instead of aligning with the look vector, but failed miserably. I don't know why - it was an easy problem to solve for the grass, but for some reason I couldn't get it to work with the leaves.

    Anyway, a quick-fix that's not 100% ideal but gets rid of all the billboarding shenanigans completely (so that those leaf clumps don't rotate at all) is:

    1) Make a copy of the SpeedTree.shader file (download builtin shaders from https://unity3d.com/get-unity/download/archive , SpeedTree shader is found in DefaultResourcesExtra/Nature). Put that copy anywhere in your Assets folder and it will automatically override the builtin ones.

    2) Crack open the shader, find all the places it is defining the vertex shader as SpeedTreeVert and change it so it calls your own MySpeedTreeVert function instead, e.g. change all #pragma ... ... ... vertex:SpeedTreeVert .. ... to #pragma .. ... ... vertex:MySpeedTreeVert.

    3) Grab the builtin SpeedTreeVert function (it's in builtin shaders/CGIncludes/SpeedTreeVertex.cginc), copy that function, paste it in your copy of SpeedTree.shader, rename the function to MySpeedTreeVert

    4) look for the block that starts with "#elif defined(GEOM_TYPE_LEAF)", look for the comment "// face camera-facing leaf to camera" and comment out the lines under it (there are a few lines where it changes finalPosition - get rid of those).

    Now those leaves don't follow nothin'.


    OR talk about burying the lede, you can just grab my SpeedTree.shader file here: https://pastebin.com/QgAb5cE5 and throw it in your Assets folder somewhere. But my copy is super gross because it has a bunch of copied code (I have 4 copies of that MySpeedTreeVert function because I dumb), and you can see my pathetic fail attempts to have those billboards face the camera position (eventually all commented out). But it works. I think this is the Unity 5.6 version of the SpeedTree.shader ( might be 5.5 but I'm running 5.6 now and it works). I don't know if it'll work for other versions, but in that case you can "fix" it the way I described above.

    Hope those instructions are vaguely understandable - it's way past my bedtime.
     
    technsmile likes this.
  2. mikesf

    mikesf

    Unity Technologies

    Joined:
    Jul 14, 2017
    Posts:
    14
    Hi guys,

    Just a heads up, we are fixing the "rotating trees that moves with your head" issue along with several other VR tree problems. We are targeting the next 2017 release, and we'll backport to 5.6 soon after that.

    Here are some of target fixes:
    1. Billboard trees rotates all the time as viewer moves the camera in VR.
    2. The close-up billboards also “grow” when camera get closer to the tree and “leans” away when camera comes in.
    3. When user looks up and down in VR, the trees also shifts up and down.
    4. Texture aliasing issues in VR
    5. Popping of 3D trees from billboards (no fade in).

    We are keeping performance as fast as possible for VR (faster than Speedtree). There are also other upcoming tree improvements for VR.
    Stay tuned!
     
    P_Jong, benjrau, SiliconDroid and 4 others like this.
  3. KospY

    KospY

    Joined:
    May 12, 2014
    Posts:
    153
    Finally! :) :) :)
    This is included in the 2017.2 beta ?
     
  4. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    393
    Any update on this? Can we expect this to be fixed relatively soon? Thanks!
     
  5. mikesf

    mikesf

    Unity Technologies

    Joined:
    Jul 14, 2017
    Posts:
    14
    Yes, VR Terrain tree changes have made it to 2017.3 and will be released soon. Check the release notes for VR tree improvements and fixes:
    1. Billboard trees rotates all the time as viewer moves the camera in VR.
    2. Trees “grow” when camera get closer.
    3. When user looks up and down in VR, the trees also shifts up and down.
    4. Texture aliasing issues in VR
    5. Popping of 3D trees from billboards (no fade in).
    6. Performance gains from "sort-independent" trees and alpha-to-coverage blending when using MSAA in VR

    If you are on an older version and can't upgrade to 2017.3, send us a note on which version you want us to backport. We'll try to prioritize the requests.
     
  6. kritoa

    kritoa

    Joined:
    Apr 21, 2017
    Posts:
    60
    Do these fixes just affect the pure billboarded trees, or do they also affect the higher detail lod trees (which have some billboarded branch/leaf clusters)?
     
  7. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    We are using unity 5.5.0p3 any chance this gets rolled back to these earlier versions?
     
    tapawafo and CloudyVR like this.
  8. mikesf

    mikesf

    Unity Technologies

    Joined:
    Jul 14, 2017
    Posts:
    14
    @kritoa The VR Trees fixes affect Unity's TreeCreator trees and billboards (non-Speedtree).
    @Migueljb We've stopped backporting changes to 5.6 and below. Should try to upgrade to 2017.3 get new fixes/features.
     
    Avotas and CloudyVR like this.
  9. Avotas

    Avotas

    Joined:
    Oct 19, 2013
    Posts:
    7
    @mikesf Hi Mike! Thank you for your efforts on Unity's Tree Creator. Would it be possible to backport the fix to 2017.1.0f3? We are close to our initial release and we are bound to this version of Unity.
     
    P_Jong and CloudyVR like this.
  10. mikesf

    mikesf

    Unity Technologies

    Joined:
    Jul 14, 2017
    Posts:
    14
    @avotas I spoke with management and because VR Trees rework is considered a feature of 2017.3, it won't be back ported, sorry. Best if you upgrade to 2017.3 at some point.
     
    Avotas likes this.
  11. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    How the heck can a bugfix be considered a feature? Some kind of bad joke? : /
     
    P_Jong likes this.
  12. Avotas

    Avotas

    Joined:
    Oct 19, 2013
    Posts:
    7
    @mikesf Thank you. I appreciate the attempt.
     
  13. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Yes, im really psyched that this is finally getting fixed for sure : )
     
    P_Jong and Avotas like this.
  14. Bradamante

    Bradamante

    Joined:
    Sep 27, 2012
    Posts:
    300
    Well SpeedTrees are pretty much unusable in VR right now (as of 2017.2) since they also contain billboarded parts that behave strangely in VR. Is there an improvement in the works for that?

    Given that the quality of the SpeedTrees is otherwise pretty decent and given how Unity advertised natively integrated SpeedTree I don't really want to use another product.
     
  15. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    You can disable billboard rotating if you have the editor (costs money)
     
  16. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Should be fixed now in 2017.3
     
    CloudyVR likes this.
  17. mikesf

    mikesf

    Unity Technologies

    Joined:
    Jul 14, 2017
    Posts:
    14
    The VR trees in 2017.3 is a new solution and we have to rewrite tree rendering to make it work for VR. See our Unite Austin talk on it (38 minute mark):
     
    CloudyVR likes this.
  18. dmennenoh

    dmennenoh

    Joined:
    Jul 1, 2015
    Posts:
    379
    Or 39:40 mark and skip a minute and a half of unprepared presenter.
     
    Last edited: Dec 24, 2017
  19. DINmatin

    DINmatin

    Joined:
    Aug 21, 2014
    Posts:
    14
    in Unity 2017.2.1f1 leaves are still turning as your head turns, in VR.
    not nice!
     
  20. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    they said this was fixed on 2017.3 not on .2... check it out there
     
  21. oumur

    oumur

    Joined:
    Sep 12, 2013
    Posts:
    11
    there is always a excuse to force people to update. this could have been a hotfix for 2017.2 but noo its better to force people to update and break their projects... much more funn...
     
  22. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    I doubt a project working in 2017.2 will break when going to 2017.3. (mine didn't). You should just make a backup of your entire project directory and give it a go.
     
  23. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Projects do break A LOT from one update to the other. Right now I can't update to 2017.3 because they messed up WWW component and it's not fixed. So usually to be safe you wait for a few patch releases.
     
  24. dmennenoh

    dmennenoh

    Joined:
    Jul 1, 2015
    Posts:
    379
    >>I doubt a project working in 2017.2 will break when going to 2017.3. (mine didn't).

    Mine just did - stereo rendering in Cardboard went wonky when building to iOS in 2017.3 Reopened the same project in 2017.2 and it's still broken now.
     
  25. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    What?!? You mean you:
    • backed up your entire project directory
    • updated unity
    • opened your project in new unity
    • closed new unity
    • deleted project folder
    • restored project folder from backup
    • rolled back unity
    • opened project
    and it was broken? how can that be? there are no registry settings or anything, all project state is contained within the project directory.
     
    Last edited: Dec 24, 2017
    Ostwind likes this.
  26. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    Safe? from what potential loss?

    I think if you make a project backup (whole directory and subs zipped somewhere) you can just roll back unity and open that if you need to.

    I am under the impression all project state is contained within the project directory and its subs? I have been able to transfer a zipped project to a brand new computer, installed unity and the project works, what am I missing here?
     
    Last edited: Dec 24, 2017
  27. dmennenoh

    dmennenoh

    Joined:
    Jul 1, 2015
    Posts:
    379
    No, I opened the project back up in 2017.2

    I have a backup at work, but that means I will have to go in to get it - I never got VPN installed. We are off between Christmas and New Years so it's a bit of a pain. Was hoping to do some work at home. Thanks for pointing out that all state is within the project folder - that is good to know.
     
    SiliconDroid likes this.
  28. SiliconDroid

    SiliconDroid

    Joined:
    Feb 20, 2017
    Posts:
    302
    Glad to hear you got it backed up at work.
     
  29. peardez

    peardez

    Joined:
    Jun 27, 2017
    Posts:
    10
    mmmm...so just to confirm I understood something: Speedtree adleaf_desktop tree is a speedtree object even if it's included in the Unity standard assets but it would still rotate leaves when rotating head in VR, right? What kind of realistic and not superkilling performance can we use then in our VR games without weird rotation issues?
     
  30. CloudyVR

    CloudyVR

    Joined:
    Mar 26, 2017
    Posts:
    715
    Just make it a winter scene and don't use leaves!! Lol, jk

    I really hope they are addressing this issue!
     
    Last edited: Dec 29, 2017
  31. technsmile

    technsmile

    Joined:
    Sep 29, 2016
    Posts:
    2
    Thank you kritoa, your shader make my day !
    No more billboarding shenanigans

    I could successfully use it in Unity 2017.3 after overriding Shader uses for each Tree and LOD

    upload_2018-2-10_17-36-25.png
     
  32. turdann

    turdann

    Joined:
    Dec 29, 2012
    Posts:
    43
    Hi @mikesf,
    for me it's working on oculus, using Unity 2017.4.3f1, but we are developing for PS4, and there it still have the same rotation problem. Any idea how to fix it for PSVR?

    Thanks
     
    Last edited: Aug 13, 2018
  33. Franckitou

    Franckitou

    Joined:
    Jun 3, 2015
    Posts:
    16
    Yoohoo I just found how to make it work
    Go to quality settings
    scroll down to other settings
    change the LOD bias. I put LOD bias = 100. worked for me. the trees are no more displayed as billboard when you are just in front of them
     
    ROBYER1 likes this.
  34. Pepe-Hoschi

    Pepe-Hoschi

    Joined:
    Feb 27, 2016
    Posts:
    8
    Hi,

    I added the missing part to Kritoas shader.
    Billboard alignment should work fine in VR now :D (As far as possible)

    You can find the complete shader here: https://pastebin.com/hUY6Njdi

    Have fun....

    @Unity & IDV:
    Why can't you fix such issues?
    The shader is from 2016. And yet noone cares about VR compatibility?
    If you want users to buy your products, you should care about their requests.

    Code (CSharp):
    1.  
    2. //Pepe - modified part
    3.     float offsetLen = length(finalPosition);
    4.     //finalPosition = mul(finalPosition.xyz, (float3x3)UNITY_MATRIX_IT_MV); //old camera facing (orients to view matrix, bad!!)
    5.  
    6.     //In case you want axis aligned billboards uncomment the lines below
    7.     //We use a modified inverse view matrix to axis align the billboards
    8.     //float3x3 axisMatrix = (float3x3)UNITY_MATRIX_IT_MV;
    9.     //axisMatrix[0].xyz = mul((float3x3)unity_WorldToObject,float3(-1, 0, 0));
    10.     //axisMatrix[1].xyz = float3(0, 1, 0);
    11.     //finalPosition = mul(finalPosition.xyz, (float3x3)axisMatrix);
    12.  
    13.     //We need the viewVector to align the billboards to the cameraposition
    14.     float3 lookAtPoint = mul(unity_ObjectToWorld, float4(data.texcoord1.xyz, data.vertex.w)) ;
    15.     float3 viewVector = normalize(_WorldSpaceCameraPos.xyz - lookAtPoint);
    16.  
    17.     //Then we create a LookAt matrix
    18.     float3 up = float3(0, 1, 0);
    19.     float3 zaxis = viewVector;
    20.     float3 xaxis = normalize(cross(up, zaxis));
    21.     float3 yaxis = cross(zaxis, xaxis);
    22.     float3x3 lookatMatrix = {
    23.       xaxis.x,            yaxis.x,            zaxis.x,
    24.       xaxis.y,            yaxis.y,            zaxis.y,
    25.       xaxis.z,            yaxis.z,            zaxis.z
    26.     };
    27.     //...and apply the rotation!
    28.     finalPosition = mul(lookatMatrix, finalPosition);
    29.  
    30.     finalPosition = normalize(finalPosition) * offsetLen; // make sure the offset vector is still scaled
     
    FlightOfOne likes this.
  35. JumPPingGG

    JumPPingGG

    Joined:
    Feb 9, 2018
    Posts:
    3
    It's 2019 and it hasn't been solved yet.ahhahahaha
     
    ROBYER1 likes this.
  36. dospunk

    dospunk

    Joined:
    Apr 26, 2019
    Posts:
    2
    2020, terrain grass still faces the camera's forward vector.
     
  37. cmdexecutor

    cmdexecutor

    Joined:
    Sep 30, 2014
    Posts:
    21
    Is this what all here are talking about?

    Btw it's almost 2021
     
  38. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    yeah, they fix it and broke it multiple times. Not sure who checks this. It seems they change every few months from working to wtf. Since Unity 2017 it's a hit or miss for billboarded trees.
     
  39. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Have you tried enable Billboards Face Camera Position in the Quality settings?
     
  40. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    yeah and same issue, on/off. Right now they are not renderer at all in Android VR single plass for instance.
     
  41. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
    Billboards Face Camera Position works with the new XR system on Android in Unity 2020. At least with Multipass, and the terrain system built in billboarding of trees. But the performance is terrible. With more than two trees visible at the same time the frame rate drops to like 10 or so. There are a note about using LOD instead for Speedtrees. Haven't tested that yet. What method did you use for the billboarding?

    Edit: Or maybe not. When I checked again, the billboards seems to follow the camera angle, and not the position. But they are showing. Not sure when it happened in the fps chase, though. Have tested different light, and baking settings, compressions, and streaming mipmaps. Perhaps that's messed it up.
     
    Last edited: Apr 22, 2021
  42. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Yeah, managed to get trees to render but the performance is complete crap. It has to be some bug, the Quest 2 cannot render more than 100 billboarded trees at a decent framerate when my 2015 Android phone renders 1000 at 40fps no problem.
     
  43. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    45
    Unity 2020.3.7f1, XR plugin with Oculus, graphics API: Vulkan
    Project Settings -> Quality -> marked Billboard Face Camera Position doesn't help
    Project Settings -> Quality -> LOD Bias set to 100 doesn't help....
    If I move (rotate) my head up then all trees are almost flat on a terrain surface... TERRIBLE issue!

    Autogenerated Billboards with the functionality of a Unity Terrain doesn't work with that assest:
    https://assetstore.unity.com/packages/3d/vegetation/trees/low-poly-tree-pack-57866
    ...but works with that asset (but it it super slow):
    https://assetstore.unity.com/packages/3d/vegetation/speedtree/free-speedtrees-package-29170

    4 years from the day when the thread was created and still it doesn't work - so I assume it will never happen. Anyone has any idea how to use unity terrain system with trees in VR?
     
    Last edited: May 17, 2021
  44. arfish

    arfish

    Joined:
    Jan 28, 2017
    Posts:
    782
  45. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    I found out how to render trees. The problem is with their default unity shader, it's crap. I'm rendering over 10k trees now on Oculus Quest 2 at 70fps.
    I read on the 2021.2 alpha 17 release notes that they fixed it.
     
  46. arczi79

    arczi79

    Joined:
    May 10, 2021
    Posts:
    45
    Not yet. Will try it later today.

    2021.2 alpha 17 is... alpha unfortunately. Last LTS version is 2020.3.8f1 :(
    Could you please provide more details about you solution? Did you replace somehow default billboarding shader used by Unity Terrain system? Can you use your trees as the predefined objects to place them randomly on terrain with use of built in Unity tools (from the Terrain component on Inspector)?
     
  47. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
  48. DAV007

    DAV007

    Joined:
    Jan 24, 2022
    Posts:
    1
    Well... I was hoping to find an easy fix, looks like I'll be using some different trees lol
     
  49. Gssev7

    Gssev7

    Joined:
    Jul 9, 2014
    Posts:
    32
    HI, Just had an issue in terrain trees in VR with the billboards being a lot lighter than the 3d ones. After different tests i found that the material colour was set darker and the billboard does not take this in to account. so landed up seiing the material colour to white and adjusting the texture in a paint program to the darkness I wanted and refreshed the trees in terrain and its good now.
     
  50. cguerr2022

    cguerr2022

    Joined:
    Jul 11, 2022
    Posts:
    1
    11/23/2022
    grass and trees in unity vr... terrible idea...very Unreal