• Advertisement
Sign in to follow this  

early depth pass

This topic is 1679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm trying to implement the early depth pass that is often mentioned but it is not working as described.  *update* I'd like to use the shadow pass for both but I have now just realized after posting that the depth is being written to an FBO and this seems likely to be the issue.   *UPDATE_2* I disabled the FBO and the results are the same, nothing is rendered. Everything works fine until I get to the part where the depth configuration code is set for the color writes.     The following is how I'm initializing the depth texture,  it is pretty much verbatim from the PowerVR SDK and works for Windows, iOS, and also through the WINE emulator. 

 

//===================================================================================================
glGenTextures(1, &m_uiShadowMapTexture);
glBindTexture(GL_TEXTURE_2D, m_uiShadowMapTexture);
 
//-------------------------------------------------
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, (GLsizei)viewWidth, (GLsizei)viewHeight, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
//------------------------------------------------------------------
glGenFramebuffers(1, &m_uiFrameBufferObject);
glBindFramebuffer(GL_FRAMEBUFFER, m_uiFrameBufferObject);
//---------------------
#ifdef WIN32 glDrawBuffer(GL_NONE);
//_ON_SOME_MACHINES_THIS_IS_REQUIRED / ON_SOME_IT_FAILS
glReadBuffer(GL_NONE);
//_SAME_AS_ABOVE
#endif
 
//---------------------
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_uiShadowMapTexture, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
//====================================================================================================
 
This next part works fine when I render the depth models to a texture
 
//====================================================================================================
glEnable(GL_DEPTH_TEST);
 
glEnable(GL_DEPTH_TEST);
glDepthMask(1);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glDepthFunc(GL_LESS);
glBindFramebuffer(GL_FRAMEBUFFER, m_uiFrameBufferObject);
 
//draw calls....
//==========================================================================
 
Next comes the part where things fail.
 
//==========================================================================
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDepthMask(0);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glDepthFunc(GL_EQUAL);
//==========================================================================  

 

The glDepthMask() and glDepthFunc() both cause the screen to go blank.  Any thoughts on this? Help on this matter would be much appreciated.   Also, how should the       glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); line be setup.  Should GL_DEPTH_BUFFER_BIT be included since we are trying to use the information already stored instead of clearing it?

Edited by Josh Petrie

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement