Search Unity

ats Colormap terrain shader [RELEASED]

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

  1. larsbertram1

    larsbertram1

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

    although i am not very happy about the texturing of the terrain here is the first demo of the colormap ultra shader:

    http://bit.ly/Wdvsch

    it shows one terrain using:
    - 1 color map
    - 1 overall terrain normal map
    - 6 detail maps supporting specular lighting and normal mapping
    - advanced multi uv mixing on the rock texture
    - 2 decals (reusing 2 of the 6 detail maps)

    the advanced multi uv mixing blends between the high and low res version of the rock texture to always give you the best visual result even at very close viewing distances.

    let me know what you think.


    lars
     
  2. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    Hey there,
    Tried the demo and noticed a few weird things, hope this is helpfull
    Weird colored mesh just under the terrain:

    Lines on the ground (line pattern changes depending on light direction):

    Visible tiling:

    Weird rendering on some edgy areas:

    Also having an issue with the camera (had this with your previous shader's webplayer too), when i turn the mouse the view gets tilted too, so it's pretty hard to control, but that may be a feature i guess.
    Thanks for your works on this!
     
  3. larsbertram1

    larsbertram1

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

    thanks for checking out the demo.

    i have just noticed that i have forgotten to turn off some helpers – but the webplayer is updated and will not show any colored meshes underneath the terrain anymore ;-)

    that looks pretty strange and like some kind of filtering issue.
    but i do not get those lines on my machine (mac book pro, nvidia geforce 9400m).
    anybody else?

    as i have said before: i am not happy with the texturing… i use some none optimized textures here.
    but to be honest: even with more optimized textures you might get some tiling artifact in a case like this with a very far viewing distance just over a completely flat terrain without any details...

    those are unity’s built in real time shadows and have nothing to do with the shader itself – unfortunately. otherwise i could work on this ;-)

    thanks!

    so most of the things you have noticed are no bugs in the shader.
    - colored mesh has been removed from the demo.
    - tiling textures occur just because of none optimized textures (multi uv mixing is only used on the rock texture)
    - weird rendering on edgy areas is due to unity’s built in shadows

    only the "lines" might be caused by the shader.
    so i would like to ask you to just take a simple plane and attach the standard bumped spec shader to it (and assign some proper textures to it of course).
    i think that you will get those lines there too – as the shader itself just uses the built in lighting functions and does not do any fancy stuff here…

    lars
     
    Last edited: Oct 13, 2012
  4. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    I'll try that.
    Btw i never got the time to do a decent WM terrain in the end (just now working on it, but i can't send you that due to the size, it's 1024 tiles at 100K poly each with 512 tex each for normal color), but my offer to re render your terrain / maps at higher res still stands if you'd like feel free to send me the WM files.
     
  5. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi ronan,
    as mentioned before: the terrain is the first one i have ever done in world machine.
    but nevertheless, here it comes:

    View attachment $myWorld.tmd.zip

    having the terrain normal map in a higher resolution (1024 or even 2048) would be nice.


    lars
     
  6. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
    It's done generating, i did 1024/2048 4096 (i can do 8K too if you want but that'll take a while to generate download)
    I switched to 16 bit png as your file didn't work as is (i'm using WM 2.3 beta 4 so i assume something broke) and leaving the exports as bmp simply gave me the wrong map each time.
    I'll post the link as soon as it's done uploading to dropbox (300MB) but it should look a "lot" better if you use those, the detail level is pretty insane
     
  7. ronan-thibaudau

    ronan-thibaudau

    Joined:
    Jun 29, 2012
    Posts:
    1,722
  8. larsbertram1

    larsbertram1

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

    thanks for the maps.
    attached you find a comparison of the terrain using different normal maps.

    lars

    (open in new window to watch in full res)
    $heighres_terrainnormal.jpg
     
  9. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Hey Lars, would you be able to include a tutorial on how you made the textures for this project when you release the shader?
     
  10. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
  11. l0cke

    l0cke

    Joined:
    Apr 15, 2012
    Posts:
    438
    Not surprising. We used some custom shaders and we have similar experience. It is not secret, that default shaders are FAR from optimized. It is pitty, but by rewriting you can almost in each case achieve both better quality and speed (if you know how to write shaders). Kungfu of Unity ninjas is lately becaming very weak.

    Btw, really good job. This approach is exactly, how good terrain should be done. It is not coincidence, that CE3, UDK, or Unigine are using very similar approach. Out of box :/
     
    Last edited: Oct 14, 2012
  12. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Yes, Unity's terrain shaders could use some more quality. You don't see UDK or CE3 users writing their own shaders, so why must we?
     
  13. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    There are many answers on that question. CE3 already ships with terrain shader that does what Lars has done for us here. UDK too. As for general shaders, UDK material editor is so powerful that it isnt actually material editor but more like a shader editor where you dont need to use a single line of code and you can do it all visually. CE3 ships with 4 "ultra" shaders that cover and behave as basically almost any shader you can find for engine, which means no need to writte shaders there too.
     
  14. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    620

    I really like what you've done to improve the terrain rendering.
    Here are some shots from my current machine... I can see some of those Moiré artifacts, the tiling and the "circle" that wanders with the camera (the distance at which you chose to fade in the color map I guess). But that's tweakable. And the shader is (visually) far superior to the one shipping with Unity:
    $coloredTerrain_Decals.png $coloredTerrain_minorArtifacts.png

    It would be great if you released this "ultra" shader as well. Cannot wait to get my hands on it and prepare it for use with substances. :)
     
  15. larsbertram1

    larsbertram1

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

    those moirés look pretty strange – and i do not have any good explanation for them…
    as far as the realse is concerned: the shader is mostly done, but i still have to write the documentation which will take quite a while.

    lars
     
  16. eagle555

    eagle555

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

    Your shader looks great !:), it would be great to see the multi-terrain version. But indeed Unity4 will make it much easier.

    I think those lines are caused by the 'cast shadows' in the unity terrain settings. I also have those lines with terrain when enabling this option with any terrain.
     
  17. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Although that's a good tutorial, I'm more interested in what workflow to use to generate the proper maps in World Machine to use with this new shader.
     
  18. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    As far as creating the colormap goes, he covers exactly that in steps 2-4. You pretty much have to watch it, it can't really be synopsized. Lars did his following the same tutorial, you can tell by looking at the colormap and the flows overlay.

    You can start makong it however you want, but the coastal overlay macro is a nice start (the one that the tutorial uses). Basic coverage is an easy one too.

    To make your splatmap so your detail textures line up with the colormap, you probably want to do that by hand in photoshop, and just tweaking your selections. The good thing about Lars' color blending from wolfire's blog is you don't have to get it perfect, the colors will match up nicely.
     
    Last edited: Oct 16, 2012
  19. larsbertram1

    larsbertram1

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

    there is nothing special about the creation of the needed textures*– except from: just make the colormap fit the colors of your detail maps or vice versa.
    but that has nothing to do with world machine.
    in fact you can download my wm-flie from one of the previous posts – the rest is just some work in photoshop. altogether it took me about half an hour and it was the first time for me ever to work with wm (but i have to admit: i did not have a special terrain in mind… so pretty much anything was ok for me).


    lars
     
  20. larsbertram1

    larsbertram1

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

    i had the chance to have a look at the shader running on a pretty cheap asus laptop showing the same morés and artifacts and i think you are right: those are shadow artifacts – and are independent from the shader…

    lars
     
    Last edited: Oct 28, 2012
  21. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    Last edited: Oct 28, 2012
  22. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    This is highly useful but it doesn't seem to work on Unity 4, it doesn't give any errors and the settings are there, but I don't see the effect
     
  23. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hi chaoss,
    are you just running the demo scene? then everything should be fine!
    you have to hit play before you will see the shader in action.

    in case you have any further problems, please let me know.

    lars
     
  24. Riptyde

    Riptyde

    Joined:
    Oct 30, 2012
    Posts:
    4
    Hi all, I'm and trying to use this shader for a terrain I created in WM2 (non commercial version) but I am having problems with the splatmap. I created an rgb map in WM2 using a channel combiner and have attempted to export it in every file format possible, both with and without an alpha map input. When I try to apply the splat map in Unity it tells me it needs to be an argb 32 bit. OK great!. I convert it to 32 bit in photoshop and create an alpha channel. But then Unity does not recognize it as a texture. I even copied my rgb image into the same file that came with the demo of this shader (customsplatmap_argb.psd), deleted the original layer and re-saved and that did not work.

    I'm at and end of what I can try to figure out. I've done a lot of google searching and have not found anything other than a process that seams very long and tedious (basically manually building the argb file - and honestly didn't really understand what they were saying).

    I am new to both unity and WM2 so I'm pretty sure I'm just missing something.

    Hope someone can help - maybe walk through the process from WM2 to photoshop to Unity?

    Thanks all

    Riptyde
     
  25. larsbertram1

    larsbertram1

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

    32bit are not 32bit!
    photoshop would take it for 32 bit per channel whereas unity needs a 32bit texture for all 4 channels which is 8 bit red, 8 bit green, 8 bit blue and 8 bit alpha.
    so just import an regluar rgba image (8 bit for each channel) and in the inspector choose "automatic truecolor" or "RGBA 32 bit" as import format for your texture. also do not forget to switch to "advanced" on the "texture type" and check "read/write enabled".

    lars
     
  26. Riptyde

    Riptyde

    Joined:
    Oct 30, 2012
    Posts:
    4
    Lars, Thanks for the feedback. Gotta love it when two different programs appear to say the same thing, but are completely different.
    I will give this a go when I get home tonight. Thanks again.

    Rip
     
  27. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    you are welcome.
    and have a closer look at the documentation ;-)

    lars
     
  28. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    Actually it appears the color map has applied, but the normal map doesn't work
     
  29. larsbertram1

    larsbertram1

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

    test the webplayer demo: http://bit.ly/P8lib6

    if the shader works in the webplayer and you see the color map, detail textures and detail normals your system is capable of rendering the shader.
    in this case please reimport the package to a completely new project and try again.
    you might also check the texture import settings of the normal maps.

    there has been a problem on some windows machines but that has been fixed weeks ago.

    lars
     
  30. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Ah damn thanks for this explanation, i was going from Unity to Photoshop whole day and not figuring out where it was problem.
    Just wondering Lars is it possible to change detail textures in Unity with terrain painting? I will be designing terrains and almost certainly doing tweaks inside Unity and not having ability to change detail maps is little problematic.
     
  31. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    you can just use the built in terrain paint tool to paint or rework your detail maps.
    that will effect the splat map of course.

    lars
     
  32. Chaoss

    Chaoss

    Joined:
    Jul 8, 2011
    Posts:
    327
    The webplayer works perfectly, however after creating a blank project and redownloading and reimporting the terrain it looks the same, I tried running the demo and it didn't make a difference.
     
  33. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Thanks thats great news.
     
  34. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    hmm. pretty strange. you are on unity 4?
    unfortunately i only own unity 3.5 so i can’t test it myself.
    but i have been told that the ultra version of this shader works with unity 4. so the basic version should too.

    does anybody else have the same kind of problem with unity 4?


    lars
     
  35. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    Unity Free 3.5 OSX.


    Doesn't happen in the webplayer.
     
  36. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    have you hit "run"?
    does it then still look like this? i guess and really hope that not!
    what you see: a shader without any textures in the foreground (no textures because they will not be passed to the shader until you hit "run") and the built in base map (as only the script executed at runtime will tell unity to not show any base map).

    lars
     
  37. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    294
    Lars, any chance of updating this to make a material for Unity 4 like you did with the Ultra version?
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    i am very short of time right now, but we will see.
     
  39. jesta

    jesta

    Joined:
    Jun 19, 2010
    Posts:
    294
    I understand. I did it on my own but added specularity on detail maps, so it's like your ultra shader but with only 4 detail maps to simplify the workflow (I need to make a lot of terrains so combining normal maps was taking too much time). PM me if you want the shader (Unity 4 version).
     
  40. Wolfos

    Wolfos

    Joined:
    Mar 17, 2011
    Posts:
    951
    Yep, that was the problem. It looks glorious!
     
  41. roger0

    roger0

    Joined:
    Feb 3, 2012
    Posts:
    1,208
    I'm having multiple problems, and wondering if someone can help.

    1. I'm following the documentation and it says this.

    I did this and I ended up with a horrible looking terrain. It appears that none of the textures assigned in the terrain have been applied to the splatmap. Bellow shows a image of the results and splatmap I used.




    Also, why is this step is required? I thought the custom terrain script color map script is suppost to do all of the texturing. Whats the difference between the splatmap and the color map?




    2. What if you want a area on the color map to appear green when seen from far away, but when seen up close, the ground becomes plain dirt? I am building a high desert landscape where grass doesn't really grow but sage bush does. I would like to represent the sage bush on the color map, but once the player gets close enough, the texture where the sage bush are needs to change to dirt and then detail meshes of the sage bush has to start appearing, if you get what I mean. Basically there's no grass but there are bushes. It might not look right if the landscape looked totally barren until you get close enough for the bush meshes to appear.

    With the demo scene. I tried replacing the green grass texture with a sand texture as an attempt to achieve this effect, but it appears that the textures look very blurry looking when seen up close. Also there is still some green showing but there are no green textures specified in the terrain editor. Whats going on? Below is a image that shows what I'm talking about.



    3. Lastly, is it possible to have more then 3-4 textures on a terrain using this system?

    help would be greatly appreciated, thanks.
     
    Last edited: Dec 6, 2012
  42. larsbertram1

    larsbertram1

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

    1. this step is only needed in case you want to import a splatmap e.g. from your terrain generation software like world mashine.
    the custom terrain script just passes the additional textures to the shader – it does not do any "texturing".
    of course you also can simply paint the splatmap manually within unity.
    having a look at your screenshoot i notice that the custom terrain script is not attached to the terrain. attach it and hit run. that might solve the problem.

    2. you would have to have a far and and close color map to achieve an effect like you have described – which are not supported by the shader.


    have you checked the tiling?

    well, that is what it’s all about! the green comes from the color map. if you want to have a mostly sandy terrain then you will have use a mostly sandy color map... make sure you apply correct tex col values in the script too.


    yes: you can buy the ultra version from the asset store ;-)

    lars
     
  43. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    The color map is a giant texture that you need to make that stretches over the entire terrain, that is visible at far distances, and blended with the terrain detail textures at close distances. You still need to distribute the detail textures on the terrain, which is why you need to use a splatmap (unless you want to paint them by hand in the editor).
     
  44. roger0

    roger0

    Joined:
    Feb 3, 2012
    Posts:
    1,208
    thanks for answering my questions. I am having another problem though. When I setup my terrain with the custom terrain script color map, I get a very bright light when I zoom in close to the terrain. Whats causing this?



    Also, im wondering how using this compares to Toms terrain tools. I'm guessing one of the advantages is the color map showing when seen from far away distances? So there is no texture tiling seen from far away.
     
    Last edited: Dec 7, 2012
  45. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    have a look at the script: you haven’t assigned all "Col Tex" parameters. those are used to make the detail textures match the color map.
    read the docs for further details.

    you can’t compare the two. this one is a shader. tom terrain tools help you importing externally modeled terrains. in fact both should even work together well.
    the color map is always shown so it enhances the visual fidelity no matter if you are far away or very close to the terrain.
    just have a look at the first page of the thread: there you will find some information about the features of the shader and a comparison shot showing standard terrain shading and the color map shader.

    lars
     
  46. roger0

    roger0

    Joined:
    Feb 3, 2012
    Posts:
    1,208
    Hello.

    The reason I left the other 2 color tex parameters black is because I was only texturing with 2 detail textures. So there was only red and green in the splatmap. I managed to fix the bright light issue however I just tweaked the col texture paramaters to different brightnesses until the light went away. So the col textures did not match the terrain, although it was fixed.... So not sure if that was the right way.

    Also, i'm very new to terrain shaders so just need some clarification . I'm still trying to figure out what the shader is good for exactly. I read the documentation and first post and it looks like it ups the contrast of the terrain. However, im not sure how this differs from just increasing the color map contrasts in photoshop.

    I also noticed that the custom color terrain script has a slot for a normal map for the color map. So I think what its doing is applying a big normal map at far distance in order to keep the detail. Then once the player is close, it fades out and starts to fade in the detail textures and their normal maps.

    So the biggest benefits I see is the normal map support for detail textures and the far away normal map for the color map, however, im not exactly sure the benefits of applying the large color map at far distance, since the detail textures can look ok at far distance, if they are tiled correctly.

    thanks
     
  47. sgoodrow

    sgoodrow

    Joined:
    Sep 28, 2012
    Posts:
    150
    Hi lars -- great work.

    I have been using your tool, and World Machine, pretty substantially over the last month and have started evolving my vision for my product. I am looking to use a terrain which is textured exclusively by a colormap. I have used your tool, here, to do this (splat distance = 0), and had a question for you.

    The colormap by itself, when applied to the terrain, becomes somewhat pixelated. I thought maybe it was a ratio thing, where the resolution of the colormap to the terrain size was causing some interpolation issues, but that isn't it. I am using a 2048x2048 colormap, across a 700x700 terrain, but the result remains pixelated when I drop the terrain size in half. I think it has to do with how the colormap is being applied, but I am not sure.

    How would you go about fixing this issue? About creating a terrain which is untextured at a high resolution? I was wondering if a splatmap might have higher resolution (and then I use RGB as my textures), but that didn't seem to work either... It's because it's being done in the vertex shader, isn't it? And the terrain model is low resolution...? Think it is feasible to parse the colormap in a pixel shader instead?

    Thanks.
     

    Attached Files:

    Last edited: Dec 8, 2012
  48. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    Because the color map isn't only for the distance, its blended with the detail textures at close distances too, so you can create more visual interest than just your detail textures and have more control over the overall color of your whole terrain. detail textures alone could never look as good as a good colormap, especially with only 4 detail textures available per shader pass.

    Look at wenda's colormap at 0:15 in this video, and try creating a terrain with that level of visual interest and quality with 4 detail textures. http://www.youtube.com/watch?feature=player_embedded&v=wNe5X0fKNfU#! (he only uses 4 detail textures in the final result).
     
  49. larsbertram1

    larsbertram1

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

    even a colormap at a resolution of 2048 x 2048 ends up in 1 pixel = 0,34m at a terrain of 700 x 700m size – which of course is quite pixelated.
    dividing the terrain size by 2 will give you a resolution of 1 pixel = 0,17m.
    using detail textures you usually get resolutions about 1 px = 0,01m or even higher. otherwise it would not be possible to display a single blade of grass.
    as the max texture resolution is 4096 x 4096 highest resolution of the color map on a 700 x 700 terrain is 1 pixel = 0,17m.

    and of course the pixelated result on screen is effected by the choosen interpolation method and aniso level in the import settings of the texture.
    i am pretty sure that the result you get is exactly the one anybody would expect.
    so there is nothing to fix.
    using the splatmap will not solve this problem as the splatmap is limited to 4096 x 4096 too of course.

    btw.: the color map is applied in the pixel shader – the vertex shader only claculates the terrain’s tangent and some distance stuff.

    lars
     
  50. sgoodrow

    sgoodrow

    Joined:
    Sep 28, 2012
    Posts:
    150
    Hmm I see.

    I played with import settings and the pixelation did indeed disperse, though was met instead with the resolution issue you are referring to. I would really like to smooth out these gradients. Everything on the terrain is a gradient, but the resolution is creating discrete edges. Do you have any ideas on techniques I could look into to blur the colormap after its been applied, or something?

    Thanks again for your help.