Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bump maps for built-in terrain

Discussion in 'Made With Unity' started by Chris Morris, Oct 10, 2010.

  1. Mirace

    Mirace

    Joined:
    Nov 29, 2010
    Posts:
    481
    Does this work other Objects also? i mean i want bump map my model walls. possible with same tactic as terrain?
     
  2. niosop2

    niosop2

    Joined:
    Jul 23, 2009
    Posts:
    1,059
    You don't need this to bump map objects, just use a bumped diffuse or bumped specular shader. If you mean you want a splat map shader, there's some on the wiki and it's pretty trivial to make a splat map shader using Strumpy's Shader Editor.
     
  3. Mirace

    Mirace

    Joined:
    Nov 29, 2010
    Posts:
    481
    Thanks for answer, but i mean if i want in my model , lets say walls. to get pumped is it possible? and answer is yes because i made it to my model. Working as it should - Nice work!
     
  4. aubergine

    aubergine

    Joined:
    Sep 12, 2009
    Posts:
    2,878
    Purri:
    You know that there is a builtin bump map shader for objects (walls as you say) which you should use instead of this one.
     
  5. ArenMook

    ArenMook

    Joined:
    Oct 20, 2010
    Posts:
    1,902
    Has anyone actually tried building a project using these shaders btw? It seems like the shader doesn't make it into the build? The terrain looks plain, normal maps are missing.

    Edit: Nevermind, it's something else that's breaking this functionality. Stand-alone brand new project works fine.
     
    Last edited: Jan 17, 2011
  6. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @Chris - I'm just starting to play with this so I'm not sure if this is expected or not: I've create a simple terrain added the script and shader per the instructions. The bump appears correctly in both forward and deferred rendering when the terrain doesn't have a lightmap, but if I add a lightmap the bump only appears in deferred rendering. Is that expected? I had hoped to use this in forward render mode.

    Thanks again, this is a much needed addition to Unity's terrain system!
     
    Last edited: Jan 17, 2011
  7. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @bigkahuna - just a quick try at what might be causing that - is your light source set to "auto" and you are using "dual lightmaps"? If so I'll try to reproduce this and see if I can't come up with a fix.
     
  8. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @Chris - That's right. I've created a test scene with a simple terrain, a directional light and a camera. I've imported your script and shader and then assigned one texture to the terrain and one bump map to your script. When I run the preview everything looks fine and I see bumps on my terrain. I then open the bake window and bake a lightmap for the terrain (the only object in the scene) and as soon as the bake is over, the bumps disappear. If I clear the lightmap in the bake window the bumps re-appear. I've tried this with more complex terrains (4 textures and 4 bumps) and the result is the same.
     
  9. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @bigkahuna - hmm.. from this thread it appears that using bumpmaps with lightmapping is only available in deferred mode:

    http://forum.unity3d.com/threads/55685-Using-a-bumpmap-with-baked-shadows

     
  10. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @Chris - Got it, thanks for the info!
     
  11. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    I just wanted to say thank you so much for this feature. It works great and display is just as good as on standart bump-spec shader. Also i havent notice any frame drop when using it.
     
  12. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Just one thing....where is specular texture read from? From color textures alphas?
     
  13. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    I just wanted to point out one thing for anyone who is using this feature....you need to confirm your normal map texture in editor as "normal map" first to get it correct working on terrain. I am not sure if that is needed for everyone but it defenetly is for me. All you need to do is to put normal map first in some random materials normal map channel and fix it.
     
  14. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    hmm, the normal maps still disappear for me when I lightmap them, even when using deferred rendering.
     
  15. Mixality_KrankyBoy

    Mixality_KrankyBoy

    Joined:
    Mar 27, 2009
    Posts:
    737
    This works awesome - but as others have requested, any chance this can be upgraded to work with more than 4 terrains?
     
  16. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @redmacmanz - are you using double lightmaps?

    KrankyBoyGames - this is a bit more complicated because you have to implement a way to distinguish between each pass, so that the first pass uses the first 4 bumpmaps, and the second uses the next 4 bumpmaps. This also means 8 bump textures sent to the shader. I was hoping that when I released this it would inspire Unity to get this implemented, so that we don't have to hack together something like this - but for now our team is only using a 4 bump and because of its inefficiency, we aren't planning to develop a version with more than that.
     
  17. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    I think 4 bump maps is enough. Or combination like 1 parallax + 3 bumps. You really dont need every terrain texture bumped.
     
  18. Mixality_KrankyBoy

    Mixality_KrankyBoy

    Joined:
    Mar 27, 2009
    Posts:
    737
    Thanks Chris - good answer =) btw UniSky is amazing and has really brought my game to life.
     
  19. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    I found strange bug, I have 3 terrains in scene and normal maps from first are affecting second and third terrain, even if other terrains have own instance of script with own maps.
     
  20. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    325
    Try adding another directional light to the scene, I have this problem, but I found that if I duplicate my main light they reappear, I am using lightmaps and forward rendering and my normals, spec are working. It's a pain to have to adjust two separate lights to make it work but it works and thats all that matters.
     
  21. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @demostenes - Yes, this is expected behavior. It's because the shader that is overridden applies to every terrain in the scene, and it can only store 4 bumps at execution. If we had more access to the internals of Unity we might be able to set it up to dynamically change per each terrain, but for now we just have to rig it the way it is which has inherent limitations. Still waiting for Unity to get around to implementing this officially themselves - my hack-around job is a poor excuse for full-featured bumpmap support.
     
  22. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Thanks. This is quite limiting, because once I am building seamless world, I have 1-4 (in worst case) terrains loaded. Anyway I really dont understand, why terrain engine does not have normal map support by default, we are in 2011 and this is not hard to implement. UT focuses on fancy/useless features and critical systems and functions, which should be there long time ago (and almost each engine have) are still missing.
     
  23. chadchat

    chadchat

    Joined:
    Apr 5, 2008
    Posts:
    154
    Any idea why I don't get proper specular happening? If I crank up the value I see specular 100% all over the terrain, so it seems to be ignoring the alpha channel of my diffuse texture. I assume it's not supposed to be in the normal map's alpha because when you designate it as a normal map the alpha is removed of course.
     
  24. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Hey Chris,

    I am wondering if you would be able to create shader for detail meshes on terrain too (for normal and specular support)?
    That would be really great. Just a thought:D
     
  25. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @chad - I actually don't think I have the specular dependent on the main splat's alpha. This should be a quick fix in the shader if you want it, by multiplying the specular in each splat by the according splat alpha.

    @janpec - That is a good idea. I haven't looked into that yet but we will probably be looking into doing that for our game. Right now I'm juggling a few responsibilities outside of Unity stuff while also working on UniSky, so I can't say when I could get to that. If I do though, I will update everyone through our team's various channels (Twitter, our blog, website, etc.)
     
  26. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    Hey Chris, I finally had a chance to check out your bump mapped terrain...and I am using it and getting some very strange behaviour like the texture swimming when I move the point light around... and I downloaded both the Terrain bump and Parallax... which one should I be really using?
     
  27. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @Chris - Not sure if I posted before, but I'm using this and it's awesome. This really needs to become part of Unity's built in features! :)
     
  28. KRGraphics

    KRGraphics

    Joined:
    Jan 5, 2010
    Posts:
    4,458
    I'm having a hard time getting this to work :(
     
  29. glnhrrs

    glnhrrs

    Joined:
    Jan 17, 2011
    Posts:
    9
    I know this is possibly a different thread. But has anyone had any success with adding normal maps to terrain rocks or grass in paint details on the terrain ?
    ie. I want a normal and spec map on rocks I am spraying around on the terrain. Currently it looks like unity only has support for its
    diffuse map. I am able to add smoothing groups. But its still not what I am after.
    Any ideas ?
    Cheers
     
  30. Chris Morris

    Chris Morris

    Joined:
    Dec 19, 2009
    Posts:
    259
    @Neptune_Imagine - Sorry, I try to check the forums every day but I must have missed your reply.

    If you can, e-mailing me is a much more reliable method of getting support. It would help if you could send me a sample project file with the error so I can try to reproduce it and give you a quick fix. As to whether to use bumpmapping or parallax, they serve different functions. Bumpmapping just modulates the texture's lighting to give the effect of 3d lighting. Parallax actually modulates the texture mapping so that the texture has the illusion of depth and protrusion.

    @bigkahuna - Thanks! I agree it should be a part of the built-in terrain. It's low cost performance wise, and really makes terrain look better.

    @glnhrrs - That will require a custom shader for the detail meshes. I'll probably develop something for this in the future, but right now I am super busy so I can't give a timeline of when that will be
     
  31. artician

    artician

    Joined:
    Nov 27, 2009
    Posts:
    345
    Had to switch my project over to using the terrain engine. It was a slap in the face when I realized what the texture limitations were. Then I found this thread. I love you guys, thanks so much for making this work.
     
  32. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Limit of this technology is, that you cant have more than one terrain in one scene.

    I really hate, when people must make hacks for something, which should be here out of box. Today is starndard parallax, or even relief shader for terrains. We dont have even bump (normal).
     
  33. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    if you hate unity that much wouldn't it make sense to stop posting here? All your threads the past 2 weeks were extremely negative and only good to demotivate people Demostenes. We both know that you were hit by limitations and that part of them were not well known to a majority of the users here and thus not to be found but still ... it will not help you and will not change unity, it will only lead to more demotivation for others that could have implemented solutions.

    I would see it from the point of view that it is great that we can override it. if UDK doesn't offer a thing you are simply F***ed with no options at all. Unity might need some extra kicks but on 50%+ of the cases you still get it to do what you wanted it to do (see the tri planar terrain shader thread as a prime example of it)
     
  34. Shad

    Shad

    Joined:
    Sep 21, 2011
    Posts:
    61
    That's not necessarily true. Most games don't use parallax for something like terrains because it's too much of a hit on performance. And many games still don't use bump maps on terrains, especially multiplayer games and MMO's. It's in no way a "standard".
     
  35. Demostenes

    Demostenes

    Joined:
    Sep 10, 2010
    Posts:
    1,106
    Bump through NM is very cheap effect and it helps a lot. I havent seen game for ages without at least normal maps on the terrain. And good habbit is to allow people to turn advanced effects off. So my terrain is parallax by default and it looks damn good, if you have weaker HW, you can downgrade to NM, or to flat. Simple, effective, proffesional.

    I ve just made very simple example, what does it mean to have parallax shader with decent blending on the terrain:

    http://forum.mymmo.cz/para.jpg
    http://forum.mymmo.cz/paral.jpg

    And believe me, performance impact is not that big. And if it is still too much? Player can switch to cheap bumped+diffuse or diffuse only. No problem.

    PS: On my HW is difference between parallax on the terrain and diffuse maps 0 fps. So for modern HW no problem at all.
     
    Last edited: Dec 15, 2011
  36. jc_lvngstn

    jc_lvngstn

    Joined:
    Jul 19, 2006
    Posts:
    1,508
    Drat, demo. Why did you have to show those pictures?
    Now I'm even more dissatisfied with Unity's terrains ;)

    Overall, demo has a point, and I understand his frustration. Unity terrain is probably "fine" for most apps that just need something basic. Anything more than that, and you either find hacks that still may not meet your needs, or you do without.

    How many of you would be happy if all of Unity's graphics were as advanced as its terrain graphics? I mean...no bump maps, parallax, whatever. Unity would be far less successful than it is today. Unity's terrain system lags FAR FAR behind its other features. I realize mobile is new, and brings $$$, and all. But at some point, some of its older systems could use a little more love.
     
    Last edited: Dec 21, 2011
  37. berserker

    berserker

    Joined:
    Apr 13, 2012
    Posts:
    2
    In advance I from Russia apologize for English.
    Hello Chris Morris! Your script and a sheyder in game added. But 4 slots are available only bamp-suited. How to increase this value? Can send a script with a sheyder in the altered view with 10 slots? I will be very grateful!!!
     
  38. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,899
    @berserker: 4 texture slots is max that you can draw in one single pass. 8 textures would need 2 passes = twice the number of drawcalls as far as the terrain is concerned = very expensive. 10 textures would be even 2,5 passes…
    and in order to have all thoese textures bump mapped you would have to pass +4 (or plus 6) global tetxures to the gpu. i am not sure if this is possible and or suitable.

    i would suggest to rather add decals to the terrain.
     
  39. berserker

    berserker

    Joined:
    Apr 13, 2012
    Posts:
    2
    larsbertram, and what then to do, if terrain uses 8 structures, and it is necessary to impose on everything bump?
     
  40. G2X44

    G2X44

    Joined:
    Jun 15, 2011
    Posts:
    11
    First of all this is an awesome shader! Thank you for sharing it.
    I have a little problem using more than 4 textures. I don't want to make bump all the 8 textures I use, just only 4.
    When I set up this shader everything is fine I can see the bump on my first 4 shader but the second 4 shader become dark looks like no light on them.

    http://tinypic.com/view.php?pic=2hxr21y&s=6

    You can see the direction light facing down and the first 4 textures are ok but the second 4 get dark.
    But, when I rotate the light to face up the first 4 get dark and the second 4 textures become lighter.
    http://tinypic.com/view.php?pic=2n1e05i&s=6

    Has anyone get this issue?

    Thanks