dot3 weird problem , help needed !

Hello OpenGl fellas , sorry to disturb you , but i have the most wierd problem wih dot3 bump mapping. Here it is :

1-My dot3 bump code wasn´t working properly, it was showing the scenes in grayscale…but bumpmapped(i wasn´t using grayscale images for this )

2-For debugging purpose, i got the Radeon simple bump example,and ran it in my computer,it worked ok

3-I changed my Render code to one similar to the Radeon example(with inverse modelview matrix multiplication instead of the binormal and tangente vectors code, for calculating tangent space) and this weird thing happened: when dot3 is enabled nothing is rendered, i got one blank screen …
so i changed the (N.L) unit texture to the base map , instead of the normal map , and i got the grayscale scene that was happening before.
When i disable the N.L texture unit , the base map appears ok,the light vector also appears correct as in the ATI demo,and the normal map alone also appear correct as in the demo.
When i change the GL_PRIMARY_COLOR_EXT in

glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT);

for other constants like GL_TEXTURE , the scene appears(not with the correct bump mapping of course,but the blank screen problem fades)

4-In a desperate moment i simply copy and paste the ATI example render code …nothing …same blank screen

so , do you guys have any idea of what may be going on ?
I´m using the TGA files that come with the radeon demo,i also used .bmp version of them

I´m using a GF4 Ti 4600,and all the extensions needed are supported

Thanks in advance, sorry for the giant post
it´s just that i can´t figure what´s happening

Thank you once more

[This message has been edited by Arashikage (edited 05-23-2003).]

  1. Copy&Pasting code you don’t understand is a very bad idea. In fact, I think copying code is always a bad idea as you’d better write your own code as you’ll be sure it does what you want it to do.

  2. Read http://tfpsly.planet-d.net/english/3d/pplight_bump.html or any other doc about dot3 bump mapping

I know that copy and paste is the worst solution possible, i did that only to see if things would work,but they didn´t

The code in your page is very similar to mine (the one that shows bumpmapping but in grayscale) except for

glTexEnvi(GL_TEXTURE_ENV,GL_SOURCE0_RGB_EXT,GL_PREVIOUS_EXT);

which in mine is
GL_PRIMARY_COLOR

and for the scaling
which i use
R = 0.5 + x0.5
G = 0.5 + y
0.5
B = 0.5 + z*0.5

i changed to yours , again in my cde is grayscale , but clearer

Thanks fr the response

P.S
there´s something wierd with your page , you put the where "i can get normal maps " section 2 times

Sounds like your base texture is being ignored. Can you post your complete texture env. combine setup (for all texture units)? Also don’t forget to mention which textures are bound to which units.

– Tom

PS: glGetError() is your friend!

Tom :
here is my texture unit setup

//unit0****
/* dot product between N (the normal map) and L(PRIMARY_COLOR_EXT)./
//
***************************************
glActiveTexture(GL_TEXTURE0_ARB);

     glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
     glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB_EXT); 
  
     glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_TEXTURE);
     glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
     glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_PRIMARY_COLOR_EXT);
     glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);

glBindTexture (GL_TEXTURE_2D,BumpTex);
glEnable(GL_TEXTURE_2D);

//unit1*********
// modulates the base texture
//****************************************

     glActiveTexture(GL_TEXTURE1_ARB);
    
     
     glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
     glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);

     glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PREVIOUS_EXT);
     glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
     glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
     glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);

glBindTexture (GL_TEXTURE_2D,BaseTex);
glEnable(GL_TEXTURE_2D);

Thanks

[This message has been edited by Arashikage (edited 05-23-2003).]

Looks okay… If you change unit 1 to GL_REPLACE, does your base texture show up correctly?

– Tom

Originally posted by Tom Nuydens:
[b]Looks okay… If you change unit 1 to GL_REPLACE, does your base texture show up correctly?

– Tom[/b]

Yes , and if i disable the texture unit 0 it appears correct too ( coloured and stuff…)

The most weird thing is that , when i use the base texture as bump ,i got no more a blank screen , but a grayscale bump.
The other things , like rendering the L vector as texture and the the normal map only works perfecly …

This makes me wonder …( i never saw that …but…)
Do i need a special loading fucntion for loading normal maps ?? or i can use the same for normal maps and base texture ?

Thanks once more
sorry for bothering

[This message has been edited by Arashikage (edited 05-23-2003).]

Originally posted by Arashikage:
there´s something wierd with your page , you put the where "i can get normal maps " section 2 times

True, thanks. Did I just say copy/pasting was bad ?

Originally posted by Arashikage:
Do i need a special loading fucntion for loading normal maps ?? or i can use the same for normal maps and base texture ?

Nop. If your normal map was properly created, it is ready to be used like any other texture.

Hey Tom i noticed that in the second texture , even if i use GL_REPLACE the screen gets blank when the bump texture is binded …

now it´s even weirder …GL_REPLACE is giving me the same result as GL_MODULATE …

I´ll check if there´s an error while trying to generate mipmaps or something for normal maps …
i changed the textures(once more for the some that came with the demo) …same result

Thank you all for attention.

Be welcome tfpsly …your page is one the best in that subject (probably the most clear explanation on D3 bumpmapping)

[This message has been edited by Arashikage (edited 05-23-2003).]

Originally posted by tfpsly:
Nop. If your normal map was properly created, it is ready to be used like any other texture.

But you shouldn’t let the hardware do the mipmapping for you and you can’t use gluBuild2DMipmaps. I have a function that deals with this but I haven’t uploaded the new version.

Also, the combiner code looks fine except that the alpha channel is not dealt with and if you have blending enabled, you might have trouble.

If both textures are valid, then it should be OK. I think you can try the glIsATexture function to check.

Debugging my code, i found out that the blank screen when bumps were used , were due to the vertexcolor , that received too low values.
still it’s not working properly,because although now i can get a bump, is still in greyscale (now for both render codes)
could this be happening due to the modelview and projection matrices ?

tfpsly : the resulting i´m getting is practically identical to the ones in your page in which you used lightmaps instead of normal maps. Any ideas ?

Thank you guys !

It works !
It works !!
Now it works !

I start debugging my own tangent trasformation , and texture unit setup , and now everything works

Tom : you were correct it was a problem with the second texture unit , it was beeing ignored…

Thank you all that replied in this forum and helped ,
thks alot
!!

[This message has been edited by Arashikage (edited 05-25-2003).]