mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Basic fix for reflections in both stereo rendering modes
This commit is contained in:
parent
fa7697b13e
commit
1198932e87
6 changed files with 150 additions and 155 deletions
|
|
@ -95,9 +95,9 @@ ReflectionManager::ReflectionManager()
|
|||
void ReflectionManager::initConsole()
|
||||
{
|
||||
Con::addVariable( "$pref::Reflect::refractTexScale", TypeF32, &ReflectionManager::smRefractTexScale, "RefractTex has dimensions equal to the active render target scaled in both x and y by this float.\n"
|
||||
"@ingroup Rendering");
|
||||
"@ingroup Rendering");
|
||||
Con::addVariable( "$pref::Reflect::frameLimitMS", TypeS32, &ReflectionManager::smFrameReflectionMS, "ReflectionManager tries not to spend more than this amount of time updating reflections per frame.\n"
|
||||
"@ingroup Rendering");
|
||||
"@ingroup Rendering");
|
||||
}
|
||||
|
||||
ReflectionManager::~ReflectionManager()
|
||||
|
|
@ -136,22 +136,49 @@ void ReflectionManager::update( F32 timeSlice,
|
|||
// visibility of reflectors.
|
||||
Frustum culler;
|
||||
|
||||
// jamesu - normally we just need a frustum which covers the current ports, however for SBS mode
|
||||
// we need something which covers both viewports.
|
||||
S32 stereoTarget = GFX->getCurrentStereoTarget();
|
||||
if (stereoTarget != -1)
|
||||
{
|
||||
MathUtils::makeFovPortFrustum(&culler, false, query.nearPlane, query.farPlane, query.fovPort[stereoTarget]);
|
||||
// In this case we're rendering in stereo using a specific eye
|
||||
MathUtils::makeFovPortFrustum(&culler, false, query.nearPlane, query.farPlane, query.fovPort[stereoTarget], query.headMatrix);
|
||||
}
|
||||
else if (GFX->getCurrentRenderStyle() == GFXDevice::RS_StereoSideBySide)
|
||||
{
|
||||
// Calculate an ideal culling size here, we'll just assume double fov based on the first fovport based on
|
||||
// the head position.
|
||||
FovPort port = query.fovPort[0];
|
||||
F32 leftSize = query.nearPlane * port.leftTan;
|
||||
F32 rightSize = query.nearPlane * port.rightTan;
|
||||
F32 upSize = query.nearPlane * port.upTan;
|
||||
F32 downSize = query.nearPlane * port.downTan;
|
||||
|
||||
F32 left = -leftSize;
|
||||
F32 right = rightSize;
|
||||
F32 top = upSize;
|
||||
F32 bottom = -downSize;
|
||||
|
||||
F32 fovInRadians = mAtan2((top - bottom) / 2.0f, query.nearPlane) * 3.0f;
|
||||
|
||||
culler.set(false,
|
||||
fovInRadians,
|
||||
(F32)(query.stereoViewports[0].extent.x + query.stereoViewports[1].extent.x) / (F32)query.stereoViewports[0].extent.y,
|
||||
query.nearPlane,
|
||||
query.farPlane,
|
||||
query.headMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
culler.set(false,
|
||||
query.fov,
|
||||
(F32)resolution.x / (F32)resolution.y,
|
||||
query.nearPlane,
|
||||
query.farPlane,
|
||||
query.cameraMatrix);
|
||||
// Normal culling
|
||||
culler.set(false,
|
||||
query.fov,
|
||||
(F32)resolution.x / (F32)resolution.y,
|
||||
query.nearPlane,
|
||||
query.farPlane,
|
||||
query.cameraMatrix);
|
||||
}
|
||||
|
||||
|
||||
// Manipulate the frustum for tiled screenshots
|
||||
const bool screenShotMode = gScreenShot && gScreenShot->isPending();
|
||||
if ( screenShotMode )
|
||||
|
|
@ -170,6 +197,7 @@ void ReflectionManager::update( F32 timeSlice,
|
|||
refparams.viewportExtent = resolution;
|
||||
refparams.culler = culler;
|
||||
refparams.startOfUpdateMs = startOfUpdateMs;
|
||||
refparams.eyeId = stereoTarget;
|
||||
|
||||
// Update the reflection score.
|
||||
ReflectorList::iterator reflectorIter = mReflectors.begin();
|
||||
|
|
@ -184,6 +212,7 @@ void ReflectionManager::update( F32 timeSlice,
|
|||
mTimer->getElapsedMs();
|
||||
mTimer->reset();
|
||||
U32 numUpdated = 0;
|
||||
U32 currentTarget = stereoTarget >= 0 ? stereoTarget : 0;
|
||||
reflectorIter = mReflectors.begin();
|
||||
for ( ; reflectorIter != mReflectors.end(); reflectorIter++ )
|
||||
{
|
||||
|
|
@ -193,7 +222,12 @@ void ReflectionManager::update( F32 timeSlice,
|
|||
break;
|
||||
|
||||
(*reflectorIter)->updateReflection( refparams );
|
||||
(*reflectorIter)->lastUpdateMs = startOfUpdateMs;
|
||||
|
||||
if (stereoTarget != 0) // only update MS if we're not rendering the left eye in separate mode
|
||||
{
|
||||
(*reflectorIter)->lastUpdateMs = startOfUpdateMs;
|
||||
}
|
||||
|
||||
numUpdated++;
|
||||
|
||||
// If we run out of update time then stop.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue