Bump maps for built-in terrain

I know people have been looking for this so I thought I’d share our solution. It is fully integrated with Unity 3.0′s surface shaders so it reacts correctly with all lights, shadows, etc. Also, this is real bump mapping using a normal map (doesn’t just use the alpha channel like previous implementations).

More details and a download link can be found here: http://sixtimesnothing.wordpress.com/2010/10/10/bump-mapping-for-built-in-unity-terrain/

NOTE: It also exposes a means of sending textures and values to the built-in shaders, so be sure to let us know what else you guys are able to come up with.

Double NOTE: The bump mapping won’t be visible in the editor since the script needs to run to send info to the shader. Press play and you’ll see it.

Enjoy!

Wow!!! Downloading now and testing. I report my results.
Thanks dude!

Looks good. Wish it supported 2.6 though as I’m not going to be able to use 3.0 until some issues are resolved. :frowning:

I have problems with the base map. If I look the terrain from certain angles the base map looses its bump map …

Don’t work in my project… I copy all files to my Assets, add script to terrain and add bump maps. No effect((
Sorry for my English …

Sorry, my mistake:) When i push play button, all will be work:)

I also wish this was for 2.6 but alas, I look forward to this when I make the upgrade :slight_smile: . This is one of the most sorely missed features in Unity IMO, and I’m glad you finally found a way to implement it.

works great!!! i think that it will improve a bit more, but it´s a very good start.

Thanks Chris!

Downloading now :slight_smile:

Can we use it with Unity Free version ? Or only with pro. ?

Thanks a lot !! :wink: :wink: :wink:

Omfg Ive been waiting for this feature!!! Thanks so much.

OMG it works GREAT thats for free :slight_smile:

wow!

thanks

and have you tried parallax mapping for this script?

that would be awesome!

I think, if that can be used local, this will be great!! Because not everywhere on terrain that need.
(Sorry for my English.)

Woah, this is amazing! :slight_smile: Still tweaking the settings, but let me give you a before and after preview based upon SpaceOreMiner ( not updated the webplayer yet, considering how best to use this :slight_smile: ).

Before :

After :

Oh, yea that was one thing I forgot to mention - it won’t show up in the editor because the terrain script needs to run.

@elias_t - The shader does not apply itself to the base map, so set the base map distance higher if you want to see it from far distances.

@bigkahuna - I suspect someone will port this to 2.x since it shows the 2 major problems we’ve run into which is sending textures to the built-in shaders and approximating the tangents of the terrain which aren’t provided in the vertex data.

@3dDude - We’re going to work on our own parallax shader soon. I’m sure someone could implement the built-in parallax with ease but I don’t think it looks very good.

@Evsign - It can be viewed only locally. It doesn’t apply itself to the base map so if you want it very local, just set the base map distance low.

Thanks for the feedback!

@Chris.

I have the base map distance at 2000. By not applying itself to the base map you mean we should not ad a bumpmap for the basemap?

I have for all 4 textures a normalmap, but from certain angles the bump seems ok but from others it shows some dark artifacts.

Here are some screenshots, and thanks again for your effort!


In the shader, try changing the tiling rate of the normal map. It looks like the bumpmap is very large. So in the shader where it shows 4 sections for each texture, find the one that applies to the texture you are seeing that looks like that and multiply the UV until it looks right.

// multiplied by 100
o.Normal = splat_control.r * UnpackNormal(tex2D(_BumpMap0, IN.uv_Splat0 * 100));

I mean not just that. I mean, what would this shader was used not on all terrain, but only in the right places. For example, in one place of my terrain i have the texture of stone, and in another place I have the texture of grass. And I need that to this shader has been applied only in the place where lies the texture of the stone

@Evsign - Yes, for the textures you don’t want bump maps on, just leave “None” in the bump map texture in the terrain script. And remember, the 4 slots line up with the 4 terrain textures respectively.

Ok Chris. thank you for replying.

But having the tiling changed didn’t resolved it. The basemap is 1024x1024 and the normalmap the same. When it shows, the tiling seems correct, but when it’s not showing you can see the artifacts:

could it be that we can’t have the terrain lightmapped?