| 1489 | } |
| 1490 | |
| 1491 | void fxFoliageReplicator::renderObject(ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance* overrideMat) |
| 1492 | { |
| 1493 | if (overrideMat) |
| 1494 | return; |
| 1495 | |
| 1496 | if ( !mShader ) |
| 1497 | return; |
| 1498 | |
| 1499 | // If we're rendering and we haven't placed any foliage yet - do it. |
| 1500 | if(!mClientReplicationStarted) |
| 1501 | { |
| 1502 | Con::warnf("fxFoliageReplicator::renderObject - tried to render a non replicated fxFoliageReplicator; replicating it now..."); |
| 1503 | |
| 1504 | StartUp(); |
| 1505 | } |
| 1506 | |
| 1507 | // Calculate Elapsed Time and take new Timestamp. |
| 1508 | S32 Time = Platform::getVirtualMilliseconds(); |
| 1509 | F32 ElapsedTime = (Time - mLastRenderTime) * 0.001f; |
| 1510 | mLastRenderTime = Time; |
| 1511 | |
| 1512 | renderPlacementArea(ElapsedTime); |
| 1513 | |
| 1514 | if (mCurrentFoliageCount > 0) { |
| 1515 | |
| 1516 | if ( mRenderSB.isNull() || mDirty) |
| 1517 | { |
| 1518 | mDirty = false; |
| 1519 | |
| 1520 | GFXStateBlockDesc desc; |
| 1521 | |
| 1522 | // Debug SB |
| 1523 | desc.samplersDefined = true; |
| 1524 | |
| 1525 | mDebugSB = GFX->createStateBlock(desc); |
| 1526 | |
| 1527 | // Render SB |
| 1528 | desc.samplers[1].addressModeU = GFXAddressClamp; |
| 1529 | desc.samplers[1].addressModeV = GFXAddressClamp; |
| 1530 | |
| 1531 | desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha); |
| 1532 | desc.setAlphaTest(true, GFXCmpGreater, (U8) (255.0f * mFieldData.mAlphaCutoff)); |
| 1533 | desc.setCullMode(GFXCullNone); |
| 1534 | |
| 1535 | mRenderSB = GFX->createStateBlock(desc); |
| 1536 | } |
| 1537 | |
| 1538 | if (!mFieldData.mHideFoliage) { |
| 1539 | // Animate Global Sway Phase (Modulus). |
| 1540 | mGlobalSwayPhase = mGlobalSwayPhase + (mGlobalSwayTimeRatio * ElapsedTime); |
| 1541 | |
| 1542 | // Animate Global Light Phase (Modulus). |
| 1543 | mGlobalLightPhase = mGlobalLightPhase + (mGlobalLightTimeRatio * ElapsedTime); |
| 1544 | |
| 1545 | // Compute other light parameters |
| 1546 | const F32 LuminanceMidPoint = (mFieldData.mMinLuminance + mFieldData.mMaxLuminance) / 2.0f; |
| 1547 | const F32 LuminanceMagnitude = mFieldData.mMaxLuminance - LuminanceMidPoint; |
| 1548 |
nothing calls this directly
no test coverage detected