depth texture about shadow mapping

Started by
-1 comments, last by CNBABY 18 years, 10 months ago
for shadow mapping,i creat a depth texture by glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,0,0,256,256,0); I set my depth texture as luminance . I am confused the texture format (especially luminance, intensity ,lunminance_alpha ). I don’t know what mapping a luminance texture could result. I just want to generate black shadow , I find using a luminance texture could not achieve it . How do I operate this texture ,if I want to make R=L,G=L,B=L. a texel have four components of R,G,B,A. A luminance texture,store the luminance value at R. but I directly stick my depth texture at a rectangle,it is blue(faint!),the color just like the cry expression chosen by me. originally,i intend to add my snapshot there,but i don't know how to do?sorry. if you are good at opengl,please help me to check the code: 1.This is my depth texture Parameter setting code: glGenTextures( 1,&g_depthTexture2 ); glBindTexture( GL_TEXTURE_2D, g_depthTexture2 ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexParameterf( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB,GL_LUMINANCE); glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_COMPARE_MODE_ARB,GL_COMPARE_R_TO_TEXTURE_ARB ); glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); //Ps. It is very strange, when I throw off the last three lines ,the result is same as before. So I am crazy…………haha! 2.This is my depth texture generation code: // after render scene from light view glBindTexture(GL_TEXTURE_2D, g_depthTexture2); glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,0,0,256,256,0); 3.This is my render scene from camera view code, in the mean time, I will finish the compare glEnable( GL_TEXTURE_GEN_S ); glEnable( GL_TEXTURE_GEN_T ); glEnable( GL_TEXTURE_GEN_R ); glEnable( GL_TEXTURE_GEN_Q ); //****************************// glMatrixMode( GL_TEXTURE ); glLoadIdentity(); glTranslatef( 0.5f, 0.5f, 0.0f ); // Offset glScalef( 0.5f, 0.5f, 0.0f ); // Bias gluPerspective( 45.0f, 1024.0f / 768.0f, 0.1f, 100.0f); // light frustum glMultMatrixf( g_lightsLookAtMatrix ); // Light matrix8 //****************************// glEnable( GL_TEXTURE_2D ); glEnable( GL_LIGHTING ); glBindTexture( GL_TEXTURE_2D, g_depthTexture2 ); renderScene(); //*********************************************// glDisable( GL_TEXTURE_2D ); glDisable( GL_TEXTURE_GEN_S ); glDisable( GL_TEXTURE_GEN_T ); glDisable( GL_TEXTURE_GEN_R ); glDisable( GL_TEXTURE_GEN_Q ); glDisable( GL_LIGHTING); thanks for any help!

This topic is closed to new replies.

Advertisement