Search Unity

[Released!] Custom tree importer

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

  1. JcAquila

    JcAquila

    Joined:
    Dec 19, 2019
    Posts:
    5
    Yeah, I'm trying to research a bit more, I think the problem is I forgot the naming conventions :/.
     
  2. JcAquila

    JcAquila

    Joined:
    Dec 19, 2019
    Posts:
    5
    Hi again, I read the documentation and finally understood how to get the trunk moving, the only problem is that the branches and trunk are all one model.
    upload_2022-8-9_8-40-20.png

    That being said, the leaves are also batched randomly, as seen in the screenshot below.
    upload_2022-8-9_8-41-19.png

    Is there any way I can work with the branches being part of the trunk, or can I somehow automatically separate them?
     
  3. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    you will have to manually separate them and create a proper hierarchy :(
    you also might consider simplifying the trunk's mesh: poly count seems a bit over the top.
    actually i does not look as if the mesh is suited for real time graphics... single leave geometry and all twig fully modeled. usually you would use alpha tested textures.
     
  4. JcAquila

    JcAquila

    Joined:
    Dec 19, 2019
    Posts:
    5
    I see, Thanks for the information!
     
  5. cuttinged

    cuttinged

    Joined:
    May 12, 2013
    Posts:
    65
    Hi. I'm getting this console error when I use Tropical Forest Pack with Vegetation Studio Pro with Unity 2021.3.9f1 URP 12.1.7
    DrawMeshInstanced does not support the shader 'CTI/LOD Leaves' because it does not read any instanced properties. Try switching to DrawMeshInstancedProcedural if the shader is doing procedural instancing.
    Everything in the project works fine and it builds for pc fine too but this error runs constantly in the editor so if you have any advice on what to do to try and fix it I would appreciate it. I tried reimporting but got the same error. Thanks.
     
  6. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    looks like you are using quite old cti shaders. so i recommend to contact @Baldinoboy and ask him for the correct version of the Tropical Forest Pack to get procedural instancing work properly.
     
    Baldinoboy likes this.
  7. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hi @cuttinged, Looks like you are using an older version of the URP package. Always recommend doing a backup of a project before lots of changed.

    So first recommend deleting the TFP folder from your project and then updating and installing the latest Tropical Forest Pack 1.3.3 from the package manager. This added the _URP 12 package that you can unpack.

    Once everything is installed unpack the _URP 12 package in the TFP folder and the shaders should be working fine.

    Let me know if there is an issue and if you are still seeing errors after this clean install with the new URP package.
     
  8. Hummy91

    Hummy91

    Joined:
    Jun 7, 2017
    Posts:
    67
    Hey guys, Im getting this error in editor and in game when using CTI. I'm using Unity 2020.3.21f1 and HDRP. Everything else works fine from this package as I've installed everything correctly, so Im unsure what could be causing this error.


    Shader error in 'CTI HDRP 10/CTI HSLS Billboard HDRP 10': undeclared identifier '_DoubleSidedConstants' at /Users/Humza/Pravitas/Pravitas/Library/PackageCache/com.unity.render-pipelines.high-definition@10.10.1/Runtime/Material/Decal/DecalUtilities.hlsl(273) (on d3d11)

    Compiling Fragment program with LOD_FADE_CROSSFADE _DOUBLESIDED_ON
    Platform defines: SHADER_API_DESKTOP UNITY_ENABLE_DETAIL_NORMALMAP UNITY_ENABLE_REFLECTION_BUFFERS UNITY_LIGHTMAP_FULL_HDR UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_PASS_SHADOWCASTER UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BLENDING UNITY_SPECCUBE_BOX_PROJECTION UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS
    Disabled keywords: INSTANCING_ON SHADER_API_GLES30 UNITY_ASTC_NORMALMAP_ENCODING UNITY_COLORSPACE_GAMMA UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_DXT5nm UNITY_NO_FULL_STANDARD_SHADER UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_VIRTUAL_TEXTURING
     
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    not sure if the provided hdrp shaders support 2020.3.21f1... your path says "CTI HDRP 10/"...
     
  10. Hummy91

    Hummy91

    Joined:
    Jun 7, 2017
    Posts:
    67
    Yeah the asset Im getting this from is: https://assetstore.unity.com/packages/3d/vegetation/trees/oak-trees-package-1056
    Where the supported HDRP versions list HDRP 7.1.2., 10.3.2. + and URP 7.3.1., 7.5.1, 10.3.2 and 11.0. The latest HDRP version I have access to in this version of Unity is 10.10.1.
    I kinda assumed it would work given how that version is sort in the middle of some of the supported versions. I guess not, does anyone know a possible fix? (I can't change my Unity version due to.. well unity, project limitations).
     
  11. nu51313932

    nu51313932

    Joined:
    Oct 28, 2016
    Posts:
    81
    Hello. Please give me the lastest tutorial for Blender. Since 3d maxs in not free. So i need to export fbx from blender instead of 3dmaxs. If i success using Blender to export fbx and make it have wind animation. I will buy this Asset soon
     
  12. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    Hei, I use Blender! Here are some of my model examples, they are a bit more complex but I think you can figure it out. Here is the manual on how to make trees, it explains everything step by step, it's not for Blender but the setup is the same. Just add an empty game object and parent a trunk then branches to the trunk then leaves to the branches as a tree would be connected. Add specific tags for wind intensity and variation to your branches. Remember to add the vertex color black to your bark and branches and 0.4 green to your leaves around the edges. If you are going to use LODs add a bounding box (I added everything in the Belnder examples)! Also very important to name your trees (afsTREE) or something like that...That's all the steps so far.

    With CTI you will get AAA shading, translucency, wind, and more. The only thing I couldn't figure out is how to add custom normals to foliage in Blender. I'm sure it can be done somehow but I couldn't figure it out, if that is something you are looking for, Blender might have a drawback here and there I think.
     

    Attached Files:

    nu51313932 likes this.
  13. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
  14. nu51313932

    nu51313932

    Joined:
    Oct 28, 2016
    Posts:
    81

    thank you so much. I will research it.

    btw, i try to import the original model from CTI into Blender and re-export it back to and fbx file. It doesn't work. So i think it will be another way to do. (I borrow my friend account to use CTI but i want it for my own account)

    SO i will follow your tutorial.
     
  15. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    You need to make a simple model first! The first time I tried it I messed up too, it's easy to mess up when you are trying to make a complex model for the first time. There's a very simple example in CTI. You should start by learning from it and making a simple tree with one Trunk and one branch and leaf card like this! Just read the manual and follow my example. I took this example and made it very simple, just one Bark and a branch.

    upload_2023-3-31_18-48-41.png
     
  16. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    Worked for me, this example!
     

    Attached Files:

    Willbkool_FPCS likes this.
  17. nu51313932

    nu51313932

    Joined:
    Oct 28, 2016
    Posts:
    81
    This evening i will come back to tell you the result again. thank you so much
     
    florianalexandru05 likes this.
  18. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Thanks for sharing.

    Blender has a great sapling generator which can make trees and I like this process. I also have some trees I like from purchasing online which are just FBX's.

    If we have premade trees of either nature and we are attempting to convert to this system, is it correct we must then hack the meshes of branches into separate objects and create a parenting tree as you describe for all the levels of branches then leaves?

    If so, I presume we should then fill all the openings that come from slicing everything apart? Ie. At bases of branches and holes opened in trunk where branches leave from?

    I have a number of trees I like in Blender and also like the Blender sapling generator. I want to convert them to a system compatible with wind zones if it is not impossible to do so.

    Is this the right idea? Any thoughts or ideas would be appreciated. Thanks.
     
    florianalexandru05 likes this.
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    yes.
    you do not have to fill the holes. either make branches slightly penetrate the trunk or stick them to the trunk using vertex colors and control tags: https://docs.google.com/document/d/...zZ21jLIgg2HPKgCnE/edit#heading=h.jew34tq970hy
     
  20. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    Hei, yes you need to split the branches from the trunk and each other, then parent them and add the wind tags. Upon importing into Unity, CTI merges them in the Unity editor as one object with 2 materials like any other tree, it reads the tree tag you gave it and converts it. No, you don't have to fill any openings, just make sure the branch and the trunk vertices are connected or intersecting if that's what you meant.
     
  21. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Thanks guys. So I bought the asset and holy S*** is the documentation unclear. I spent an hour trying to make it work in URP and nothing is happening. The directions don't make sense.

    I followed the primary document here:
    https://docs.google.com/document/d/1gywLRpk5h5OStZC0HlJ7Vj7iv2MOJU-3EtiTYLnSrFA

    Which tells me to set up parenting of branches and leaves in my tree as you suggested. Done in Blender. No problem. Export FBX with name simple_tree_afsTREE.fbx. This triggers Unity to create simple_tree_afsTREE_modified (Mesh) in the same folder which I presume I ignore (fused mesh).

    I can drop the FBX into my scene at assign the tree material, but if I add a windzone nothing happens. I changed the material shader to "CTI LOD" which then makes everything pink, as I presume this is not for URP.

    I read the directions more for URP here but they seem completely out of date and not useful:

    https://docs.google.com/document/d/1gywLRpk5h5OStZC0HlJ7Vj7iv2MOJU-3EtiTYLnSrFA

    Then I found \Assets\Custom Tree Importer v3\CTI Runtime Components LWRP URP\. I tried double clicking CTI_URP_RuntimeComponents.unitypackage.

    I added that to my project which I presume added the URP shaders I need. However, these don't work. I get:

    windzone bark.PNG
    windzone billboard.PNG

    windzone leaves.PNG

    So then I tried installing CTI_URP_12.0_b9_RuntimeComponents.unitypackage instead which is a bit better but instead all the shaders it adds instead give these errors identically:

    windzone leaves 2.PNG

    Very frustrating but still need this working. Any ideas? Anyone have this working in URP? If so, how? What version Unity? Thanks.
     
    Last edited: Apr 19, 2023
  22. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    authoring using urp or hdrp is not supported.
     
  23. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    What is supported then? It says on the asset page:

    CTI LOD shaders support the built in RP as well as LWRP/URP 7.2, 10.3.2, 11.0. and 12.0. Shaders for HDRP 7.2 and HDRP 10.3.2 are included.

    Do I need to check my URP version and downgrade to a supported version or what? If so, do you know how I check my URP version? Thanks
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    when authoring trees you should use the built in render pipeline. only this one allows e.g. creating billboards.
    check your urp version by opening the package manager window.
     
  25. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    As Lars said, you can create your trees in the build-in pipeline first, then just change the shaders to URP or HDRP, it works for me fine. I tried it in Unity 2020.3.0f1, 2021.3.11f1 and 2023. That's how it is with some tools nowadays because it's hard to support all 3 pipelines at once, one of them needs to be used as a bridge for the others.
     
    Baldinoboy likes this.
  26. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    I am not using any billboard or LOD functions. I just want my trees to sway in wind.

    The problem I am running into is not in any authoring or tree building function. The problem is I can't seem to get any of the URP shaders to run without errors. I had switched to 2023 but now am back on Unity 2022.2.9. I am using URP 14.0.6 which is the current package that is automatically installed.

    I then in my project double clicked the "CTI_URP_RuntimeComponents" and installed that. Then I double clicked the "CTI_URP_12.0_b9_RuntimeComponents" and installed that.

    I then have a folder "CTI Runtime Components URP\Shaders" which has for example "CTI URP Leaves". I presume this is what I must use. However, when I click it, it demonstrates the following error:

    cti leaves error.PNG

    cti leaves error code.PNG

    I do not know what this error is for or how to fix it. I obviously can't get the trees to render correctly in URP if I cannot assign the correct URP shader to their materials.

    Do you know what I am doing wrong or how to fix it? Do I need to manually downgrade my URP version (and if so how) or is there some way to make this work?
     
  27. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Hi @mikejm_ , I ran into the same issue when upgrading to newer URP. The issue lies with GetMeshRenderingLightLayer, which apparently is no longer supported. The fix would be to go through the shader and replace:

    uint meshRenderingLayers = GetMeshRenderingLightLayer();

    with:

    #if defined(URP_14_OR_NEWER)
    uint meshRenderingLayers = GetMeshRenderingLayer();
    #elif defined(URP_12_OR_NEWER)
    uint meshRenderingLayers = GetMeshRenderingLightLayer();
    #endif

    I think there were 2 or 3 spots, a simple Find/Replace will help you here.
     
  28. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Thanks that's great! Getting closer now... I can now make my trees move but I am still having trouble making them behave as expected with hierarchal motion.

    I am trying with a low poly simple tree like this in Blender:

    custom tree importer branch.PNG

    I have chopped it apart into branches and leaves. The origins of the branches are set to where they attach (selected one has red cursor showing its origin). I set up the hierarchy like this:

    custom tree importer hierarchy.PNG

    So branch 0 is the main trunk at the base with origin at 0,0,0 along with the "empty origin" plane requested in the manual. The three "branch1" meshes are the three main branches that attach to the base trunk.

    However, despite this parenting, I can't get the three branches to move along with the base trunk. They seem to all move independently. The three branches that come off the trunk all pivot together at their origins, and the base trunk pivots separately at 0,0,0.

    For example, here it is on high wind:

    custom tree importer branch extreme.PNG

    You can see the base (branch 0) pivoting at 0,0,0 and the three sub branches from this then pivoting at their origins above this. The main branch swaying is not making the three sub-branches' origins shift as well to match.

    Does anyone know what the solution is to this?

    I am also noticing even on minor wind settings the bark is opening up holes in it. For example, you can see this phenomenon here:

    custom tree importer.PNG

    A vertical strip has opened up the length of the tree bark and branches which you can see through. I am also not sure of the cause or solution of this. Any help?

    Thanks.
     
    Last edited: May 8, 2023
  29. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    Hei, that's od I think that happened to me too the first time. Not sure exactly what the problem is but I could give some tips.

    1. Make sure the branches and trunk vertexes are connecting or intersecting each other, if they aren't that will cause the branch to separate from the mesh.

    b3.png

    2. Try to name the objects as I did for convenience and to make sure. Also make sure you add that highlighted name in the pivot also to the file name when you export the tree. "afsTREE _root_xlod00_xlp"

    b1.png

    3. Make sure you named your bark and leaf materials as "something_Bark" and "Something_Leaf".

    b2.png

    4. Reset all your transforms scale and rotation, make sure you have your vertex or edge "shading to shaded smooth"

    b4.png

    and clear seams, that makes the leaves break apart for me for some reason. Hopefully, it will work this time.

    Edit: Oh, I see you don't have a "trunk object", try parenting a trunk to the empty and then the branches to the trunk, that might be it maybe!!
     
  30. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    I have tried some more experimenting but I cannot narrow down the problem. I have an empty root object, I have a trunk under that, then I have 3 branches under that, then leaves. The hierarchy seems correct. I have labeled my materials bark and leaves. It is importing fine as shown here with the merged mesh and no wind:

    cti tree wireframe.PNG
    cti tree no wind.PNG

    It seems I must control the wind in the material for the bark and leaves this way. I am wondering if there is perhaps some trick to how the UV mapping must be set up for the bark and leaves. I notice that when you apply wind to the material, it distorts the UV map as follows:

    1) No wind:

    cti bark mat no wind.PNG


    2) Wind:
    cti bark mat wind.PNG

    The UV is warping in a very specific way which is then warping the whole tree in a bizarre way as well:

    cti tree wind.PNG

    Currently it won't even bend side to side anymore, it just fluctuates up and down in this weird manner while being narrow and skinny/distorted and disjointed at all the trunk joints. Absolutely bizarre and not in any way usable.

    I managed to get my Blender FBX importing into Unity with no transforms or rotations so the tree is naturally perfectly upright when imported same as the example FBX given above but yet I get this bizarre behavior.

    Any further thoughts?

    Note that as per my reply after this post the same problem is occurring in other supposedly working FBX trees from this thread so this is not specific to my tree design.
     
    Last edited: May 9, 2023
  31. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    I note I am getting the same weird results from the posted example tree here:

    When I apply the leaf and bark material to it, it has this weird up and down motion but won't show any directional sideways bending and the trunk becomes narrow and strange similarly distorted.

    So it does not appear to be anything I am uniquely doing in my tree. There seems to be something wrong I presume with the URP shaders:

    1) Without Wind On Material:

    cti simple tree no wind.PNG


    2) With Wind on Material:

    cti simple tree.PNG

    Obviously the material application is silly here but that is not the point. We can see similarly the wind is just warping the trunk by making it skinny and it is also giving a weird up and down effect rather than sideways wind.

    I think the URP shaders must be broken. Otherwise I can't explain why both trees are doing the same bizarre thing. Any solution or explanation? Is there some other trick to applying wind in URP?

    Can anyone make this example work in current URP 14.0.6?

    https://forum.unity.com/threads/released-custom-tree-importer.263224/page-18#post-8918537
     
    Last edited: May 9, 2023
  32. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    My first two thoughts there.... you're certain you've got your vertex colors set up correctly? Vertex colors will determine how much influence they receive. Also, I can't quite remember if your pivot orientations matter, whether they need to be properly aligned or not. If I recall correctly I tend to align all pivots in the same way but I'd need to double check.

    For what it's worth, I'm working with that same URP and have got things mostly working fine (besides a weird shadow issue I'm trying to sort with the author).
     
  33. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    You need to give the bark vertex color black, also, the leaves need to have vertex green on black. Make sure the vertexes of the leaves that are connected to the branches are pure black. The wind is driven from the vertex color green so black means no wind. That's usually how every foliage shader works, not just CTI.

    upload_2023-5-9_10-16-8.png upload_2023-5-9_10-18-5.png
     
  34. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Okay, I've narrowed down the issue even further. I do not think it is a matter of vertex painting, which only controls as I understand the degree of animation. I tried playing with vertex painting and no change.

    I have figured out two things:

    1) A single "CTI_SRP_CustomWind" script added to a tree in the scene will control the wind in the appropriate fashion in URP. One script controls everything in the scene or at least anything using that tree's materials it seems.

    2) My tree import is not using the "_modified" mesh correctly. I note using this tree: https://forum.unity.com/threads/released-custom-tree-importer.263224/page-18#post-8918537 which I at least have animating correctly using #1, it uses the "_modified" mesh exclusively.

    In inspector, it shows like this:
    cti simple tree inspector.PNG

    In the object hierarchy, it also shows as single object with a single fused mesh:
    cti simple tree hierarchy.PNG

    And in the scene, it now animates nicely:

    cti simple tree wind working.PNG

    However, my actual tree does not seem to use the "_modified" mesh although this object is created on import of my FBX. It is maintaining the full hierarchy of objects and meshes when I drag it into the scene:

    cti cerbera hierarchy.PNG

    So although the fused mesh is being made and is visible in my project, this is not being implemented and the final object is still just a hierarchy of individual objects (hence why the pieces are breaking apart):

    cti cerbera mesh.PNG

    Is there something I must do to make the "_modified" mesh useful? There is no error being given on generation of the "_modified" mesh or import of my hierarchy FBX. Should I just manually make a new object using the "_modified" mesh if this is supposed to be happening automatically and yet isn't?
     
  35. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Tested further, and yes, manually creating a new game object with a mesh and mesh renderer, then dragging on the "_modified" mesh works now.

    Whether this is the intended workflow or not I am not sure as I see no explanation of this in the manual. Either way it works at least.

    I am still getting some tears opening up in the bark at joints at extreme settings but at least now it is moving as one unit. I will perhaps test making vertexes overlap a bit more at joints to see if it fixes that issue roughly enough.

    Is this how we're supposed to be creating the trees? Ie. Make a new game object from the "_modified" mesh? Or is this supposed to happen automatically? I didn't see anything about this in the manuals but maybe I missed that???

    cti cerbera trunk.PNG

    Also is the only solution to the breaks in the trunk joints to just overlap the vertexes more? They share identical positions at the joints (each branch shares the identical same vertexes as the trunk at the joints). With no wind there are zero gaps.
     
    Last edited: May 11, 2023
  36. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Ah yes, after importing and having CTI create it's own modified variation, you shouldn't use your original model. Always use the new _modified one to take advantage of the shaders. The process of applying the new mesh to your renderer is not automatic.

    As far as vertices go, I know that if you have them set up correctly, and vertex colors are right, CTI does a pretty good job of not creating seams between individual pieces. Looking at the trees I've modeled, the base of the branch are blue vertices, and the rest are black. The manual says what each vertex color represents.

    I also seem to have the pivot (I'm using 3DS Max) of the branch roughly where it meets the trunk. Not sure if that mattered. Also, it's been years since I built this but I named the branch "branch_xsn10_xp009", you can poke around the manual to see what that all means. My final exported tree was named "tree_afsTREE_xlb01_xlp_xmvcb_xlod00".
     
  37. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    Yeah as Noogy said, it's not automatic, but when you import your tree into unity it should be converted into one single mesh, if not something went wrong. And yes you need to intersect the vertexes as much as you can, if even a single vertex isn't overlapping "I think?" that could lead to your branches breaking.

    Can you send me the model over?! I want to try it out for you and see if everything is in place.
     
  38. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Thanks guys, I spent the day converting 5 cartoony low poly trees over into the system. Now that I know you need to manually recreate the game object / prefab with the mesh it's not too hard.

    The only trouble now I'm running into I can't explain is some trees will have an animating trunk and others will not. I cannot figure out why. In all cases, I have the same style hierarchy. In all I have an empty axis as the root object. Then a trunk, then branches, then leaves. In all there are two materials, one labeled "bark" to parse. All the bark elements have the same material.

    Yet one or two trees will animate the trunk and the others won't. Here's an extreme setting for demonstration. The birch tree will not animate its trunk. It stays upright. While the darker bark tree animates all the way to the bottom as it should.

    Is there any good or possible explanation for this?

    I tried vertex painting the trunk black on the birch and it still didn't change.

    Any ideas?

    cti trunk vs. no trunk anim.PNG

    I notice when I try to reimport the FBX to recreate it, repeatedly I get this error:

    Code (csharp):
    1.  
    2. Calls to "AssetDatabase.Refresh" are restricted during asset importing.
    3. UnityEditor.AssetDatabase:Refresh ()
    4. AFSTreeMeshPostprocessor:OnPreprocessModel () (at Assets/Custom Tree Importer v3/CTI/Scripts/TreeMeshPostprocessor AFS.cs:113)
    5. UnityEditor.AssetPostprocessingInternal:PreprocessModel (string)
    6.  
    This refers to AssetDatabase.Refresh() line. Perhaps it might be breaking the import from this?

    Code (csharp):
    1.  
    2. //  Fix Material import settings
    3.     public void  OnPreprocessModel () {
    4.         if (assetPath.Contains(TreeSuffix)) {
    5.             var modelImporter = assetImporter as ModelImporter;
    6.             if (modelImporter.materialName != ModelImporterMaterialName.BasedOnMaterialName) {
    7.                 Debug.Log("Fixing material names.");
    8.                 modelImporter.materialName = ModelImporterMaterialName.BasedOnMaterialName;
    9.                 AssetDatabase.Refresh();
    10.             }
    11.         }
    12.     }
    I am not sure if I had the same error on the working trees or why it would be different. I don't know if this is the issue. It's just the only thing I see. The combined mesh at least looks correct but the trunk just won't animate.

    I don't know how to stop this error either to prove whether it is the issue.

    @florianalexandru05 I messaged you the Blender file for the broken birch tree that won't bend. I'm happy for any solution or explanation if you can.

    Any thoughts?
     
    Last edited: May 12, 2023
  39. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Hmm not sure about that error, @larsbertram1 might have better input there. Triple check you have the right names/links on everything. You might even need to do silly things like completely remove those items from Unity and do a fresh import.... heck I've even had to delete my entire library folder and rebuild the project because sometimes.... that just works.

    One thing I see, and this took me ... literally years to figure out, is the height of each tree mesh actually matters. Although I had the opposite problem, where my shorter trees would be extremely bendy, despite everything having the exact same name/hierarchy.

    The solution was to actually have a nearly invisible tiny polygon just floating above trunk mesh way up where the leaves would be, so that the actual bounding box of the mesh roughly matched the taller tree model. Then I finally ended up with two trees of varying heights that acted similarly. I suspect that the importer must be looking at the mesh's bounding box or something. Not really sure if that's what's going on here, but just FYI.
     
  40. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    Hei, I took a look at your tree and it seems you forgot some things. Unfortunately with CTI, you have to do all the steps like in the book otherwise the smallest thing will break your tree. I sent you the blend, FBX, and Unity package so you see what it should look like.

    Not sure if these are all required but after doing these it worked perfectly so here are the fixes you need to apply:

    1. Make all your branches and leaves vertex color black, not just your trunk. Add vertex gree around the edge of the leaves and keep the pivot point where it should contact the branch black. Not all your leaves are connected to a branch but that's fine. I even added pivots there for good measure.

    2. Keep your trunk as one mesh, this split right here is probably the reason your tree broke apart!

    Issue_01.jpg

    3. You forgot to add the mandatory naming to the model file name, "afsTREE", the other name tags are for adding lods to your tree and other functions etc.

    upload_2023-5-13_11-37-56.png
    If you drag the fbx in unity it will automatically convert it to a tree object as a merged mesh, that should be the correct outcome. If you drop your model and it shows as an object with sub mesh then it didn't import correctly. This is true even when you drag the fbx file in the scene, it should instance the converted tree instead.

    CTI_wind 3.jpg
     

    Attached Files:

    Noogy likes this.
  41. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    Here are more screenshots proving the tree works fine with wind, btw I used the wind from script instead because I like it more but you can just go back to the regular wind in the material. I think for wind from script you need add some wind variations to the branches with tags. Let me know if you need any help with that. You can add more variation to the wind by adding name tags to your branches.

    CTI_wind.jpg
     

    Attached Files:

    Last edited: May 13, 2023
  42. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Thanks, but now based on your post I definitely think I'm going crazy.

    I was able to export FBX from your Blender that works but still not mine.

    To review:
    • Thanks for sharing how you would paint the leaves - I wasn't too worried about that yet but it's good to see. I also left the pivots for the leaves crude as I was just trying to get it working, but again thanks for that.
    • I actually cut the trunk in two to test if that might help (ie. if it needed a joint somewhere) - it did not help and having it as one object didn't help either (I have had it both ways).
    • I have definitely been using "_asfTREE" as the filename for my FBX's.
    • I tried painting the whole tree black just now and the trunk still won't bend.
    To simplify the problem, I deleted all the leaves from both yours and mine. I even named my objects the same as yours. I painted my trunks/bark all black. I can't see a single substantial difference between yours and mine yet yours can bend the trunk and mine can't.

    Working (Yours):
    cti -birch working.PNG

    Broken (Mine):
    cti -birch broken.PNG

    Working (Yours):
    cti -birch working blend.PNG

    Broken (Mine):
    cti -birch broken blend.PNG

    I cannot find a single difference between these but no matter how many times I export yours trunk works and my trunk doesn't.

    I attached a zip of the two blender files (only 8 objects inside each, identical as far as I can see) and FBX's made from each.

    To make an FBX from these:

    - Right click the Empty and Select Hierarchy
    - File > Export FBX
    - Object Types: Empty & Mesh
    - Apply Scalings: FBX Units
    - Forward: Y forward
    - Up: Z up
    - Uncheck Apply Unit, Uncheck Use Space Transform, Uncheck Apply Transform

    Would you be able to just for one more minute look at these two blender files and FBX's and confirm you are getting the same glitch as me with the trunk on the "broken" one and let me know if you can see any reason?


    I would appreciate it as I have no way to see what is going on here. It makes no sense to me.

    On another note, it definitely seems this import error is stopping me from getting a fully made tree automatically as you describe I should which is why I'm having to make my objects manually:

    Code (csharp):
    1. Calls to "AssetDatabase.Refresh" are restricted during asset importing.
    2. UnityEditor.AssetDatabase:Refresh ()
    3. AFSTreeMeshPostprocessor:OnPreprocessModel () (at Assets/Custom Tree Importer v3/CTI/Scripts/TreeMeshPostprocessor AFS.cs:113)
    4. UnityEditor.AssetPostprocessingInternal:PreprocessModel (string)
    5.  
    6. Calls to "AssetDatabase.CreateAsset" are restricted during asset importing. AssetDatabase.CreateAsset() was called as part of running an import. Please make sure this function is not called from ScriptedImporters or PostProcessors, as it is a source of non-determinism and will be disallowed in a forthcoming release.
    7. UnityEngine.StackTraceUtility:ExtractStackTrace ()
    8. AFSTreeMeshPostprocessor:OnPostprocessModel (UnityEngine.GameObject) (at Assets/Custom Tree Importer v3/CTI/Scripts/TreeMeshPostprocessor AFS.cs:1194)
    9. UnityEditor.AssetPostprocessingInternal:PostprocessMesh (UnityEngine.GameObject)
    I get that any time I put in an FBX with the name "_afsTREE" and the processor tries to run.

    I still don't know how to fix that, but unless the "broken" one I attached works on your system, that does not seem to be what's stopping the trunk from bending as I can make yours bend still fine despite also getting that error in import. I will try deleting my Library perhaps next for that issue as Noogy suggested.
     

    Attached Files:

    Last edited: May 13, 2023
  43. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    I can confirm the broken one is indeed broken, I tried exporting it from my version of Blender, mine works but yours is still broken. I didn't get any errors on importing in to Unity however, both trees have converted as one mesh, I think you should figure out why you get that error but we could figure that out later, that's not the reason your tree breaks for sure.

    upload_2023-5-13_19-15-59.png

    I might know what it is, I have a hunch. Be right back!
     
  44. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    Ok, I figured it out, I made your broken tree work! I recall having this issue before and being just as frustrated. It's simply the wrong orientation of the pivots. Make sure you reset the transform rotation of all your meshes and sub meshes to 000 except the pivot which needs to be set at 90degrees!! The bark has to be set to 0 not 90 degrees, not sure if you followed up on that step but the one I opened had the bark and a branch rotation with 90 degrees. Hopefully, it's not a blender bug on your end.

    1.jpg 2.jpg 3.jpg

    Works now! Try importing this.
    upload_2023-5-13_19-22-26.png
     

    Attached Files:

    Last edited: May 13, 2023
  45. Noogy

    Noogy

    Joined:
    May 18, 2014
    Posts:
    132
    Ah yes the pivots, the cause of so many import issues in Unity. I couldn't really offer a suggestion since I was using Max, but it seems every 3D program and engine likes to use different default orientation for their pivots.
     
    florianalexandru05 likes this.
  46. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Okay now that is very weird. Because when I open the blender file I posted (birchbark-broken.blend) this is how it looks:

    cti - root zero rotation.PNG

    There is zero rotation on that as it should be and the empty axis has the 90 degrees rotation in the X, exactly as it should be:

    cti - axis 90 rotation.PNG

    You see a negative 90 on the bark object X rotation in that "broken.blend" file? This must be a Blender problem then if so, as I just opened it directly from the zip I attached and there is no -90 on mine.

    I just updated to the newest Blender 2.93.17 and I am still not seeing the -90 rotation you show. Bizarre. So I still don't know how to fix it.

    Thanks for your diligence in helping me find the error either way if this is it then. There would have been no way I could have guessed such a thing would be happening. I find it surreal if so.
     
    Last edited: May 13, 2023
    florianalexandru05 likes this.
  47. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    Yes, it seems to be coming from Blender, it is weird, perhaps try an older version of Blender maybe it will be different. I use Blender 2.79 because I'm used it for so long, ofc I also have the new versions but you might want to give it a try for the sake of testing this out. Hope you get this work soon, we are looking forward to seeing you succeed! :)
     
    mikejm_ likes this.
  48. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Thanks @florianalexandru05 there is definitely something weird with Blender going on and I have figured out how to reproduce the issue though I don't know why it is happening.

    As far as I can tell, if you open the two ".blend" files I posted in the zip, both of them show NO ROTATION on anything except the root axis right? That is what I see. ie. Root empty axis has 90 on x. Trunk has 0. For both the same. Please correct me if you see different here.

    But when I try exporting an FBX from the broken ".blend" file and then re-importing the FBX, a -90 rotation is added to the trunk. Whereas if I do the same from the working ".blend" file , when it is exported as FBX and then re-imported it does not add a -90 rotation on this trunk.

    So the extra -90 trunk rotation can be reproduced, but it is only visible when you re-import the FBX back into Blender from what I see. I don't know why it is happening. The source ".blend" files look identical to me and I am using the same export/import settings.

    Please correct me if you are seeing something different. I am going to post this to the Blender StackExchange and forum and see if anyone has any ideas.

    I can also confirm that the blender trees I have that are working (bending all the way to the bottom) are similar to your "working" Blender version - they are not creating FBX's with a -90 on the trunk. I wonder if it has something to do with the order things are parented in Blender. As far as I can see it must be some sort of glitch though because the raw .blend files don't show it (it only shows up once you export to FBX then re-import).

    I note someone earlier in the thread was commenting about troubles with Blender working sometimes and then projects suddenly stopping working and not being able to figure out why. I wonder if this was the same problem they were running into.

    At least we seem to have narrowed down the issue if not why it is happening and it does not appear to be an asset issue but rather a Blender issue.

    The other "Asset Import Refresh" error is just cosmetic to me at this point since I can manually create the trees from the merged mesh (if I can get the FBX/Blend to cooperate first).

    I'll post back just for any other Blender users if I find the solution or explanation.
     

    Attached Files:

    florianalexandru05 likes this.
  49. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,813
    Screenshot_1.jpg

    Yes indeed, if I open the files in recent versions of Blender, like 2.8 and 3.4, I see it like yours, 000 and 90 on the pivot however, if I open or import it in older versions like 2.7 I get the wrong orientations on branches and bark by -90. I'm not sure this is a parenting issue as it is more of a fbx export issue after making some more tests. I actually use Blender 2.75 to export my trees and it always worked. I have tried it in Blender 2.79 and I couldn't get it to export correctly. I changed the fbx exporter to fbx 6.1 ASCII and that seemed to be the only thing that worked. I tried messing with random fbx settings in the other blender versions and nothing. I think this is an FBX exporter issue, everything seems fine but it's actually not exporting correctly, it's all kind of messed up which is causing the model to break.
    Screenshot_2.jpg

    I'm sure it doesn't work with the new versions of Blender because of the FBX exporter so may I suggest you try Blender 2.75 to confirm what I said? If you do, turn off "Apply Unit" and it should work correctly!
    Screenshot_3.jpg
    ---------------------

    Now perhaps you could fiddle with fbx settings until something works or maybe try autodesk fbx converter if you want to insist on using your Blender version.

    upload_2023-5-14_12-35-32.png
    On another note, I used a model arrow like this to make sure the directions match in Unity and Blender, and only then did my tree work the first time. Unity tries to correct pivots so I think that if it's exported wrong but corrected and it looks right in Unity that could be misleading because incorrect axis orientation will cause CTI to break. The first time the axis of the arrow model seem to match Unity and I saw 000 on the transform settings but the model orientation wasn't matching how it looked in Blender, it was definitely flipped. I think that's something to look into if you want to get your tree to work.
     

    Attached Files:

    Last edited: May 14, 2023
    mikejm_ likes this.
  50. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Couldn't get my projects to open in old versions of Blender but found a workaround in the current Blender.

    Export the FBX as described in my steps above, then re-import it. If any child of the empty axis gets the -90 x-rotation, select it and all its children and Apply Rotation. Then export the FBX from this fixed version again. The new FBX ("2nd generation FBX") will re-import correctly with no -90 x-rotation.

    This has been quite tedious @florianalexandru05 but I believe we just found a major bug that has been plaguing Blender/Unity users for a long time. I have noticed this behavior before but didn't realize what was happening. It has always been very temperamental trying to get FBX's out of Blender and into Unity and this is likely a major reason.

    I posted a bug report to Blender. We will see if they process it. In the mean time this will be my FBX strategy. Thanks
     
    florianalexandru05 likes this.