|
@@ -326,36 +326,32 @@ void CubeReflector::updateReflection( const ReflectParams ¶ms, Point3F expli
|
|
if ( mRenderTarget.isNull() )
|
|
if ( mRenderTarget.isNull() )
|
|
mRenderTarget = GFX->allocRenderToTextureTarget();
|
|
mRenderTarget = GFX->allocRenderToTextureTarget();
|
|
|
|
|
|
- GFX->pushActiveRenderTarget();
|
|
|
|
mDepthBuff = LightShadowMap::_getDepthTarget(texDim, texDim);
|
|
mDepthBuff = LightShadowMap::_getDepthTarget(texDim, texDim);
|
|
mRenderTarget->attachTexture(GFXTextureTarget::DepthStencil, mDepthBuff);
|
|
mRenderTarget->attachTexture(GFXTextureTarget::DepthStencil, mDepthBuff);
|
|
F32 oldVisibleDist = gClientSceneGraph->getVisibleDistance();
|
|
F32 oldVisibleDist = gClientSceneGraph->getVisibleDistance();
|
|
gClientSceneGraph->setVisibleDistance( mDesc->farDist );
|
|
gClientSceneGraph->setVisibleDistance( mDesc->farDist );
|
|
|
|
|
|
- // store current matrices
|
|
|
|
- GFXTransformSaver saver;
|
|
|
|
-
|
|
|
|
F32 detailAdjustBackup = TSShapeInstance::smDetailAdjust;
|
|
F32 detailAdjustBackup = TSShapeInstance::smDetailAdjust;
|
|
TSShapeInstance::smDetailAdjust *= mDesc->detailAdjust;
|
|
TSShapeInstance::smDetailAdjust *= mDesc->detailAdjust;
|
|
|
|
|
|
|
|
+ // store current matrices
|
|
|
|
+ GFXTransformSaver saver;
|
|
|
|
+
|
|
// set projection to 90 degrees vertical and horizontal
|
|
// set projection to 90 degrees vertical and horizontal
|
|
F32 left, right, top, bottom;
|
|
F32 left, right, top, bottom;
|
|
MathUtils::makeFrustum(&left, &right, &top, &bottom, M_HALFPI_F, 1.0f, mDesc->nearDist);
|
|
MathUtils::makeFrustum(&left, &right, &top, &bottom, M_HALFPI_F, 1.0f, mDesc->nearDist);
|
|
GFX->setFrustum(left, right, bottom, top, mDesc->nearDist, mDesc->farDist);
|
|
GFX->setFrustum(left, right, bottom, top, mDesc->nearDist, mDesc->farDist);
|
|
|
|
|
|
- // We don't use a special clipping projection, but still need to initialize
|
|
|
|
- // this for objects like SkyBox which will use it during a reflect pass.
|
|
|
|
- gClientSceneGraph->setNonClipProjection(GFX->getProjectionMatrix());
|
|
|
|
-
|
|
|
|
|
|
+ GFX->pushActiveRenderTarget();
|
|
for (S32 i = 5; i >= 0; i--) {
|
|
for (S32 i = 5; i >= 0; i--) {
|
|
updateFace(params, i, explicitPostion);
|
|
updateFace(params, i, explicitPostion);
|
|
}
|
|
}
|
|
|
|
+ GFX->popActiveRenderTarget();
|
|
|
|
|
|
TSShapeInstance::smDetailAdjust = detailAdjustBackup;
|
|
TSShapeInstance::smDetailAdjust = detailAdjustBackup;
|
|
|
|
|
|
mCubemap->generateMipMaps();
|
|
mCubemap->generateMipMaps();
|
|
|
|
|
|
- GFX->popActiveRenderTarget();
|
|
|
|
|
|
|
|
gClientSceneGraph->setVisibleDistance(oldVisibleDist);
|
|
gClientSceneGraph->setVisibleDistance(oldVisibleDist);
|
|
|
|
|
|
@@ -379,47 +375,51 @@ void CubeReflector::updateFace( const ReflectParams ¶ms, U32 faceidx, Point3
|
|
eye = explicitPostion;
|
|
eye = explicitPostion;
|
|
}
|
|
}
|
|
|
|
|
|
- VectorF vUpVec(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
+ // Standard view that will be overridden below.
|
|
|
|
+ VectorF vLookatPt(0.0f, 0.0f, 0.0f), vUpVec(0.0f, 0.0f, 0.0f), vRight(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
- switch( faceidx )
|
|
|
|
|
|
+ switch (faceidx)
|
|
{
|
|
{
|
|
- case 0 : // D3DCUBEMAP_FACE_POSITIVE_X:
|
|
|
|
- target = eye + VectorF( 1.0f, 0.0f, 0.0f );
|
|
|
|
- vUpVec = VectorF( 0.0f, 1.0f, 0.0f );
|
|
|
|
|
|
+ case 0: // D3DCUBEMAP_FACE_POSITIVE_X:
|
|
|
|
+ vLookatPt = VectorF(1.0f, 0.0f, 0.0f);
|
|
|
|
+ vUpVec = VectorF(0.0f, 1.0f, 0.0f);
|
|
break;
|
|
break;
|
|
- case 1 : // D3DCUBEMAP_FACE_NEGATIVE_X:
|
|
|
|
- target = eye + VectorF( -1.0f, 0.0f, 0.0f );
|
|
|
|
- vUpVec = VectorF( 0.0f, 1.0f, 0.0f );
|
|
|
|
|
|
+ case 1: // D3DCUBEMAP_FACE_NEGATIVE_X:
|
|
|
|
+ vLookatPt = VectorF(-1.0f, 0.0f, 0.0f);
|
|
|
|
+ vUpVec = VectorF(0.0f, 1.0f, 0.0f);
|
|
break;
|
|
break;
|
|
- case 2 : // D3DCUBEMAP_FACE_POSITIVE_Y:
|
|
|
|
- target = eye + VectorF( 0.0f, 1.0f, 0.0f );
|
|
|
|
- vUpVec = VectorF( 0.0f, 0.0f,-1.0f );
|
|
|
|
|
|
+ case 2: // D3DCUBEMAP_FACE_POSITIVE_Y:
|
|
|
|
+ vLookatPt = VectorF(0.0f, 1.0f, 0.0f);
|
|
|
|
+ vUpVec = VectorF(0.0f, 0.0f, -1.0f);
|
|
break;
|
|
break;
|
|
- case 3 : // D3DCUBEMAP_FACE_NEGATIVE_Y:
|
|
|
|
- target = eye + VectorF( 0.0f, -1.0f, 0.0f );
|
|
|
|
- vUpVec = VectorF( 0.0f, 0.0f, 1.0f );
|
|
|
|
|
|
+ case 3: // D3DCUBEMAP_FACE_NEGATIVE_Y:
|
|
|
|
+ vLookatPt = VectorF(0.0f, -1.0f, 0.0f);
|
|
|
|
+ vUpVec = VectorF(0.0f, 0.0f, 1.0f);
|
|
break;
|
|
break;
|
|
- case 4 : // D3DCUBEMAP_FACE_POSITIVE_Z:
|
|
|
|
- target = eye + VectorF( 0.0f, 0.0f, 1.0f );
|
|
|
|
- vUpVec = VectorF( 0.0f, 1.0f, 0.0f );
|
|
|
|
|
|
+ case 4: // D3DCUBEMAP_FACE_POSITIVE_Z:
|
|
|
|
+ vLookatPt = VectorF(0.0f, 0.0f, 1.0f);
|
|
|
|
+ vUpVec = VectorF(0.0f, 1.0f, 0.0f);
|
|
break;
|
|
break;
|
|
case 5: // D3DCUBEMAP_FACE_NEGATIVE_Z:
|
|
case 5: // D3DCUBEMAP_FACE_NEGATIVE_Z:
|
|
- target = eye + VectorF( 0.0f, 0.0f, -1.0f );
|
|
|
|
- vUpVec = VectorF( 0.0f, 1.0f, 0.0f );
|
|
|
|
|
|
+ vLookatPt = VectorF(0.0f, 0.0f, -1.0f);
|
|
|
|
+ vUpVec = VectorF(0.0f, 1.0f, 0.0f);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
// create camera matrix
|
|
// create camera matrix
|
|
- MatrixF matView(true);
|
|
|
|
- matView.LookAt(eye, target, vUpVec);
|
|
|
|
- matView.inverse();
|
|
|
|
|
|
+ MatrixF lightMatrix(true);
|
|
|
|
+ lightMatrix.LookAt(eye, vLookatPt, vUpVec);
|
|
|
|
+ lightMatrix.inverse();
|
|
|
|
|
|
- GFX->setWorldMatrix(matView);
|
|
|
|
|
|
+ GFX->setWorldMatrix(lightMatrix);
|
|
GFX->clearTextureStateImmediate(0);
|
|
GFX->clearTextureStateImmediate(0);
|
|
- mRenderTarget->attachTexture( GFXTextureTarget::Color0, mCubemap, faceidx );
|
|
|
|
|
|
+ mRenderTarget->attachTexture( GFXTextureTarget::Color0, mCubemap, faceidx ); // Setup textures and targets...
|
|
|
|
+ S32 texDim = mDesc->texSize;
|
|
|
|
+ texDim = getMax(texDim, 32);
|
|
|
|
+ mRenderTarget->attachTexture(GFXTextureTarget::DepthStencil, LightShadowMap::_getDepthTarget(texDim, texDim));
|
|
|
|
|
|
GFX->setActiveRenderTarget(mRenderTarget);
|
|
GFX->setActiveRenderTarget(mRenderTarget);
|
|
- GFX->clear( GFXClearStencil | GFXClearTarget | GFXClearZBuffer, gCanvasClearColor, 0.0f, 0);
|
|
|
|
|
|
+ GFX->clear( GFXClearStencil | GFXClearTarget | GFXClearZBuffer, gCanvasClearColor, 1.0f, 0);
|
|
|
|
|
|
SceneRenderState reflectRenderState
|
|
SceneRenderState reflectRenderState
|
|
(
|
|
(
|
|
@@ -429,7 +429,11 @@ void CubeReflector::updateFace( const ReflectParams ¶ms, U32 faceidx, Point3
|
|
);
|
|
);
|
|
|
|
|
|
reflectRenderState.getMaterialDelegate().bind( REFLECTMGR, &ReflectionManager::getReflectionMaterial );
|
|
reflectRenderState.getMaterialDelegate().bind( REFLECTMGR, &ReflectionManager::getReflectionMaterial );
|
|
- reflectRenderState.setDiffuseCameraTransform( params.query->headMatrix );
|
|
|
|
|
|
+ reflectRenderState.setDiffuseCameraTransform(lightMatrix);//params.query->headMatrix );
|
|
|
|
+
|
|
|
|
+ // We don't use a special clipping projection, but still need to initialize
|
|
|
|
+ // this for objects like SkyBox which will use it during a reflect pass.
|
|
|
|
+ gClientSceneGraph->setNonClipProjection(GFX->getProjectionMatrix());
|
|
|
|
|
|
// render scene
|
|
// render scene
|
|
LIGHTMGR->registerGlobalLights( &reflectRenderState.getCullingFrustum(), false );
|
|
LIGHTMGR->registerGlobalLights( &reflectRenderState.getCullingFrustum(), false );
|