| 297 | } |
| 298 | |
| 299 | void CubeReflector::updateReflection( const ReflectParams ¶ms, Point3F explicitPostion) |
| 300 | { |
| 301 | GFXDEBUGEVENT_SCOPE( CubeReflector_UpdateReflection, ColorI::WHITE ); |
| 302 | |
| 303 | mIsRendering = true; |
| 304 | |
| 305 | // Setup textures and targets... |
| 306 | S32 texDim = mDesc->texSize; |
| 307 | texDim = getMax( texDim, 32 ); |
| 308 | |
| 309 | // Protect against the reflection texture being bigger |
| 310 | // than the current game back buffer. |
| 311 | texDim = getMin( texDim, params.viewportExtent.x ); |
| 312 | texDim = getMin( texDim, params.viewportExtent.y ); |
| 313 | |
| 314 | bool texResize = ( texDim != mLastTexSize ); |
| 315 | |
| 316 | const GFXFormat reflectFormat = REFLECTMGR->getReflectFormat(); |
| 317 | |
| 318 | if ( texResize || |
| 319 | mCubemap.isNull() || |
| 320 | mCubemap->getFormat() != reflectFormat ) |
| 321 | { |
| 322 | mCubemap = GFX->createCubemap(); |
| 323 | mCubemap->initDynamic( texDim, reflectFormat ); |
| 324 | } |
| 325 | |
| 326 | mDepthBuff = LightShadowMap::_getDepthTarget( texDim, texDim ); |
| 327 | |
| 328 | if ( mRenderTarget.isNull() ) |
| 329 | mRenderTarget = GFX->allocRenderToTextureTarget(); |
| 330 | |
| 331 | GFX->pushActiveRenderTarget(); |
| 332 | mRenderTarget->attachTexture( GFXTextureTarget::DepthStencil, mDepthBuff ); |
| 333 | |
| 334 | |
| 335 | F32 oldVisibleDist = gClientSceneGraph->getVisibleDistance(); |
| 336 | gClientSceneGraph->setVisibleDistance( mDesc->farDist ); |
| 337 | |
| 338 | |
| 339 | for ( U32 i = 0; i < 6; i++ ) |
| 340 | updateFace( params, i, explicitPostion); |
| 341 | |
| 342 | |
| 343 | GFX->popActiveRenderTarget(); |
| 344 | |
| 345 | gClientSceneGraph->setVisibleDistance(oldVisibleDist); |
| 346 | |
| 347 | mIsRendering = false; |
| 348 | mLastTexSize = texDim; |
| 349 | } |
| 350 | |
| 351 | void CubeReflector::updateFace( const ReflectParams ¶ms, U32 faceidx, Point3F explicitPostion) |
| 352 | { |
no test coverage detected