PDA

View Full Version : Simple BumpMapping Question



azcoder
05-28-2004, 03:26 PM
Does BumpMapping add significant overhead? I am thinking about adding it to my Quadtree Terrain engine, but I am worried that it might slow things down too much...

Thanks in advance for any input...

JanHH
05-28-2004, 04:09 PM
I just added bump mapping to my terrain engine, so I might give you some hints.

- the improvement in visual quality is dramatic, so it is really worth the effort. In my engine, the terrain has a rather low resolution color texture, combined with a very fine bump texture, and it looks really great and much more realistic than with only the color texture

- performance loss mainly depends on two things: a) which hardware you are using and b) if only diffuse bump mapping is sufficient or if you also need specular lighting.

Afaik, on ATI hardware using pixel shaders (fragment programs) is as fast as using fixed function pipeline, so bump mapping would not cause any performance loss at all (at least, if you use diffuse bump mapping only).

My program is running on nvidia hardware and there, using NV_fragment_program with low precision registers causes a slight slowdown (~5-10 %) when using diffuse bump mapping only, and quite a lot (~30-50 %) when also rendering specular highlights. So I decided to use only diffuse, and performance can also be improved by using bump mapping only for the parts of the scene that are near enough for the viewer to acutally see the bumps.. for the other parts of the scene, you obviously do not need bump mapping. So when only drawing the ground, no objects, trees, water or sky, performance of my program went down to ~180 from ~200 fps.

Jan

MrShoe
05-28-2004, 04:22 PM
Hi, can you maybe post a screenshot? Because Im kinda thinking about using a detail bump map in combination with texture splatting, but Im not sure how the bump mapping would turn out, since I always thought youd need movement between the object and light source for the best results for bump mapping, otherwise you dont get as much of a sense of bumpiness :-)

mogumbo
05-28-2004, 06:16 PM
The worst case scenario for bump mapping is when you have a bump map tiled on a flat surface under an infinite light source. Under those conditions, the lighting from the bump map looks perfectly tiled just like a regular texture. It makes it so that you have to move the light around to get a good sense of bumpiness.

The addition of per-pixel specular to the same scene will break up the repetition in the lighting and make the bumps more visible. What helps even more is to use a local light source, but you can't usually do that in outdoor scenes.

Christian Schüler
05-29-2004, 02:42 AM
I would second that. Under a directional light, a bump map reduces about to a standard grayscale detail texture that you would GL_MODULATE or GL_ADD_SIGNED.

knackered
05-29-2004, 03:34 AM
Oh yes, terrain always looks shiny to me. Deffo worth per pixel lighting. Use a static light map texture.

JanHH
05-29-2004, 05:43 AM
screenshots, they are a little outdated and there still is a bug in the program, but you can see how the bumps enhance the visual quality:

http://de.geocities.com/westphj2003/scene1.jpg
http://de.geocities.com/westphj2003/scene2.jpg
http://de.geocities.com/westphj2003/scene6.jpg
http://de.geocities.com/westphj2003/scene8.jpg

it the links don't seem to work, simply re-type them in the browser's url field and hit enter, for strange reasons, they don't work when clicked on, but do so after hitting enter in the url field.

It is true that the bump effect degenrates to something you could theoretically also do with a light map when only having one static directional light source, but it is still a great improvement.. simply due to adding a fine granularity to the terrain.

edit:

I just added some acual screenshots:

http://de.geocities.com/westphj2003/a.jpg
http://de.geocities.com/westphj2003/b.jpg
http://de.geocities.com/westphj2003/c.jpg
http://de.geocities.com/westphj2003/d.jpg

knackered
05-30-2004, 12:43 PM
but it is still a great improvement.. simply due to adding a fine granularity to the terrain.So what you're saying is that using tangent space per pixel lighting, you get better resolution because you're using a small normal map locally rather than a large precalculated light map.
It's a valid point.

