Skip to main content
GameDev.net gamedev.net
🔒 Locked

Procedural Detail Map generation - How to?

Started by 67rtyus Feb 9, 2009 at 9:55 AM 9 replies 3.3k views
Original Post
67rtyus
67rtyus
Hi; I have a big terrain which I want to cover with two textures: First is the coarse,low frequency ground texture. I procedurally create this by mixing grass,dirt,snow and rock textures at different ratios for different heights. This covers the whole terrain without tiling; so it gets extremely magnified and blurred. To add fine details to this blurred ground; I use a second,grayscale "detail map" texture. It gets tiled on the whole terrain to add high frequency information. What I am doing is common multitexturing, I just blend these two textures in the pixel shader. My problem here is, I just have one detail map, which I found on the internet long ago. Just like the ground texture, I need to generate this detail map procedurally,too. Normally, I generate heightmap images with the perlin noise algorithm. I tried to generate different detail maps with the perlin noise, using different parameters(frequency,amplitude,octave number) every time, but I could never obtain the desired image. Here is the detail map I am using at the moment: http://img15.imageshack.us/img15/9169/detailqd7.png So, my question is how can I procedurally generate similar detail maps? Which methods do you follow in your programs to add high frequency detail to the terrain? Thanks in advance.
MRTN
MRTN
You could try "Texture Bombing" (In the Orange Book its called Glyph Bombing).
With this technique you distribute a texture randomly over the surface ( and if you want you could scale and rotate the texture randomly, but this will cost some performance).
If you have not the orange book, you could find an Article with Texture-Bombing here:

http://http.developer.nvidia.com/GPUGems/gpugems_ch20.html

I hope this will help you out! :)
swiftcoder
swiftcoder
Straight perlin noise isn't going to cut the mustard, you need to mix a couple of noise generators. The plus to implementing this is that everything looks more natural with a mixture of noise types [smile]

For the cracked mud pattern in that texture, I would recommend a voronoi cell generator. For the larger, dark cracks a ridged multi-fractal ought to do the trick, and you can fill in the high frequency details with perlin noise.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
67rtyus
67rtyus
Well, actually I wanted to use normal mapping to add detail and lighting to my scene. Everything has worked fine until I realized that it wouldn't go along with my geomipmapped and geomorphed terrain: The TBN data bundled with the vertices just doesn't get interpolated and this results in abrupt lighting changes when the terrain LOD switches.

If I had a way to interpolate the TBN spaces between GeoMipMap levels, this would work me too and in a very good looking way.

So is there any way I can make the normal mapping and terrain geomipmapping compatible with each other?
swiftcoder
swiftcoder
Quote:
Original post by 67rtyus
Well, actually I wanted to use normal mapping to add detail and lighting to my scene. Everything has worked fine until I realized that it wouldn't go along with my geomipmapped and geomorphed terrain: The TBN data bundled with the vertices just doesn't get interpolated and this results in abrupt lighting changes when the terrain LOD switches.
I generate my terrain normal maps in object space (rather than tangent space), so the a TBN basis is unneeded. This seems to reduce popping due to LOD pretty well on its own.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
jpd
jpd
The best way i've found is while creating your texturemap from different height, create One Alpha (ARGB) map containing detail level for each detail mpa. , .Example:

In a BMP file.
A = % of grass
R = % of rock
G = % of sand
B = % of dirt.

Then, you load your 4 (small) detail map + your alpha + your terrain texture in DX.

In you shader you create a sampler for each texture.

you
ADDRESSU = WRAP;
ADDRESSV = WRAP;
your small detail map.

and
And in your pixel shader, you lerp each detail map by there respective alpha map.

lerp(CombiDetail, Sand, AlphaCombine.x);

you then Add-signed your detail map to your texture map. And you got a nicelly blended result. ( you can also multiply square the two texture, but you'll have a nicer result, but you'll see more tiling from distance).

you can see the result there
http://www.jpdoiron.com/map/

Let me know if that was not clear.

JP.

note: to save vertex shader processing, you can skip you detail calculation when you vertex if too far from your view.
67rtyus
67rtyus
swiftcoder:
Quote:
I generate my terrain normal maps in object space (rather than tangent space), so the a TBN basis is unneeded. This seems to reduce popping due to LOD pretty well on its own.


How do you do that exactly? In my case, I have a 512x512 seamless normal map texture and I cover the whole terrain with it, tiling the texture many times. The texture itself contains normals in texture space.

Do you embed the object space normals into a texture image,too ? If you do, how do you manage to embed the whole terrain surface's normal data into it? I mean, the terrain is usually supposed to be huge and a texture to contain its surface normals in terrain object space has to be excessively large. If a normal map texture of common sizes of 512x512 or 1024x1024 should be used instead, it would get streched so badly, that our purpose of adding high frequeny data to the terrain would diminish.

jpd:
I am afraid, I didn't completely understand that. Could you explain a little bit more? Or maybe a little bit of sample code?
jpd
jpd
I might also have misunderstood you,

You're talking about detail map , and also normal map. both are use for totally different objective.

Normal map will be used with your light to generate "shadow" detail where you dont have, It gives the impression of detail, that move with your light and view vector.

Detail map in the simplest way of adding noise to a texture map, It also give the impression of a much more detail texture, but without light, view calculation.

For what i've read in to your description, your trying to have different detail over your big texture, grass, rock.. but only have one detail map.

If this is the case, forget about the normal map, and look into texture spatting
http://www.gamedev.net/community/forums/topic.asp?topic_id=372098
http://www.gamedev.net/reference/articles/article2238.asp

And save you some time, dont generate you detail map, find them on the net.

hope this helped.

jpd
swiftcoder
swiftcoder
Quote:
Original post by 67rtyus
swiftcoder:
Quote:
I generate my terrain normal maps in object space (rather than tangent space), so the a TBN basis is unneeded. This seems to reduce popping due to LOD pretty well on its own.
How do you do that exactly? In my case, I have a 512x512 seamless normal map texture and I cover the whole terrain with it, tiling the texture many times. The texture itself contains normals in texture space.
No, I don't tile the normal map - it is unique for every terrain tile.
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]
67rtyus
67rtyus
Quote:
No, I don't tile the normal map - it is unique for every terrain tile.


OK; but doesn't a unique normal map for every terrain tile cause a very high memory consumption? For example my 1025x1025 terrain consists of 256 65x65 tiles. This means 256 seperate textures for every terrain node. How do you manage the memory management of this system? Can you give more details about this?
swiftcoder
swiftcoder
Quote:
Original post by 67rtyus
Quote:
No, I don't tile the normal map - it is unique for every terrain tile.
OK; but doesn't a unique normal map for every terrain tile cause a very high memory consumption? For example my 1025x1025 terrain consists of 256 65x65 tiles. This means 256 seperate textures for every terrain node. How do you manage the memory management of this system? Can you give more details about this?
Well, if you want globally unique terrain, you can't have a lower density of normals than you have vertices, so your normal map must be at least the same resolution as the vertices. And to make any actual gains from a normal map, you need it to be higher resolution than your vertices - a minimum of 2x.

So for your 1025x1025 terrain, your minimal normal map is 2048x2048, but you will likely want to go higher. And of course, a 1025x1025 terrain with a 2048x2048 normal map, is much cheaper to render than a 2048x2048 terrain.

In general, my normal maps are 4x the vertex resolution. My terrain is streamed in in chunks, to keep only visible patches in memory, and LOD is applied (lower resolution vertices and normal maps in the distance).
Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.