Search Unity

[Released!] Custom tree importer

Discussion in 'Assets and Asset Store' started by larsbertram1, Aug 19, 2014.

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    no, the shader is missing a depth normal pass. and ii misses a multi compile directive. so lighting will not pick up ssao. i will add it some day...
     
    Noogy likes this.
  2. GotAThing

    GotAThing

    Joined:
    Jan 10, 2019
    Posts:
    14
    Hi im having trouble getting LOD fade to work in HDRP. As the fade starts the leaves on the mesh object vanish(shrink at the pivot). I suspect it has something to do with my import tags, i am using "_afsTREE_xlpr_xlod00" & "_afsTREE_xlpr_xlod01" in the filenames. do i need to add tags to leaf objects also? (other than _xlod01 on emitted objects)
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    that is the expected behavior for leaves being marked to fade out.
    hmm, filenames should not drive the fading as it is per "level" – not per object.
    there is an _xlod tags per level as well: Mark the branches and leaf planes that should be skipped at the specified level by adding "_xlod" plus 2 digits to the level name.

    as you mentioned hdrp explicitly: do they work in standard rp as expected?
     
  4. GotAThing

    GotAThing

    Joined:
    Jan 10, 2019
    Posts:
    14
    I've just tested in standard rp, the transition from mesh to billboard seems to work fine. i noticed fade issues on mesh to mesh transitions with SpeedTree selected but the behaviour was the same on the demo LOD tree. so probably just something to do with project settings, i havent used standard rp for a long time.

    the demo birch in the HDPR project works fine, iv taken a closer look at whats happening compared to the my tree. It seems the actual fading is working the same, the problem with mine is just the leaf planes shrinking then expanding.
    I can uplaod an image of whats happening if thats any help?
     
    Last edited: Dec 1, 2020
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    of course.
     
  6. GotAThing

    GotAThing

    Joined:
    Jan 10, 2019
    Posts:
    14
    I've disabled the billboard so its easier to see whats happening. My tree is on the left, the demo on right.
     

    Attached Files:

  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm, which HDRP shader package do you use?
    i just tested "CTI_HDRP_RuntimeComponents_7.2." which works fine on the "Jatoba LOD Group for Terrain" as well.
     
  8. GotAThing

    GotAThing

    Joined:
    Jan 10, 2019
    Posts:
    14
    Im using the standard package, the 7.2 versions throws errors for me. (failed to open source file: '/Includes/CTI_HDRP_Wind.hlsl)
    Yes iv also tested Jatoba, it works fine. Also tried everything in a fresh HDRP project and get the same result. Something to do with the blender fbx export maybe?
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i remember something similar when i was working with an updated version of the importer script which encoded lod information slightly differently... but that was due to my changes in code?!
    not sure about blender. @Baldinoboy might know more?
     
  10. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hey @larsbertram1 & @GotAThing, Was following this but did not give any input because I am not sure. Had this happen to me before but was an import bug and happened in the Standard RP. Not sure why it would be doing this in HDRP and not Standard.

    Only thing I can think to further test if is you could PM us with the tree model you are having this issue with.
     
  11. GotAThing

    GotAThing

    Joined:
    Jan 10, 2019
    Posts:
    14
    Thankyou that would be great, im all out of ideas. The problem happens with all my trees i have tested. I have a basic test tree i can send over if that simplifies debugging? How would be best to send the files over?
     
  12. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Sent you a PM
     
  13. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Hi @larsbertram1, is there an option to fade out the transparency of the CTI bark and leaves shaders? Sort of how it currently transitions betweens LODs, but transitioning to nothing? I'm using the shader for tree branches and such after a tree is cut down and it'd be nice to fade out. Thanks.
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    no , there is nothing like this. it ould need you to add a new multi_compile, enable/disable the related keyword from script and feed in a fade value.
     
    Noogy likes this.
  15. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    @Baldinoboy

    Hi!

    I am currently testing out the Custom Tree Importer. Unfortunately, I have two errors that I can't get resolved.

    First, as you can see, the shader changes the mesh. At the top image, the mesh is with standard shader. On the lower image, with the shader from Custom Tree.





    Furthermore, I have the problem that the tree moves, but randomly. It does not react to the wind.

    3D-Programm:



    What am I doing wrong?

    Thanks! :)
     
  16. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i don't know.
    are your materials named properly?
    are your transforms reseted properly?
     
  17. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    Names should be correct:

    Stem: Red Bark
    Leaves: Green Leaf

    Transformations I have frozen all.

    EDIT:

    I overlooked the fact that you have to assign a material already in the 3D program. If I assign this in the program, the import also works.

    The problem with the distortion is gone. Also, it now reacts correctly to the wind. Small problem now, the trunk does not move in the wind, but the tree top flies away:

     
    Last edited: Mar 30, 2021
  18. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    maybe it is rotated?
     
  19. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    @Kojote, Yeah it looks like it might be a rotation issue. I get this a lot in Blender if I forget to set the root and trunk to a rotation of x90, y00, z00 and position them upright. Not sure if it needs to be the same in that program.
     
  20. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    It was not a rotation problem, the pivot points of the blades were on the ground. I have now brought them into the canopy, now it works. Two problems would be still open, then it is pefekt. The trunk does not move yet, but the leaves too much. At least with the leaves this should be solvable with the control tags.
     
  21. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Kojote likes this.
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    @Kojote the leaves should be separated and not be a single mesh in order to get most out of it.
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    @Kojote was ist denn das für ein 3d programm?
     
  24. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    The leaves are separated. Thinking it is a scale issue in Max. Was able to get it working fine exporting from Blender but I am not familiar with Max.

    Does anyone use 3DS Max for exporting trees to CTI?
     
  25. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hey @larsbertram1, Is it possible to have multiple trunks on the same import? Thinking no but maybe use the additional as branches and set the bending xt00. Will test but wanted to ask.
     
  26. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    @larsbertram1 Thanks for the help! :) I actually use 3ds Max. However, I have noticed that there are problems with the import and export, because the scaling in 3ds Max is not correct.

    I got myself Blender and split the tree into its parts, changed the hirarchy and attached the tags. Polybrush should also be correct. The scaling is set to 1|1|1. The tree is imported correctly, at least there is no error message. The leaves move well, but I can't get the tree to bend.

    Could you possibly have time to look at the tree?
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    just drop it
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    never really tested this, sorry. having an invisible trunk and several branches tho should just work.
     
    Baldinoboy likes this.
  29. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Hello @larsbertram1, I'm having an odd issue with CTI and DrawMeshInstanced. I've attempted to replicate this issue with other shaders and I think it's specific to CTI.

    So the issue is that when I'm drawing a group of trees with DrawMeshInstanced, everything is fine unless the trees are out of view. It then has trouble drawing the shadows... the meshes will draw fine but something is swapping the leaves textures used with other trees also being drawn with DrawMeshInstanced.

    So the result is that the leaves shadows are randomly using the wrong materials. Sorry I know it's hard to describe and it might be difficult to create a test project, but I hope you can help me to figure this out. Thanks.
     
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    it is an old issue? i am not aware of this...
    are these mesh trees or billboards?

    which version of unity? which render pipeline? any info you can provide will help :)
     
  31. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    I also have another question. Normal Map (GA) Specular (B) or AI (G) Translucency (B) Smoothness (A) cause a very unattractive bluish colour gradient on my sheets. Here is a picture of this:



    It definitely has to do with the two materials mentioned above. Is there any way to prevent these colour gradients?
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    it is most likely specular reflections which can be controlled setting Specular (B) accordingly. setting it to 0 will unity make fall back to diffuse lighting only.
     
  33. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    Where do I have to set what to 0? ^^
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    in the combined texture "Normal Map (GA) Specular (B)" set the blue color channel to 0.
     
  35. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    These are mesh trees. Using CTI for the bark and leaves materials. I've noticed the issue for a while and assumed it was a general URP issue but can't replicate it outside of CTI shaders.

    Currently using Unity 2020.2.21f1, URP 10.2.2. Attached a screen of what I'm seeing, same tree in both, but moving the camera a bit switches the leaves material with another. It's almost like, I'm queueing up the various drawmeshinstanced batches and something somewhere confuses the materials when drawing.

    Another interesting observation... if I'm looking at the exact same spot from different angles in the scene view and game view in the editor, both views swap the materials independent from one another.

    I doubt this is related but maybe there's a hint here: https://forum.unity.com/threads/urp-casting-the-wrong-shadow.1044001/
     

    Attached Files:

    Last edited: Apr 10, 2021
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i haven't been able to reproduce this using urp 10.2.2. (maybe due to missing drawmeshinstancedindirect) - but from hdrp 10.2.2. i know that it randomly switches between materials/textures in the shadow caster pass. this even happens with shaders created in shader graph! disabling the srp batcher fixes this but of course is no option.
    to be more precisely: it switches between materials using the same shader. in case you have opaque geometry this doesn't matter at all as only the mesh is needed.
    when it comes to alpha tested geometry you need the proper texture of course. so you may not simply use any material using the given shader but the correct one.
    i did not find any solution in hdrp 10.2.2. the only way to fix it was changing to hdrp 10.3.2.

    a quick test using urp 10.2.2. and unity 2020.2.1f1 did not show any problems tho. see image attached.

    do shadows work properly if you do not use drawmeshinstancedindirect?
    how many different leave materials do you use in your scene?
    have you checked unity 2020.2.1f1?
    do other shaders using alpha testing show the same problem?

    [Edit] i upgraded the test project to unity 2020.2.7f1 which automatically updated urp to 10.3.1.: no problems either. so it might just be caused by your combination of unity and urp.



    urp 10.2.2. 6 spheres using 3 different cti leaves materials: shadow casters pick the right material/texture.

    urpShadows.PNG
     
    Last edited: Apr 10, 2021
    Noogy likes this.
  37. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    @larsbertram1, thank you for looking into this. Have you tested this when the materials themselves aren't viewed within the scene? I only see the issue when the tree is out of range of the camera, but still casting shadows within camera view. It might also be more prevalent if there are a large number of trees drawn.... 20+ or more.

    I'll attempt to upgrade to a later version of Unity and URP. If I still have the issue I'll try to create an example build for you.

    Edit: Upgraded to 2020.3.3f1 and URP 10.4.0, still seeing the same issue.
     
    Last edited: Apr 11, 2021
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i checked this as well and it works. but still i am not using drawmeshinstancedindirect. and had only 3 different leaf materials in the scene.

    ctishadows.gif
     
  39. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    @larsbertram1 I'm just now noticing that there are a few warnings. Can these be fixed?



    Furthermore, I have a question about the dark areas on the tree. Neither the GA/B nor the second texture G/B/A can remove these dark areas. Am I doing something wrong or am I overlooking something?

     
    Last edited: Apr 12, 2021
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    only warnings, nothing to fix.
    switch to deferred and go through the gbuffers to see what causes them.
     
  41. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    Could you please be a little more detailed. :) Unfortunately, I don't know what you mean.

    I almost suspect that it is due to GA/ B and AO/ B /A. Since the material leaf LOD contained in the project does not generate this error on my tree. The only difference here is that the leaf pattern is present in the corresponding RPGs. Unfortunately, the manual does not explain how to reproduce this.
     
    Last edited: Apr 12, 2021
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    warnings are wranings and nothing to worry about. at least not these warnings.

    these could be causes by pretty much anything. so if you switch your camera to deferred rendering you can debug the gbuffers in the scene view: so you can preview albedo (diffuse) and the normals. most likely you have quite some discontinuities in the normal buffer – as some faces actually are backfaces.
     
  43. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    I'm not familiar with it, unfortunately, Camera is on Deferred.
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    normalview1.gif
     
  45. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    I don't have that display. xD The display is greyed out for me.
     
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    then your camera is not set to deferred...
     
  47. Kojote

    Kojote

    Joined:
    May 6, 2017
    Posts:
    200
    I work with her demo scene, the camera is set to Deferred.
     
  48. Mojo-Game-Studio

    Mojo-Game-Studio

    Joined:
    Sep 18, 2015
    Posts:
    111
    Hi, this has probably been asked before, but I'm too lazy to read through the whole thread :D, is there any support for HDRP instanced indirect currently or planned? If planned any eta?
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    latest shaders for hdrp are back to shader graph. so they will not support it out of the box. you would have to grab the generated shader and then add "it" manually.
    "it" would be the instancing setup code and multi_compile pragma code you need to make your specific instanced indirect work.
     
  50. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,811
    I just got emails from two different customers saying that the billboards don't work when cti is used with VSP. I heard there might be a bug with the CTI billboard and VSP? Any insight, I haven't got to test it myself yet? I might try it with my version of 2020 and let you know if it happens for me.