JanHH
05-30-2004, 04:55 PM
Yes, I guess that is what I mean. During the project, we made the experience (in fact, we knew before) that the design aspect of a terrain simulation is lot more effort than the programming work.. and combinig a large color texture with a finer bump or color texture is a very efficient way to make things look more natural. We did this with simple multitexturing before, to make a tiled color texture look less repetative and monotonous by adding another one, and doing this with a bump map is giving even much better results. Did you look at the screenshots? I think the effect is self-explanatory.

zed
05-30-2004, 08:23 PM
<http://uk.geocities.com/sloppyturds/zed.html is bugger the large color texture and just go for multiple detailed textures (blended together, splatted) its what im doing at the bottom of this page http://uk.geocities.com/sloppyturds/zed.html hmmm looking at it there it doesnt look as good as large color + detail but believe me it is 'in the flesh' the downside is though u idealy need more powerful hardware.
azcoder - dont worry about it slowing down, that is the least of your concerns, the visual benifits of bumpmapping are huge.

Ninja
06-01-2004, 02:37 AM
So the best result is to use both diffuse texture, a detail texture and a bumpmap?
Or do u use the bumpmap instead of the detail map? Can you create the bumpmap texture from the detail map?

Regards, Ninja

knackered
06-01-2004, 05:57 AM
Following on from my previous comment...
The tangent space bump mapping only breaks up the repetitiveness of the normal map if there is variation in the angle of each surface it's applied to...in a terrain, you'll get large areas of flatness, which combined with an infinite light give you ugly tiling. So, the bump map is not useful in those circumstances.
I'm finding it difficult to envisage a situation where normal mapping would enhance the terrain, parallax mapping maybe, but plain old dot3 diffuse is not going to give you any advantage over a static light map. Your screenshots could just as easily be of a lightmap than a normal map.

JanHH
06-01-2004, 07:43 AM
knackered, I doubt what you are saying, my experience is that adding a bump map enhances the quality very much, it does not look tiled and could not be achieved by adding a simple second color-/lightmap.

zed
06-01-2004, 09:10 PM
'The tangent space bump mapping only breaks up the repetitiveness of the normal map if there is variation in the angle of each surface it's applied to...in a terrain, you'll get large areas of flatness, which combined with an infinite light give you ugly tiling.'

i believe youre mentioning two different types of terrain bumpmaps
A/ a large one (simulating opengl per vertex lighting, but with greater resolution)
B/ detailmap bumpmapping

now im sure everyone agrees A/ is a good thing and looks great (of course if the terrain is 100% flat its not gonna enhance it at allthough)
B/ can lead to tiling esp if u use just the one bumpmap texture throughout (unless u get rid of the high frequency crap in the texture, which tends to nullify the whole effect).
thus a good method is to blend multiple bumpmaps together thus getting rid of the tiling effect

'I'm finding it difficult to envisage a situation where normal mapping would enhance the terrain, parallax mapping maybe, but plain old dot3 diffuse is not going to give you any advantage over a static light map. Your screenshots could just as easily be of a lightmap than a normal map'

a bit diffucult to simulate the sun moving with a lightmap.

faceit bumpmapping is prolly the single biggest thing to hit computergraphics in the last 30 years (bar hardware acceleration)

knackered
06-01-2004, 10:56 PM
Mmm, why would simulating the sun moving be of concern in a game? Even if I agreed that a moving sun is worth millions of dot products per frame, the speed the sun moves would give many many frames in which to recalculate a lightmap.
No argument about bump mapping being revolutionary...but really only for geometry reduction, not for replacing stuff that ain't broke.

JanHH
06-02-2004, 04:01 AM
what about this aspect: I added bump mapping (detail), and it looks much better now. Isn't this proof enough?

knackered
06-02-2004, 05:22 AM
I've looked at your screenshots Jan, and I must repeat my earlier observation - it could have been done with a detail light map.

ZbuffeR
06-02-2004, 07:48 AM
May I add something ?

Originally posted by knackered:
- it could have been done with a detail light map.Yes. Of course. But this detail lightmap would have been a super huge resolution. Just look at http://de.geocities.com/westphj2003/b.jpg you will see that the bump map is quite small and tiled a lot over the terrain. A detail light map would only be effective for a totally flat terrain.

