summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@geenzo.com>2023-09-29 16:25:25 -0700
committerJonathan "Geenz" Goodman <geenz@geenzo.com>2023-09-29 16:25:25 -0700
commit1d3d94a514a74b41f1fafaef45e105774d5d8505 (patch)
treedd34d5c5cf6027206d9fbc56d9e0815a679fd1e1 /indra
parent32bfafca4dab088b5aab89affb233aaaac65666a (diff)
Add probe near clipping.
DRTVWR-583
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/app_settings/settings.xml11
-rw-r--r--indra/newview/llheroprobemanager.cpp41
-rw-r--r--indra/newview/llheroprobemanager.h2
-rw-r--r--indra/newview/llreflectionmap.cpp6
-rw-r--r--indra/newview/llreflectionmap.h2
5 files changed, 35 insertions, 27 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 709dfd3844..82545a5dda 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -10434,6 +10434,17 @@
<key>Value</key>
<real>16</real>
</map>
+ <key>RenderHeroProbeNearClipOffset</key>
+ <map>
+ <key>Comment</key>
+ <string>Distance offset in meters for hero probes to near clip.</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>F32</string>
+ <key>Value</key>
+ <real>2.1</real>
+ </map>
<key>RenderReflectionProbeVolumes</key>
<map>
<key>Comment</key>
diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp
index dec75f5d2b..15b54ec6bc 100644
--- a/indra/newview/llheroprobemanager.cpp
+++ b/indra/newview/llheroprobemanager.cpp
@@ -83,8 +83,8 @@ void LLHeroProbeManager::update()
if (!mRenderTarget.isComplete())
{
- U32 color_fmt = GL_RGB16F;
- U32 targetRes = mProbeResolution * 4; // super sample
+ U32 color_fmt = GL_RGBA16F;
+ U32 targetRes = mProbeResolution; // super sample
mRenderTarget.allocate(targetRes, targetRes, color_fmt, true);
}
@@ -96,7 +96,7 @@ void LLHeroProbeManager::update()
mMipChain.resize(count);
for (int i = 0; i < count; ++i)
{
- mMipChain[i].allocate(res, res, GL_RGB16F);
+ mMipChain[i].allocate(res, res, GL_RGBA16F);
res /= 2;
}
}
@@ -105,6 +105,7 @@ void LLHeroProbeManager::update()
LLVector4a probe_pos;
LLVector3 camera_pos = LLViewerCamera::instance().mOrigin;
+ F32 near_clip = 0.1f;
if (mHeroVOList.size() > 0)
{
if (mNearestHero != nullptr && mNearestHero->mDrawable.notNull())
@@ -136,6 +137,8 @@ void LLHeroProbeManager::update()
LLVector3 reject = offset - project;
LLVector3 point = (reject - project) + hero_pos;
+ near_clip = abs(dist_vec(hero_pos, point)) - gSavedSettings.getF32("RenderHeroProbeNearClipOffset");
+
probe_pos.load3(point.mV);
}
@@ -163,7 +166,7 @@ void LLHeroProbeManager::update()
{
for (U32 i = 0; i < 6; ++i)
{
- updateProbeFace(mProbes[j], i);
+ updateProbeFace(mProbes[j], i, near_clip);
}
}
@@ -179,12 +182,12 @@ void LLHeroProbeManager::update()
// The next six passes render the scene with both radiance and irradiance into the same scratch space cube map and generate a simple mip chain.
// At the end of these passes, a radiance map is generated for this probe and placed into the radiance cube map array at the index for this probe.
// In effect this simulates single-bounce lighting.
-void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face)
+void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face, F32 near_clip)
{
// hacky hot-swap of camera specific render targets
gPipeline.mRT = &gPipeline.mAuxillaryRT;
- probe->update(mRenderTarget.getWidth(), face, true);
+ probe->update(mRenderTarget.getWidth(), face, true, near_clip);
gPipeline.mRT = &gPipeline.mMainRT;
@@ -217,7 +220,8 @@ void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face)
static LLStaticHashedString znear("znear");
static LLStaticHashedString zfar("zfar");
- LLRenderTarget* screen_rt = &gPipeline.mAuxillaryRT.screen;
+ LLRenderTarget *screen_rt = &gPipeline.mAuxillaryRT.screen;
+ LLRenderTarget *depth_rt = &gPipeline.mAuxillaryRT.deferredScreen;
// perform a gaussian blur on the super sampled render before downsampling
{
@@ -247,6 +251,7 @@ void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face)
gReflectionMipProgram.bind();
S32 diffuseChannel = gReflectionMipProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, LLTexUnit::TT_TEXTURE);
+ S32 depthChannel = gReflectionMipProgram.enableTexture(LLShaderMgr::DEFERRED_DEPTH, LLTexUnit::TT_TEXTURE);
for (int i = 0; i < mMipChain.size(); ++i)
{
@@ -261,8 +266,11 @@ void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face)
gGL.getTexUnit(diffuseChannel)->bind(&(mMipChain[i - 1]));
}
+ gGL.getTexUnit(depthChannel)->bind(depth_rt, true);
- gReflectionMipProgram.uniform1f(resScale, 1.f/(mProbeResolution*2));
+ gReflectionMipProgram.uniform1f(resScale, 1.f / (mProbeResolution * 2));
+ gReflectionMipProgram.uniform1f(znear, probe->getNearClip());
+ gReflectionMipProgram.uniform1f(zfar, MAX_FAR_CLIP);
gPipeline.mScreenTriangleVB->setBuffer();
gPipeline.mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3);
@@ -315,10 +323,12 @@ void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face)
static LLStaticHashedString sMipLevel("mipLevel");
static LLStaticHashedString sRoughness("roughness");
static LLStaticHashedString sWidth("u_width");
+ static LLStaticHashedString sStrength("probe_strength");
gRadianceGenProgram.uniform1f(sRoughness, (F32)i / (F32)(mMipChain.size() - 1));
gRadianceGenProgram.uniform1f(sMipLevel, i);
gRadianceGenProgram.uniform1i(sWidth, mProbeResolution);
+ gRadianceGenProgram.uniform1f(sStrength, 1);
for (int cf = 0; cf < 6; ++cf)
{ // for each cube face
@@ -385,21 +395,6 @@ void LLHeroProbeManager::updateUniforms()
glBufferData(GL_UNIFORM_BUFFER, sizeof(HeroProbeData), &hpd, GL_STREAM_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
-
-#if 0
- if (!gCubeSnapshot)
- {
- for (auto& probe : mProbes)
- {
- LLViewerObject* vobj = probe->mViewerObject;
- if (vobj)
- {
- F32 time = (F32)gFrameTimeSeconds - probe->mLastUpdateTime;
- vobj->setDebugText(llformat("%d/%d/%d/%.1f - %.1f/%.1f", probe->mCubeIndex, probe->mProbeIndex, (U32) probe->mNeighbors.size(), probe->mMinDepth, probe->mMaxDepth, time), time > 1.f ? LLColor4::white : LLColor4::green);
- }
- }
- }
-#endif
}
void LLHeroProbeManager::setUniforms()
diff --git a/indra/newview/llheroprobemanager.h b/indra/newview/llheroprobemanager.h
index 30943f739b..4a243e6cf2 100644
--- a/indra/newview/llheroprobemanager.h
+++ b/indra/newview/llheroprobemanager.h
@@ -95,7 +95,7 @@ private:
LLPointer<LLVertexBuffer> mVertexBuffer;
// update the specified face of the specified probe
- void updateProbeFace(LLReflectionMap* probe, U32 face);
+ void updateProbeFace(LLReflectionMap* probe, U32 face, F32 near_clip);
// list of active reflection maps
std::vector<LLPointer<LLReflectionMap> > mProbes;
diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp
index 07c712a9a6..06624e8fea 100644
--- a/indra/newview/llreflectionmap.cpp
+++ b/indra/newview/llreflectionmap.cpp
@@ -49,7 +49,7 @@ LLReflectionMap::~LLReflectionMap()
}
}
-void LLReflectionMap::update(U32 resolution, U32 face, bool force_dynamic)
+void LLReflectionMap::update(U32 resolution, U32 face, bool force_dynamic, F32 near_clip)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
mLastUpdateTime = gFrameTimeSeconds;
@@ -63,8 +63,10 @@ void LLReflectionMap::update(U32 resolution, U32 face, bool force_dynamic)
{
resolution /= 2;
}
+
+ F32 clip = (near_clip > 0) ? near_clip : getNearClip();
- gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip(), getIsDynamic() || force_dynamic);
+ gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, clip, getIsDynamic() || force_dynamic);
}
void LLReflectionMap::autoAdjustOrigin()
diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h
index a23bdc3a98..e97b28c855 100644
--- a/indra/newview/llreflectionmap.h
+++ b/indra/newview/llreflectionmap.h
@@ -52,7 +52,7 @@ public:
// update this environment map
// resolution - size of cube map to generate
- void update(U32 resolution, U32 face, bool force_dynamic = false);
+ void update(U32 resolution, U32 face, bool force_dynamic = false, F32 near_clip = -1.f);
// for volume partition probes, try to place this probe in the best spot
void autoAdjustOrigin();