PDA

View Full Version : dot3 weird problem , help needed !



Arashikage
05-23-2003, 02:24 AM
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).]

tfpsly
05-23-2003, 02:52 AM
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

Arashikage
05-23-2003, 03:14 AM
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 http://192.48.159.181/discussion_boards/ubb/frown.gif

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_PRE VIOUS_EXT);

which in mine is
GL_PRIMARY_COLOR

and for the scaling
which i use
R = 0.5 + x*0.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 http://192.48.159.181/discussion_boards/ubb/frown.gif

Thanks fr the response http://192.48.159.181/discussion_boards/ubb/smile.gif

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

Tom Nuydens
05-23-2003, 03:21 AM
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!

Arashikage
05-23-2003, 03:40 AM
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 http://192.48.159.181/discussion_boards/ubb/smile.gif

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

Tom Nuydens
05-23-2003, 04:14 AM
Looks okay... If you change unit 1 to GL_REPLACE, does your base texture show up correctly?

-- Tom

Arashikage
05-23-2003, 04:27 AM
Originally posted by Tom Nuydens:
Looks okay... If you change unit 1 to GL_REPLACE, does your base texture show up correctly?

-- Tom


Yes , and if i disable the texture unit 0 it appears correct too ( coloured and stuff..) http://192.48.159.181/discussion_boards/ubb/smile.gif

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).]

tfpsly
05-23-2003, 05:57 AM
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 ?

tfpsly
05-23-2003, 06:03 AM
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.

Arashikage
05-23-2003, 06:57 AM
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 http://192.48.159.181/discussion_boards/ubb/frown.gif

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) http://192.48.159.181/discussion_boards/ubb/smile.gif

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

V-man
05-23-2003, 07:06 AM
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.

Arashikage
05-23-2003, 03:16 PM
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 http://192.48.159.181/discussion_boards/ubb/frown.gif (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 !

Arashikage
05-25-2003, 12:12 PM
It works !
It works !!
Now it works !
http://192.48.159.181/discussion_boards/ubb/biggrin.gif

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
!!
http://192.48.159.181/discussion_boards/ubb/smile.gif

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