PDA

View Full Version : Confused on how to write Depth Texture



uwi2k2
03-26-2013, 11:32 PM
hi,

i just canīt find the right way to write my depth texture for shadow mapping.

What i do:
1. create a FBO with a depth attechment:
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, this->ShadowMapSize_W, this->ShadowMapSize_H, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);

2. i render the szene to FBO and use shadow-texture to draw shoadows -> works fine so far

3. NEW: i grap the data from the `shadow depth texture` like this ans blur it:

glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, GL_FLOAT, buffer);

for(int y = 0; y < textureWidth * textureHeight; y++)
{ ......
..

Getting data and bluring it works fine- tested by commandline output - it just 1 float per pixel .

4. NEW: i try to write the data back to the texture - THAT FAILS - no error no output any more on screen ...

glBindTexture( GL_TEXTURE_2D , SzeneOne->m_uiShadowMapTexture );
BlurTexture( SzeneOne->ShadowMapSize_W , SzeneOne->ShadowMapSize_H, 6 , &shadowTmpBuffer );
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, SzeneOne->ShadowMapSize_W, SzeneOne->ShadowMapSize_H, 0, GL_DEPTH_COMPONENT, GL_FLOAT, &shadowTmpBuffer );

by commenting out, i know its about the glTexImage2D() line...
can you tell me what iīm doing wrong here ?

thanx
uwi

thokra
03-27-2013, 01:12 AM
Any GL errors?

uwi2k2
03-27-2013, 01:22 AM
hi,

thats the strange part .. no opengl errors ...

uwi