| 1560 | } |
| 1561 | |
| 1562 | void GroundCover::prepRenderImage( SceneRenderState *state ) |
| 1563 | { |
| 1564 | // Reset stats each time we hit the diffuse pass. |
| 1565 | if (mMaterialInst == nullptr) |
| 1566 | return; |
| 1567 | |
| 1568 | if( state->isDiffusePass() ) |
| 1569 | { |
| 1570 | smStatRenderedCells = 0; |
| 1571 | smStatRenderedBillboards = 0; |
| 1572 | smStatRenderedBatches = 0; |
| 1573 | smStatRenderedShapes = 0; |
| 1574 | } |
| 1575 | |
| 1576 | // TODO: Make sure that the ground cover stops rendering |
| 1577 | // if you're inside a zoned interior. |
| 1578 | |
| 1579 | if ( state->isReflectPass() && mReflectRadiusScale <= 0.0f ) |
| 1580 | return; |
| 1581 | |
| 1582 | // Nothing to do if this is a shadow pass and shapes in this GoundCover |
| 1583 | // should not be casting shadows. |
| 1584 | |
| 1585 | if( state->isShadowPass() && !mShapesCastShadows ) |
| 1586 | return; |
| 1587 | |
| 1588 | GFXTransformSaver saver; |
| 1589 | |
| 1590 | // Setup the frustum culler. |
| 1591 | if ( ( mCuller.getPosition().isZero() || !mDebugLockFrustum ) && !state->isShadowPass() ) |
| 1592 | mCuller = state->getCullingFrustum(); |
| 1593 | |
| 1594 | // Update the cells, but only during the diffuse pass. |
| 1595 | // We don't want cell generation to thrash when the reflection camera |
| 1596 | // position doesn't match the diffuse camera! |
| 1597 | if ( state->isDiffusePass() ) |
| 1598 | _updateCoverGrid( mCuller ); |
| 1599 | |
| 1600 | // Render billboards but not into shadow passes. |
| 1601 | |
| 1602 | if ( !state->isShadowPass() && mMaterialInst->isValid() && !mDebugNoBillboards ) |
| 1603 | { |
| 1604 | PROFILE_SCOPE( GroundCover_RenderBillboards ); |
| 1605 | |
| 1606 | // Take zoom into account. |
| 1607 | F32 screenScale = state->getWorldToScreenScale().y / state->getViewport().extent.y; |
| 1608 | |
| 1609 | // Set the far distance for billboards. |
| 1610 | F32 radius = mRadius * smFadeScale; |
| 1611 | mCuller.setFarDist(radius * screenScale ); |
| 1612 | |
| 1613 | F32 cullScale = 1.0f; |
| 1614 | if ( state->isReflectPass() ) |
| 1615 | cullScale = mReflectRadiusScale; |
| 1616 | |
| 1617 | // Setup our shader const data. |
| 1618 | // Must be done prior to submitting our render instance. |
| 1619 |
nothing calls this directly
no test coverage detected