| 318 | } |
| 319 | |
| 320 | void RenderPrePassMgr::render( SceneRenderState *state ) |
| 321 | { |
| 322 | PROFILE_SCOPE(RenderPrePassMgr_render); |
| 323 | |
| 324 | // Take a look at the SceneRenderState and see if we should skip drawing the pre-pass |
| 325 | if ( state->disableAdvancedLightingBins() ) |
| 326 | return; |
| 327 | |
| 328 | // NOTE: We don't early out here when the element list is |
| 329 | // zero because we need the prepass to be cleared. |
| 330 | |
| 331 | // Automagically save & restore our viewport and transforms. |
| 332 | GFXTransformSaver saver; |
| 333 | |
| 334 | GFXDEBUGEVENT_SCOPE( RenderPrePassMgr_Render, ColorI::RED ); |
| 335 | |
| 336 | // Tell the superclass we're about to render |
| 337 | const bool isRenderingToTarget = _onPreRender(state); |
| 338 | |
| 339 | // Clear all z-buffer, and g-buffer. |
| 340 | clearBuffers(); |
| 341 | |
| 342 | // Restore transforms |
| 343 | MatrixSet &matrixSet = getRenderPass()->getMatrixSet(); |
| 344 | matrixSet.restoreSceneViewProjection(); |
| 345 | const MatrixF worldViewXfm = GFX->getWorldMatrix(); |
| 346 | |
| 347 | // Setup the default prepass material for object instances. |
| 348 | if ( !mPrePassMatInstance ) |
| 349 | _createPrePassMaterial(); |
| 350 | if ( mPrePassMatInstance ) |
| 351 | { |
| 352 | matrixSet.setWorld(MatrixF::Identity); |
| 353 | mPrePassMatInstance->setTransforms(matrixSet, state); |
| 354 | } |
| 355 | |
| 356 | // Signal start of pre-pass |
| 357 | getRenderSignal().trigger( state, this, true ); |
| 358 | |
| 359 | // First do a loop and render all the terrain... these are |
| 360 | // usually the big blockers in a scene and will save us fillrate |
| 361 | // on the smaller meshes and objects. |
| 362 | |
| 363 | // The terrain doesn't need any scene graph data |
| 364 | // in the the prepass... so just clear it. |
| 365 | SceneData sgData; |
| 366 | sgData.init( state, SceneData::PrePassBin ); |
| 367 | |
| 368 | Vector< MainSortElem >::const_iterator itr = mTerrainElementList.begin(); |
| 369 | for ( ; itr != mTerrainElementList.end(); itr++ ) |
| 370 | { |
| 371 | TerrainRenderInst *ri = static_cast<TerrainRenderInst*>( itr->inst ); |
| 372 | |
| 373 | TerrainCellMaterial *mat = ri->cellMat->getPrePassMat(); |
| 374 | |
| 375 | GFX->setPrimitiveBuffer( ri->primBuff ); |
| 376 | GFX->setVertexBuffer( ri->vertBuff ); |
| 377 |
nothing calls this directly
no test coverage detected