Hi all
I am unable to understand why front-face of my cube - boxes is culling on rendering the scene to FBO Texture (GL_COLOR_ATTACHMENT0) instead of BackBuffer.
Here I am presenting my rendering function-
void gmRenderLoop(SDL_Window *gmWin, GLint winWidth, GLint winHeight)
{
/** Preparing Buffers for RTT */
prepareRTTFBO(winWidth, winHeight);
/** Preparing Buffers for Environment Map */
prepareSkyBoxFBO();
/** Preparing Buffers for Cube Map */
prepareCubeMapFBO();
/** Preparing Buffers for Cube Box */
prepareCubeBoxMapFBO();
/** Preparing Buffers for Cube Map */
prepareGroundFBO();
bool gmLoop = true;
SDL_Event windowEvnt;
while (gmLoop)
{
if (SDL_PollEvent(&windowEvnt))
{
if (windowEvnt.type == SDL_QUIT)
gmLoop = false;
else if (windowEvnt.key.keysym.sym == SDLK_ESCAPE)
gmLoop = false;
}
/** -----------------------PASS-1: Start Render To Texture ---------------------------- */
glBindFramebuffer(GL_FRAMEBUFFER, rttFBO);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDisable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
/* Draw Calls For Environment Map*/
drawSkyBox(winWidth, winHeight);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
/* Draw Calls For Ground Map*/
drawGround(winWidth, winHeight);
/* Draw Calls For Cube Map */
drawCube(winWidth, winHeight);
/* Draw Calls For Ground Map*/
drawCubeBox(winWidth, winHeight);
// Seting Render Buffer to Back- Buffer (screen)
glBindFramebuffer(GL_FRAMEBUFFER, 0);
/** -----------------------PASS-1: End Render To Texture ---------------------------- */
/** -----------------------PASS-2: Start Draw to default FBO(backbuffer) ---------------------------- */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* Draw Calls For Environment Map*/
drawRTTQuad(winWidth, winHeight);
/** -----------------------PASS-2: END Draw to default FBO(backbuffer) ---------------------------- */
SDL_GL_SwapWindow(gmWin);
}
/** Deleting Environment Buffers*/
glDeleteVertexArrays(1, &vaoSky);
glDeleteBuffers(1, &vboSky);
/** Deleting Cube Buffers*/
glDeleteVertexArrays(1, &cubeVao);
glDeleteBuffers(1, &cubeVbo);
/** Deleting Cube Buffers*/
glDeleteVertexArrays(1, &groundVao);
glDeleteBuffers(1, &groundVbo);
/** Deleting Cube-Box Buffers*/
glDeleteVertexArrays(1, &cubeBoxVao);
glDeleteBuffers(1, &cubeBoxVbo);
glDeleteBuffers(1, &cubeBoxEbo);
/** Deleting Cube-Box Buffers*/
glDeleteVertexArrays(1, &rttQuadVao);
glDeleteBuffers(1, &rttQuadVbo);
glDeleteBuffers(1, &rttQuadEbo);
}
So In First Pass, I am just rendering my scene to RTT (Color_Attachment0) and in 2nd Pass, I am rendering a qaud with Texture Map (as Color_Atachment0) of RTT.
I am also attaching my scene, with attachment.
scene rendered in BackBuffer: BackFace_Culled.jpg
scene rendered in RTT: frontFace_Culled.jpg
In scene Rendered in RTT, all the cube’s (Texture-Maps as well as Reflection-Maps) front-face culled but same set of call glDisable/Enable to “GL_Depth_Test” is rendering everything fine on Back-Buffer.
Any Pointers or suggestion would be helpful.