From b3283036af886de56f45c731ab21e2b16383a770 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 26 Feb 2024 04:02:09 -0800 Subject: #681 Start adding blending boilerplate. --- indra/newview/llheroprobemanager.cpp | 37 +++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'indra/newview/llheroprobemanager.cpp') diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index a00b6d6b5d..ee993c6ba1 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -417,7 +417,7 @@ void LLHeroProbeManager::generateRadiance(LLReflectionMap* probe) void LLHeroProbeManager::updateUniforms() { - if (!LLPipeline::sReflectionProbesEnabled) + if (!gPipeline.RenderMirrors) { return; } @@ -426,8 +426,11 @@ void LLHeroProbeManager::updateUniforms() struct HeroProbeData { - LLVector4 heroPosition[1]; - GLint heroProbeCount = 1; + LLMatrix4 heroBox[1]; + LLVector4 heroSphere[1]; + GLint heroShape[1]; + GLint heroMipCount; + GLint heroProbeCount; }; HeroProbeData hpd; @@ -437,8 +440,32 @@ void LLHeroProbeManager::updateUniforms() LLVector4a oa; // scratch space for transformed origin oa.set(0, 0, 0, 0); hpd.heroProbeCount = 1; - modelview.affineTransform(mProbes[0]->mOrigin, oa); - hpd.heroPosition[0].set(oa.getF32ptr()); + + if (mNearestHero != nullptr) + { + mProbes[0]->mViewerObject = mNearestHero; + if (mNearestHero->getReflectionProbeIsBox()) + { + LLVector3 s = mNearestHero->getScale().scaledVec(LLVector3(0.5f, 0.5f, 0.5f)); + mProbes[0]->mRadius = s.magVec(); + } + else + { + mProbes[0]->mRadius = mNearestHero->getScale().mV[0] * 0.5f; + } + + modelview.affineTransform(mProbes[0]->mOrigin, oa); + hpd.heroShape[0] = 0; + if (!mProbes[0]->getBox(hpd.heroBox[0])) + { + hpd.heroShape[0] = 1; + } + + hpd.heroSphere[0].set(oa.getF32ptr()); + hpd.heroSphere[0].mV[3] = mProbes[0]->mRadius; + } + + hpd.heroMipCount = mMipChain.size(); //copy rpd into uniform buffer object if (mUBO == 0) -- cgit v1.2.3 From 1fc45a50ff15e6f31a4554da83256b7f59b1af15 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Wed, 6 Mar 2024 17:56:16 -0800 Subject: #681 Add probe blending for mirrors. --- indra/newview/llheroprobemanager.cpp | 62 +++++++----------------------------- 1 file changed, 12 insertions(+), 50 deletions(-) (limited to 'indra/newview/llheroprobemanager.cpp') diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index ee993c6ba1..8f1c1848cc 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -151,6 +151,7 @@ void LLHeroProbeManager::update() // Collect the list of faces that need updating based upon the camera's rotation. LLVector3 cam_direction = LLVector3(0, 0, 1) * LLViewerCamera::instance().getQuaternion(); + cam_direction.normalize(); static LLVector3 cubeFaces[6] = { LLVector3(1, 0, 0), @@ -163,7 +164,7 @@ void LLHeroProbeManager::update() for (int i = 0; i < 6; i++) { - float shouldUpdate = cam_direction * cubeFaces[i] * 0.5 + 0.5; + float shouldUpdate = fminf(1, (fmaxf(-1, cam_direction * cubeFaces[i]) * 0.5 + 0.5)); int updateRate = ceilf((1 - shouldUpdate) * gPipeline.RenderHeroProbeConservativeUpdateMultiplier); @@ -215,6 +216,9 @@ void LLHeroProbeManager::update() mRenderingMirror = false; gPipeline.mReflectionMapManager.mRadiancePass = radiance_pass; + + mProbes[0]->mViewerObject = mNearestHero; + mProbes[0]->autoAdjustOrigin(); } mCurrentProbeUpdateFrame++; @@ -424,26 +428,14 @@ void LLHeroProbeManager::updateUniforms() LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; - struct HeroProbeData - { - LLMatrix4 heroBox[1]; - LLVector4 heroSphere[1]; - GLint heroShape[1]; - GLint heroMipCount; - GLint heroProbeCount; - }; - - HeroProbeData hpd; - LLMatrix4a modelview; modelview.loadu(gGLModelView); LLVector4a oa; // scratch space for transformed origin oa.set(0, 0, 0, 0); - hpd.heroProbeCount = 1; + mHeroData.heroProbeCount = 1; if (mNearestHero != nullptr) { - mProbes[0]->mViewerObject = mNearestHero; if (mNearestHero->getReflectionProbeIsBox()) { LLVector3 s = mNearestHero->getScale().scaledVec(LLVector3(0.5f, 0.5f, 0.5f)); @@ -455,44 +447,17 @@ void LLHeroProbeManager::updateUniforms() } modelview.affineTransform(mProbes[0]->mOrigin, oa); - hpd.heroShape[0] = 0; - if (!mProbes[0]->getBox(hpd.heroBox[0])) + mHeroData.heroShape = 0; + if (!mProbes[0]->getBox(mHeroData.heroBox)) { - hpd.heroShape[0] = 1; + mHeroData.heroShape = 1; } - hpd.heroSphere[0].set(oa.getF32ptr()); - hpd.heroSphere[0].mV[3] = mProbes[0]->mRadius; + mHeroData.heroSphere.set(oa.getF32ptr()); + mHeroData.heroSphere.mV[3] = mProbes[0]->mRadius; } - hpd.heroMipCount = mMipChain.size(); - - //copy rpd into uniform buffer object - if (mUBO == 0) - { - glGenBuffers(1, &mUBO); - } - - { - LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmsu - update buffer"); - glBindBuffer(GL_UNIFORM_BUFFER, mUBO); - glBufferData(GL_UNIFORM_BUFFER, sizeof(HeroProbeData), &hpd, GL_STREAM_DRAW); - glBindBuffer(GL_UNIFORM_BUFFER, 0); - } -} - -void LLHeroProbeManager::setUniforms() -{ - if (!LLPipeline::sReflectionProbesEnabled) - { - return; - } - - if (mUBO == 0) - { - updateUniforms(); - } - glBindBufferBase(GL_UNIFORM_BUFFER, 1, mUBO); + mHeroData.heroMipCount = mMipChain.size(); } void LLHeroProbeManager::renderDebug() @@ -581,9 +546,6 @@ void LLHeroProbeManager::cleanup() mDefaultProbe = nullptr; mUpdatingProbe = nullptr; - - glDeleteBuffers(1, &mUBO); - mUBO = 0; mHeroVOList.clear(); mNearestHero = nullptr; -- cgit v1.2.3 From 4b738a619a475447af8b917644357cb49dc22fb9 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Wed, 6 Mar 2024 18:24:36 -0800 Subject: #681 Small fix for if a viewer object may be dead. --- indra/newview/llheroprobemanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llheroprobemanager.cpp') diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index 8f1c1848cc..10b743ceef 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -434,7 +434,7 @@ void LLHeroProbeManager::updateUniforms() oa.set(0, 0, 0, 0); mHeroData.heroProbeCount = 1; - if (mNearestHero != nullptr) + if (mNearestHero != nullptr && !mNearestHero->isDead()) { if (mNearestHero->getReflectionProbeIsBox()) { -- cgit v1.2.3