Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

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:
    12
    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:
    97
    Finally! :) :) :)
    This is included in the 2017.2 beta ?
     
  4. silentslack

    silentslack

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

    mikesf

    Unity Technologies

    Joined:
    Jul 14, 2017
    Posts:
    12
    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:
    512
    We are using unity 5.5.0p3 any chance this gets rolled back to these earlier versions?
     
    matteumayo and trappist-1 like this.
  8. mikesf

    mikesf

    Unity Technologies

    Joined:
    Jul 14, 2017
    Posts:
    12
    @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 trappist-1 like this.
  9. avotas

    avotas

    Joined:
    Oct 19, 2013
    Posts:
    6
    @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 trappist-1 like this.
  10. mikesf

    mikesf

    Unity Technologies

    Joined:
    Jul 14, 2017
    Posts:
    12
    @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,961
    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:
    6
    @mikesf Thank you. I appreciate the attempt.
     
  13. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,961
    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,406
    You can disable billboard rotating if you have the editor (costs money)
     
  16. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,961
    Should be fixed now in 2017.3
     
    trappist-1 likes this.
  17. mikesf

    mikesf

    Unity Technologies

    Joined:
    Jul 14, 2017
    Posts:
    12
    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):
     
    trappist-1 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:
    8
    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,221
    they said this was fixed on 2017.3 not on .2... check it out there
     
  21. oumur

    oumur

    Joined:
    Sep 12, 2013
    Posts:
    10
    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,221
    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. trappist-1

    trappist-1

    Joined:
    Mar 26, 2017
    Posts:
    535
    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:
    1
    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:
    34
    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:
    12
    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:
    5
    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.
     
unityunity