Question about terrain shaders?

I searched here and the wiki and found some very nice, multi-texture terrain shaders (2 layer, 3 layer and 4 layer). But what I didn’t find is a multi-texture shader that also supports bump mapping. Does this exist? Thanks!

I just wanted to post this myself a few days ago :smile:

Well… aside that you can always write one yourself :roll: Do you want multiple base textures and a single bumpmap on the terrain? Or do you also want to mix multiple bumpmaps?

Also, keep in mind that a bumpmapped terrain may quickly get very expensive to render. Bump-mapping by definition is per-pixel lighting, and it’s much slower than the vertex lit terrain shaders.

Well, my skills as a script kid are well evolving :smile:

What i am currently trying to do (thats the reason why i did not post it :wink: ), is using a single bump or normal map on a 4 level layerd terrain. I now know how to blend textures using alphas (YEAH!) and my layered shader works already.
And i will surely get those bumps in… somehow and if necessary with a sledge hammer…

If i get this one finished, hopefully, i will post it.

Got any general advice, basic approach or dontdo´s for a complete code-newbie?

Also just wanted to remind, if the lights don’t move in the scene, the bump mapped terrain is pointless and could just be made with normal diffuse texturing.

-Jon

Yes, sure.

A better approach is to build some eye-catchers and place them somewhere important instead of doing a complete bump-mapped terrain.
But there are places in a level where such a shader could be very useful. Caves for example, where the player´s got the only light source.

And it is a good point to start, when learning how to programm shaders. The code structure isnt that hard to understand (so far…) and you get fast and satisfying results…

@Jon:
Not necessarily true - you can use bump maps like detail maps. I’ve also used bumpmaps for general terrain shading - If you generate a bumpmap of your terrain at 1024x1024 it gets REALLY nice shading no matter if it’s actually quite lowpoly.

Never tried to write a shader before so I thought I’d ask before getting started…

I thought I’d start with a single bumpmap, but would prefer to use multiple bumpmaps so I can tile them over large areas.

Yes, I realise this. I’ve got pretty complex (ie. expensive) lighting in my underwater scene: I’m using an animated cookie on a directional light to simulate caustic effects and the user’s vehicle has two spot lights they can direct into dark “caves”. I’m getting about 45 - 50 fps on my Macintel iMac at max resolution, which I’m guessing means a lesser machine would get half that framerate or less.

The public gets what the public wants: a two-layer bumpmapped terrain shader on Unify wiki. Enjoy!

20214--660--$twolayerterrainshot_118.jpg

:smile:

Well, thanks Aras! I cant wait to analyze it!

I love this forum.

Still trying to understand this. :slight_smile: The bump map buys you better shading than just vertex shading. I get that. But if the lights are static shouldn’t that all be baked into a lightmap?

Also, is a detail map cheaper than a bump map? Why would you prefer to use a bump map? Thoughts are appreciated.

Thanks
-Jon

WOW :!: Thanks :!:

For a start, yes, if the lighting is static, there’s (almost) no reason to use bumpmaps. There may be some reason to use them, if your terrain is really very-non-flat and bumpmap contains steep areas. In that case a “real bumpmap” will get proper lighting, whereas a baked texture, tiled over the terrain only approximates that (because the same texture is tiled over flat and steep terrain areas).

Yes, a detail map is cheaper. A lightmap is cheaper. Mostly because both don’t require using pixel lights, so you can just use vertex lighting.

So about the only reason is “correctness” (see above) or per-pixel effects such as light cookies and good looking small point lights near the terrain. In that case you need a pixel lighting shader; and a diffuse+bump is not much more expensive than just per pixel diffuse (a couple of instructions and one more texture to read).