summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2023-03-24 14:33:41 -0500
committerDave Parks <davep@lindenlab.com>2023-03-24 14:33:41 -0500
commit5882215a6d53f5a20779be78805392f4e38c3669 (patch)
treebdc89e2b0ccdcb336a61c915399324cde6b83e60 /indra
parentdf9d2b6e9613d15d39e3e870fc09686e41b6c37f (diff)
SL-19321 Optimization pass -- Remove another shadow split from probe render, incidental decruft.
Diffstat (limited to 'indra')
-rw-r--r--indra/llmath/llcamera.cpp222
-rw-r--r--indra/llmath/llcamera.h9
-rw-r--r--indra/newview/app_settings/settings.xml46
-rw-r--r--indra/newview/pipeline.cpp39
-rw-r--r--indra/newview/pipeline.h3
5 files changed, 10 insertions, 309 deletions
diff --git a/indra/llmath/llcamera.cpp b/indra/llmath/llcamera.cpp
index 9034182072..18d704dd0f 100644
--- a/indra/llmath/llcamera.cpp
+++ b/indra/llmath/llcamera.cpp
@@ -311,104 +311,6 @@ int LLCamera::sphereInFrustumQuick(const LLVector3 &sphere_center, const F32 rad
return 0;
}
-// HACK: This version is still around because the version below doesn't work
-// unless the agent planes are initialized.
-// Return 1 if sphere is in frustum, 2 if fully in frustum, otherwise 0.
-// NOTE: 'center' is in absolute frame.
-int LLCamera::sphereInFrustumOld(const LLVector3 &sphere_center, const F32 radius) const
-{
- // Returns 1 if sphere is in frustum, 0 if not.
- // modified so that default view frust is along X with Z vertical
- F32 x, y, z, rightDist, leftDist, topDist, bottomDist;
-
- // Subtract the view position
- //LLVector3 relative_center;
- //relative_center = sphere_center - getOrigin();
- LLVector3 rel_center(sphere_center);
- rel_center -= mOrigin;
-
- bool all_in = TRUE;
-
- // Transform relative_center.x to camera frame
- x = mXAxis * rel_center;
- if (x < MIN_NEAR_PLANE - radius)
- {
- return 0;
- }
- else if (x < MIN_NEAR_PLANE + radius)
- {
- all_in = FALSE;
- }
-
- if (x > mFarPlane + radius)
- {
- return 0;
- }
- else if (x > mFarPlane - radius)
- {
- all_in = FALSE;
- }
-
- // Transform relative_center.y to camera frame
- y = mYAxis * rel_center;
-
- // distance to plane is the dot product of (x, y, 0) * plane_normal
- rightDist = x * mLocalPlanes[PLANE_RIGHT][VX] + y * mLocalPlanes[PLANE_RIGHT][VY];
- if (rightDist < -radius)
- {
- return 0;
- }
- else if (rightDist < radius)
- {
- all_in = FALSE;
- }
-
- leftDist = x * mLocalPlanes[PLANE_LEFT][VX] + y * mLocalPlanes[PLANE_LEFT][VY];
- if (leftDist < -radius)
- {
- return 0;
- }
- else if (leftDist < radius)
- {
- all_in = FALSE;
- }
-
- // Transform relative_center.y to camera frame
- z = mZAxis * rel_center;
-
- topDist = x * mLocalPlanes[PLANE_TOP][VX] + z * mLocalPlanes[PLANE_TOP][VZ];
- if (topDist < -radius)
- {
- return 0;
- }
- else if (topDist < radius)
- {
- all_in = FALSE;
- }
-
- bottomDist = x * mLocalPlanes[PLANE_BOTTOM][VX] + z * mLocalPlanes[PLANE_BOTTOM][VZ];
- if (bottomDist < -radius)
- {
- return 0;
- }
- else if (bottomDist < radius)
- {
- all_in = FALSE;
- }
-
- if (all_in)
- {
- return 2;
- }
-
- return 1;
-}
-
-
-// HACK: This (presumably faster) version only currently works if you set up the
-// frustum planes using GL. At some point we should get those planes through another
-// mechanism, and then we can get rid of the "old" version above.
-
// Return 1 if sphere is in frustum, 2 if fully in frustum, otherwise 0.
// NOTE: 'center' is in absolute frame.
int LLCamera::sphereInFrustum(const LLVector3 &sphere_center, const F32 radius) const
@@ -463,65 +365,6 @@ F32 LLCamera::heightInPixels(const LLVector3 &center, F32 radius ) const
}
}
-// If pos is visible, return the distance from pos to the camera.
-// Use fudge distance to scale rad against top/bot/left/right planes
-// Otherwise, return -distance
-F32 LLCamera::visibleDistance(const LLVector3 &pos, F32 rad, F32 fudgedist, U32 planemask) const
-{
- if (mFixedDistance > 0)
- {
- return mFixedDistance;
- }
- LLVector3 dvec = pos - mOrigin;
- // Check visibility
- F32 dist = dvec.magVec();
- if (dist > rad)
- {
- F32 dp,tdist;
- dp = dvec * mXAxis;
- if (dp < -rad)
- return -dist;
-
- rad *= fudgedist;
- LLVector3 tvec(pos);
- for (int p=0; p<PLANE_NUM; p++)
- {
- if (!(planemask & (1<<p)))
- continue;
- tdist = -(mWorldPlanes[p].dist(tvec));
- if (tdist > rad)
- return -dist;
- }
- }
- return dist;
-}
-
-// Like visibleDistance, except uses mHorizPlanes[], which are left and right
-// planes perpindicular to (0,0,1) in world space
-F32 LLCamera::visibleHorizDistance(const LLVector3 &pos, F32 rad, F32 fudgedist, U32 planemask) const
-{
- if (mFixedDistance > 0)
- {
- return mFixedDistance;
- }
- LLVector3 dvec = pos - mOrigin;
- // Check visibility
- F32 dist = dvec.magVec();
- if (dist > rad)
- {
- rad *= fudgedist;
- LLVector3 tvec(pos);
- for (int p=0; p<HORIZ_PLANE_NUM; p++)
- {
- if (!(planemask & (1<<p)))
- continue;
- F32 tdist = -(mHorizPlanes[p].dist(tvec));
- if (tdist > rad)
- return -dist;
- }
- }
- return dist;
-}
// ---------------- friends and operators ----------------
@@ -536,18 +379,6 @@ std::ostream& operator<<(std::ostream &s, const LLCamera &C)
s << " Aspect = " << C.getAspect() << "\n";
s << " NearPlane = " << C.mNearPlane << "\n";
s << " FarPlane = " << C.mFarPlane << "\n";
- s << " TopPlane = " << C.mLocalPlanes[LLCamera::PLANE_TOP][VX] << " "
- << C.mLocalPlanes[LLCamera::PLANE_TOP][VY] << " "
- << C.mLocalPlanes[LLCamera::PLANE_TOP][VZ] << "\n";
- s << " BottomPlane = " << C.mLocalPlanes[LLCamera::PLANE_BOTTOM][VX] << " "
- << C.mLocalPlanes[LLCamera::PLANE_BOTTOM][VY] << " "
- << C.mLocalPlanes[LLCamera::PLANE_BOTTOM][VZ] << "\n";
- s << " LeftPlane = " << C.mLocalPlanes[LLCamera::PLANE_LEFT][VX] << " "
- << C.mLocalPlanes[LLCamera::PLANE_LEFT][VY] << " "
- << C.mLocalPlanes[LLCamera::PLANE_LEFT][VZ] << "\n";
- s << " RightPlane = " << C.mLocalPlanes[LLCamera::PLANE_RIGHT][VX] << " "
- << C.mLocalPlanes[LLCamera::PLANE_RIGHT][VY] << " "
- << C.mLocalPlanes[LLCamera::PLANE_RIGHT][VZ] << "\n";
s << "}";
return s;
}
@@ -675,26 +506,6 @@ void LLCamera::calcRegionFrustumPlanes(const LLVector3& shift, F32 far_clip_dist
void LLCamera::calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom)
{
- LLVector3 a, b, c;
-
- // For each plane we need to define 3 points (LLVector3's) in camera view space.
- // The order in which we pass the points to planeFromPoints() matters, because the
- // plane normal has a degeneracy of 2; we want it pointing _into_ the frustum.
-
- a.setVec(0.0f, 0.0f, 0.0f);
- b.setVec(mFarPlane, right, top);
- c.setVec(mFarPlane, right, bottom);
- mLocalPlanes[PLANE_RIGHT].setVec(a, b, c);
-
- c.setVec(mFarPlane, left, top);
- mLocalPlanes[PLANE_TOP].setVec(a, c, b);
-
- b.setVec(mFarPlane, left, bottom);
- mLocalPlanes[PLANE_LEFT].setVec(a, b, c);
-
- c.setVec(mFarPlane, right, bottom);
- mLocalPlanes[PLANE_BOTTOM].setVec( a, c, b);
-
//calculate center and radius squared of frustum in world absolute coordinates
static LLVector3 const X_AXIS(1.f, 0.f, 0.f);
mFrustCenter = X_AXIS*mFarPlane*0.5f;
@@ -718,39 +529,6 @@ void LLCamera::calculateFrustumPlanesFromWindow(F32 x1, F32 y1, F32 x2, F32 y2)
calculateFrustumPlanes(left, right, top, bottom);
}
-void LLCamera::calculateWorldFrustumPlanes()
-{
- F32 d;
- LLVector3 center = mOrigin - mXAxis*mNearPlane;
- mWorldPlanePos = center;
- LLVector3 pnorm;
- for (int p = 0; p < PLANE_NUM; p++)
- {
- mLocalPlanes[p].getVector3(pnorm);
- LLVector3 norm = rotateToAbsolute(pnorm);
- norm.normVec();
- d = -(center * norm);
- mWorldPlanes[p] = LLPlane(norm, d);
- }
- // horizontal planes, perpindicular to (0,0,1);
- LLVector3 zaxis(0, 0, 1.0f);
- F32 yaw = getYaw();
- {
- LLVector3 tnorm;
- mLocalPlanes[PLANE_LEFT].getVector3(tnorm);
- tnorm.rotVec(yaw, zaxis);
- d = -(mOrigin * tnorm);
- mHorizPlanes[HORIZ_PLANE_LEFT] = LLPlane(tnorm, d);
- }
- {
- LLVector3 tnorm;
- mLocalPlanes[PLANE_RIGHT].getVector3(tnorm);
- tnorm.rotVec(yaw, zaxis);
- d = -(mOrigin * tnorm);
- mHorizPlanes[HORIZ_PLANE_RIGHT] = LLPlane(tnorm, d);
- }
-}
-
// NOTE: this is the OpenGL matrix that will transform the default OpenGL view
// (-Z=at, Y=up) to the default view of the LLCamera class (X=at, Z=up):
//
diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h
index d0afa0e88f..27eaa614c9 100644
--- a/indra/llmath/llcamera.h
+++ b/indra/llmath/llcamera.h
@@ -131,14 +131,10 @@ private:
S32 mViewHeightInPixels; // for ViewHeightInPixels() only
F32 mNearPlane;
F32 mFarPlane;
- LL_ALIGN_16(LLPlane mLocalPlanes[PLANE_NUM]);
F32 mFixedDistance; // Always return this distance, unless < 0
LLVector3 mFrustCenter; // center of frustum and radius squared for ultra-quick exclusion test
F32 mFrustRadiusSquared;
- LL_ALIGN_16(LLPlane mWorldPlanes[PLANE_NUM]);
- LL_ALIGN_16(LLPlane mHorizPlanes[HORIZ_PLANE_NUM]);
-
U32 mPlaneCount; //defaults to 6, if setUserClipPlane is called, uses user supplied clip plane in
LLVector3 mWorldPlanePos; // Position of World Planes (may be offset from camera)
@@ -184,7 +180,6 @@ public:
return atan2f(mXAxis[VZ], xylen);
}
- const LLPlane& getWorldPlane(S32 index) const { return mWorldPlanes[index]; }
const LLVector3& getWorldPlanePos() const { return mWorldPlanePos; }
// Copy mView, mAspect, mNearPlane, and mFarPlane to buffer.
@@ -200,7 +195,6 @@ public:
// Returns 1 if partly in, 2 if fully in.
// NOTE: 'center' is in absolute frame.
- S32 sphereInFrustumOld(const LLVector3 &center, const F32 radius) const;
S32 sphereInFrustum(const LLVector3 &center, const F32 radius) const;
S32 pointInFrustum(const LLVector3 &point) const { return sphereInFrustum(point, 0.0f); }
S32 sphereInFrustumFull(const LLVector3 &center, const F32 radius) const { return sphereInFrustum(center, radius); }
@@ -217,8 +211,6 @@ public:
F32 heightInPixels(const LLVector3 &center, F32 radius ) const;
// return the distance from pos to camera if visible (-distance if not visible)
- F32 visibleDistance(const LLVector3 &pos, F32 rad, F32 fudgescale = 1.0f, U32 planemask = PLANE_ALL_MASK) const;
- F32 visibleHorizDistance(const LLVector3 &pos, F32 rad, F32 fudgescale = 1.0f, U32 planemask = HORIZ_PLANE_ALL_MASK) const;
void setFixedDistance(F32 distance) { mFixedDistance = distance; }
friend std::ostream& operator<<(std::ostream &s, const LLCamera &C);
@@ -227,7 +219,6 @@ protected:
void calculateFrustumPlanes();
void calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom);
void calculateFrustumPlanesFromWindow(F32 x1, F32 y1, F32 x2, F32 y2);
- void calculateWorldFrustumPlanes();
} LL_ALIGN_POSTFIX(16);
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 5ade88e32b..e0662b8115 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9002,37 +9002,6 @@
<key>Value</key>
<integer>1</integer>
</map>
-
- <key>RenderShadowNearDist</key>
- <map>
- <key>Comment</key>
- <string>Near clip plane of shadow camera (affects precision of depth shadows).</string>
- <key>Persist</key>
- <integer>1</integer>
- <key>Type</key>
- <string>Vector3</string>
- <key>Value</key>
- <array>
- <real>256</real>
- <real>256</real>
- <real>256</real>
- </array>
- </map>
- <key>RenderShadowClipPlanes</key>
- <map>
- <key>Comment</key>
- <string>Near clip plane split distances for shadow map frusta.</string>
- <key>Persist</key>
- <integer>1</integer>
- <key>Type</key>
- <string>Vector3</string>
- <key>Value</key>
- <array>
- <real>1.0</real>
- <real>12.0</real>
- <real>32.0</real>
- </array>
- </map>
<key>RenderShadowSplitExponent</key>
<map>
<key>Comment</key>
@@ -9048,21 +9017,6 @@
<real>2.0</real>
</array>
</map>
- <key>RenderShadowOrthoClipPlanes</key>
- <map>
- <key>Comment</key>
- <string>Near clip plane split distances for orthographic shadow map frusta.</string>
- <key>Persist</key>
- <integer>1</integer>
- <key>Type</key>
- <string>Vector3</string>
- <key>Value</key>
- <array>
- <real>4.0</real>
- <real>8.0</real>
- <real>24.0</real>
- </array>
- </map>
<key>RenderShadowProjOffset</key>
<map>
<key>Comment</key>
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index f059c87c91..a53b3aac8e 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -202,9 +202,6 @@ LLVector3 LLPipeline::RenderShadowGaussian;
F32 LLPipeline::RenderShadowBlurDistFactor;
bool LLPipeline::RenderDeferredAtmospheric;
F32 LLPipeline::RenderHighlightFadeTime;
-LLVector3 LLPipeline::RenderShadowClipPlanes;
-LLVector3 LLPipeline::RenderShadowOrthoClipPlanes;
-LLVector3 LLPipeline::RenderShadowNearDist;
F32 LLPipeline::RenderFarClip;
LLVector3 LLPipeline::RenderShadowSplitExponent;
F32 LLPipeline::RenderShadowErrorCutoff;
@@ -558,9 +555,6 @@ void LLPipeline::init()
connectRefreshCachedSettingsSafe("RenderShadowBlurDistFactor");
connectRefreshCachedSettingsSafe("RenderDeferredAtmospheric");
connectRefreshCachedSettingsSafe("RenderHighlightFadeTime");
- connectRefreshCachedSettingsSafe("RenderShadowClipPlanes");
- connectRefreshCachedSettingsSafe("RenderShadowOrthoClipPlanes");
- connectRefreshCachedSettingsSafe("RenderShadowNearDist");
connectRefreshCachedSettingsSafe("RenderFarClip");
connectRefreshCachedSettingsSafe("RenderShadowSplitExponent");
connectRefreshCachedSettingsSafe("RenderShadowErrorCutoff");
@@ -1043,9 +1037,6 @@ void LLPipeline::refreshCachedSettings()
RenderShadowBlurDistFactor = gSavedSettings.getF32("RenderShadowBlurDistFactor");
RenderDeferredAtmospheric = gSavedSettings.getBOOL("RenderDeferredAtmospheric");
RenderHighlightFadeTime = gSavedSettings.getF32("RenderHighlightFadeTime");
- RenderShadowClipPlanes = gSavedSettings.getVector3("RenderShadowClipPlanes");
- RenderShadowOrthoClipPlanes = gSavedSettings.getVector3("RenderShadowOrthoClipPlanes");
- RenderShadowNearDist = gSavedSettings.getVector3("RenderShadowNearDist");
RenderFarClip = gSavedSettings.getF32("RenderFarClip");
RenderShadowSplitExponent = gSavedSettings.getVector3("RenderShadowSplitExponent");
RenderShadowErrorCutoff = gSavedSettings.getF32("RenderShadowErrorCutoff");
@@ -9277,27 +9268,12 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
glh::matrix4f view[6];
glh::matrix4f proj[6];
- //clip contains parallel split distances for 3 splits
- LLVector3 clip = RenderShadowClipPlanes;
-
LLVector3 caster_dir(environment.getIsSunUp() ? mSunDir : mMoonDir);
- //F32 slope_threshold = gSavedSettings.getF32("RenderShadowSlopeThreshold");
-
- //far clip on last split is minimum of camera view distance and 128
- mSunClipPlanes = LLVector4(clip, clip.mV[2] * clip.mV[2]/clip.mV[1]);
-
- clip = RenderShadowOrthoClipPlanes;
- mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]);
-
- //currently used for amount to extrude frusta corners for constructing shadow frusta
- //LLVector3 n = RenderShadowNearDist;
- //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] };
-
//put together a universal "near clip" plane for shadow frusta
LLPlane shadow_near_clip;
{
- LLVector3 p = gAgent.getPositionAgent();
+ LLVector3 p = camera.getOrigin(); // gAgent.getPositionAgent();
p += caster_dir * RenderFarClip*2.f;
shadow_near_clip.setVec(p, caster_dir);
}
@@ -9318,9 +9294,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
up = camera.getUpAxis();
}
- /*LLVector3 left = up%at;
- up = at%left;*/
-
up.normVec();
at.normVec();
@@ -9403,6 +9376,14 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
mSunClipPlanes.mV[0] *= 1.25f; //bump back first split for transition padding
}
+ if (gCubeSnapshot)
+ { // stretch clip planes for reflection probe renders to reduce number of shadow passes
+ mSunClipPlanes.mV[1] = mSunClipPlanes.mV[2];
+ mSunClipPlanes.mV[2] = mSunClipPlanes.mV[3];
+ mSunClipPlanes.mV[3] *= 1.5f;
+ }
+
+
// convenience array of 4 near clip plane distances
F32 dist[] = { near_clip, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] };
@@ -9419,7 +9400,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
}
else
{
- for (S32 j = 0; j < (gCubeSnapshot ? 3 : 4); j++)
+ for (S32 j = 0; j < (gCubeSnapshot ? 2 : 4); j++)
{
if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot)
{
diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h
index 0faa0c3f20..4cefb719fd 100644
--- a/indra/newview/pipeline.h
+++ b/indra/newview/pipeline.h
@@ -999,9 +999,6 @@ public:
static F32 RenderShadowBlurDistFactor;
static bool RenderDeferredAtmospheric;
static F32 RenderHighlightFadeTime;
- static LLVector3 RenderShadowClipPlanes;
- static LLVector3 RenderShadowOrthoClipPlanes;
- static LLVector3 RenderShadowNearDist;
static F32 RenderFarClip;
static LLVector3 RenderShadowSplitExponent;
static F32 RenderShadowErrorCutoff;