Search Unity

ats Colormap terrain shader [RELEASED]

Discussion in 'Assets and Asset Store' started by larsbertram1, Aug 9, 2012.

  1. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    No the screen is in Unity, its obvious isnt it:D? But the terrain was created in WM, basically heightmap and all other texture maps.
     
  2. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Hello Lars,

    I'm using your multi terrain color map shader now. And the results I get are really great. Here are two screenshots of the Island I made with Terrain Composer using 4x2k terrain. Could you also build in specular in the multi terrain version of your shader?



     
    Last edited: Oct 7, 2012
  3. l0cke

    l0cke

    Joined:
    Apr 15, 2012
    Posts:
    438
    Sorry, I meant WM.
     
  4. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Don't mind me asking but what's that program you rendering the terrain in? That "EsqClient"?
     
  5. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Ups gonna reply and correct myself, seems like screen is from EsqClient. I am wondering now too, havent noticed anywhere about this software, is it similar to Terragen?
     
  6. larsbertram1

    larsbertram1

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

    your pictures look nice – although i am not sure whether the lighting is correct. somehow it is a pretty weird.
    as far as specular lighting and multi terrains is concerned: i am not sure when it will come as right now i am working on an enhanced version of the colormap shader supporting 6 or even 8 detailmaps within a single shader pass.
    multi terrain setup will get much easier in unity 4 i guess, so may be this won’t come before the official release. but we will see.

    lars
     
  7. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Hello Lars,

    Yes in Unity4 you have a material for the terrain shader, it's must be much easier to pass the color/normal map to the shader. As for the lighting, I understand what you mean. It looks very realistic and big scale when you go through it with the camera. But from a distance it looks not 100% correct. I'm using real world low resolution heightmap data, this causes too many ridges, currently I'm working on stitching terrains together and building in a smooth/lerp option for the heightmap to reduce the ridges you get with low detail heightmap.

    It might also be caused by the 4th detail texture, I removed it now and it looks better. Have to take a more detailed look at your shader, I activated lines 90/96/120/121 before, but it give an error on line 96, I figured that splat4 should be splat3. And a little bit confusing how to set the 4th color as I might have not done it correctly. Is it an option to build in the 4th color in the alpha channel of the 3 other colors? (red channel on alpha color1, green on alpha color2, and blue on alpha color3).

     
    Last edited: Oct 7, 2012
  8. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    shadows/lighting
    at close distances the shader only takes the geometry + the detail normal maps into account, so your lighting looks ok.
    at far viewing distances the shader also looks up the overall terrain normal map. as your lighting looks a bit weird at far distances may be your terrain normal map is corrupt (e.g. not marked as normal map in the import settings or may be even flipped? have a look at the base textures from the original package: the heightmap has to be flipped vertically to make it fit the color map and terrain normal map! have a look at the second picture attached)

    4th detail texture
    it might be a bit complicated to add a fourth detail texture as the sum of r+g+b+a of the splatmap always has to be 1.0 which does not fit the way e.g. photoshop handles the different channels: the alpha channel usually is treated completely independently which might lead to overbrightened texturing of the terrain. so make sure that r+g+b+a = 1.0 at every pixel!

    next to that there seem to be some heavy tiling artifacts – either inyour detail maps or some starnge "lines" in the color map.
    have a look at the picture attached.

    lars

    $ats_correct.jpg


    correct orientation of the maps:

    $map_orientation.jpg
     
    Last edited: Oct 7, 2012
  9. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Lars one question, i dont know if you noticed but there is tool called Terrain mesh blending, what it does is it blends any mesh placed on terrain with terrain textures and (not sure) terrain mesh itself. Do you think that it is compatible with your shader i am just asking becouse i wouldnt like to spend 100$ on something that wouldnt work with your shader.
     
  10. larsbertram1

    larsbertram1

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

    as far as i know they have their own shaders for the terrain (bumped diffuse i guess) and for the meshes.
    but in case the mesh shader comes as surface shader it should not be that big problem to make it fit the color map terrain shader’s needs.
    i would ask those people for further details.

    lars
     
  11. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Ok thanks i will ask them before i plan to make purchase.
     
  12. Knightmore

    Knightmore

    Joined:
    May 11, 2012
    Posts:
    227
    You can ask them a lot but they won't answer. I mailed and asked them the same 4-5 days ago and i'm still waiting.
     
  13. l0cke

    l0cke

    Joined:
    Apr 15, 2012
    Posts:
    438
    Unigine.
     
  14. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Hello Lars,

    Thank you very much for your help. As for the far distance it was caused by incorrect normal maps. I generated the normal maps with TC based on the normals of the terrain after making the heightmap more detailed with TC. But I had to tweak it a little to get the right RGB output, hopefully it's right now. On flat surface I use RGB (128,128,255), which is normal.x = 0, y = 1, and z = 0. I have x and z axis on RG channel and y axis on the B channel (which is inverted). I also build in a function to smoothen the terrain, as that is the cause of the artifacts, and those are then generated in the colormap as I use degree of terrain as one of the rules to pick a color (It can be a nice effect but not too much and everywhere), you can see it in the first heightmap picture and the other 3 pictures is the result of more smoothing. I'm making that you can use a RGB channel from a picture to smoothen the terrain with different strength based on pixel color.

    I'm generating the colormap and splatmap with Terrain Composer, so I don't need to make splatmap textures in photoshop. So the alpha channel would be no problem. TC can convert/blend any color on any channel to any output. For example you can use 1 RGB texture for the first 3 splats and the 4th splat a red channel or a grey scale image, it doesn't matter. The same can be done for placing trees, you can assign any color to any tree or make more rules like placing on height and degree, normal, etc, etc. Yes it's very important to have sum of splat always 1, especially >1 gives a rare overlighting effect. I build in a measure tool where you can measure height, degree, normals and splatmap values + sum, on any part of terrain to make sure they are right.



    From a distance it looks a little better now.

     
  15. larsbertram1

    larsbertram1

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

    it does not look a little bit better: it looks gorgeous!
    and perfectly light.
    i am glad that you have found the source of the incorrect lighting at far distances in the corrupted normal map ;-)

    keep up your work and post some more pictures.

    lars
     
  16. larsbertram1

    larsbertram1

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


    just a short update on the ultra version of the shader: right now i have done the first layout for the first flavour of the shader supporting:
    - 6 detail maps (all bump mapped and perfectly belended)
    - specular lighting
    - 1 overall color map
    - 1 overall normal map

    all drawn within 1 single shader pass.
    all 6 detail maps can be drwan onto the terrain using unity’s built in painting tools using a simple workaround.
    alternatively you can just import your generated splatmaps.
     
  17. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Could you provide an alternate version that works on a mesh? When i first looked into this i was using unity's terrain but i've switched over to meshes and had to drop it, however i do have a single large normal/color map per terrain tile and will be applying detail textures on it so i would love to reuse this shader (the ubber version with 6 detail maps support sounds great).
     
  18. larsbertram1

    larsbertram1

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

    this is just the first preview on the ultra version supporting up to 6 detail maps (bump mapped) – fully drawn within a single shader pass:

    $colormap_ultra_01.jpg


    lars
     
    Last edited: Oct 8, 2012
  19. larsbertram1

    larsbertram1

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

    i am sorry, but the color map shader won’t come for regular meshes within the near future as i can’t see any need for this.

    the only case that should you make thinking of dropping the built in terrain is the heavy usage of cliffs and overhangs.
    but those can easily be added by using additional geometry. in any other case using the built in terrain will always be the fastest solution as it comes with its own very effective LOD solution. Not to mention all its built in features like grass and trees… which you can’t compete with unless you bring up your very own terrain solution.

    there might be another reason to not use the built in terrain which is the development for mobile devices –*but in this case you will have to live without the color map shader as it uses far too many texture samples (it is shader model 3!).

    so if you do not develop for mobile devices please come back and use the built in terrain: it might not be the best solution out there, but it still is the best and fastest solution to draw any kind of terrains within unity.

    thanks.
    in fact i am quite happy with what i have got so far: fully manually controlled terrain texturing – using 6 detail (bumped) textures running at the same speed (as far as i can measure and the same number of draw calls) as the initial version.
    so watch out for the update!

    lars
     
  20. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    I'm not targeting mobile, but i'm targeting things i don't want to do with the terrain engine, i don't want to use the LoD it provides (not any LoD, dynamically loading terrain as i go, not visible from the sky so loading everything at full resolution is fine).
    I definately want to add overhangs / caves etc later on too, and the built in terrain doesn't bring me much in exchange for what i lose (polycount is a non issue, and i'd rather not have those thouthands of draw calls + just for terrain with the high res maps i'm using).
    I'm talking millions to 10s of millions of poly visible terrain here, it definately didn't feel faster using built in than meshes except when detail resolution was turned down, but it immediately looked like crap.
     
  21. larsbertram1

    larsbertram1

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

    this sounds like a very special case – but the color map terrain shader just addresses a very wide range of different cases – and mainly was designed for giving you better terrain shading while keeping the needed computation power as low as possible.
    so it works just within one single shader pass and gives you hopefully nice looking terrains at even more or less decent frame rates and specs. just have a look at the picture attached: not many polys were harmed!

    so in case you really have to use manually modeled geometry you will have to find your own solution. but the color map shader is written as straight forward surface shader so it should not be any problem to port it in order to make it support any kind of mesh.

    lars


    $ats_colormap_specs.jpg
     
  22. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Aye i can port it, was just wondering if you had plans to.
    Considering my target i'll wait for the uber version before porting it, any idea when you would release it and under what licence?
     
  23. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Wow 6 splat maps, where do you stuck all those things inside and still keeping 1 pass:D?
    Do you think that there is any chance that you could combine your detail shader with this shader, or maybe just using two additional splat maps as detail maps?
     
  24. larsbertram1

    larsbertram1

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

    may be decal like blending will be one of the flavours the shader will come with – not supporting spec lighting in this case i think.
    but we will see.

    lars
     
  25. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @lars - What are you using to create your terrains? The last screenie looked really nice.
     
  26. larsbertram1

    larsbertram1

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

    it is still my first terrain ever modelled in the free version of world machine.


    lars
     
  27. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Came out pretty good! ;)
     
  28. botumys

    botumys

    Joined:
    Apr 16, 2009
    Posts:
    707
    Thanks for everything you do for the community Lars!
    I'll try this shader soon.

    O.
     
  29. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi botumys, your welcome.
    and i am looking forward to see what you will do with the shader.

    lars
     
  30. larsbertram1

    larsbertram1

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

    here is a little update about the colormap ultra shader.
    it now supports 6 bumped mapped detail textures, specular lighting and the possibility to reuse up to 2 terrain textures and paint them onto the terrain using a decal blending method instead of the standard soft blending mode.

    painting terrain textures as decals onto the terrain gives you the possibility to create much more variety as far as the blending between several terrain textures is concerned. just have a look at the pictures attached:

    $decals_edges.jpg


    $decals_colorblending.jpg

    lars
     
    Last edited: Oct 10, 2012
  31. larsbertram1

    larsbertram1

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

    colormap shader and decal shader have just been unified.
    have a look at my post above.

    lars
     
  32. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Perfect just perfect, exactly what was needed for decails, usually there is only 1 or two textures on terrain that are really in need of decal blending and this just makes it up for. Not sure about color correction but we shall see what it is usefull for:p
     
  33. larsbertram1

    larsbertram1

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

    the ultra shader will come to the asset store pretty soon i hope – may be within the next days.
    most of the work on the shader itself is done but i have to write the docs.
    it will come with the standard unity asset store license – but unlike the standard colormap shader this time i might ask for some money.
    i am not really happy about that, but the development costs quite some time and i have to fill up my fridge.

    lars
     
  34. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    About filling up the fridge, would you be interested in porting it to meshes for a fee and if so how much (i'm not asking for exclusive work, just doing it and making it part of the asset store package would be fine)?
     
  35. larsbertram1

    larsbertram1

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

    you are talking about the color correction of the decals, right?
    well, playing around with them i came to a point where i would like them to keep their own color.
    using decals just to redefine edges would not need this feature: you would better go with fully color correction.
    but using decals to spice up the terrain’s texturing really needs this feature. so it is up to you to choose for each decal whether you want color correction to fit the terrain’s color map or not.

    lars
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    thanks for your offer, but it is a quite quick task and i am pretty sure that anybody with a little bit of knowledge as far as shaderlab is concerned can do it within 10 minutes: just add the needed textures (passed via script) to the material block and rename the shader!

    lars
     
  37. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Is it? I'm not well versed with how the built in terrain works but how does the detail painting work? Because i assume if i have a mesh and a splatmap of where each color goes and i'm not using the terrain i can't just pass in the splatmap to the shader? (does it expect a map or is data encoded in vertex colors?). I expected the shader change to be trivial but the passing the detail splatmap data to be complex, i could've imagined it much harder than it is however.
     
  38. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @Lars - Just have one word for you... WOW! :D
     
  39. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    That looks amazing! Can I ask when its going to be on Asset Store and how much? :D
     
  40. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    This is looking splendid, i'm hoping it'll be somewhat affordable but it looks perfect for some things i have planned and well worth whatever's asked, and i think it'll be a nice little earner for you Lars
     
  41. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    thanks guys,

    the ultra version won’t be more than 10€ but there is still some work to do:
    optimization, preparing the demo, writing the docs…

    lars
     
  42. larsbertram1

    larsbertram1

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

    just a super short update as far as optimization is concerned:

    current stats

    standard unity terrain shader (4 detail maps diffuse only):
    0,37ms rendering time

    colormap ultra terrain shader (6 detail maps bumped diffuse with specular lighting + color map + terrain normal):
    0,42ms redering time

    lars
     
  43. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,527
    any change this will work on iPad 2 and up?
     
  44. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    as it is shader model 3 it won’t work on mobile devices.

    lars
     
  45. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Oh that's a real shame. :(
    <Puts money back into his pocket>

    Make it work on mobile and I will throw money at you!! :D
     
  46. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Why would you expect this shader to work on mobile? You even dont see bump mapping in most of mobile projects due to sparing with resources, let asside full color specular and normal map of whole terrain that this shader provides. Even if it would work it would probably eat too much to get anything usefull beside terrain working.
     
  47. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    nothing to add…
     
  48. x70x

    x70x

    Joined:
    Aug 20, 2011
    Posts:
    49
    Will the new "ultra" version of this shader work with multiple terrains? 6 detail maps instead of 3 or 4 would be awesome. I'm currently using a grid of 16 terrains that work great with the multiple terrain shader.
     
  49. larsbertram1

    larsbertram1

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

    right now the ultra version only works on one single terrain.
    i might add support for multiple terrains but i guess i will wait until unity 4 is released as it makes things much easier.

    lars
     
  50. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    x70x what multiple shader are you using ? Is it from lars or some other shader?