| 302 | } |
| 303 | |
| 304 | void RenderDeferredMgr::render( SceneRenderState *state ) |
| 305 | { |
| 306 | PROFILE_SCOPE(RenderDeferredMgr_render); |
| 307 | |
| 308 | // Take a look at the SceneRenderState and see if we should skip drawing the pre-pass |
| 309 | if ( state->disableAdvancedLightingBins() ) |
| 310 | return; |
| 311 | |
| 312 | // NOTE: We don't early out here when the element list is |
| 313 | // zero because we need the deferred to be cleared. |
| 314 | |
| 315 | // Automagically save & restore our viewport and transforms. |
| 316 | GFXTransformSaver saver; |
| 317 | |
| 318 | GFXDEBUGEVENT_SCOPE( RenderDeferredMgr_Render, ColorI::RED ); |
| 319 | |
| 320 | // Tell the superclass we're about to render |
| 321 | const bool isRenderingToTarget = _onPreRender(state); |
| 322 | |
| 323 | // Clear z-buffer and g-buffer. |
| 324 | GFX->clear(GFXClearZBuffer | GFXClearStencil, LinearColorF::ZERO, 1.0f, 0); |
| 325 | GFX->clearColorAttachment(0, LinearColorF::ONE);//normdepth |
| 326 | GFX->clearColorAttachment(1, LinearColorF::ZERO);//albedo |
| 327 | GFX->clearColorAttachment(2, LinearColorF::ZERO);//matinfo |
| 328 | //AL_FormatToken is cleared by it's own class |
| 329 | |
| 330 | // Restore transforms |
| 331 | MatrixSet &matrixSet = getRenderPass()->getMatrixSet(); |
| 332 | matrixSet.restoreSceneViewProjection(); |
| 333 | const MatrixF worldViewXfm = GFX->getWorldMatrix(); |
| 334 | |
| 335 | // Setup the default deferred material for object instances. |
| 336 | if ( !mDeferredMatInstance ) |
| 337 | _createDeferredMaterial(); |
| 338 | if ( mDeferredMatInstance ) |
| 339 | { |
| 340 | matrixSet.setWorld(MatrixF::Identity); |
| 341 | mDeferredMatInstance->setTransforms(matrixSet, state); |
| 342 | } |
| 343 | |
| 344 | // Signal start of deferred |
| 345 | getRenderSignal().trigger( state, this, true ); |
| 346 | |
| 347 | // First do a loop and render all the terrain... these are |
| 348 | // usually the big blockers in a scene and will save us fillrate |
| 349 | // on the smaller meshes and objects. |
| 350 | |
| 351 | // The terrain doesn't need any scene graph data |
| 352 | // in the the deferred... so just clear it. |
| 353 | SceneData sgData; |
| 354 | sgData.init( state, SceneData::DeferredBin ); |
| 355 | |
| 356 | Vector< MainSortElem >::const_iterator itr = mTerrainElementList.begin(); |
| 357 | for ( ; itr != mTerrainElementList.end(); itr++ ) |
| 358 | { |
| 359 | TerrainRenderInst *ri = static_cast<TerrainRenderInst*>( itr->inst ); |
| 360 | |
| 361 | TerrainCellMaterial *mat = ri->cellMat->getDeferredMat(); |
nothing calls this directly
no test coverage detected