| 633 | } |
| 634 | |
| 635 | void ScatterSky::prepRenderImage( SceneRenderState *state ) |
| 636 | { |
| 637 | // Only render into diffuse and reflect passes. |
| 638 | |
| 639 | if( !state->isDiffusePass() && |
| 640 | !state->isReflectPass() ) |
| 641 | return; |
| 642 | |
| 643 | // Regular sky render instance. |
| 644 | RenderPassManager* renderPass = state->getRenderPass(); |
| 645 | ObjectRenderInst *ri = renderPass->allocInst<ObjectRenderInst>(); |
| 646 | ri->renderDelegate.bind( this, &ScatterSky::_render ); |
| 647 | ri->type = RenderPassManager::RIT_Sky; |
| 648 | ri->defaultKey = 10; |
| 649 | ri->defaultKey2 = 0; |
| 650 | renderPass->addInst(ri); |
| 651 | |
| 652 | // Debug render instance. |
| 653 | /* |
| 654 | if ( Con::getBoolVariable( "$ScatterSky::debug", false ) ) |
| 655 | { |
| 656 | ri = state->getRenderPass()->allocInst<ObjectRenderInst>(); |
| 657 | ri->renderDelegate.bind( this, &ScatterSky::_debugRender ); |
| 658 | ri->type = RenderPassManager::RIT_Editor; |
| 659 | state->getRenderPass()->addInst( ri ); |
| 660 | } |
| 661 | */ |
| 662 | |
| 663 | // Light flare effect render instance. |
| 664 | if ( mFlareData && mNightInterpolant != 1.0f ) |
| 665 | { |
| 666 | mFlareState.fullBrightness = mBrightness; |
| 667 | mFlareState.scale = mFlareScale; |
| 668 | mFlareState.lightInfo = mLight; |
| 669 | |
| 670 | Point3F lightPos = state->getDiffuseCameraPosition() - state->getFarPlane() * mLight->getDirection() * 0.9f; |
| 671 | mFlareState.lightMat.identity(); |
| 672 | mFlareState.lightMat.setPosition( lightPos ); |
| 673 | |
| 674 | F32 dist = ( lightPos - state->getDiffuseCameraPosition( ) ).len( ); |
| 675 | F32 coronaScale = 0.5f; |
| 676 | F32 screenRadius = GFX->getViewport( ).extent.y * coronaScale * 0.5f; |
| 677 | mFlareState.worldRadius = screenRadius * dist / state->getWorldToScreenScale( ).y; |
| 678 | |
| 679 | mFlareData->prepRender( state, &mFlareState ); |
| 680 | } |
| 681 | |
| 682 | // Render instances for Night effects. |
| 683 | if ( mNightInterpolant <= 0.0f ) |
| 684 | return; |
| 685 | |
| 686 | // Render instance for Moon sprite. |
| 687 | if ( mMoonEnabled && mMoonMatInst ) |
| 688 | { |
| 689 | mMatrixSet->setSceneView(GFX->getWorldMatrix()); |
| 690 | mMatrixSet->setSceneProjection(GFX->getProjectionMatrix()); |
| 691 | mMatrixSet->setWorld(GFX->getWorldMatrix()); |
| 692 |
nothing calls this directly
no test coverage detected