void SceneRenderer::renderFrame() { CHECK_GL_ERROR(); { m_scene.calcVectors(); m_particles->depthSort(m_scene); } CHECK_GL_ERROR(); { m_particles->updateEBO(); CHECK_GL_ERROR(); } { // render scene depth to buffer for particle to be depth tested against renderLowResSceneDepth(); CHECK_GL_ERROR(); } // clear light buffer glBindFramebuffer(GL_FRAMEBUFFER, m_fbos->m_lightFbo->fbo); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); CHECK_GL_ERROR(); // clear volume image glBindFramebuffer(GL_FRAMEBUFFER, m_fbos->m_particleFbo->fbo); glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); CHECK_GL_ERROR(); { m_particles->renderParticles(m_scene); CHECK_GL_ERROR(); } { // the opaque colors need to be rendered after the particles // for the particles to cast shadows on the opaque scene renderFullResSceneColor(); CHECK_GL_ERROR(); } { // upsample the particles & composite them on top of the opaque scene colors m_upsampler->upsampleParticleColors(m_scene); CHECK_GL_ERROR(); } { // final bilinear upsampling from scene resolution to backbuffer resolution m_upsampler->upsampleSceneColors(m_scene); CHECK_GL_ERROR(); } m_particles->swapBuffers(); }
void SceneRenderer::renderFrame() { m_fbos->updateBuffers(); // Update screen FBO glGetIntegerv(0x8CA6, (GLint*)&(m_fbos->m_backBufferFbo->fbo)); CPU_TIMER_SCOPE(CPU_TIMER_TOTAL); GPU_TIMER_SCOPE(GPU_TIMER_TOTAL); MatrixStorage mats; setupMatrices(mats); { // render a full-screen depth pass. CPU_TIMER_SCOPE(CPU_TIMER_SCENE_DEPTH); GPU_TIMER_SCOPE(GPU_TIMER_SCENE_DEPTH); if (m_params.useDepthPrepass) renderSceneDepth(mats, m_fbos->m_sceneFbo); // render scene depth to buffer for particle to be depth tested against // This may just down-sample the above depth pre-pass. renderLowResSceneDepth(mats); CHECK_GL_ERROR(); } { // the opaque colors need to be rendered after the particles //LOGI("OE renderFullResSceneColor\n"); CPU_TIMER_SCOPE(CPU_TIMER_SCENE_COLOR); GPU_TIMER_SCOPE(GPU_TIMER_SCENE_COLOR); renderFullResSceneColor(mats); CHECK_GL_ERROR(); } if (m_particles->getParams().render) { CPU_TIMER_SCOPE(CPU_TIMER_PARTICLES); GPU_TIMER_SCOPE(GPU_TIMER_PARTICLES); renderParticles(mats); CHECK_GL_ERROR(); if (m_particles->getParams().renderLowResolution) { // upsample the particles & composite them on top of the opaque scene colors CPU_TIMER_SCOPE(CPU_TIMER_UPSAMPLE_PARTICLES); GPU_TIMER_SCOPE(GPU_TIMER_UPSAMPLE_PARTICLES); m_upsampler->upsampleParticleColors(*m_fbos->m_sceneFbo); CHECK_GL_ERROR(); } } { // final bilinear upsampling from scene resolution to backbuffer resolution CPU_TIMER_SCOPE(CPU_TIMER_UPSAMPLE_SCENE); GPU_TIMER_SCOPE(GPU_TIMER_UPSAMPLE_SCENE); m_upsampler->upsampleSceneColors(*m_fbos->m_backBufferFbo); CHECK_GL_ERROR(); } m_particles->swapBuffers(); }