PDA

View Full Version : Multiple Bump Maps on one surface?



Swiftless
05-13-2006, 12:06 AM
Hi,

I have my basic bump mapping, mapped to my current surface with the following code:


glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTexture(GL_TEXTURE0);
glActiveTextureARB(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_CUBE_MAP);
glBindTexture(GL_TEXTURE_CUBE_MAP, normalization_cube_map);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE);
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoordsNorm );
glTexCoordPointer( 3, GL_FLOAT, 0, (char *) NULL );

glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTexture(GL_TEXTURE1);
glActiveTextureARB(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture[tGNormalMap]);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB) ;
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS) ;
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE) ;
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoordsGround );
glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL );
This works fine, but I now want to add a 'sub texture' to the surface.

I have multitexturing (obviously), so I also have a detail texture which goes over my base texture which is modulated over this current bump map.

I want to be able to add bump mapping to the detail texture and still have the original bump mapping intact.

Is this possible? If so, how would I go about it?

sqrt[-1]
05-13-2006, 01:37 AM
I would probably use a shader to do the combining.(it may be possible in texture stages, but much more difficult to get it looking nice)

Humus has a demo that does just that:
http://www.humus.ca/index.php?page=3D&ID=49
It is in D3D but the shader code should be esay to understand.

Swiftless
05-13-2006, 02:16 AM
Up until now I have never used a shader, as I want my program to be as compatible as possible with older cards.

I shall have a look into shaders, but if anyone can tell me how to do it without shaders, I would be very grateful.

CrazyButcher
05-13-2006, 02:58 AM
add_signed in the combiner might work, however it would need a very subtle detail normalmap, else you will destroy too much of the original.

so you might want to change the texture data of the detail normal map, in a fashion that the normals are short in length.
In all cases you loose the normalized length of the combine normal map, which will create issues with lighting intensity. And you cant renormalize it with regular combiners.

Swiftless
05-13-2006, 06:05 AM
Yes, I have it working now and I know exactly what you mean. The original bump map is now darkening everything extremely.. A bit of tweaking to my normal maps and I should have it as good as ever :D

Thanks for your help.

*Acctually, the problem is not within the normals maps, it appears to be something to do with my Texture environment settings... I will get back to you if I cannot find the correct settings...

skynet
05-13-2006, 11:08 AM
Another tip: If you want visually pleasing results, dont just average the base normalmap and the detail normalmap. You´ll get "muddy" results. Instead, look at the detail normalmap as detail that is added ontop of the base normalmap. (imagine a sphere-shaped normalmap that you want to add bumps and indents to make is look like an orange).
So, you first have to transform the detail normal vector into the space of the base normal. Then add both, then renormalize. Works beautifully :)

Swiftless
05-14-2006, 04:36 PM
I have been working off the sample code found on NeHe for this so I would not know how to


transform the detail normal vector into the space of the base normal. Then add both, then renormalize
But I have adjusted the normalization cube map and have got it looking pretty alright at the moment. A big improvement on how it used to look without the detail bump map :D

skynet
05-14-2006, 05:14 PM
This is most probably not possible with texture combiners. But offline or with the help of a fragment shader, it can be done easily.

Swiftless
05-14-2006, 09:31 PM
But I have done it already? Sure I haven't gotten a perfect result, but a little more tweaking to my normal maps and it should be fine.

Swiftless
05-16-2006, 03:57 AM
Ok, I was happy with the two bump maps on one surface, and until I get into relief mapping, I now want three bump maps on one surface.

The only problem with this is that when I try doing what I did before, with another texture, it decided it wants to go black and white... The bump mapping itself is working, but I have lost all color in my image.

It appears as though any texture overand including GL_TEXTURE4 doesn't want to show.

Is it possible that my graphics card supports no more than 4 textures per surface? I am using a GF 5900XT 128mb.

*EDIT*

I go back to 4 textures and it works fine. But now I cannot get the result I wanted.

I want to map the same texture once scaled to 10, and another time scaled to 100 so that I can get different detail effects on my surface, am I able to do this in a single GL_TEXTURE and have both, or do I have to do two seperate, one for the 10 times scale, and another for the 100 times scale?

zed
05-16-2006, 04:12 AM
short note, what u want is very difficult, as u want the detail bumpmap to 'be orientated' with the underlying bumpmap. the only easy way is to not use bumpmaps but to store the heights instead and then just add the main height + detailheight together + create a normal from that in a shader.
though for all intents and purposes doing the way u are wont even though its wrong wont be to easily detected

CrazyButcher
05-16-2006, 04:26 AM
you will have more texture image units available if you use fragment shaders/programs