vincoof
06-02-2004, 09:19 AM
Even though I love bump mapping and I recommend it for pretty everything at this board, I have to admit it's not my favourite shading for terrain rendering.
Bump mapping could really improve terrain rendering if used in conjunction with horizon mapping or virtual displacement mapping but this will kill both memory usage and performance. Without such advanced bump mapping techniques, you will merely not make the difference between a detail map and bump map since terrain normals have a priviliged direction. And detail mapping is supported on much wider range of hardware, plus is rendered much faster and uses less texture memory (greyscale image instead of RGB-encoded normal maps) and wastes less texture units than bump mapping.

Real-time moving sun isn't a problem either. Sun movement (yes I know the Sun does not move, the Earth rotates around itself) is so slow that it is negligible to move bumps in realtime when the sun moves.

As a last note, I can't stand how http://de.geocities.com/westphj2003/b.jpg shows the efficiency of bump maps. This picture is a combination of two maps : a low-frequency map (colormap or lightmap) and a high-frequency map (the bump map). The same thing could just happen with detail map replacing the bump map.

JanHH
06-02-2004, 09:54 AM
Please note that the terrain is not very flat at certain spots, and also, bump mapping will take the light vector into concern, what a detail color map will not do.. lighting can quite easily be replaced by point lights (for example, car lights) and the of course the bump mapping will take advantage. And even if it can also be done with a color map, it can still be done with bump mapping, which will not cost very much performance. And of course the idea is to add specular lighting later (with faster hardware ;) ) and probably create a night scene with some point lights.

edit:

added some screenshots from a different scene which is not as flat, maybe they are more convincing.

http://de.geocities.com/westphj2003/e.jpg
http://de.geocities.com/westphj2003/f.jpg
http://de.geocities.com/westphj2003/g.jpg
http://de.geocities.com/westphj2003/h.jpg
http://de.geocities.com/westphj2003/i.jpg

ZbuffeR
06-02-2004, 10:13 AM
@vincoof : I guess I did not made myself clear. My point was to show that given this bump map resolution, to have an equivalent lightmap for the whole non-flat terrain would need a super high resolution.
As you can see on some of the earlier shots, there is no way to just tile a lightmap of the same resoluion as the bumpmap and hope to get the same effect.

vincoof
06-02-2004, 12:33 PM
@JanHH : I agree that specular lighting makes the difference between (static) lightmaps and (dynamic) bumpmaps. However, you're not likely to generate a specular map for a whole terrain. It's already a hard task to make a diffuse map for a large area.

@ZbuffeR : Because normals over a terrain are pretty similar, it is not a great loss to approximate overall lighting with some tiled texture built for an "average" normal direction. In essence, 3D objects like characters or vehicles can't be reasonably approximated by such "overall normal" vectors, but terrains can (especially digital elevation models, i.e. terrains without overhangs).

JustHanging
06-03-2004, 02:23 AM
I'd also choose detail color textures over bumpmaps for terrains. As it's been pointed out, you can achieve almost the same result with them. You can also add color variations to your detail, which you can't do with bump maps. Besides, while blending several color textures together is fast and easy, you can't really say the same about bumpmaps.

It's also worth noting, that while it's easy to extract color textures from photographs, it's very difficult to get bumpmaps from them. This will make a huge difference if you're trying to create something realistic, creating realistic stuff with the current per-pixel lighting standard is a rare skill.

-Ilkka

Korval
06-03-2004, 11:35 AM
As a last note, I can't stand how http://de.geocities.com/westphj2003/b.jpg shows the efficiency of bump maps. This picture is a combination of two maps : a low-frequency map (colormap or lightmap) and a high-frequency map (the bump map). The same thing could just happen with detail map replacing the bump map.Except for 2 things.

1: I don't have to write any code to get sun movement to work perfectly.

