Skip to main content
gamedev.net
🔒 Locked 🎯 Unreal

Shadow mapping

Started by glmisscelan Feb 27, 2007 at 2:35 PM 0 replies 550+ views
Original Post
glmisscelan
glmisscelan
Hi, Im having some problems implemeting shadow maps. Im using quake3 map for my levels. I have shadow map working for simple escenes, rendering without glTexPointer and glDrawElements, so i supose that mi problem is passing the texture coords with this procs. Here is the code from the fixed pipeline. gl_sl_generate_shadow_map(); //proc generate shadow map glUniform1iARB(glGetUniformLocationARB(glsl_get_program(), "texture1"), 1); //initializing pointers glVertexPointer(3, GL_FLOAT, sizeof(tBSPVertex), &(BSPVertex[0].vPosition)); //vertex coords glClientActiveTextureARB(GL_TEXTURE0_ARB); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(tBSPVertex), &(BSPVertex[0].vLightmapCoord)); //lightmpap coord it be overwritten by shader glClientActiveTextureARB(GL_TEXTURE1_ARB); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glTexCoordPointer(2, GL_FLOAT, sizeof(tBSPVertex), &(BSPVertex[0].vTextureCoord)); //texture coords glEnableClientState( GL_VERTEX_ARRAY ); //here the code to seaching and optimizin area for bsp maps . . . //rendering actual face glActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, all_textures[pFace->textureID]); glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, gl_sl_get_shadow_map()); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_INTENSITY); glMatrixMode(GL_TEXTURE); glLoadIdentity(); glTranslatef(0.5, 0.5, 0.5); glScalef(0.5, 0.5, 0.5); gluPerspective(70.0f, conf_get_scr(SCR_WD)/conf_get_scr(SCR_HG), 10.0f, 250.0f); gluLookAt( 30, 0, 80, 30.0f, 0.0, 0.0f, 0.0f, 1.0f, 0.0f); glMatrixMode(GL_MODELVIEW); glDrawArrays(GL_TRIANGLE_FAN, pFace->vertexIndex, pFace->numOfVerts); //disble all states . . . // Here is the code from the shaders //vert varying vec4 ProjShadow; void main(void) { ProjShadow = gl_TextureMatrix[0] * gl_Vertex; gl_TexCoord[1] = gl_MultiTexCoord1; gl_Position = ftransform(); } //frag uniform sampler2DShadow ShadowMap; varying vec4 ProjShadow; uniform sampler2D texture0; uniform sampler2D texture1; void main (void) { gl_FragColor = texture2D(texture1, vec2(gl_TexCoord[1])) * shadow2DProj(ShadowMap, ProjShadow).r; } screenshot. http://img118.imageshack.us/img118/9771/cubwinci4.jpg I seems that problems is on the shadow map coords but i have no idea what im doing wrong. Any ideas? Thanks in advance.
glmisscelan
glmisscelan
Nobody nkows?

Nobody knows any example using shadow map with vertex and texture pointers?

Any one knows if shader can modify text coords setted with gltexPointer?

something that i misunderstanding with shaders combined with glDrawArrays?

Thanks

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.