Search Unity

[Released!] Custom tree importer

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

  1. Em-de-Nem

    Em-de-Nem

    Joined:
    Mar 19, 2013
    Posts:
    104
    :)))) I was experimenting with something similar a few weeks ago:) Nice work!
     
  2. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Okay. That is one feature that I can not wait to try out. AFS 4 is coming along great so take your time. Do not mind waiting for awesomeness;).
     
  3. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Thanks. Yeah this is the first time I tried this script with a non-tree object. Worked like a charm. Looking forward to trying rocks and overhangs with ivy that moves in the wind. How did your experiments go?
     
    Em-de-Nem likes this.
  4. Em-de-Nem

    Em-de-Nem

    Joined:
    Mar 19, 2013
    Posts:
    104
    It went well, but it was just testing for non-tree objects. I spent more time (but not too much) on trying using test trees with the terrain, but had no luck with billboards yet as they were black (needs more testing).
     
  5. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Strange. As long as the trees are using the tree creator shaders they should billboard correctly. When I first started in Unity 5 my tree billboards were dark. Do not remember exactly but it might have been enlighten. Are you using the GI?
     
  6. Em-de-Nem

    Em-de-Nem

    Joined:
    Mar 19, 2013
    Posts:
    104
    I think it was in Unity 4. I will test it again when I will have time.
     
  7. Ali-Nagori

    Ali-Nagori

    Joined:
    Apr 9, 2010
    Posts:
    147
    i currently shifted my project to U5 pro , and had custom importer prier to it , i have so many trees for import but the shaders seems to have some issues with U5, is these shaders are related to AFS? and will be updated when i update to ASF4.
     
  8. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Lars is working on AFS 4 for Unity 5 but until then you can grab the U5 built-in shaders here:

    https://unity3d.com/get-unity/download/archive

    Once downloaded go to builtin_shaders - DefaultResourcesExtra - Nature - in the nature folder you will see the TreeCreator folder. Delete the treecreator folder that is in the Custom Tree Importer folder in your project and copy the TreeCreator folder from the built-in shaders to that place. It should work fine now. Then when AFS 4 comes out you can change the shaders over to that awesomeness;).
     
    Last edited: Mar 24, 2015
    Ali-Nagori likes this.
  9. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,281
    So is this asset working with Unity 5?
    I realy want to buy it if so.
     
  10. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Until it is updated make sure to replace the shaders like I said above. Other than a quick shader folder swap it works great.
     
  11. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,277
    hi there,
    just a quick update on the upcoming version for unity 5 and baked pivots which will allow us to have some leaf tumbling:



    lars
     
    Mister-D and Baldinoboy like this.
  12. danicrem

    danicrem

    Joined:
    Nov 9, 2014
    Posts:
    45
    That looks soo cool!
    I have tried using this asset, but the manual was to complex for me. Is there any video tutorial on making a custom tree with this asset?
    I have Xfrog and can make some nice custom strees. Now I only can import them as static meshes.
     
  13. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    I do not think there is any yet. I am very slow when it comes to understanding instructions so I read the manual over a lot. Is quite simple once you get it. I do not know how advanced you are with design but I find the difficult part to be understanding your modeling program. Best thing to do is find what you do not understand in the Custom Tree Importer manual and do a search on google with that instruction on the 3d app you use. For instance 'How to parent objects in Blender?'. I actually never parented anything before using this script so that was something that helped me.
     
    Last edited: May 12, 2015
  14. givecake

    givecake

    Joined:
    Mar 28, 2013
    Posts:
    14
    Hi Baldinoboy,

    Thanks for the mini-tutorial for blender exports, I can't quite get it working though. May I ask:

    What did you mean by: ''set all your edits(xw, xt, xp)''?

    The problem I have is that when I import the .fbx, the model appears in the asset view as on it's side. Then when put into the hierarchy and scene, it is broken up and rotated strangely. The mesh is also deformed.

    I have the pivots set correctly, I have the trunk parented to the root, the branch parented to the trunk, and the leaves parented to the branch. The shaders apply correctly, and the meshes do move in play mode. It must be something to do with my export..
     
  15. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Hey. The model has to be rotated 90 degrees on the x axis but still standing normal to export correctly.

    From my previous post:
    - If not already done rotate the model so blender will export it correctly. Rotate the model in edit mode negative 90 on the x axis - leave edit mode and rotate the model 90 on the x axis (make sure to rotate it with the pivot being the 3d cursor,Shift+C to move the 3d cursor to 0,0,0) After this is done the model rotation should show x90, y0, z0.

    Not sure if there is another way to export it correctly without doing this. Can be annoying if you already have the model broken up. If this does not work let me know and I will get back to you in a few hours.
     
    givecake likes this.
  16. givecake

    givecake

    Joined:
    Mar 28, 2013
    Posts:
    14
    Yeh, I followed your instructions as best I could, including doing that, but alas, still not working.

    Also, no matter how I rotate it - once imported, when I switch between local and global rotation in Unity (with 'x'), it always switches :eek: I suppose I'm just missing something key..

    Would you be willing to talk on Steam or something about blender in general? I can't help but admire your work, but realise you may be pretty busy.
     
  17. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Started a conversation with you. Can hopefully help you easier.

    I am not the best talker;). I do plan on maybe doing some tutorials but I am not an expert. Still learning things everyday.
     
  18. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi there Lars,

    Im trying to test your Demo Scene in unity 5.1.2f1, and seems that the scene is not working. Dragged the modified Trees into the scene setting materials to "Tree creator Bark optimized Tumbling" and "Tree creator Leaves Optimized tumbling" and they are bending when I hit play, but without any sync with the Wind Zone.
    I can remove Wind zone and they still get the same animation, I can set the wind zone strenght to 1000 and there is no difference.

    I have Advanced foliage Shader in the same project, there is any conflict with it?
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,277
    just tested it with unity 5.1.2f1 – and it works fine.
    but you have to import the package first and then reimport the trees as the tree importer script does not work when importing package as it is just not present.
    custom trees work for me even after importing afs. and they still work when adding the afs setupscript to the scene.
    sorry, but i have no idea what is going on there.

    lars
     
  20. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    But they work with Wind Zones (they are sync with them )?
    Cause as i said, they are working, but not with wind zones.

    EDIT: Removed Wind Zone and added it again. Now its working.
     
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,277
    crazy!
     
  22. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi Lars,

    Thanks for the fast support. Can I ask you to point me in some more direction? I'm doing what your manual says about doing first tests, and im building a simple Tree with only a trunk and a few branches (or leaf). The results are pretty bad (no main bending at all). Can you download the Tree fbx and say me what im doing worng? (I think the heriarchy and pivots are ok, but maybe there is something worng).

    Download Link: https://dl.dropboxusercontent.com/u/72551597/Plantas_Bosque_5_afsTREE_xlb21_xlprl.fbx
     
  23. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Hey. There are two things I did.

    Fixed the rotation so it is upright and rotated x90 so it remains upright in Unity.

    The previous fixed part of it but it still did not have a UV2 and was not bending besides the leaves. Not sure what modeler you are using but I recently moved to Blender 2.75a. You had the hierarchy and pivots right so the only thing I could single out was the export. I moved the model back to Blender 2.74 and exported the SAME model and it worked. Created a UV2 and has main bending. So unless it is just me Blender 2.75 is doing something different that does not work with Custom Tree Importer.

    So here is an export that is working for me: test_afsTREE_xlprl
     
  24. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Wow Baldinoboy, really thank you!

    So seems there is a problem with blender 2.75a fbx export because I tested before the rotation method. I will have to go with 2.74, but all my plugins I have to edit vertex colors and combine layers.... ahhhhhh hope they will work with 2.74.

    By the way, with your custom tree importer is posible to use combined trees?

    >Root
    >>>Trunk
    >>>>>>Branch
    >>>Trunk
    >>>>>>Branch
    >>>Trunk
    >>>>>>Branch
    >>>>>>Branch
    >>>etc....

    Really thank you for your support on all of your assets, as soon as I can test with 2.74 I will write a nice review!
     
  25. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Your welcome. Did not notice this problem before you brought it up. So your mentioning the problem probably saved me a few hours of hair pulling later on. So thank you;).

    You can still create the tree in 2.75. Setup vertex colors and everything. Just export it and import into 2.74. Then once again export it and it should work.

    Not sure about the multi trunks. Never tried. Lars will have to help you there. Would come in handy with some trees. Especially bamboo.
     
  26. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Thanks for the find. Noticed the Experimental Apply Transform button but it does the same thing as previous apply transform and deletes everything but the trunk. Did not notice the Apply Unit. Love how they default these new options to on. The scale for me is fine. In Blender it is 1.47m and in Unity is 1.47m at an import scale of 1. Thank again for the find.
     
  27. Project-Mysh

    Project-Mysh

    Joined:
    Nov 3, 2013
    Posts:
    223
    Hi there Baldinoboy,

    Testing further, now I can say that solving the problem about main bending its a little more tricky than only disabling "apply unit" checkbox from export.

    There is a tricky part about applying rotations:
    1. Apply transform (rotation and scale) for all parents of the Tree Hierarchy (all should be at 0,0,0 rotation now).
    2. Select the "empty" root.
    3. Rotate X -90º.
    4. Apply transform only for the empty.
    5. Rotate the empty X 90º.
    6. Check that the only element of the tree that have X rotation 90º is the root "empty". All other parents should be at 0,0,0.
    7. Done, ready for export.

    (Remember to disable "Apply unit" and "Apply Transform" at export)

    I will delete my previous post, because this is not a thread about how to solve problems of blender 2.75a with Custom Tree Importer. But I think that this post is important for other blender users working with Custom Tree Importer.
     
    Baldinoboy likes this.
  28. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Yeah. I noticed that just the root needs to be rotating. I was rotating every part of the tree x90 but I guess it all builds to the root when going through the custom tree importer. In the .fbx I attached everything but the trunk is rotated x90. It works fine exported from 2.75 once you disable Apply Unity. Thanks again for letting me know about that. Probably would have never noticed that new option.
     
  29. ZenMicro

    ZenMicro

    Joined:
    Aug 9, 2015
    Posts:
    206
    Hi Lars and Co.,

    I have been eyeing off this utility for a while now as i purchased over 300 trees from Xfrog. I have since tried to find modelers who could lower the poly count with LOD etc. with no luck, they seem to think it is about $100 per tree in work.

    My question to you is are you familiar with Xfrog 3D trees and have you imported them before into Unity with Custom Tree Importer?

    The models come in .OBJ (amongst many other formats) so i have simply loaded them and changed the orientation on the x to -90 so they are upright and set the leaf and bark to the appropriate Tree Creator shaders... and they are beautiful! Here is a screenshot of an entire species (9 trees of various ages) of a Teatree...

    upload_2015-10-24_3-57-45.png

    here are some free samples from their site http://xfrog.com/category/samples.html if you or someone else would like to try!

    So one major problem is the poly count is about a million (or 30,000 or something per tree)... I know your other asset can do billboarding very well so i'll likely grab that and see if i can get away with these trees as is...

    How ever i really want them to be affected by a WindZone and i'm no animator so just like to know if it'll work as is also what you think about your Advanced Foliage Shader working with these trees, these tree should be affected by walking through them (smaller ones) and the bigger should probably shake if you hit them ideally.

    Thanks
     
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,277
    hi there,
    i have not imported any xfrog tree yet - but 30.000 polys per tree seems way too much.
    i know that far cry 4 even has up to 50.000 ploys on LOD0 but that is a custom engine...
    so my advice would be to keep the polycount bewteen 2000 and 5000 max as unit’s tree creator trees do not sopport LODs (unlike speed trees).
    and as the billboards all share on single texture you won’t be able to add a vast amount of different trees to your terrain as the texture resolution for each billboard will decrease with any prefab you add.
    so 5 to 10 different trees might be the max.
    (you may however use multiple terrain of which only one gets rendered).

    lars
     
  31. ZenMicro

    ZenMicro

    Joined:
    Aug 9, 2015
    Posts:
    206
    Hi Lars,

    I just loaded the tree second from the left (the biggest one) into Blender and it says it has 185,000 tris.. oh damn.

    Can you explain what you mean by the resolution for each Billboard will decrease with any prefab you add? I'm not sure i understand that bit.

    10 different trees is not too bad if it is per terrain, assuming my terrain made up of 16x16 terrain chunks is considered a terrain each.

    But you do also mean that the same tree has the same billboard so if it's rotated differently it will still pop to look all the same? i was under the impression your billboards took a fresh snapshot depending on the trees orientation to the camera? - I'll have to check your demo out again.
     
    Last edited: Oct 24, 2015
  32. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Each prefab you add adds its own billboard image to the one billboard texture that the terrain system creates. It will not increase in size or create new textures for more trees. So when you get to a few trees the billboards start getting horribly blurred. So if you want a varied natural environment Unitys terrain system will throw a tantrum. That is how I see it at least ;).
     
  33. Janwalli

    Janwalli

    Joined:
    Oct 26, 2015
    Posts:
    3
    Hi,
    I am trying to get this script to work, but still struggle at the moment. I have a simple test tree, brought to Untiy as *c4d. You can see the result on the right.
    Importer sets the two shaders to Tree Creator Leaves/Bark Optimized.
    A modified mesh is generated, the preview looks fine (and says 2submeshes, uv, uv2, colors) except it is without material/shader. When dragging this version into the scene, I get a pink trunk without leaves. Inspector only lists one empty element under materials.
    Also tried to go via FBX and also via Blender, in all cases I only get this pink trunk.
    Console seems to be fine, no error message (apart from missing Vertex Colors when using the Cinema4D File)
    The mesh uses a hierarchy, pivot points work fine, no tags used so far. It seems that I am doing something wrong
     

    Attached Files:

  34. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Hey Janwalli,

    What you need to do is drag the imported mesh and not the modified mesh into the scene. The script creates the modified mesh and inputs that mesh into the imported object. Here is a simple image.



    If the import mesh has problems too then it is a setup issue. It should be a single object without any children when moved into the scene. So if it is bending nicely just setup correct materials, textures and input them.
     
  35. Janwalli

    Janwalli

    Joined:
    Oct 26, 2015
    Posts:
    3
    oh man, thanks a lot - this was really a stupid error I did.
    It works as you say, now I need to figure out, if it is better to use Cinema4D, or go the route via Blender (because of Vertex Painting)
     
  36. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Awesome. Glad it is working.

    Have not tried Cinema4D but I do know Blender is annoying to vertex paint. I use workarounds like making a texture where I paint the uv edges green and then bake to the tree using the Bake to Vertex Color option. It is quite easy once you get used to it but if Cinema4D has a more useful approach to vertex painting that is the way to go.
     
  37. Janwalli

    Janwalli

    Joined:
    Oct 26, 2015
    Posts:
    3
    by the way - thank you also for your freebie scripts!
     
  38. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Thanks but I am not the dev. @larsbertram1 is the developer of this asset. I am just a very happy user ;).
     
  39. hike1

    hike1

    Joined:
    Sep 6, 2009
    Posts:
    401
    I'm having 3 problems with the tree creator, I followed your tutorial from 2011. The 1st is I can't get this
    texture to UV map correctly on the trunk, 2nd-I can't make unique prefabs out of these trees even if I duplicate
    in project view and 'break prefab instance', all the trees get the new materials. #3 is I can't import a unitypackage
    of a tree with the mesh, it says it's in the prefab but it's not. Is your importer any use here?
     

    Attached Files:

  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,277
    @hike1
    the custom tree importer is written to import custom meshes.
    unfortunately it won’t fix any problems on trees created using the built in tree creator.
     
  41. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    1) Do you have your bark texture Wrap Mode set to Repeat or Clamp?

    2) Duplicating the tree prefab in project view and then dragging that one out to edit should work. Just tried it out and it worked fine.

    3) Sorry. Not sure on this one.
     
  42. QuantumTheory

    QuantumTheory

    Joined:
    Jan 19, 2012
    Posts:
    1,083
    Purchased, but I'm getting a "missing prefab" in the demo scene.
     
  43. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Have you re-imported it yet? I skip importing the demo scene so not sure. Will try it out.
     
  44. deekpyro

    deekpyro

    Joined:
    Oct 16, 2012
    Posts:
    63
    Hey Lars and thanks for making this great plugin. Does it work with trees that have their branches and leaves in the same submeshes?

     
  45. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Sorry if my answer is not clear, I am 3/4 asleep ;).

    You export the tree with every leaf, branch as its own object. The two submeshes will be selected based on the texture, material applied to that each object. bark and leaf. So the script will create the two submeshes that will shade and bend correctly if setup correctly. So that conifer branch should be set as a leaf so it has translucency and with a darker green vertex on the edges will bend nicely.
     
  46. deekpyro

    deekpyro

    Joined:
    Oct 16, 2012
    Posts:
    63
    Thanks @Baldinoboy. I was able to import my tree using the custom tree importer with no errors though it's not yet responding to the wind. I haven't added any green vertex colors to the tree yet.
     
  47. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Cool. You do not need the green vertex colors for the tree to bend. Just for the addition of edge bending. Couple things

    When imported did the script create a _modified version of the tree next to the original import?

    Do you have a windzone in the scene?
     
  48. deekpyro

    deekpyro

    Joined:
    Oct 16, 2012
    Posts:
    63
    I do indeed both have a _modified mesh and a wind zone in the scene. Perhaps it has to do with the fact my tree doesn't have any branches? (here's a picture of a copy of the mesh before the mesh importer does it's magic)

     
  49. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,455
    Nothing has to be named branch. The only name you need to have is root for the empty object the trunk is parented to. I am thinking trunk too but think I have a few plants that have no trunk naming.
     
  50. GameTechnix

    GameTechnix

    Joined:
    Oct 5, 2015
    Posts:
    84
    I could have used this tool a few weeks ago! Looks very helpful as I had a bit of trouble setting up trees for the first time.
     
unityunity