Water not rendered in mirrors
by Ryan Nunn · in Torque Game Engine · 10/11/2005 (6:16 am) · 2 replies
I noticed a bug where water wasn't being rendered in mirrors. I've tracked it down to 2 problems.
1) SceneState::mFlipCull is being ignored by the fluid code so glCullFace() calls are wrong and clip planes are not being flipped
2) The near clipping plane is being incorrectly generated
Here are a list of changes to fix the problem:
Change the method
Then in fluid::Render() change the two glCullFace() calls to
Then in WaterBlock::renderObject() change the call
Also in WaterBlock::renderObject(), change the following to fix the clipping plane problems
1) SceneState::mFlipCull is being ignored by the fluid code so glCullFace() calls are wrong and clip planes are not being flipped
2) The near clipping plane is being incorrectly generated
Here are a list of changes to fix the problem:
Change the method
void fluid::Render ( bool& EyeSubmerged )to
void fluid::Render ( bool& EyeSubmerged, bool FlipCull )
Then in fluid::Render() change the two glCullFace() calls to
// MM: Set culling mode. glCullFace(EyeSubmerged^FlipCull?GL_BACK:GL_FRONT);and
// MM: Restore culling mode. glCullFace(FlipCull?GL_FRONT:GL_BACK);
Then in WaterBlock::renderObject() change the call
mFluid.Render( CameraSubmergedFlag );to
mFluid.Render( CameraSubmergedFlag, state->mFlipCull );
Also in WaterBlock::renderObject(), change the following to fix the clipping plane problems
// near plane is needed as well... PlaneF p(0, 1, 0, -frustumParam[4]); mTransformPlane(L2Cm, Point3F(1,1,1), p, &mClipPlane[0]); mFluid.SetFrustrumPlanes( (F32*)mClipPlane );to
// near plane is needed as well...
PlaneF p(0, 1, 0, -frustumParam[1]);
mTransformPlane(L2Cm, Point3F(1,1,1), p, &mClipPlane[0]);
// ensure clipping planes are flipped where required
if (state->mFlipCull) {
mClipPlane[2].neg();
mClipPlane[3].neg();
mClipPlane[4].neg();
mClipPlane[5].neg();
}
mFluid.SetFrustrumPlanes( (F32*)mClipPlane );
Associate Joseph Euan