2: If I later decide to add additional lights, I don't have to do anything except use the bump map I already have to do more lighting computations.

The bump map approach is, not only the more physically correct solution, it is also the more general one. It works, 100% of the time, with no external hacks, for anything I want the terrain to do. Sure, I have to add a few more opcodes to the fragment program, but I can definately live with that.

plasmonster
06-03-2004, 01:55 PM
I'd put a check in the bump mapping column as well. Why would you make the distinction between the terrain and a wall in a dungeon? They will both benefit from bump mapping, and for the same reasons. If you are limiting the the terrain to only one static directional light, it's not going to be very interesting, IMHO.

JanHH
06-03-2004, 03:16 PM
It seems that this discussion became a little hair splitting (is this the correct word for it?).. I simply said "we added bump mapping and it looks much better than without". I did not say that bump mapping is better or an alternative to a color detail map (in fact, my engine offers the possibility to add a second color map), it is simply a good thing to have. Even if it is in the engine, you still do not have to use it if you don't like it, and it does not cost any performance at all (a *little* bit but as there are other things in the scene, such as buildings, trees and sky, it is negletable).

And I still think that it is a very easy way to get the terrain to look more realistically "rough" with such simple means (simply adding two textures, both of which were not taken very much care of, in fact both were automatically generated without much love and affection). Also, the way the bumps interact with the terrain at rather steep parts give a very interesting, quite realisticlook which can certainly not be acquired with a color detail map, at least not without a lot more work.

To make clear what I am talking about, I have drawn red boxes around the parts of the picture that show the effect that I am talking about. Pls have a look:

http://de.geocities.com/westphj2003/red1.jpg
http://de.geocities.com/westphj2003/red2.jpg
http://de.geocities.com/westphj2003/red3.jpg

Regards,
Jan

vincoof
06-03-2004, 03:34 PM
The bump map approach is, not only the more physically correct solution, it is also the more general one.If you consider computing a real tiled lightmap for the decal texture, lighting model can be much more advanced that a simple dot product bump mapping provides.


Sure, I have to add a few more opcodes to the fragment program, but I can definately live with that.Not to mention performance issues, you're limited to the number of lights.
Actually it's pretty easy to setup bump mapping for one light on almost every hardware since GeForce 1, but when it comes to deal with more lights things get much harder and slower, when it even works (you'll hit the shader limits if you consider too many lights casting bump mapping).


Why would you make the distinction between the terrain and a wall in a dungeon?Because you can approximate terrain lighting with a decal map with almost no loss. Dungeon can't be approximated with such lighting because normals vary too much. And while you point that terrain lighting and dungeon lighting will differ too much, I invite you to test it by yourself.


It seems that this discussion became a little hair splitting (is this the correct word for it?).. I simply said "we added bump mapping and it looks much better than without". I did not say that bump mapping is better or an alternative to a color detail map (in fact, my engine offers the possibility to add a second color map), it is simply a good thing to have.couldn't agree more about the 'best solution' debate.
I'm not telling you never to use bump mapping for terrains. As I stated above, there are some cases where bump mapping will be better. I just tend to recommend decals which IMHO look very similar to bump mapping (sometimes better, sometimes worse, depending on the desired effect) but are much easier to use and renders much faster than bump mapping.

Korval
06-03-2004, 05:02 PM
If you consider computing a real tiled lightmap for the decal texture, lighting model can be much more advanced that a simple dot product bump mapping provides.But, again, only for one light. I would prefer to have 2-3 dynamic lights possible than 1 light that looks better, but requires a lot of engine code in order to make the sun move.


Not to mention performance issues, you're limited to the number of lights.At least they are dynamic lights, rather than static ones.

Besides, generating a bump map is easy/trivial. Just do some fractal height generation on your terrain, and read back the normals.

plasmonster
06-03-2004, 05:29 PM
Because you can approximate terrain lighting with a decal map with almost no loss.
Perhaps this is true with a single static light, but not for multiple dynamic lights, which was my complete thought. If you're looking for a uniform lighting model, decals are not going to give you the most consistent results, IMO.



