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
    it should...
    works fine for me.
     
  2. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Hmm ok I'll continue to mess around with it. I'm able to get the crossfading working as gameobject (switch from speedtree to crossfade in fade mode), but not sure how to get VSP to respect this. And VSP continues to struggle with the trunks. Right now it seems like it's all on VSP so I may ask the creator.

    But thank you so much for helping me with the other issues, I've been extremely happy with the tool and honestly couldn't make my game without it.

    Edit: Ah, ok solved the bark issue... I had to unhide the property, and while it's set to 1 in the shader it was 0 in my material, maybe because the material predates the change, who knows. Anyway that part now works. Now to see about the VSP crossfading.
     
    Last edited: May 9, 2019
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    ah, ok... :)

    have you checked the free conifers from the asset store?
    they use a 301 shader version but should fade properly.

    can you share some screenshots or even a video?
     
  4. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hi. Has some experience with CTI and GPU Instancer and could give some tips?
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    do you have any problems using cti wit gpu instancer?
     
  6. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    yey. i used the standard prefab tool on the cti oaks and copied around 1000 instances. Frustrum and occlusion culling is fine. But all trees are culled around 300m far clip from camera. Both GPU instancer max settings in script and preferences doesnt have any influence 300m +. Under 300 both settings cull against 0.

    The GPU instancer tree script doesn has any output.

    btw. quality from birchs and oaks is outstanding.

    The trees should guide a 2km long racetrack on both side and terrain is flat so you have a far vista. Trees are very dense.
    Do you have any experience if Vegetation Studio and GPU instancer deliever similar results?
     
    Last edited: May 9, 2019
  7. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm, strange... there is nothing in the cti shaders that would "cull" the trees – or better billboards: i guess at 300 meters you see billboards?
    you may try to replace the billboard with a simple capsule e.g. and see if this gets culled as well.
    you may check your layers' culling settings of course :)

    as far as i remember gpui injects some code for its indirect instanced rendering into the shaders.
    maybe this is interfering with the code already in the shaders: the billboard shader e.g. contains "noinstancing".

    have you checked "generate billboards" in the gpui settings?
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    you may export the generated meshes from MTree as fbx, then manually break them up and recombine them, yes.
    quite some work, but once you have done it you can do pretty much everything with your tree.
     
    Duffer123 likes this.
  10. Duffer123

    Duffer123

    Joined:
    May 24, 2015
    Posts:
    1,216
    Thanks for the swift response.
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    First tests to bring CTI to HDRP.


    Unfortunately subsurface scattering seems to be totally broken in HDRP 5.13.0. And as shader graph does not support custom nodes anymore and amplify shader editor is broken i actually had to go down into the engine room and write hlsl. a real pain.
     
    Last edited: May 11, 2019
  12. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Hey,

    Therefore i stopped with HDRP toying and wait for the out of preview.

    Could you probably add this to an version of the bark and leave shaders for BuiltIn pipeline.

    https://github.com/0lento/OcclusionProbesDemo/tree/legacy/Assets

    It would add Ocllusion Probes what really looks nic for more dense tree setups.

    OCCProbes_BuiltInRP.png

    More Info here. Simple Demo from the Screenshots.
    https://forum.unity.com/threads/occlusion-probes.531573/page-2#post-3660322

    I I thinks this is all. Orange marked areas in UnityStandardCoreRP.cginc.

    OcclusionProbes.JPG

    and here an HDRP version.
    https://forum.unity.com/threads/occlusion-probes.531573/page-2#post-4349689

    There is a nice Package for Package Manager.
    For BuiltInRP StanfardShaders and Amplify Shaderfunction.
    For HDRP ShaderGraph Functions.

    best,

    Sascha
     
  13. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,811
    CTI coming to HDRP? That's great NEWS!! I have been waiting for this, HD is also slowly becoming better and I'm currently experimenting in it myself, I like it. What I didn't like was lack of terrain and foliage, but now with CTI in HD this changes everything also there is a terrain in HD now, it's not bad. Thinking, HDRP is a bit more ready and good enough for making nature scenes. Would still like for it to get out of preview though.
    I have been trying to figure out how to use those occlusion probes... do you just add the probe and bake in progressive lightmapper?
     
  14. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    fortunately the current cti shaders are written as surface shaders.
    so you can add the needed code yourself easily :)
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    well, this will still take quite some time. as i wrote subsurface scattering seems to be broken in 5.13.0.: no matter which diffusion profile i assign or what i set to subsurface mask or thickness – the result is always the same.
    at least i managed to write a version using shader graph including a custom hlsl file which should make it easier to catch up as far as the progress of the hdrp is concerned. on the other hand shader graph does not support lodfade_percentage and other features used by the current cti shaders so it will be a hybrid approach: letting shader graph do the initial work and then hand optimize/tweak the generated code.

    regarding the occlusion probes: one will have to add support for these to all shaders – not just the cti ones. so it does not relly make any sense to add them just to cti. you will need them on the terrain as well as on the grass at least.
     
    florianalexandru05 likes this.
  16. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Yes.Thats all. You must set the trees as static.
     
    florianalexandru05 likes this.
  17. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    lol, nobody told me that i would have to assign the used profiles to the settings first.
    now it works.

    proper_sss.PNG
     
  18. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,811
    Wow thanks, I'll give it a try when I play with HD again.
    Yeah makes sense, no problem here. Yep, that's my intention, I'm gonna to use those AO probes in the entire environment, I'll just use it in screenshot purposes.

    Congrats on getting subsurface scattering to work!!
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    thanks!
     
  20. swredcam

    swredcam

    Joined:
    Apr 16, 2017
    Posts:
    130
    Is there a trick to adding flowers to a tree? It seems like the only way is to child a flower to a branch and put the flower texture into a texture atlas with the trunk and branch textures. My problem there is that the bark shader does not do cut-outs and my flowers need a cutout shader. Is there some way to have the flower (or fruit etc) have its own material and shader and still follow the branch wind motion?
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi there,

    just to be clear: cti supports 2 different materials: bark and leaves.
    while bark is fully opaque leaves use alpha testing and translucent lighting.
    so you can simply put your flower texture onto the atlas you use for leaves (or branches).
    a fruit would most likely not need alpha testing (thinking about a solid apple) or translucent lighting. nevertheless i would put it into the altas used by the leaves simply because you need a seamless tiling texture for the bark.
     
  22. swredcam

    swredcam

    Joined:
    Apr 16, 2017
    Posts:
    130
    Hmm yes I thought about making an atlas for the leaves, but the actual "leaf" does not really have a UV map. It is an entire plane. I could not figure out how to carve an area for the flower out. Would I simply map the leaf plane onto a smaller subsection of the leaf atlas? That sounds like it would work.
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    yes. and you should enclose your leaf texture as close as possible in order to safe fillrate.
    attached you will find an atlas which contains textures for 3 different leaf "details". and it still has some room for some more details...


    atltas.jpg
     
  24. swredcam

    swredcam

    Joined:
    Apr 16, 2017
    Posts:
    130
    That is perfect thank you!
     
  25. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    you are welcome!
     
  26. swredcam

    swredcam

    Joined:
    Apr 16, 2017
    Posts:
    130
    Splitting the transparent map as above is working well. I have a normal map that was created in a 3D program, and is a PNG that is generally blue. It seems like the normal map actually needs to be in the red and green channels only, and the blue channel would have a solid color. Does anyone have any guidance as to how to craft these separate layers in photoshop? I have the same issue with Smoothness, I have a map but it is not in the alpha channel. I've looked for tutorials that focus specifically on this topic but have not found a good one.
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    in photoshop you cn simply select a channel and copy its content to another channel. if there is no alpha, add one.
     
  28. swredcam

    swredcam

    Joined:
    Apr 16, 2017
    Posts:
    130
    Yes I see that apparent capability but I'm not finding success with it. For example my normal map, while generally blue, has a lot of red in it. So there are three channels that need to map into two. Also, when creating (adding) a channel, what makes it the alpha channel?
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    if you already have 3 (RGB) the 4th will be alpha automatically.
    you need only red and green. blue will be reconstructed in the shader.
     
  30. swredcam

    swredcam

    Joined:
    Apr 16, 2017
    Posts:
    130
    Thanks Lars. One other thing I found helpful is the "Channel Mixer" in photoshop. It can easily map one channel into another. I found duplicating channels a little hit or miss.
     
  31. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,811
    Copy the channel and paste it in to another layer then edit it and copy/paste it where else you want, that's what I usually do!
     
  32. ArturoUSR

    ArturoUSR

    Joined:
    May 31, 2019
    Posts:
    15
    Hello, I'm planning to buy this script, but I have a couple questions:

    I bought a pack of conifer trees, but I'd like to optimize the LOD transition with this Script, can I use the FBX and directly set them up in CTI? or should I use a 3d program as a bridge? I read the documentation, but I think I'm a bit lost with the extentions used.

    Do you have tutorial videos?

    Thanks in advance.
     
  33. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    you probably bought the conifers as a flattened mesh. so you have to use a 3d program to break them up and bring them into a hierarchical structure as needed by cti.
     
    ArturoUSR likes this.
  34. ArturoUSR

    ArturoUSR

    Joined:
    May 31, 2019
    Posts:
    15
    Yeah. the models need a lot of work. We just bought CTI at the studio and I'm currently preparing the models. Is a bit complex, but my initial test was smooth, so I think we did the right choice! Thanks.
     
  35. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    great!
     
  36. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Hi Lars, so I'm revisiting my crossfading problem. I tried out the conifers and they do properly transition from one LOD to the next, but it made me realize that maybe I'm misunderstanding what crossfading actually means.

    I assumed that crossfading would actually adjust the alpha/dithering of each LOD so that the next one would appear underneath, and this works fine if the tree is a normal gameobject. Is this sort of fading possible with CTI and VegStudioPro, or does that method only support the adjustment of vertex positions like these conifers (where foliage scales in/out)? Sorry if I'm a bit unclear, thanks.
     
  37. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    It works great for me with GPU instancer.
    The CTI Oaks and Birchs are nicely crossfaded with the standard prefab method there.
    Vegetation Studio i did not tried.
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    crossfading is relatively expensive as during the transition unity would have to draw both lods.
    for this reason speedtree and cti use "LOD_FADE_PERCENTAGE" which is only available if the lodgroup is set to blending = speedtree. only the transition from the last lod to the billboard uses crossfading.
    so cti the shaders support both fading methods.
    regarding vspro i have to admit that i haven't looked into it for quite a while so i am not sure how it sets up the fading.
    it might be using hard coded fading for trees using the cti shaders... best would be to ask lennart about it.
     
  39. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    At the moment VS & VS Pro do not support CrossFading. Not sure if it is for all shaders or just CTI but have talked to Lennart about it. Could use both supported though. Not saying CTI as it already supports both but VS.

    Know it is a more expensive technique but it is handy for some larger, optimized trees as SpeedTree fade does very little to help them transition. SpeedTree fade works great for most medium to smaller trees and plants though.
     
  40. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Many thanks everyone, I guess I was spoiled by CTI's elegant crossfading and didn't realize how Speedtree's solution worked. Oh well, better late than never before I moved onto other trees.

    One final question, is there a way to adjust the transition speed between LOD levels? My transitions are smooth but happen much too quickly, and I'd like for them to occur over a longer distance.
     
    Last edited: Jul 12, 2019
  41. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    Hi - I'm the one who bought four of the tree assets then posted a one star review for the Horse Chestnut. I appreciate your very fast response, but refreshing in Tree Creator made no difference. I am using 2019.2.0f1, HDRP preview 6.9.1. I cannot see a support forum for the tree assets, so posting here.

    I imported into Standard 3D scene as well but got the same problems, again with 2019.2.0f1.

    Would appreciate a solution please - I bought these on seeing them recommended on Discord. They look great in the demo images, but I'm stuck to get them working.

    Thanks.

    On import, I get these errors:

    Shader error in 'Hidden/Nature/Tree Creator Leaves Fast Optimized': undeclared identifier 'TreeVertLeaf' at line 60 (on d3d11)

    Compiling Vertex program with UNITY_PASS_FORWARDBASE DIRECTIONAL
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR

    Shader error in 'Hidden/Nature/Tree Creator Bark Optimized': Surface shader vertex function 'TreeVertBark' not found at line 18

    Shader error in 'Nature/Tree Creator Leaves Fast': undeclared identifier 'TreeVertLeaf' at line 59 (on d3d11)

    Compiling Vertex program with UNITY_PASS_FORWARDBASE DIRECTIONAL
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR

    Shader error in 'Hidden/Nature/Tree Creator Leaves Optimized': Surface shader vertex function 'TreeVertLeaf' not found at line 31

    Shader error in 'Hidden/Nature/Tree Creator Leaves Optimized': undeclared identifier 'TreeVertLeaf' at line 99 (on d3d11)

    Compiling Vertex program with UNITY_PASS_SHADOWCASTER SHADOWS_DEPTH
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i updated the horse chestnut package for unity 2018.3. and i hope it will work in higher versions as well.
    please update and let me know.
     
  43. JBT27

    JBT27

    Joined:
    Jul 13, 2016
    Posts:
    197
    Thank you very much - I will check it out and let you know.
     
  44. Migueljb

    Migueljb

    Joined:
    Feb 27, 2008
    Posts:
    562
    Can CTI work with say any trees bought off the asset store that are in FBX format without any needing to take back into 3ds max and fix up accordingly. Say if there 2 materials. 1 for bark and the other for leaves etc. CTI has such pretty shaders just wanna know what my limits are here.
     
  45. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hi @Migueljb,
    No, a tree literally needs to be taken apart and setup in your 3d app to be imported and work correct with CTI. CTI takes the trunk, branches, leaf branches as separate meshes and combines them when imported. This is how it gets the awesome accurate bending and LOD features. It can be annoying at first but once you get used to the process it is easier.

    Honestly do not recommend on extreme dense trees like a speedtree mesh because of the time in separating each branch. Normal modeled asset store trees though should be pretty simple.
     
    florianalexandru05 likes this.
  46. nova234

    nova234

    Joined:
    Feb 19, 2018
    Posts:
    17
    Hello @larsbertram1,

    i read that you stopped toying with HDRP because its in Preview state, but what is with the out of preview LWRP ? I read nothing here about the LWRP, or i over read it. A 11 people team is waiting for good news. Did you have some for us.

    Greets
    Nova
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    LWRP is going to change to URP in 2019.3... but which unity version do you use? and which version of the LWRP?
     
  48. nova234

    nova234

    Joined:
    Feb 19, 2018
    Posts:
    17
    We are on 2019.2.6 and LWRP version 6.9.1.

    Greets
    Nova
     
  49. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    The LWRP version of the basic CTI LOD shaders is pretty much done.
    Docs
     
    Last edited: Sep 24, 2019
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    Version 3.18 has been published which adds CTI LOD shaders for LWRP.