Search Unity

[Released!] Custom tree importer

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

  1. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    His layout in Blender looks fine. Only thing I am not sure if have the empty objects name different will change anything. For safety I always name it root_(object name). It seems to have been combined okay in Unity so guess it does not have to be root.
     
    Last edited: Aug 30, 2017
  2. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    as always: thanks a lot @Baldinoboy to jump in here!
     
    Baldinoboy likes this.
  3. theLittleSettler

    theLittleSettler

    Joined:
    Jul 14, 2012
    Posts:
    36
    @Baldinoboy @larsbertram1

    Hey, so I'm after the same thing - just want to confirm the process for billboard creation and clear up a couple of things.

    First off, this asset makes tree-creator trees, so that would mean legacy trees... with a speedtree billboard? That seems unecesary...? Is that just for better quality and/or more efficient billboards?

    Second, I've looked into billboard generation extensively back in the unity 5.3 days, and never found a convenient way to do it. I started making my own thing, which I finished but for transitions. I reckon this would save me time in so far as I wouldn't have to finish that.

    Looking at the billboard asset page now, I'm not sure the situation has changed that much for creating billboards for non-speedtrees as it is unclear what format they expect normals to be. There doesn't seem to be any automatic way to create those textures outside of speedtree modeler (but of course, I'm not after speedtrees). Granted, docs are improved.

    Cheers :)
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    cti trees are compatible with legacy tree creator shaders.
    but it also lets you generate trees using LODgroups and speed tree like billboards. in this case trees are rendered using cti custom shaders – which support improved bending compared to tree creator trees.

    cti generates billboard textures right within unity.
     
    Last edited: Aug 30, 2017
  5. theLittleSettler

    theLittleSettler

    Joined:
    Jul 14, 2012
    Posts:
    36
    perfect

    yeah, I do remember some...interesting...bending artifacts with legacy trees
     
  6. Kopter

    Kopter

    Joined:
    May 23, 2016
    Posts:
    2
    Hello :)

    I've been working with the CTI script for a good while now, but I always felt like there was something missing in order to make this workflow "really shine". I think we've all started poking at unity's tree creator.. and yeah. I don't think I need to explain more.

    Anyway- I made a little toolset for opening up the ability to work with instances, groups, and variable scales to quickly be able to iterate and try new things- plus have the ability to make LODs in a smart way without too much extra work. I felt like I should share this with the others that use the same script, since it really made CTI amazing to me. BE AWARE THOUGH, this is a script for 3ds Max!

    To sum it up:

    - Enables you to create branch groups that you can instance and place in your tree hierarchy, that consists of both leaf and bark objects. These can be scaled, parented and rotated however you want, without you having to re-set scales or freeze anything. The process handles this and keeps everything intact.

    - A tool to update the branch groups with the click of a button, so you don't have to manually go in and replace them for each time you update them or want to change them.

    - It creates a copy for each time it will process the tree, so it's completely safe if "something would go wrong".

    - The ability to automatically apply phase variation in a systematic way that lets lods and future iterations get the same phase for each branch/ leaf to match it.

    - Built in normal projecting tool based on normal thief, but applied specifically for this usage and is executed as a part of the process. It can also be used outside of the process to quickly project normals on smaller setups.

    - Quick selection tool to select parent object's child objects with the click of a button (it gets useful in some situations).

    Looks like this:
    https://i.imgur.com/iDF7xiI.png

    It's adapted to work for the CTI pipeline, so you set it up completely according to documentation and let the tool handle the rest. This means, you need apply the correct names on materials for the corresponding objects, etc. Make sure to read the README ;)

    I hope someone can find this useful!
     

    Attached Files:

    ChinChiaYeh and Baldinoboy like this.
  7. larsbertram1

    larsbertram1

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

    after working on cti for more than a year under the radar doing a lot of custom work, it is time to announce a major update.

    you may expect a way more simplified workflow to create all needed assets – especially billboards.
    next to that the upcoming update will add official support for instancing, unity 2017 and advanced bark shading using texture arrays or uv2.

    you will also be able to import complex models to be compatible with the advanced foliage shaders (including touch bending) and the advanced terrain grass. of course these will not support cti's generic leaf tumbling and turbulence but let you create assets for the packages mentioned before.

    i am also working on an integration with critias foliage – which may come as soon as the author of this package has time to pick it up.

    cti will also be supported by the upcoming vegetation studio.

    so i hope i will see a lot of custom trees in the nearby future which simply render as fast as possible and do not shiver like that standard speed trees :)

    i will keep you posted,
    lars
     
    Alverik likes this.
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    this screen shoot shows one of the new bark texturing features:
    texture arrays.

    left: the birch uses texture array to add a 2nd detail texture towards the roots of the tree. costs in the pixel shader: more or less 0.0 – as the shader always only samples a single array.
    right: the tree uses just a single tiling texture for the bark.

    Bildschirmfoto 2017-11-06 um 20.56.20.png
     
    theLittleSettler and Alverik like this.
  9. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    the 2nd bark texturing feature is shown in the screen shoot below: using uv2.

    this feature is a bit more expensive – as the pixel shader samples up to 4 (instead of just 2) textures – but lets you create pretty lively textured barks.
    lower lods however my simply fall back to just sample the low res global maps and therefore are cheap.

    left pine: mixing a detail texture set (using uv0) and a global texture set (uv2), which lets you add the nice gradient in color as well as the partially added moss.
    right pine: using the detail textures only.


    pine_test.jpg
     
    Alverik likes this.
  10. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    did i mention tessellation?
    for those of you who have strong GPUs and are addressing next gen tesellation at east for the bark materials will come.

    Bildschirmfoto 2017-11-22 um 00.23.12.png
     
  11. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Awesome work on this latest version Lars! Looking forward to testing more thoroughly
     
  12. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
  13. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,811
    This really looks like a must have! I really don't want to settle for the unity terrain shaders when I wanna have a AAA environment. I might pick this up when I have money. Is there any proper tutorial for Blender?
     
  14. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Yeah it is an incredible system that I can not recommend more! Unfortunately there is not a tutorial for Blender to CTI yet. It is something I have been wanting to do for a year now but can not get the time.

    The documentation covers the process well though. Just a basic knowledge of Blender with the documentation should get you going.

    Only thing I recommend for Blender users and CTI is to use Blender 2.74 and Applying Transforms on export does not work. The FBX exporter seems to have a lot of issues in Blender.
     
  15. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,811
    Yeah it's true Blender has a lot of exporting issues but I'll see. I'll get documented about your product better first.
     
  16. DmitriSkif

    DmitriSkif

    Joined:
    Oct 28, 2017
    Posts:
    10
    Could you please provide any kind of guide how to assemble, set up and import properly a tree which uses texture arrays and multiply UVs? E.g. Scots pine or birch. Thanks!
     
  17. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,811
    I decided to make my trees using unity standard tools and upload my pack sooner for now. I'm still interested in purchasing your tools but it will probably be a bit later. I would like to know how billboards work, or does it automatically generate good working billboards in the editor, or do I have to make them myself?? Proper wind and billboards (perhaps better foliage shaders) is probably all I'm interested in from your tool.
     
  18. DmitriSkif

    DmitriSkif

    Joined:
    Oct 28, 2017
    Posts:
    10
    I'm interested in advanced billboarding too cause only trees made with Tree creator or SpeedTree support camera-facing cards. I have a huge pack of such trees and want to use them in my project. I can re-assemble them in Tree creator but unfortunately, it doesn't support multi-metarials or texture arrays for trunks. I need two different textures on trunk, one for bottom and one for top part.
     
  19. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    please have a look into the documentation and the provided demo content.
    setting up a second uv channel should be an easy an common task for any modeler. and texture arrays simply pick up the 2 bark materials that you assign to your trunk: make sure you name them properly, then the importer will take care about baking the needed information.
     
  20. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    the package ships with a script that lets you easily generate the needed billboard textures and billboard assset with just a few click and adjustments.
    billboards themselves pretty much work like speedtree billboards: 8 diffuse/translucency/smoothness textures plus normals which get mapped onto a camera facing billboard asset and are lit in realtime.
     
    florianalexandru05 likes this.
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    that is what cti's latest bark shader version offers.
     
  22. florianalexandru05

    florianalexandru05

    Joined:
    Mar 31, 2014
    Posts:
    1,811
    Excelent, that sounds good!
     
  23. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    wow how did i miss that! what does it mean it supports atg can i use those shaders with it or can i place trees as detail mesh ?
     
  24. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    it means that you can model your vegetation in your 3d app, add cti control tags and import the model which then will be ready to be used with the afs foliage shader: bending properly baked in.
     
  25. DmitriSkif

    DmitriSkif

    Joined:
    Oct 28, 2017
    Posts:
    10
    "that is what cti's latest bark shader version offers."

    Yes, and it looks nice, but your shaders don't support camera-facing polys. That's on your business, to like them or not, of course, but currently now it's a significant feature loss for me. And I think, I'm not alone here who wants to have "mean Importer for every tree you have".
     
  26. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    atg is just for bushes or could it handle trees as well or do i need afs for that in conjunction with cti. the documentation is not answering a lot of those supported assets stuff. nothing besides the tagging stuff. and even this confuses me. and what shading do i get without atg or afs?
     
    Last edited: Dec 22, 2017
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    as i wrote privately: you can't really author camera facing planes in e.g. Maya or Blender – so it is pretty pointless to support these in the shaders.
     
  28. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    atg has less sophisticated bending – so i would not use it on trees.
    you can do bushes or fern using cti only. you may have a look at baldinoboy's tropical forest pack at the asset store which uses cti even for grass.
    you only need afs in case you want touch bending.
    afg however is another topic – as atg is abut rendering vast amounts of grass or smaller foliage. latter can be set up manually painting vertex colors – however using cti instead makes things much more easy if it comes to more complex models like a young sappling.
    pretty much the same.
     
  29. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    thanks for the response i really do not understand why you do not have a propper showcase the most sofisticated example with new bark rendering is a birch with 3 branches on it without any texture. it is hard to tell what i get. i guess i will purchase but showcase whise you make it really hard. since i already now about your qualtiy assets from atg i hope it is what i need
     
  30. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    this is not an art package.
    if you want to see what you could achieve using cti you should watch this:

     
  31. nbac

    nbac

    Joined:
    Jul 7, 2015
    Posts:
    267
    i am aware of this but what is additional effort tech from the creator!? and does he use atg or afs !? i dont know.
    anyway thanks a lot for fast response
     
  32. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    he uses blender to model the trees. all the rest is done by cti.
    and he neither uses afs nor atg.
     
  33. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    Hi @nbac ,

    For what is shown in this video, like Lars said, I used Blender for modeling and imported everything as CTI trees. AFS and ATG compatibility is new and I am now exporting some models to be compatible. It is incredibly powerful and the quality is amazing!

    ATG and AFS export support is really great and, once you have the rest of the process down, it is just a matter of exporting with a different name.

    When I get a chance I will share a video showing a simple test in action.
     
  34. fayers

    fayers

    Joined:
    May 10, 2017
    Posts:
    8
    Could you create a nice video tutorial where it is explained, step by step, the proper functioning of a plant created in blender (moderately complex) and imported in unity with CTI?
    While before I was able to make everything work by exporting as .obj, now this does not work anymore and in .fbx the trunk does not move and the branches go for their business.
    Thank you.
     
  35. Baldinoboy

    Baldinoboy

    Joined:
    Apr 14, 2012
    Posts:
    1,526
    I do plan to but tutorials take a lot of time to make and lately my three jobs are kind of putting a damper on doing it. I really do want to though and if I get a day off that is the plan.
     
  36. DmitriSkif

    DmitriSkif

    Joined:
    Oct 28, 2017
    Posts:
    10
    Sorry, but you're not right. I can do it - cause I already have such trees in another game, configured completely in 3D Max. Rotation of their cards are all made by shader. SCS's Euro Truck simulator 2 also has trees of such kind, and Trackmania: Turbo by Codex too. Actually, that's the only disadvantage of your asset comparing to ST or Tree creator, cause both support all tree technologies possible.
     
  37. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    then how do your cards look like in 3d max? do you have a screen shoot?
    and how does the shader rotate these planes?
    is it a unity shader? how does it look like?
    most billboard shaders that i know use simple points at the pivot of the billboard and then expands the vertices in the shader according to the view direction and some data stored in e.g. uv2.
     
  38. DmitriSkif

    DmitriSkif

    Joined:
    Oct 28, 2017
    Posts:
    10
    They're simple polygons, all oriented same direction. If you're interested, I can send You not only the scrrenshot but the whole source file in .max

    I don't know cause I'm not a shader guru (and not advanced in code at all), but it takes all the work and the only you should do in 3D max while exporting the asset to game, is to assign "Camera facing" shaders. This shader has no shadowing pass so cards don't cast shadows (but receive them). I think, it possibly can be resolved by adding the 2nd pass to re-orient cards to the Directional light...

    There's a shader's .fx files, and game is DTG's Train simulator. Possibly, it will help. You can simply open them using Notepad++ or similar extended text editor.
     

    Attached Files:

  39. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Hi lars,
    I'm mainly a coder and now starting to use speedtree and 3dsmax to model some trees for my game.
    But I have no idea how to set up hierarchy and paint vertex color in 3dsmax.
    Any suggestions?
     
  40. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm, i do not know 3dmax but in maya you would have to break up the unified mesh first.
    then you get a lot of single mesh objects. create an empty locator, then parent the trunk mesh under it.
    pick the first branch mesh and make it a child object of the trunk etc.
    https://knowledge.autodesk.com/supp...0AE92021-9E16-4616-840B-B19773AD9A6E-htm.html
     
  41. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    I know how to break up a mesh, but 3dsmax's modeling logic is quite different from maya, it does not have hierarchy so there is no parent and child.
    Every individual is an object, then inside object there are elements. All elements are equal, cannot have sub elements.
    And objects cannot contain sub objects, only elements.
    Then I can put multiple objects into a group, groups can be put into groups too if I remembered right.
    I think multiple layers of groups can form some kind of a hierarchy, but have no idea what they would be like when exported FBX.

    BTW, my tree's main trunk will be separated into several parts for procedural chopping function, can CTI recognize them as a whole trunk and apply proper wind?
     
  42. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm, having a look at the page i linked in my previous post there is something like a hierarchy. anything else would be very strange – as any other 3d app i know (maya, modo, cinema 4d, blender) offers such hierarchies.

    you will have to create 2 trees:
    - 1st the regular tree as one single mesh containing 2 materials – mainly for performance reasons.
    - 2nd the split tree. i can think of 2 parts: stump and upper part. while the stump does not need any bending the upper part does as otherwise the tree would pop as soon as you switch the prefabs from the 1st to the 2nd one.
    the importer should apply correct bending to the upper parts i guess. if it does not it would need you to change 1 or 2 lines of code. but there are a few more challenges:

    break position
    as already said the stump most likely will not need any bending. however the importer applies bending along the whole height of the tree. in case the break position is pretty low you will not get much visible popping of the stump suddenly not bending anymore. if you have a higher break position or even want to have multiple break positions things get a bit complicated.
    - higher break points: you can make the script apply any bending only to vertices e.g. higher than a given y position like 3 meters: 2 or 3 lines of code you would have to change.
    - multiple and even higher break points: this would be very special...

    falling trees
    right now the shader derives a lot of variation just from the transform's world position like color variation and variation in bending. letting your tree fall down would change that position so you will get different values each frame: diffeent colors and time shifts in bending... so you have to create a shader variant that does take the actual worl position into account but grab one from a materialpropertyblock which you set by script to match the tree's world position just at the moment you switch between the 2 prefabs.
     
  43. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    In my case it actually needs more than 6 parts for one simple coconut tree.
    For the trunk is divided into several parts to make sense when player chop them down piece by piece instead of the whole tree fall down and suddenly turn into several tree log items in The Forest.
    My worries are the separated trunks can not bend correctly between each other, like the connecting point may break after the bending.
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i do not know the size of your coconut tree. but usually trees get chopped at the bottom. then the tree falls. and if it has fallen it gets gets divided.
    so this would need probably 3 prefabs 1) regular tree, 2) tree with one cut which can fall down (while still being animated by wind) 3) the fallen tree which can be further divided.

    in case you talk about cryengine like palm trees which can be chopped at many different points using your gun things will become a bit more complex.
    actually the importer handles only one single trunk mesh. trunk in this case means that the bending is calculated a bit different from branches: it only receives main bending but no secondary bending e.g. but you can simulate further trunk meshes using control tags or even add custom tags the achieve your goal.
    but you still would have to create a shader version which derives variation from a property in a materialpropertyblock.
     
  45. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Thank you for the detailed explanation!
    Now I know how should I prepare my model :)
     
  46. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    you are welcome!
    i always recommend to start with very simple geometry in order to get the workflow right.
    so in your case i would just start using sevaral cylinders stacked on top of each other and some others as branches and see how to set all this up to get imported properly.
     
    Harekelas likes this.
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    actually i did a quick test – and with a simple modification/addon to the script it is possible to calculate proper bending even if the trunk is split into several meshes.
    so when you have finished setting up your workflow for regular trees just come back to me to discuss the needed changes.

    the outline shows the construction of the tree: the trunk consists of 3 independent cylinders.
    the shaded version shows how the tree bends.

    Bildschirmfoto 2018-01-19 um 10.10.31.png

    the tree and its hierarchy inside maya:

    Bildschirmfoto 2018-01-19 um 10.16.33.png
     
  48. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Wow! This is Amazing! Seems I won't worry about making three prefabs for just one tree now!
     
  49. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    864
    Hi Lars,
    I've created a very simple poly tree in max:
    upload_2018-1-21_11-13-7.png

    And set their hierarchy into this:
    upload_2018-1-21_11-13-15.png

    As you can see there are three part of the trunk, the stump should be static without any wind effects.
    And the trunk1 and trunk2 should act together like the main trunk of a tree(only apply main force)
    Then some of the branches are children of trunk1 and others are with trunk2, they should follow their own parents.
    What next should I do before I export them as FBX and import into unity?

    Edit: Imported successfully, but the bending is weird:
    upload_2018-1-21_12-48-9.png

    Any further steps I should take?

    Edit2: And I got another problem here, I'll need the models keep separated inside unity so I can disable some of them to create the chopped down effects, but the imported tree models fused together into one, is it possible to have them separated and still get the wind effects on them?
     
    Last edited: Jan 21, 2018
  50. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    all parts of the tree always are effected by bending...
    i t does not look that weird – at least all parts seem to be connected to each other. bending however might be a bit strong which may be simply adjusted using a control tag.
    the importer always flattens down the meshes.
    so in order to get several go you will have to do several exports: 1. only containing stump, 2. containing chunk 1 and its children etc.
    unfortunately this will not give you correct or equal bending on all objects – as the importer calculates bending relative to the trunk's height – which will be different for the different exports (as trunk is always just the first child in the hierarchy)
    this height is stored inside the variable "maxY". so you will have to set it manually for all imports.
    you may do so by adding the following lines at around line 280:
    if (assetPath.Contains("_maxy")) {
    maxY = GetAttributeVal(maxY, assetPath, "_maxy") * 0.5f;
    }

    then you have to add "_maxy" plus a 2/3 digit value to all the different fbx files to set the height min and secondary bending are calculated relatively to.