And while you point that terrain lighting and dungeon lighting will differ too much, I invite you to test it by yourself.
I've been using decals, and countless other hacks on my terrain for the last 4 years. Now that bump mapping is practical, I am going to use it. :cool:

vincoof
06-03-2004, 11:42 PM
But, again, only for one light. I would prefer to have 2-3 dynamic lights possible than 1 light that looks better, but requires a lot of engine code in order to make the sun move.And, again, it's just a matter of preference :)
It depends on your willing/ability to integrate per-pixel lighting in your engine, on your willing/ability to render fast on every hardware, it also depends on the world context. Many games don't move the sun for instance.


If you're looking for a uniform lighting model, decals are not going to give you the most consistent results, IMO.Do you know of any engine that ensures uniform lighting across terrain and objects ? Even the "I-can-do-everything" Unreal Engine 3.0 seems to use different rendering paths for objects and terrains.


I've been using decals, and countless other hacks on my terrain for the last 4 yearsNot to start a troll, but please stop reasoning with "hacks". Everything is a hack in computer graphics.

JanHH
06-04-2004, 04:23 AM
vincoof: If you want to use a light map with such a fine granularity as the bump map in my screenshots for a terrain with a size of 2000 x 2000 m, how large should that be?

I am NOT using a bump map which is computed from the terrain data in a sophisticated way, it is in fact a simple color texture showing grass converted to a bump map with the gimp plugin to make the ground look more rough. As I said, much gain for only a little work.

in terms of lighting models in general, I think neither bump mapping nor lightmaps are the best solution (again, lightmaps have to be very high resolution, or there have to be quite a lot of them), we decided to add perspective shadow mapping, I think this will be much better ;) . Pixel perfect shadows that do not only appear on the ground, but offer a realistic shadows of all things in the scene on all other things in the scene.

Performance is not really an issue I think, as our current rendering engines run smooth on our current hardware, and next generation hardware is *much* faster, so we can add fancy things and it will still run fast enough.

The best I can imagine at the moment would be ppl/bump mapping implemented as deffered shading, combined with a perspective shadow map for each light source, although I don't know if that is even possible on current hardware, but that's what I am looking forward to for my engine.

vincoof
06-04-2004, 08:05 AM
Originally posted by JanHH:
vincoof: If you want to use a light map with such a fine granularity as the bump map in my screenshots for a terrain with a size of 2000 x 2000 m, how large should that be?Something like 256x256 :)
I mean tiled lightmap of course, that is a decal map. Sorry, I agree the 'lightmap' term is too confusing in this case.

plasmonster
06-04-2004, 12:37 PM
Do you know of any engine that ensures uniform lighting across terrain and objects ?
Yeah, mine. :cool:



Not to start a troll, but please stop reasoning with "hacks". Everything is a hack in computer graphics.
Thanks buddy, I'll try to keep that in mind. But I think it was clear from the context that the term "hack" was in reference to the approximation of bump mapping.

JanHH
06-04-2004, 04:27 PM
Our old Opengl 1.1 1997 engine has uniform lighting for everything ;) and among the more advanced things, doom3 comes to my mind, although it does not really display terrains.

Chuck0
06-04-2004, 04:42 PM
just a little idea i (and certainly others) had just reading this thread... what about using 2 detail maps where the texture coordinates for one of them is perturbed (a little bit) by the vertex normal? this would certainly remove some of the repetition a simple detail map causes and wont be as expensive as bumpmapping... :)

vincoof
06-05-2004, 12:34 AM
Originally posted by Chuck0:
just a little idea i (and certainly others) had just reading this thread... what about using 2 detail maps where the texture coordinates for one of them is perturbed (a little bit) by the vertex normal? this would certainly remove some of the repetition a simple detail map causes and wont be as expensive as bumpmapping... :) Please don't tell us you want to introduce emboss bump mapping :)

Chuck0
06-05-2004, 04:09 AM
arg i knew that there was already a technique like that (just forgot the name :) )