| 642 | } |
| 643 | |
| 644 | void WaterPlane::setShaderParams( SceneRenderState *state, BaseMatInstance* mat, const WaterMatParams& paramHandles) |
| 645 | { |
| 646 | // Set variables that will be assigned to shader consts within WaterCommon |
| 647 | // before calling Parent::setShaderParams |
| 648 | |
| 649 | mUndulateMaxDist = mGridElementSize * mGridSizeMinusOne * 0.5f; |
| 650 | |
| 651 | Parent::setShaderParams( state, mat, paramHandles ); |
| 652 | |
| 653 | // Now set the rest of the shader consts that are either unique to this |
| 654 | // class or that WaterObject leaves to us to handle... |
| 655 | |
| 656 | MaterialParameters* matParams = mat->getMaterialParameters(); |
| 657 | |
| 658 | // set vertex shader constants |
| 659 | //----------------------------------- |
| 660 | matParams->setSafe(paramHandles.mGridElementSizeSC, (F32)mGridElementSize); |
| 661 | //matParams->setSafe( paramHandles.mReflectTexSizeSC, mReflectTexSize ); |
| 662 | if ( paramHandles.mModelMatSC->isValid() ) |
| 663 | matParams->set(paramHandles.mModelMatSC, getRenderTransform(), GFXSCT_Float4x4); |
| 664 | |
| 665 | // set pixel shader constants |
| 666 | //----------------------------------- |
| 667 | |
| 668 | LinearColorF c( mWaterFogData.color ); |
| 669 | matParams->setSafe( paramHandles.mBaseColorSC, c ); |
| 670 | |
| 671 | // By default we need to show a true reflection is fullReflect is enabled and |
| 672 | // we are above water. |
| 673 | F32 reflect = mPlaneReflector.isEnabled() && !isUnderwater( state->getCameraPosition() ); |
| 674 | |
| 675 | // If we were occluded the last frame a query was fetched ( not necessarily last frame ) |
| 676 | // and we weren't updated last frame... we don't have a valid texture to show |
| 677 | // so use the cubemap / fake reflection color this frame. |
| 678 | if ( mPlaneReflector.lastUpdateMs != REFLECTMGR->getLastUpdateMs() && mPlaneReflector.isOccluded() ) |
| 679 | reflect = false; |
| 680 | |
| 681 | //Point4F reflectParams( getRenderPosition().z, mReflectMinDist, mReflectMaxDist, reflect ); |
| 682 | Point4F reflectParams( getRenderPosition().z, 0.0f, 1000.0f, !reflect ); |
| 683 | |
| 684 | // TODO: This is a hack... why is this broken... check after |
| 685 | // we merge advanced lighting with trunk! |
| 686 | // |
| 687 | reflectParams.z = 0.0f; |
| 688 | matParams->setSafe( paramHandles.mReflectParamsSC, reflectParams ); |
| 689 | |
| 690 | VectorF reflectNorm( 0, 0, 1 ); |
| 691 | matParams->setSafe(paramHandles.mReflectNormalSC, reflectNorm ); |
| 692 | } |
| 693 | |
| 694 | void WaterPlane::prepRenderImage( SceneRenderState *state ) |
| 695 | { |
nothing calls this directly
no test coverage detected