T4M Black Edition

Discussion in 'Assets and Asset Store' started by azert2k, Feb 14, 2012.

  1. Dambusters

    Dambusters

    New Member

    Joined:
    Jan 6, 2012
    Messages:
    32
    I have a Unity Terrain and I want to create meshes of different resolutions and use LOD Manager to switch between them at various distances.
    How do I create the multiple meshes?
    Does T4M do this automatically?
    Last edited: Apr 24, 2012
  2. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Hi,

    You must create 3 differents meshes on your 3D software to use LOD System, the T4M don't make that automatically currently. An automatic mesh simplifier can degrade considerably the quality of your object and I don't have enough time to make that, for now.

    Best Regards

    Stephane
  3. Dambusters

    Dambusters

    New Member

    Joined:
    Jan 6, 2012
    Messages:
    32
    Hi Stepane,

    Just to explain further, I'm not importing an object to convert - I'm using T4M to convert an existing Unity Terrain and T4M lets me choose the resolution, I was hoping that T4M would let me repeat the conversion process at 3 different settings. I guess I can just manually repeat the process - but it would be a nice feature and I would guess reasonably easy to add?

    Best regards,

    Bruce
  4. n8

    n8

    Member

    Joined:
    Mar 4, 2010
    Messages:
    147
    I think this would be a great addition to the tool, but I think what Azert2k is saying, is that by importing the generated mesh to your 3d app you would get a much lower resolution mesh that would ultimately work better for the LOD. The whole point of the LOD would be to have an extremely low poly version of your mesh at far distances, not something you really get with the t4m conversion tool even on the lowest settings. I just use the decimator modifier in blender and get pretty good results.
  5. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Hi N8 :)

    Of course you can repeat the process without problem to have 3 differents resolution of same terrain. But the LOD System is not expected to manage parcels of land, so you may encounter problems with it.
  6. Dambusters

    Dambusters

    New Member

    Joined:
    Jan 6, 2012
    Messages:
    32
    Thanks, you're right, ultimately it's probably best to optimize it by hand anyway.
    @ Stepane - very nice software BTW, and I'm looking forward to reading the manual.
  7. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Yes, I finished Convertor - Optimizer - Painting tool... with a lot of screenshot. I think, I will finish that, this week end. But you will have a complete manual
  8. n8

    n8

    Member

    Joined:
    Mar 4, 2010
    Messages:
    147
    Azert2k,

    I was working on the tips you gave me a while back, and ran into a problem that I am not sure how to overcome. You were saying that the non-lit shader + light map has better performance for mobile. My problem is that since I am using multiple terrain objects, I am loading them in dynamically at the beginning of my scene from prefabs. Can you still have light maps associated with those when done this way?
  9. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Hi n8,

    Sorry, I don't understand your question, can you explain more, please (sorry for my poor english)

    Thank
    Last edited: Apr 26, 2012
  10. n8

    n8

    Member

    Joined:
    Mar 4, 2010
    Messages:
    147
    no problem,

    Ok so I have 16 t4m objects arranged in a grid pattern. Having 16 massive terrain objects all sitting in the scene at load makes for a very very long loading time for older devices. To fix that I have removed all of the t4m objects and set them as prefabs in the Resources folder to be dynamically instantiated after the scene loads. With this setup, is it possible to use the built in Lightmapping tool with Unity? How do you create a lightmap for an object that is loaded dynamically after the scene is running?
  11. ParaLogic

    ParaLogic

    Member

    Joined:
    Aug 19, 2010
    Messages:
    166
  12. n8

    n8

    Member

    Joined:
    Mar 4, 2010
    Messages:
    147
    @ParaLogic, Yeah I wish I had the $$$ to grab pro, but as for now I am stuck on the indie. With the method I have currently implemented, I have taken the load time down from ~4min to under 1 on the iphone 4.
  13. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Written Manual of the T4M HERE


    @n8
    Hi,
    So no problem for that :
    - just put all your terrains on the scene
    - Create the Lightmap
    - put each terrain in prefabs in the Ressources Folder
    - delete the terrains you don't want on the scene
    - and use your script to instantiate each terrain with the new prebabs

    In this case, all lightmap are kept.
  14. sjm tech

    sjm tech

    Member

    Joined:
    Sep 23, 2010
    Messages:
    461
    great job Stephane ... very clear and complete manual... thanks!
  15. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Thank Max :)

    Despite my bad english, I hope that everybody will understand...
  16. shoyuken

    shoyuken

    New Member

    Joined:
    Mar 9, 2012
    Messages:
    2
    Hi everybody. I need some help. Is there a way to split an obj terrain into smaller square pieces? I tried doing it manually in C4D but the process is tedious, especially when I have to split the terrain into 80 pieces.
    Any idea is welcome.
  17. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Hi,

    You can make that with a 3D software. I would make that in the T4M, but without result. Maybe someone has make a script to split a geometrie into many tlies.
  18. Wolfos

    Wolfos

    Member

    Joined:
    Mar 17, 2011
    Messages:
    656
    But does it dynamically subdivide geometry like the built-in terrain does? I make massive terrains, sometimes tying 4 or even more together (default size, 2000x2000). How would the performance be, compared to Unity terrain?
  19. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    It don't subdivide the geometrie. For mobile the T4M is better because it give only 1 drawcall. But big terrain (unity terrain to T4M) can be also heavy on mobile.
    UnityTerrain : a lot of drawcall, and the number of vertices can be too high.
    T4M : only 1 drawcall, you can choice the number of vertices(for UnityTerrain conversion, number of vertices can be too high if you need a lot of detail)
    The T4M is more usefull for terrain made with 3D software.

    Keep me aware

    Stephane.
  20. Gherid_lacksGPS

    Gherid_lacksGPS

    New Member

    Joined:
    Dec 3, 2011
    Messages:
    99
    Words do not describe the awesome of this asset. Great work on the manual, btw..
  21. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Thank a lot :)
  22. tripknotix

    tripknotix

    Member

    Joined:
    Apr 21, 2011
    Messages:
    533
    i think your next step should be the subdivision tool, i think everyone is coming to that same conclusion, bringing down the geometry in t4m has its disadvantages, like the trees do not turn into LOD automatically like the unity terrain does, so its a different system, and we are running out of polygons for that. so the bottleneck for t4m is not the terrain itself, but the other objects like trees that dont have the dynamic tree system from unity terrain.

    so in order to reduce polygons, for mobile and flash, it would be great to see you, #1. Split terrain into 4 peices (or more) and make atleast 2 versions of each peice, for lod visually (but not effect the collider possibly?, just turn off mesh renderer), so automatically we have a dramatic reduction in polygons without making our entire terrain not be so blocky, i have roads between mountains that get destroyed when i run t4m at 128k poly conversion.
  23. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Hi,

    I don't think its a disadvantage, because the UnityTerrain with a lot drawcall + tree(and Automatic Lod), stay totally unplayable on mobile and don't work on flash. On T4M you can also use tree made with tree creator... with wind, lod. Just need to modify the tree creator shader to work on mobile.
    But The subdivision is a good feature and good for a terrain Lod system.
  24. Tiles

    Tiles

    Member

    Joined:
    Feb 5, 2010
    Messages:
    2,210
    I have a question regarding the splatmap. I create it outside of Unity. What i start with is a black and white png with an alpha channel. Let`s say black is my rock texture, and white is my grass texture. So i fill all white areas with red. And make them transparent then. This works with sharp corners. And T4m deals with this splatmap fine then.

    But when i open this splatmap and soften the result to get a bit more soft transitions, then i get black borders instead a soft transition between grass and rock. See shot with the red arrow. How can i avoid this?
  25. Lars Steenhoff

    Lars Steenhoff

    Member

    Joined:
    Aug 7, 2007
    Messages:
    874
    I'm not a shader programmer, but let me tell you if there were a unity tree shader for mobile I would be more than happy to buy this ( hint )

    Thanks
  26. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    In fact, the T4M (like Unity terrain) use 32bit alpha png. All color are paint with (255,0,0,0) for first splat, (0,255,0,0) for the second, (0,0,255,0) for the 3, and (0,0,0,255) for the last one.

    I don't know if you can make that with a paint tool like photoshop or other...
    Last edited: May 9, 2012
  27. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Hey, Lars

    Ok, I will make that for the next update this weekend ;)

    Edit : I made one, but it work only on android, the translucid effect don't work on iphone. Think that the clip shader (cutout) is heavy for mobile, so I will make both : blend and cutout shader and with and without translucid effects.
    Last edited: May 9, 2012
  28. Lars Steenhoff

    Lars Steenhoff

    Member

    Joined:
    Aug 7, 2007
    Messages:
    874
    Super! iOS is what I use, so if you can get it to work, this will be great!
  29. Tiles

    Tiles

    Member

    Joined:
    Feb 5, 2010
    Messages:
    2,210
    Thanks Azert2k. Too bad that you don`t know the solution. Seems that i have to do some more experiments :)

    EDIT. have it. With four textures the colours red green and blue gets stored in the invisible part of the image. And black at the visible part of the image. When i soften the image with black involved, then i get this borders where black gets softened.

    Looking at a in Unity painted result shows me that there needs to be red in the transition areas in the visible part too. Something that is not this easy to achieve with simply soften in a paint software. Here it just softens with what is visible. And making red visible looses other informations in the invisible layer then. The black border stays.

    So i go another route. I use red and blue for my mask now instead red and black. That way i have colours that are both in the invisible part of the splatmap. I can soften my image, and can make it invisible afterwards. This works at least for three of the four textures. The black channel needs to be painted in Unity then. But i can live with that :)
    Last edited by a moderator: May 10, 2012
  30. Tiles

    Tiles

    Member

    Joined:
    Feb 5, 2010
    Messages:
    2,210
    I have one more question about planting trees. T4m creates a hierarchical object full of trees in the hierarchy when i paint my terrain with the trees. And every single tree gives me one drawcall now. 100 trees means 100 drawcalls. I thought planting is part of the terrain. Is it meant that way or is there something i miss or did wrong?
  31. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Hi Tiles,

    The planting is not a part of the terrain... so, each object on scene give you 1 drawcall (like UnityTerrain), it's normal. Unity free and Pro can make batching several trees to give you 1 drawcall (each tree must have less than 300 vertices), or with Unity Pro several trees in 1 drawcall on static mesh.

    The T4M give you 1 drawcall for terrain, while the UnityTerrain give you more than 30, add to this 1 drawcalls by object.

    If you work on a mobile game you must master the number of drawcall with the view distances, combine same objects by script (see unify communauty for that) or others tricks.

    It's a eternal problem of 3D scenes on mobile device for now... finding the best compromise between Vertices/Drawcall/performance

    Stephane
  32. tripknotix

    tripknotix

    Member

    Joined:
    Apr 21, 2011
    Messages:
    533
    The real issue tiles, is taht he doesnt have a culling setup for it yet, or a way to transform the trees into billboards. its a tough situation for alot of people when the default terrain performs better because it handles trees better than T4M, but he said hes going to try to make a shader and hopefully hell make a system around it like his billboard plants.
  33. Tiles

    Tiles

    Member

    Joined:
    Feb 5, 2010
    Messages:
    2,210
    I see. Thanks a bunch for the explanation :)

    Mh, this would be a useful information for the manual i would say :)

    EDIT. crossposting. Yes, Thanks tripknotix. Trees billboards can be done by hand for now. But a proper culling setup would definitely be cool!
    Last edited by a moderator: May 10, 2012
  34. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    The T4M have a culling system : It use the Layerculldistance class.

    "The way to transform the trees into billboards"
    But it's the same problem with that, each billboard object will give 1 draw call, this will only resolve the vertice problem, not the drawcall problem...

    Also, if I integrate some UnityTerrain features, the T4M will become too heavy for mobile like UntiyTerrain, and is not the goal.
    Last edited: May 10, 2012
  35. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    @Tripknotix
    I know you use the T4M for a Flash Game and you want use the T4M like UnityTerrain, but if the UnityTerrain is not compatible with Flash for now, it's because the UnityTerrain is too heavy for it, tree creator compatibility and the shaders problem.

    I can't make better than the creators of unity (full time/ more than one person), I offer an alternative who works on flash/mobile with good performances, plus, a lot of architects love the T4M and use it for web. If Unity Team can't propose all the UnityTerrain features, I can't... I have the same limit and more (is not me who have created the engine).

    Best Regards

    Stephane
    Last edited: May 10, 2012
  36. Tiles

    Tiles

    Member

    Joined:
    Feb 5, 2010
    Messages:
    2,210
    Hmm, The current situation remains a bit unsatisfying. I have a faster terrain, but slower planting.

    Fact is, with the Unity terrain i don`t have a drawcall for every tree (Mass place trees of 10.000 does not end in 10.000 more drawcalls). So how does Unity deal with trees? Is it really impossible to implement that into T4M? And wouldn`t the mobiles also benefit when the trees and grass would have less drawcalls?

    And what are the alternatives? How can i reduce the drawcalls? I haven`t had a look at it yet, but could the Bob script help here for example? What else could be done?
    Last edited by a moderator: May 11, 2012
  37. rockysam888

    rockysam888

    Member

    Joined:
    Jul 28, 2009
    Messages:
    622
    Why not ask unity team for internal working of tree?
  38. Tiles

    Tiles

    Member

    Joined:
    Feb 5, 2010
    Messages:
    2,210
    Hehe, i doubt that they will share the code for that :D
  39. rockysam888

    rockysam888

    Member

    Joined:
    Jul 28, 2009
    Messages:
    622
    No one knows the result besides Azert2k ask them. (In fact, they don't need to share code, just tell him how to reduce drawcall.):)

    Will Azert2k ask them?
    Last edited: May 11, 2012
  40. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Hi,

    Wierd to learn that the trees on UnityTerrain don't give 1 drawcall for each tree exept with dynamic or static batch like on T4M.
    Like I say before, in T4M you can use the LayerCullDistance to limit the distance of view like UnityTerrain. I will see that tonight and make some tests. And post the comparaison.

    I'm curious to know how much drawcall the UnityTerrain will give me and how many framerate I have with both on the same scene. My mission of this weekend...

    If there is something particular on the UnityTerrain to make batch for the trees, I will see how I can integrate it on the T4M, but I have a doubt at this fact.

    Keep in mind that if I make more scripts to resemble at the UnityTerrain, less you will have of performance.

    To combine trees and limit drawcall, I work on a script since last weekend, but when the transparent objects are combined, I have a lot of Z-Fighting problem, exept with Cutout shader, but it very slow on mobile.

    So, this weekend, I will make several test to compare the T4M and UnityTerrain on Android/iOS.


    EDIT :
    Please, just try both system before said you are unsatisfied.
    Already, I win more than 30 drawcall with T4M compared to UnityTerrain, I'm not a magical man to make better than the Unity Team... :confused:
    You are more limited by the UnityTerrain Than T4M for Quality/Performance.

    @RockySam : If it the case, I will ask... ;)
    Last edited: May 11, 2012
  41. Tiles

    Tiles

    Member

    Joined:
    Feb 5, 2010
    Messages:
    2,210
    That sounds great, thanks Azert2k. I look forward to what you come up with, and am really curious about the results :)

    By the way, my questions weren`t meant to nag you about missing features. I am not really unsatisfied, i am simply just learning and am curious. I`m just one of those satisfied customers that always wants even more :)

    When you cannot provide the missing functionality, then i`m fine with that. But maybe there is nevertheless a solution. Thus my question if there are other ways around.

    Hm, but what about the benefit? Less drawcalls means better performance, doesn`t it?

    Your terrain system doesn`t only get used with mobiles. I for example am using it for Windows standalone as the target platform. So what about a modular approach for such stuff where you can turn on or off what you need?
    Last edited by a moderator: May 11, 2012
  42. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Touché ! In this case (windows build), you right. Some unityterrain features can be missing. Anyway, I will do my best to find the best compromise ;)

    I keep you aware this weekend

    Edit : the benefit of less drawcall is good but a script algorytm to control all that can be very bad for performance on mobile device...

    The T4M works fine on all devices, but for PC/Mac it can be limited than unityterrain. Its normal.

    To be continue this weekend :)
    Last edited: May 11, 2012
  43. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Ok, so :

    I'm glad to say the UnityTerrain don't batch the tree like you say, each tree give 1 drawcall ! exept that the culling works InEditMode (the T4M using culling in playMode (Fixed now).

    But the difference is : when the tree is far of the camera, the tree become a billboard... So I will try to add this feature on the T4M. It's a UnityTerrain feature, so I don't know yet, if I can use it externally of Unity Terrain

    I think you must to read the documentation to learn how use the cullingDistanceLayer function in waiting I find a way (if I can) to use a part of TerrainEngine.

    Anyway, I will make some modifications on the T4M to simplify that, I need to optimize the LOD and Billboard systems. Create the shaders for Treecreator. I have a lot of work ...

    First Screenshot
    No Culling, no Billboard, Distance of view Maximum (900 vertices per tree). I have planting all trees manualy, with UnityTerrain System and T4M System (approximately the same place but exactly same number)
    To equalize approximately the vertices, I use 12100 vertices for T4M terrain.

    UnityTerrain : 290 drawcalls
    T4M : 203 drawcalls

    [​IMG]

    Same Scene but with culling at 160... UnityTerrain use a build-in TerrainEngine script for that, the T4M the LayerCulling Distance, so you can see more trees on T4M screenshot

    UnityTerrain : 113 drawcalls
    T4M : 38 drawcalls

    [​IMG]

    EDIT :

    So, you can try youself with this 4 scenes the differences of Drawcall and performances (I need to work on Update), for Billboard culling, I will try integrate that on the T4M.

    In these scenes, I use the Unlit Shader + lightmap for T4M to show how you can optimize the scene for Mobile.
    COMPARATIVE SCENES
    Last edited: May 12, 2012
  44. Tiles

    Tiles

    Member

    Joined:
    Feb 5, 2010
    Messages:
    2,210
    Thanks for diving into this issue. Every improvement is very welcome. And your terrain system is getting better and better by that. Keep it up :)

    This still confuses me a bit. Because when i mass place 10.000 trees then i don`t get 10.000 more drawcalls at the unity terrain. Does the billboards count as one drawcall then?
  45. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    In fact, after an distance (Billboard Start), the tree will become a billboard tree, just an texture, in this case the tree is batched.
    So less vertices and less drawcall.

    In my demo scene, I have deactivate this, to compare the comparable.

    Right now, I go crazy to find a way to activate it on my new shaders, and I don't know if I can, because like the wind, on classic mesh all settings haven't any effect, exept on "UnityTerrain" and "Tree" component...

    If there are one way, I will find it, otherwise, I will contact Unity Team, to know if it possible and how.

    This is a good feature for T4M.
    Last edited: May 12, 2012
  46. larsbertram1

    larsbertram1

    Member

    Joined:
    Oct 7, 2008
    Messages:
    2,383
    hi azert2k,

    just some words about trees:

    it is true that:
    a) trees placed within the terrain engine (both: tree creator trees and imported models using the the tree soft occlusion shaders) and
    b) trees created with the tree creator but placed as single game objects outside the terrain engine
    do not get batched.

    it seems that both the terrain engine and the tree creator script disable batching.
    this makes sense because the bending function of the tree shaders needs the position of each single tree in order to create some variation in bending. plus each tree has to have its own wind parameters in case you use a spherical wind zone.

    but let’s assume that we do not care about all trees bend in the same phase and we just wan’t to use directional wind then it is possible to place single game objects (not trees made with the tree creator but imported meshes using the tree creator shaders) and make them be effected by wind.
    all you have to do is to pass the wind to the shader as globalvector – somehow like this:

    Code (csharp):
    1.  
    2. var Wind : Vector4 = Vector4(0.85,0.075,0.4,0.5);
    3. function Start ()
    4. {
    5.     Shader.SetGlobalVector("_Wind", Wind);
    6. }
    7.  
    please note, that this wind has nothing to do with built in wind zones.

    those meshes can be batched!

    by the way: each tree causes 2 draw calls as it uses 2 materials: 1 for the trunk and branches, one for the leaves ;-)

    i hope that will help somehow.
    if you have further questions just let me know.

    lars
  47. Tiles

    Tiles

    Member

    Joined:
    Feb 5, 2010
    Messages:
    2,210
    That`s with selfmade trees. The Tree creator creates one material and one texture for both. Just wanted to add that :)

    Thanks for explanation. And, yes, this would be a marvellous addition. Fingers crossed that you can manage it :)
  48. azert2k

    azert2k

    Member

    Joined:
    Jan 11, 2009
    Messages:
    664
    Hi Lars,

    Thank for this, I will make some tests...

    Yes, but in my scene I use one shader for both :)

    Hard to know that I can or I can't make with all that, when nothing is written in Unity Documentation about this.

    With all ramifications between shader/Cg, I just make a node to my brain :-?
    Last edited: May 12, 2012
  49. larsbertram1

    larsbertram1

    Member

    Joined:
    Oct 7, 2008
    Messages:
    2,383
    you are right: leaves and trunk share the same texture but still have their own materials: optimized leave material and optimized bark material. hence: 2 drawcalls.

    batching "hacked trees" works pretty well and gives you a significantly lower number of draw calls unless you do not use real time shadows:

    $original_trees.jpg

    $hacked_trees.jpg

    but as you can see in the images above dynamically batching trees does not necessarily speed up rendering…

    using real time shadows reduces the safe of drawcalls dramatically:
    * 80 drawcalls for 8 original trees
    * 60 drawcalls (batched: 24) for 8 hacked trees (both in deferred rendering mode)

    lars
    Last edited: May 13, 2012
  50. Tiles

    Tiles

    Member

    Joined:
    Feb 5, 2010
    Messages:
    2,210
    I stand corrected, thanks Lars :)