| 906 | } |
| 907 | |
| 908 | void River::setShaderParams( SceneRenderState *state, BaseMatInstance* mat, const WaterMatParams& paramHandles ) |
| 909 | { |
| 910 | // Set variables that will be assigned to shader consts within WaterCommon |
| 911 | // before calling Parent::setShaderParams |
| 912 | |
| 913 | mUndulateMaxDist = mLodDistance; |
| 914 | |
| 915 | Parent::setShaderParams( state, mat, paramHandles ); |
| 916 | |
| 917 | // Now set the rest of the shader consts that are either unique to this |
| 918 | // class or that WaterObject leaves to us to handle... |
| 919 | |
| 920 | MaterialParameters* matParams = mat->getMaterialParameters(); |
| 921 | |
| 922 | // set vertex shader constants |
| 923 | //----------------------------------- |
| 924 | |
| 925 | matParams->setSafe(paramHandles.mGridElementSizeSC, 1.0f); |
| 926 | if ( paramHandles.mModelMatSC->isValid() ) |
| 927 | matParams->set(paramHandles.mModelMatSC, MatrixF::Identity, GFXSCT_Float4x4); |
| 928 | |
| 929 | // set pixel shader constants |
| 930 | //----------------------------------- |
| 931 | |
| 932 | LinearColorF c( mWaterFogData.color ); |
| 933 | matParams->setSafe(paramHandles.mBaseColorSC, c); |
| 934 | |
| 935 | // By default we need to show a true reflection is fullReflect is enabled and |
| 936 | // we are above water. |
| 937 | F32 reflect = mPlaneReflector.isEnabled() && !isUnderwater( state->getCameraPosition() ); |
| 938 | |
| 939 | // If we were occluded the last frame a query was fetched ( not necessarily last frame ) |
| 940 | // and we weren't updated last frame... we don't have a valid texture to show |
| 941 | // so use the cubemap / fake reflection color this frame. |
| 942 | if ( mPlaneReflector.lastUpdateMs != REFLECTMGR->getLastUpdateMs() && mPlaneReflector.isOccluded() ) |
| 943 | reflect = false; |
| 944 | |
| 945 | Point4F reflectParams( mWaterPos.z, 0.0f, 1000.0f, !reflect ); |
| 946 | matParams->setSafe(paramHandles.mReflectParamsSC, reflectParams ); |
| 947 | |
| 948 | matParams->setSafe(paramHandles.mReflectNormalSC, mPlaneReflector.refplane ); |
| 949 | } |
| 950 | |
| 951 | bool River::isUnderwater( const Point3F &pnt ) const |
| 952 | { |
nothing calls this directly
no test coverage detected