| 1122 | } |
| 1123 | |
| 1124 | void ScatterSky::_renderMoon( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *overrideMat ) |
| 1125 | { |
| 1126 | if ( !mMoonMatInst ) |
| 1127 | return; |
| 1128 | |
| 1129 | Point3F moonlightPosition = state->getCameraPosition() - /*mLight->getDirection()*/ mMoonLightDir * state->getFarPlane() * 0.9f; |
| 1130 | F32 dist = (moonlightPosition - state->getCameraPosition()).len(); |
| 1131 | |
| 1132 | // worldRadius = screenRadius * dist / worldToScreen |
| 1133 | // screenRadius = worldRadius / dist * worldToScreen |
| 1134 | |
| 1135 | // |
| 1136 | F32 screenRadius = GFX->getViewport().extent.y * mMoonScale * 0.5f; |
| 1137 | F32 worldRadius = screenRadius * dist / state->getWorldToScreenScale().y; |
| 1138 | |
| 1139 | // Calculate Billboard Radius (in world units) to be constant, independent of distance. |
| 1140 | // Takes into account distance, viewport size, and specified size in editor |
| 1141 | |
| 1142 | F32 BBRadius = worldRadius; |
| 1143 | |
| 1144 | |
| 1145 | mMatrixSet->restoreSceneViewProjection(); |
| 1146 | |
| 1147 | if ( state->isReflectPass() ) |
| 1148 | mMatrixSet->setProjection( state->getSceneManager()->getNonClipProjection() ); |
| 1149 | |
| 1150 | mMatrixSet->setWorld( MatrixF::Identity ); |
| 1151 | |
| 1152 | // Initialize points with basic info |
| 1153 | Point3F points[4]; |
| 1154 | points[0] = Point3F( -BBRadius, 0.0, -BBRadius); |
| 1155 | points[1] = Point3F( -BBRadius, 0.0, BBRadius); |
| 1156 | points[2] = Point3F( BBRadius, 0.0, -BBRadius); |
| 1157 | points[3] = Point3F( BBRadius, 0.0, BBRadius); |
| 1158 | |
| 1159 | static const Point2F sCoords[4] = |
| 1160 | { |
| 1161 | Point2F( 0.0f, 0.0f ), |
| 1162 | Point2F( 0.0f, 1.0f ), |
| 1163 | Point2F( 1.0f, 0.0f ), |
| 1164 | Point2F( 1.0f, 1.0f ) |
| 1165 | }; |
| 1166 | |
| 1167 | // Get info we need to adjust points |
| 1168 | const MatrixF &camView = state->getCameraTransform(); |
| 1169 | |
| 1170 | // Finalize points |
| 1171 | for(S32 i = 0; i < 4; i++) |
| 1172 | { |
| 1173 | // align with camera |
| 1174 | camView.mulV(points[i]); |
| 1175 | // offset |
| 1176 | points[i] += moonlightPosition; |
| 1177 | } |
| 1178 | |
| 1179 | // Vertex color. |
| 1180 | LinearColorF moonVertColor( 1.0f, 1.0f, 1.0f, mNightInterpolant ); |
| 1181 |
nothing calls this directly
no test coverage detected