Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

SplatTerrain: Color Splat Map Based Shaders

Discussion in 'Assets and Asset Store' started by chronos78, Apr 30, 2014.

  1. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154

    Description
    SplatTerrain is a suite of shaders designed to run fast while making your terrain meshes look amazing. Looking for an alternative to Unity's built in terrain system? This is the solution for you.

    Features
    • Color splat map driven texturing
    • Fast efficient (1 pass, 1 draw call)
    • Up to 4 Detail Maps
    • 1 Normal Map + up to 4 Detail Normal Maps
    • Up to 4 Detail Specular Maps
    • Lightmaps supported in all shaders
    • Realtime shadows supported when possible
    • Multi UV texturing to hide tiling patterns
    • Controllable detail / color map transition
    • Ability to boost normal map intensity
    • Ability to tune lightmap contribution
    • All shaders work with DirectX 11
    • Works on both Unity and Pro
    • Tested on Unity 3.5.7 through 4.3.4
     
    Last edited: Oct 25, 2015
  2. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Nice tool. Purchased. One question: how did you realize the terrain (obj). What tool did you use?
     
  3. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Thank you for purchasing, I'm glad you like it.

    The terrain, color, and splat maps included in the package were created with a combination of WorldMachine, Maya, Mudbox, and Photoshop. This workflow is something I learned after watching some videos on the Polycount forums located here.

    As the result of frustration with the high overhead of standard Unity terrains and I began looking for a low draw call low poly solution. One where the entire level could be constructed in an external modeller and then streamed into Unity without having to worry if everything would lined up correctly with a height map. These shaders were created as part of that research.
     
  4. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    Very nice looking shaders, I like the variety.
    One big question/wish...hardly anyone wants to release 8 texture support for splat shaders. I'd be willing to give up some of the bump maps, or have a designated bump map for slots 1-4 and a different one for slots 5-8. Any thoughts on this?
     
  5. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    If you are willing to sacrifice mobile platform support and/or some of the detail bump maps making a shader with more than 4 detail textures using two splat maps is simple. It would probably only take a few minutes for me to write such a shader. The trick will be in creating the splat maps. A single splat map itself while not trivial is fairly straight forward to create, adding a second that blends with the first to get the next four textures makes it a bit more of a challenge but should still be possible without custom tools.

    I have ideas on how it might be possible to push if even further than 8 textures. It might be possible to get 16, 32, 48, or even 64 detail texture bump maps in a single shader. The problem lies in authoring the splat maps for such a system and would require a custom splat painting tool be written. It is something that I've been toying around with and might be willing pursue further if there was enough interest in such a thing.
     
  6. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    Thanks for the consideration, it does sound like it may require significant effort.
    Aren't custom tools such as World Machine generally used anyway? I'm curious as to what is involved in creating multiple splat maps with it, as in is it much more effort to 8 texture splats (2 total) as opposed to 1 splat. I haven't done that yet, so I'm not really sure.
    Also, seeing as how the global color map is separate from the textures generated by the splats (though they are blended in the final result), isn't it really a matter of 4, 8 or more splat based textures blended with a single global color map?

    Thanks for any clarification on this, always eager to learn more about this subject :)
     
  7. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Think you might have misunderstood. For up to 8 textures it is fairly easy to do. Modifying the shader would only take a few minutes of work. And if you know your way around WorldMachine creating a network that is able to export two splats isn't difficult. Getting it to look just the way you want may take a bit of effort though. However if you plan to hand paint the splat maps in Mudbox, Phototshop, or whatever other program, wrangling all the different channels might be a headache. Even so it would not require any custom written tools.

    When speaking of a custom tool I was referring to the idea of having many more than 8 detail maps. What I've in mind might allow as many as 64 different detail textures to be blended together using atlases of tileable textures. Because of the way the splats would need to be encoded to index all those different possible textures a custom Unity tool that would allow you to paint the splat maps by hand would be needed.
     
  8. i9mobile

    i9mobile

    Joined:
    Aug 8, 2013
    Posts:
    54
    Hi, I'm very interested on your shader... it's sounds promising.
    Can you modify it to a Multi-colored splat map? Then we can fill a lot of textures with only one splat map....
     
  9. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Hey i9mobile thanks for your interest. The splat map is broken up by channels RGBA so it technically is a multi colored map since those channels combine to produce all colors from black to white. The advantage to doing this is that you can then have smooth blending between 4 different detail maps.

    The solution I believe you are thinking of is to have various preassigned colors index to a bank of textures. This is completely possible and would allow you to have more than 4 detail maps. In fact you could have as many textures as allowed by the shader model or probably more likely the amount of data you are able to encode with Unity's shader system.

    There are several reasons why this might not be a good choice though. First is that by indexing your colors you lose the ability to control the blending between two different detail maps as it would either have to be on or off base on the color of the pixel. The next major problem is that your shader would than have to handle a ton of branching at a pixel level to determine which detail map is to be used and on shaders where performance is critical this is never a good thing. Another problem is that the more texture lookups you have the slower things get. Not so much of an issue on desktop computers but for mobiles this could be a show stopper. Even 5 or 6 lookups on an iPhone 4 in a single shader is pushing the upper limit.

    Can I modify it to be as a true multicolor splat shader? Yes, not trying to be smart here but I wouldn't. There are other things that I've been playing around with for future releases that may increase the number of detail maps but those make more use of multi-pass shaders and masking similar to UE4 or CryEngine since I consider the ability to have fine control between detail maps of utmost importance.

    Could you modify it? Depending on your shader writing ability possibly. Everything is there in the suite to do so. The shaders are broken up to be as modular as possible so someone with the know how could take the existing code and modify or extent it anyway the wanted to. I've tried to name everything as verbosely as possible and break things into single tasks so even with a little know how and some time a novice could break it apart and figure out what is going on. If you are already familiar with shader writing I'd estimate it'd probably take less than an hour to modify it to do what you're looking for.
     
  10. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Unity 5 if here, Yay!

    Great news unless you have assets that are broken because of the changes that are part of the new version. Unfortunately SplatTerrain is one of those. The new lighting models that are now part of Unity 5 has caused a lot of issues with the SplatTerrain shader suite and I'm currently in the process of trying to update the shaders to work with this new version. Which is proving to be quite difficult. The problem is mainly two fold. The first being that there is absolutely no documentation on how to access any of the new features via vertex and fragment programs yet. The second being in order to access the new features the shaders currently have to be rewritten as surface shaders.

    Moving to surface shaders hasn't been too difficult in of itself but it has reintroduced several issues that prompted me to write vertex / fragment shaders to begin with. Issues like performance, texture limits, register limits, etc. For example, what the previous shaders could do in shader model 3 now requires shader model 4 and you still lose one of the bump maps, the cliff bump in this instance. Another example is to make a shader model 3 shader I will have to either drop one of the four detail maps or all detail maps will have to use the same tiling. All because of the addition overhead that is introduced by how surface shaders work.

    So what does this mean for the future of SplatTerrain? Well in the short term it will mean that the new Unity 5 shaders when released will be surface shader based. Which means to get most of the functionality as the previous full shader you will need a shader model 4 video card and DirectX 11. No mobile devices currently that I know can handle shader model 4. I am currently working on cut down versions of the shaders that will still run on mobile devices but it will mean that they will most likely not be able to make use of Unity's new GI, ambient lighting, real time shadows, and possibly lightmaps all together.

    Another issue I'm battling with is on how to handle the creation of this new suite of shaders. And a whole new suite is exactly what this is turning into as I still want to have shaders that run on all versions of Unity 3.5 and 4. Since these new shaders won't work on previous versions of Unity there will have to be a way to keep them separate to limit confusion on which shaders to use and without breaking existing projects using SplatTerrain. The next issues are what shaders are needed? Do I still need shader model 2.0 shaders or is 3.0 good enough? What feature do I include or drop in each shader? Lots of questions that still need to be worked through and I ask for your patience as SplatTerrain goes through this period of change.

    Time to break up the wall of text with a screen shot of the new Unity 5 shader in action.



    This is the current full shader. As you can see it's using the new lighting features available in Unity 5 including dynamic GI and the new ambient lighting system. The rest of the new shaders will be stripped down versions of this one to fit the various shader models and platforms where applicable.

    Long term plans for SplatTerrain on Unity 5 is to continue to tweak the shaders and increase their performance. I would also like to once again move back to vertex / fragment shaders once documentation becomes available so that I can leverage all available performance, textures, and registers without the overhead brought by surface shaders. I also plan on incorporated all the requests that you guys make where possible. I've received a lot of good feed back and suggestions up till now and hope to in the future.

    Look for a new update with at least some Unity 5 functionality in the next week or so and more updates soon to follow after.

    Thanks again to all you who have purchased and are using SplatTerrain.

    P.S.

    If you've purchased SplatTerrain already and would like to try out the Unity 5 shaders in development before they are available on the asset store PM or email me with your invoice number and I'll send you a copy of what I currently have working. This offer will only be available until the first release of SplatTerrain with Unity 5 support goes live on the asset store.
     
  11. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    A new update will be submitted by the end of the day tomorrow that fixes a couple of bugs and adds some new features. The main new feature being is to once again be able to have gloss(spec) maps in the alpha channels of the detail textures. The other features are to improve the blending between the base color map and the detail maps.

    Here are some screenshots that I made while working on the update. This time I went with a more photo realistic look since it seemed that more than a few people were under the impression that these shaders could only produce stylized results.




    Here is a screenshot to show off the gloss maps in action.
     
    Last edited: Apr 3, 2015
  12. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    could you explain your workflow to create those maps?
     
  13. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    The terrains used in the my last post weren't created by me but provided to help tune my shaders. The arctic terrain can be found here and the desert one I've been told should be available soon.

    I did tweak the included textures and created my own where needed to get the visual look I was after so what you see in my post won't look the same as the Cerberus's asset but it is the same terrain.

    I do create my own terrains as well and the process I use is explained in the 3rd post of this thread along with a link to videos that got me started.
     
  14. Tiny-Tree

    Tiny-Tree

    Joined:
    Dec 26, 2012
    Posts:
    1,314
    if i have a splatmap ( raw image from geocontrol ) what is the simplest way to generate a low poly terrain ? we have to use mesh and not unity terrains?
     
  15. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    I've never used GeoControl before but if it is like every other terrain generator out there you should be able to either export an obj mesh file or a height map. If you're working with a height map than you can used most modeling software to generate a mesh from the height map. Personally I prefer Mudbox for this step. Then you'll need to reduce the triangle count to something game friendly, ZBrush is my go to tool for this.

    The process I use is a bit tedious with a lot of jumping between apps but the results are far superior to anything you can build with Unity's built in system in my opinion. To answer your last question these shaders do not work with Unity's built in terrain you wil have to create meshes.
     
  16. psycocrusher

    psycocrusher

    Joined:
    Jul 24, 2011
    Posts:
    71
    The simplest way is to export from geocontrol the height map a (tif 16), then in mudbox create a plane and subdivide it to how many polygons you want, then go to Uvs & Maps --> Sculpt using map ---> New operations.

    Or you can export directly in Obj from geocontrol, but you have way less control for extracting maps like Normals, ambient occlusion etc..
     
    Tiny-Tree likes this.
  17. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Since all the shaders had to be rewritten from scratch for the Unity 5 release, figured why stop there? So the demo scene is getting a makeover too. Here is a preview of the new scene that will be included with the next update of SpatTerrain. The textures haven't been finalized yet so those may change between now and release but this is pretty much the way it should look. Oh and this terrain is one of mine so you'll be free to use it in your own projects if you want. Hope you guys approve.


     
  18. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    This latest version has been submitted to the asset store for review. Here's a screenshot of the new demo scene as included with this update.

    The base color, normal, and splat maps have been re-rendered at 8k and the new details textures are 2k. The detail textures also include matching normal and gloss maps. Enjoy, I'll make another post when it gets approved.
     
  19. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,291
    I am not sure what this is.
    Will this create its own terrain inside unity with a special shader/map type that control the amount of polygons?
    Or can i import obj or fbx objects from thirdparty 3D apps?
    If so, do the objects have to be square?
    Can they have holes inside them and/or overhangs?
    Can i use more then one in a scene?
    If so can i use different maps on each of them?
    Also how will they look if i use more then one on the connecting sides?
    Can i rotate them for example use one as a bottom and one as a top of i big cave?
    Can i use them on top of each other meaning one bigger ground and then 3D models as clifs and on top of the clifs a second, shorter one of your terrains as the top of the hill with other textures?
     
  20. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    For those who don't know yet the latest version just went live.

    SplatTerrain is simply a suite of shaders designed to take a selection detail textures, normal & spec maps and apply them to a mesh based on a splat map and tinted with a color map. What sets this asset apart is the amount of control afforded in the shader and the simplicity of use as all control is in the shader itself and requires no pre-processing be done in the editor, just provide the needed textures and you're off.

    No these are just shaders to be applied to a material that is in turn applied to a mesh you provide.

    These shaders were explicitly designed to be applied to objects that you provide in any format that Unity can import. But they do not work with Unity's built in terrain system.

    The objects do not have to be square. They can be any shape you want. In fact they don't even have to be terrain objects.

    Yes and yes. There is no limitation to the shape of the mesh. As long as you properly layout the uv's and paint your color and splat maps correctly any shape is possible.

    Yes, the arctic and desert screenshot feature terrains that are made up of 16 separate meshes and the new demo scene included with the asset is made up of nine separate meshes.

    You can use a separate material and set of textures for each mesh or you could use a single material for multiple meshes. They choice is up to you and how you would like to setup your workflow. There is some more work involve using multiple materials to ensure that the base maps align at the boundaries if you want them to be seamless, but that is to be expected.

    See for yourself. all the screenshots of the arctic, desert, and new highlands demo scene are made with meshes that connect on more than one side. You just have to make sure that your meshes vertices, normals, and uv's all aligned where ever they meet another mesh.

    Orientation does not matter to these shaders. You can put your meshes in whatever configuration you desire. The success will depend on how successfully you layout you're uv's and paint your maps.

    Again any configuration goes as long as you're maps are painted correctly it should work. The only limitations are that transparency is not supported so you can't blend between different meshes and if the faces of two or more of your meshes are to close together you may have problems with Z order fighting at further distances. But that is an issue you have to deal with any geometry in any scene and is not an issue specifically related to this asset.

    I hope this answers your questions. If you need me to clarify any of the points just let me know.
     
  21. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,291
    Thank you for all the great information :)
    I only now have two things that i want to know.

    At first, how do i have to layout the uv´s of a hill so it look more streched like in the first picture and the demo video or the other way so it look more like in the dessert picture where it look like there is plenty of detail on the hill sides.

    The second thing is can i use these kind of landscapes as a real terrain alternative with a good collider solution or do i just have to use meshcollider what will double the vertex counting?
     
  22. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    You're welcome.

    The stretched textures in the first image were achieved by using the original color and splat maps directly from World Machine on a terrain that had the uv's projected from above the terrain mesh. Because the terrain in the desert picture was provided I don't know how Cerberus laid out their uv's. In my highland demo that also doesn't have stretching, the way I did it was to project the uv's from above similar to the first image but then used Maya's uv tools to relax the uv's and then used Mudbox to project the color and splat maps to the new uv's thus eliminating any stretching. Both option are viable with the first yielding a more stylized look and the second a more realistic one.

    Personally I just set the terrain mesh as the collider mesh and leave it at that. Though I do only active the collider for the mesh my character is actually standing on. There are lots of ways you could do it, the choice is again up to you. It would even be possible to divide each terrain mesh into many sub meshes to be used solely for the purpose of collision checking and only activate those that are in play at any given to to increase performance. Another option is to have several lod's for each terrain mesh and use lower levels for collision depending on how accurate the collision checking needs to be at that location.

    Just for fun I decide to do an apple to apple comparison of Unity's terrain system to the way I do terrains. To be fair I'm not an expert on using Unity terrain and I didn't spend a lot of time cleaning up the generated terrain. I just set the basic settings and imported the largest height map Unity allows. I did though try to get Unity's terrain to output at the highest resolution possible Here are the results.

    First Unity's built-in terrain.

    and mine


    It's pretty obvious which looks better. Now for some numbers.

    Unity:
    Batches = 1535
    Triangles = 779.2k
    Vertices = 448.4k
    SetPass Calls = 3

    Mine:
    Batches = 10
    Triangles = 425.9k
    Vertices = 222.9k
    SetPass Calls = 2

    And it's no contests which technique is more efficient.

    Like I said though I'm not a Unity terrain expert and I've seen some fantastic work done with it. Could I have made it look better? Yes, but it would've increased the poly count into the millions to do so. Unity's strong point is that everything is built into the editor and my workflow requires working with several external software packages to pull off. It's my opinion though that gamers don't care how easy it was for the developer to create something as long as it looks good and runs fast. Not that it is painfully slow to create terrains with my workflow. I textured both the arctic and desert scenes and created the highlands terrain and textures from scratch over the course of 3 or 4 days and that was while rewriting and tuning the terrain shaders. So once you get the workflow nailed down it is pretty easy to crank out awesome looking terrains.
     
    Last edited: Apr 10, 2015
  23. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,291
    Great infos again.
    I already bought this nice asset and now will test some things.
    Do you know if the shaders can or will support PBR in the future?
    Do you plan also to make some shaders for grass and foliage?
     
  24. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Thanks for purchasing SplatTerrain.

    The shaders have already been updated to support Unity 5's new lighting features and use the standard specular lighting as the base for all the non mobile versions of the shaders. So PBR is already supported by default. There are no plans to make grass or foliage shaders at this time since there are already several available on the asset store.
     
  25. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,291
    Ok, i think i have one bought a while ago wich i can try.
    But today i have another question.
    Is there a way how i can find out on wich texture i am at the moment as a player character for foot sounds and decals like on normal landscape? At least i have one asset for this to that can find it out on a normal unity terrain.
     
  26. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    SplatTerrain is just a suite of shaders they have no functionality apart from controlling how things look on the screen. That being said you could use ray casting and query RaycastHit.textureCoord to determine where in the splat map the player is located and then extrapolate which of the textures is most prevalent at that location. The documentation for using RaycastHit.textureCoord can be found here.

    Keep in mind that by using your own meshes to replace Unity's terrain system means that any add ons or functionality that require Unity terrains will not work. It also means that you are also responsible for duplicating any needed functionality that is part of what Unity provides with their terrain system. It is a bit of a pain but I find that the final look and performance benefits are well worth the effort.
     
  27. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,291
    Oh, thank you for the link.
    At least it can be a solution and maybe i can mix it together with the one i have here for the unity terrain.
     
  28. RandAlThor

    RandAlThor

    Joined:
    Dec 2, 2007
    Posts:
    1,291
    Just try to test it on my Mac and there i only can see a big bluish unlit terrain.
    Maybe the mac is to slow for the scene.
    But noticed that you realy used some big textures pixelwise.
     
  29. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Make sure you aren't using the Full_SM4 shader which requires DirectX 11 and won't work on a Mac. There are 7 shaders included, each with different features removed so you can select the one that runs best on your platform. The full and detail shaders are the most performance hungry of the bunch while the bump and diffuse are less so and the mobile version even less.

    I included the color, base normal and splat maps at the highest resolution Unity supports which is 8k and the detail textures at 2k in case people wanted them. It doesn't mean you have to use them at those resolutions. In fact unless you are planning on only running on high end desktops you shouldn't use them as is. The good thing is that Unity makes it trivial to adjust the resolutions to whatever you need non destructively. Just click on a textures and select a smaller resolution and hit apply.
     
  30. SpencerPDX

    SpencerPDX

    Joined:
    Jan 3, 2012
    Posts:
    168
    Hello! I've purchased SplatTerrain and am really enjoying it.

    We're working on a mobile project, and have been using SplatTerrain for a cartoony field of flowers, using the mobile shader of course. Now the way it seems to work with that one is that the base texture and the detail texture (which has the flowers painted into it) are both pretty much always visible at the same time - they appear to be blended like Photoshop layers where one is set to a lower opacity. This means the green grass of the base texture dulls the flowers somewhat. As opposed to what I saw in your YouTube video where - with the higher-end shaders - the detail texture fades out at a certain distance and the base texture fades in; in that case they're not overlapping each other much. So with the mobile shader, is there any way around this? Any way to fade out the influence of the base texture up close? Just hoping to keep those flowers as bright as possible. :)

    Apologies if I've missed the documentation that covers this - I've mostly read/scanned this thread, and watched the video but I could have missed something. (Partly because I'm in a hurry with a deadline looming.)

    Thanks!
     
  31. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Hey Spencer,

    Thanks for purchasing. You didn't miss anything. The mobile shaders have been stripped down to make them as fast as possible. If you can email at info@cygengames.com with your invoice number and which of the three mobile shaders you are using I'll put together and send you a version that includes the distance fading feature. It will run a little slower than the existing ones obviously but it will give you the effect you are trying to get.

    Later
     
    SpencerPDX likes this.
  32. AdamGoodrich

    AdamGoodrich

    Joined:
    Feb 12, 2013
    Posts:
    3,777
    Hi this looks awesome - well done! :)

    I do have a question though - there is a lot more to a nice game environment than a terrain, and I am specifically interested in creating lush environments with trees, bushes & grass.

    My understanding is that unity terrain does a lot of work to minimise their impact on performance - if you were to then add the same level of trees and grass to a mesh as in your example - for example a few thousand or so SpeedTree's, how does the performance compare then ?



    Here is an example of mine done with standard Unity terrain. I am curious as to how your numbers stack up then - again with reference to a mesh - i would imagine the terrain numbers would be pretty similar.

    And if they are good, then how do you do it so as kill it performance ?

    Thanks,
    Adam.
     
    Last edited: Apr 23, 2015
  33. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Hey Adam,

    You bring up a good point and you are absolutely correct that there is more to a nice game environment than just the terrain. That being said while you can take an average terrain and make it look great with foliage imagine what you can do when you start with an terrain that looks great before you start adding the foliage.

    Yes, Unity does a lot of work trying to optimize grass and trees, though from reading the forums and playing with their terrain system it seems like they have a very long way to go. Especially with all the problems with the new SpeedTree implementation causing LOD popping and killing performance. Besides if it were perfect they wouldn't be in the process of building an entirely new terrain system. It's been known for a long time that Unity's terrain system is one of the weakest of the major game engines and is in serious need of some love.

    Still this is an area where Unity does have an all-in-one solution where SplatTerrain does not. In fact SplatTerrain isn't even a terrain system. It is simply a set of splat map base shaders, technically they don't even have to be used on terrains.

    As far as numbers are concerned I'd like to point out that my numbers are from comparing just the terrain meshes. So even after adding in all the grass and trees the numbers will still be the same because adding grass and trees will not magically reduce the poly count of Unity's terrains.

    You were wondering how I deal with grass, bushes, and trees so not to kill performance? The answer to that is with a lot of old school tricks. First off no SpeedTree. Everything is modeled and placed in Maya and then scripts are used to instantiate trees and control their LODs. I make liberal use of object pools so instead of hundreds or thousands of trees I only have a dozen or so that are reused depending on the camera angle. The same goes for grass and bushes or any set piece really. Since the game I make are usually top-down and not FPS this works really well for me. Also animations for my foliage are shader base via vertex color painting or vertex world position depending on the look I'm after.

    A lot of these are tricks are only possible because I'm equally comfortable writing custom functionality into scripts and/or shaders and I'm also able to create my own assets to work exactly as needed for my production pipeline This may not be feasible for everyone. In that case there are some really good plugins on the asset store to handle grass and trees that could used instead.

    I guess what I'm trying to say with this really long post is that there are other ways to handle terrain in Unity besides their built in system and that SplatTerrain in itself is not that replacement. It is simply a part of a possible solution if one wishes to implement their own alternative.

    Really like the look of your scene. One critique I would offer is that your trees are too equally spaced across the terrain. In nature they tend to clump up more. With a few trees clumped together with spaces in between the different clumpings. Check this link out for a better description.
     
  34. AdamGoodrich

    AdamGoodrich

    Joined:
    Feb 12, 2013
    Posts:
    3,777
    Hi Chonos,

    Thanks for the response :)

    I really like your asset btw - and was curious about how you handled things. As with all problems - its about choosing the right tool for the job.

    Thanks for the link too - I have been working on my own procedural vegetation placement tools and have experimented with a whole range of techniques. Totally agree on the point you made re placement. Nature is a sort of gorgeous directed rules based but semi random thing - having a lot of fun with it.

    Cheers,
    Adam.
     
  35. SpencerPDX

    SpencerPDX

    Joined:
    Jan 3, 2012
    Posts:
    168
    Just wanted to say thanks for the detailed and thorough replies via email! Very helpful.

    -Spencer

     
  36. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Just bought. Fun shader! wondered if any updates are in mind regarding things like POM, or just overall better shading as currently things get a bit too shiny in a uniform way. It's nice but still stylised.
     
  37. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Hi,

    What is the best way to use these shaders with a procedural terrain (or planet)?
     
  38. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    POM's might be out of the question for awhile since these shaders are using every bit of the available resources as it is while still being a single pass shader. But there are more updates in the works, including the ability to use vertex colors instead of a splat map to specify detail texture blending and another mobile variant that includes depth fading. Once I get the multipass version of my shaders working I might take a look at POM's.

    The too shiny problem can be fixed by adjusting the gloss slider and adjusting the specular color. The uniform shininess is caused most likely not having gloss maps in the alpha channels of both the color and detail maps which are needed to breakup the spec. Without them you end up with a very fake looking scene as you noted. But with them can can get fairly realistic looking scenes as can be seen in my previous screenshots. If that doesn't fixed the problem let me know and I'll do what I can to help you sort it out.

    To use these shaders for procedural terrains will require you to be able to bake out color, splat and possibly a normal maps for each terrain mesh you generate. Trying to do this in realtime will be a technical challenge. Soon I'll be releasing an update that includes the ability to use vertex colors instead of splat maps which was a feature requested by a customer who is trying to generate terrains in realtime.
     
    Last edited: Apr 30, 2015
  39. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Vert colour one will be VERY welcome! we already have robust vert col painting in our game development setup! In this case, we would probably not restrict the shader to just terrain.

    Don't forget you can ubershader ie conditionally compile shaders to cut down on any complexity ie unused slots get optimised out :)

    Another nice to have would just be vertex blend 4 textures (Unity's standard shader) without the other stuff so we can better blend rocks in with terrain or do the inside of caves in interesting ways, all sorts really. It's just useful extra that's not extra work at that point?
     
  40. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    There are still a few things to work out with the vertex color feature. Part of which has to deal with your 2nd statement, but it should be included in the next update. And as you notice these shader aren't restricted to just using on terrains, just disable the cliff texture feature and you're good to go.

    I still have mixed feelings about uber shaders. I've done some initial experiments but finding good documentation and / or tutorials is almost impossible. Lot of stuff about the concept but very little on how to do it. So it's taken me awhile to figure out how to get shader features and custom material inspectors to play nice. The premise of uber shaders is awesome but the main issue I have so far is that it seems they must still be functional when all options are enabled and don't have the ability to prevent the shader from enabling too many features that would break it, that will have to be done via a custom material inspector. The problem is that SplatTerrain shaders are right up against the upper limit of interpreters and samplers most of the time, to the point of adding just one more feature will break that variant. I've done my best to compartmentalize the features so they can be enabled using #defines on a variant by variant basis. This was done because uber shaders didn't exist back in Unity 3 days when SplatTerrain first came to be and it means that each variant only uses what it needs so no wasted resources. The exception are the mobile shaders which are are unrolled and optimized for pure performance.

    The thing I'm playing with now that Unity 5 is out and development on the older shaders has come to an end is to utilize custom material inspectors to control the compile path of the shader. Before switching to a single uber shader or two I want to make sure that there is absolutely no way the end user can break the shader simply by enabling a feature.

    This one is easy to do now that SplatTerrain has been switched over to use the new standard specular lighting model. Should probably make a variant for the standard metallic model too (or uber shader). I'll add it to the roadmap as a to do once the custom inspector and uber shader stuff is working.

    Some of the stuff on the roadmap:
    - Vertex color driven detail maps (next update)
    - Depth faded mobile shader (next update)
    - Custom material inspector (maybe next update)
    - Uber shader if possible (depends on custom inspector)
    - Multipass variant to allow for even more maps and features
    - Distance fog / ambient perspective
    - Parallax occlusion maps (depends on multipass)
     
    Last edited: Apr 30, 2015
  41. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Awesome!
     
  42. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Nice. Thanks.
     
  43. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It also saves a texture read, which saves on bandwidth (particularly important on consoles)
     
  44. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Perhaps a mild bug:
    bad.png

    How it should look:
    good.png

    This is using your demo scene terrain which a character's shadows cast from sunrise at horizon for effect. Essentially the problem goes away if there is no reflection probe which hints that there's perhaps incorrect blending of shadows? I use DX11/Deferred/Linear/HDR if that's any help.

    Edit: It might not be your fault, since if I blend probes AND skybox for your meshes, it correctly blends again. But worth sharing this data with you anyway.
     
  45. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Hey Hippocoder,

    All lighting and shadows are handle directly by Unity's lighting models so any errors in the shadows is on their side and beyond my control. There are occasionally some normal issues that are the result of the way the shaders try to composite normals from 5 different sources. I've tried to minimize those to the best of my ability. One thing to make sure if you run into these is that the splat map channels do not sum to zero if you are using detail maps which will result in lighting errors due to the normals all being zero because of the way they are calculated.

    Another thing to watch out for I've found is that Unity's real time GI and shadows break in editor when zooming way out. But that maybe because of the stupidly long shadow distances I was playing with at the time. :) Which may be related to the issue you are seeing.
     
  46. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Thanks for reply! btw if you were considering something insane like POM, you could have a mode where height is stored in each pixel albedo alpha which would probably work fine in 2 ways:

    1. POM height - but pom would also need a distance fade effect otherwise when switching to a lower lod tile (we lod each chunk spit out from WM) it would look wrong, so if you do POM I respectfully ask you look at having a fade out value :)

    2. optionally can reuse height for - bit like dissolve I guess?

    2015-05-03_10h21_19.png 2015-05-03_10h20_42.png 2015-05-03_10h21_01.png


    Just suggestions of course!
     
  47. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    If I ever get POM working it will definitely have a distance fade like there is for the color / detail now. It will most likely have a separate set of sliders since it should fade out a lot closer to the camera than the detail maps do.

    I like this idea. I'm guessing the best option is to stack 4 height maps in the 4 channels of another texture since all the channels are already being used in the detail maps. Though this will present an issue with being able to independently tile things though so I will have to think about this more when / if it ever gets implemented. It will also be a challenge on how to blend with more than just two layers like images you posted. The results definitely merit some experimentation so I'll add to the roadmap as something to play around with.

    Unfortunately SplatTerrain development is going to slow down for the next two months as my boss at my real job goes out on a leave of absence and I have to pick up their responsibilities. I'll still be tinkering with it but only when I have some free time.
     
  48. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    That's fine - I look forward to updates when you get the time :)
     
  49. radimoto

    radimoto

    Joined:
    Aug 23, 2012
    Posts:
    257
    I purchased this Shader today, it is really nice getting great results pretty quickly. Love the Multi UV Blend which really helps to break up any tiling.

    I have a few questions about "Cliff Tex" - hopefully this screen capture will help to show what I'm seeing...



    #1 - I've noticed is that the Cliff Tex tiling has no effect, it looks as though this can only be achieved through the Multi UV Scale? Not sure how possible this is but it would be nice to have an option for Triplanar projection for cliffs. I'm experimenting with an optimised mesh and the only real issue I can see is that the Cliff Tex is stretching. I can't adjust the tiling of the Cliff Tex directly, and adjusting it within Multi UV Scale scales both the height and width so I can't really fix the problem.

    #2 and #3 - I have the Cliff Threshold set the maximum of 0.99, however the Cliff Tex is being projected out onto the ground. The ground is completely flat at these points.

    #4 - How does Cliff Threshold work exactly? I wonder if it would be possible to add an option to adjust the falloff, as I notice the texture still displaying on the top of the mesh which isn't really part of the "cliff" face. It would be nice to have access to a curve to adjust how it falls off. This might allow the cliff texture to be kept only to the vertical cliff face itself.

    Overall I'm really happy these Shaders have a lot of options without being overly complicated, and solve a number of problems nicely.
     
  50. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Thanks for the purchase radimote, it is very much appreciated.

    Due to changes in the way shaders work in Unity 5 and the desire to keep the SplatTerrain shaders down to a single pass using the lowest possible shader model some features had to be stripped out or combined. The ability to individually tile the detail and cliff textures is one such feature. The full SM4 variant is the only version that still retains the ability to independently tile the detail and cliff textures. Triplanar projection is not possible in these shaders for the above mentioned reason. Because these shaders are using every possible resource available, without using multipass shaders or pushing everything to shader model 4 there is no room to add anything to these shaders without having to take something else away in exchange. Not to mention that using shader model 4 would break any possibility to run these shaders on mobile platforms. At least until mobile devices are capable of shader model 4. I am working on a multipass variants that will allow additional features as well as restore the functionality that was available prior to Unity 5 but it is unknown at this time if the will run on mobile devices or when they will be ready. If your are targeting a desktop platform than just use the full sm4 variant which has the functionality that you are looking for.

    I'm trying to look into now but I just noticed that Unity 5.1 has yet again changed something fundamental to the way shaders work. A technique that I relied on to bypass the limitations of samplers imposed with Unity 5's new shader system seems to have been modified to the point that it is now very brittle and any change I make is breaking every shader compile. Unfortunately this means for the time being SplatTerrain is going to be stuck in this condition until I have time to figure out how to fix it.

    Right now the cliff texture is calculated by taking the dot product of the vertex normal and world up, then inverted, clipped by the cliff threshold, and finally remapped to the 0 to 1 space. Prior to Unity 5 there was a falloff adjustment but this removed to reduce shader instructions. Adding a curve is not possible as it is not possible to pass curves into Unity shaders. Adding a falloff value would be possible but as mentioned above until I can resolve the issues caused by the latest release of Unity I'm not sure when that will be.


    Okay rant time, if you don't want to listen to me vent skip the next couple paragraphs.

    I understand the need to constantly push their product to new levels and this is a good thing, but what I don't get is Unity's apparent lack of disregard for developers whose assets and projects they break. It is one thing to deprecate features but to change things with very little to no documentation is infuriating. The changes to Unity 5 forced a complete rewrite of SplatTerrain shader code. The effort involved means that if by some miracle my average monthly revenue never changes it will take 8 years to recoup the cost of development and that doesn't include all the time assisting you my customers. Not to mention that sales never recouped the cost of developing SplatTerrain the first time around. Nor does that take into consideration and changes that Unity makes in the future.

    SplatTerrain was and is a labor of love. It came about from a personal project that I thought others might like and find it useful. It was never about making me rich which is good because it hasn't. Unfortunately I can't allow it to become a time sinkhole just because Unity keeps making changes that breaks it every few months. I understand people paid money for SplatTerrain and to them I am very grateful and I will continue to do my best to keep SplatTerrain working for the time being. If possible I'll try to resolve the newly found issues as well as some of the outstanding in the next update. That being said development on this project is currently very slow as my time has to be spent earning a living to provide for my family. I will continue to work on it as time permits. However there is a chance that if SplatTerrain gets broken to the point that another complete rewrite is needed that development will be halted all together and the product will be held at whatever the current version of Unity is at that time.

    Rant off.

    Again thanks to everyone whose purchased SplatTerrain and as everyone who has contacted me for supports knows I really do try my best to make sure SplatTerrain is the best product I can make it and I hope to continue to do so.