void eDeferredRenderer::_visualizeGeometryBuffer(const eRect &area) const { eStateManager::push(); eStateManager::bindVertexShader(m_vsQuad); eStateManager::bindPixelShader(m_psQuad); eStateManager::setCullingMode(eCULLING_NONE); eStateManager::setTextureAddressMode(0, eTEXADDRMODE_CLAMP); eStateManager::setCap(eCAP_ZBUFFER, eFALSE); eStateManager::setCap(eCAP_BLENDING, eFALSE); const eInt w = area.getWidth(); const eInt h = area.getHeight(); // Image at top left. eStateManager::bindTexture(0, m_specularRt); // renderQuad(eRect(0, h/2, w/2, h-1), area.getDimension()); // Image at top right. eStateManager::bindTexture(0, m_diffuseRt); renderQuad(eRect(w/2, h/2, w-1, h-1), area.getDimension()); // Image at bottom left. eStateManager::bindTexture(0, m_normalsRt); renderQuad(eRect(0, 0, w/2, h/2), area.getDimension()); // Image at bottom right. eStateManager::bindTexture(0, m_positionRt); renderQuad(eRect(w/2, 0, w-1, h/2), area.getDimension()); eStateManager::pop(); }
void eDeferredRenderer::_renderLightPass(eScene &scene, const eCamera &cam, const eRect &area) { eStateManager::push(); eStateManager::bindTexture(0, m_diffuseRt); eStateManager::bindTexture(1, m_normalsRt); eStateManager::bindTexture(2, m_specularRt); eStateManager::bindTexture(3, m_positionRt); eStateManager::bindTexture(4, m_deferredShadowMap); eStateManager::setTextureFilter(0, eTEXFILTER_NEAREST); eStateManager::setTextureFilter(1, eTEXFILTER_NEAREST); eStateManager::setTextureFilter(2, eTEXFILTER_NEAREST); eStateManager::setTextureFilter(3, eTEXFILTER_NEAREST); eStateManager::setTextureFilter(4, eTEXFILTER_BILINEAR); eStateManager::setTextureAddressMode(4, eTEXADDRMODE_CLAMP); eStateManager::setCap(eCAP_BLENDING, eTRUE); eStateManager::setBlendModes(eBLEND_ONE, eBLEND_ONE, eBLENDOP_ADD); eStateManager::bindPixelShader(m_psDefLight); eStateManager::bindVertexShader(m_vsQuad); for (eU32 i=0; i<scene.getLightCount(); i++) { const eLight &light = scene.getLight(i); if (light.activateScissor(area.getDimension(), cam)) { _renderLightDistance(scene, light); _renderShadowMap(cam, light); light.activate(m_gfx, cam.getViewMatrix()); renderQuad(area, area.getDimension()); } } eStateManager::pop(); }
void eDeferredRenderer::_renderAlphaLightPass(const eScene &scene, const eCamera &cam, const eRect &area) { eStateManager::push(); eStateManager::bindVertexShader(m_vsInstGeo); eStateManager::bindPixelShader(m_psForwLight); for (eU32 i=0; i<scene.getLightCount(); i++) { const eLight &light = scene.getLight(i); if (light.activateScissor(area.getDimension(), cam)) { light.activate(m_gfx, cam.getViewMatrix()); _renderRenderJobs(m_allJobs, cam, eRenderJob::ALPHA_ON | eRenderJob::LIGHTED_ON | eRenderJob::CASTSHADOW_BOTH | eRenderJob::REFRACTED_OFF); } } eStateManager::pop(); }
void eDeferredRenderer::_renderAmbientPass(const eScene &scene, const eRect &area) { // Calculate the ambient color. eColor ambient; for (eU32 i=0; i<scene.getLightCount(); i++) { ambient += scene.getLight(i).getAmbient(); } m_gfx->setPsConst(ePSCONST_LIGHT_TOTALAMBIENT, ambient); // Render the ambient light. eStateManager::push(); eStateManager::bindTexture(0, m_diffuseRt); eStateManager::bindVertexShader(m_vsQuad); eStateManager::bindPixelShader(m_psDefAmbient); renderQuad(area, area.getDimension()); eStateManager::pop(); }
void eDeferredRenderer::_renderEnvPass(const eRect &area) { eStateManager::push(); eStateManager::bindTexture(1, m_normalsRt); eStateManager::bindTexture(2, m_specularRt); eStateManager::bindTexture(3, m_positionRt); eStateManager::setTextureFilter(0, eTEXFILTER_BILINEAR); eStateManager::setTextureFilter(1, eTEXFILTER_NEAREST); eStateManager::setTextureFilter(3, eTEXFILTER_NEAREST); eStateManager::setCap(eCAP_BLENDING, eTRUE); eStateManager::bindVertexShader(m_vsQuad); eStateManager::bindPixelShader(m_psDefEnv); for (eU32 i=0; i<m_materialArray.size(); i++) { const eMaterial* mat = m_materialArray[i]; eStateManager::bindTexture(0, mat->getTexture(eMaterial::UNIT_ENVIRONMENT)); m_gfx->setPsConst(ePSCONST_MAT_INDEX, (eF32)mat->m_render_material_id/256.0f); renderQuad(area, area.getDimension()); } eStateManager::pop(); }