Bump mapping for built-in Unity terrain

10 10 2010

This is a feature that a lot of Unity users gripe about, so I thought I would post our solution for it. In the .zip file (download below) you’ll find a shader replacement and a C# script for sending the bump maps to the shader.

To use it simply attach the C# script to your terrain object and add the shader replacement in your assets folder. You will probably need to restart Unity after this so that the shader replaces the built-in.

The script allows 4 bump map slots. These slots correspond respectively to up to 4 terrain textures. For each of these bump maps you also need to specify the tile size which should match the same as the terrain texture. You will also notice seperate specular levels for each texture.

It is fully integrated with Unity 3.0′s surface shaders so it reacts correctly with all lights, shadows, etc. It also exposes a means of sending textures and values to the built-in shaders, so let us know what you guys end up doing with this.

Note: The bump maps won’t affect the base map, so you’ll need to set the base map distance high.

Download here

Enjoy!

Advertisement

Actions

Information

8 responses

11 10 2010
mikesgamespro

Thanks for this guys!

I will post the results on my blog a little bit later – http://www.mgproblog.wordpress.com

11 10 2010
Bump Mapping an Asteroid « GreenSlimeGames

[...] which links to this awesome bit of code : http://sixtimesnothing.wordpress.com/2010/10/10/bump-mapping-for-built-in-unity-terrain/. I’ve played around a bit with it, to see if it will fit SpaceOreMiner, and you can see the [...]

13 01 2011
Hamed

Nice & very usable work!
thank you very much

16 03 2011
Jeddong

Is it possible to increase bump map slot?

28 05 2011
Paulo Patez

It don’t works with lightmapped terrains. Is it possible to increase lightmap suport?

29 05 2011
Chris Morris

It should work with lightmapped terrain, but you need to make sure your lightmaps are setup correctly. You need to use dual lightmaps with deferred lighting – this is how Unity handles lightmaps with normal maps

8 06 2011
marvin

hey i tried everything wt u said,,even i watched youtube video

,,but this doesnt work!!,,and i’v a pro!,,so ma models have normal maps,,but terrain doesnt!!
need help!! pls

8 06 2011
Chris Morris

Can you send me an e-mail with screenshots, and go into more detail about what your process was and what isn’t working?

Chris AT sixtimesnothing DOT com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.