diff options
| author | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2023-08-29 05:08:47 -0700 | 
|---|---|---|
| committer | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2023-08-29 05:08:47 -0700 | 
| commit | 348d427db6537746c5c8c9a0d1aa021f074afbb5 (patch) | |
| tree | e2782a5638bd489d30dcd0bb1fd507e575cc1fe2 | |
| parent | c5bfe869154cd4708c9bca63f08cb4c958198638 (diff) | |
Add a probe strength uniform for hero probes.
On standard reflection probes this doesn't really do anything.
DRTVWR-583
| -rw-r--r-- | indra/llrender/llshadermgr.cpp | 1 | ||||
| -rw-r--r-- | indra/llrender/llshadermgr.h | 1 | ||||
| -rw-r--r-- | indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl | 2 | ||||
| -rw-r--r-- | indra/newview/llheroprobemanager.cpp | 73 | ||||
| -rw-r--r-- | indra/newview/llheroprobemanager.h | 7 | ||||
| -rw-r--r-- | indra/newview/llreflectionmapmanager.cpp | 1 | ||||
| -rw-r--r-- | indra/newview/llvovolume.cpp | 2 | 
7 files changed, 34 insertions, 53 deletions
| diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 6730a12d6c..8bb5be0332 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1460,6 +1460,7 @@ void LLShaderMgr::initAttribsAndUniforms()      mReservedUniforms.push_back("cloud_variance");      mReservedUniforms.push_back("reflection_probe_ambiance");      mReservedUniforms.push_back("max_probe_lod"); +    mReservedUniforms.push_back("probe_strength");      mReservedUniforms.push_back("sh_input_r");      mReservedUniforms.push_back("sh_input_g"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 53c8323cff..6a5243a898 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -278,6 +278,7 @@ public:          REFLECTION_PROBE_AMBIANCE,          //  "reflection_probe_ambiance"          REFLECTION_PROBE_MAX_LOD,            //  "max_probe_lod" +        REFLECTION_PROBE_STRENGTH,            //  "probe_strength"          SH_INPUT_L1R,                       //  "sh_input_r"          SH_INPUT_L1G,                       //  "sh_input_g"          SH_INPUT_L1B,                       //  "sh_input_b" diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index 9ecdf0bf77..cb6f34713c 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -38,6 +38,7 @@ in vec3 vary_dir;  uniform float mipLevel;  uniform int u_width;   uniform float max_probe_lod; +uniform float probe_strength;  // ============================================================================================================= @@ -163,5 +164,6 @@ void main()  {		  	vec3 N = normalize(vary_dir);  	frag_color = max(prefilterEnvMap(N), vec4(0)); +    frag_color.a *= probe_strength;  }  // ============================================================================================================= diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index 6374b10823..c385c9a99f 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -104,68 +104,41 @@ void LLHeroProbeManager::update()      llassert(mProbes[0] == mDefaultProbe);      LLVector4a probe_pos; -     -    if (mHeroList.empty()) +    LLVector3 camera_pos = LLViewerCamera::instance().mOrigin;      { -        LLVector3 focus_point; +        // Get the nearest hero. +        float distance = F32_MAX; -        LLViewerObject* obj = LLViewerMediaFocus::getInstance()->getFocusedObject(); -        if (obj && obj->mDrawable && obj->isSelected()) -        { // focus on selected media object -            S32 face_idx = LLViewerMediaFocus::getInstance()->getFocusedFace(); -            if (obj && obj->mDrawable) -            { -                LLFace* face = obj->mDrawable->getFace(face_idx); -                if (face) -                { -                    focus_point = face->getPositionAgent(); -                } -            } +        if (mNearestHero.notNull()) +        { +            distance = mNearestHero->mDistanceWRTCamera;          } -        if (focus_point.isExactlyZero()) +        for (auto drawable : mHeroList)          { -            if (LLViewerJoystick::getInstance()->getOverrideCamera()) -            { // focus on point under cursor -                focus_point.set(gDebugRaycastIntersection.getF32ptr()); -            } -            else if (gAgentCamera.cameraMouselook()) -            { // focus on point under mouselook crosshairs -                LLVector4a result; -                result.clear(); -                 -                gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); -                 -                focus_point.set(result.getF32ptr()); -            } -            else +            if (drawable.notNull() && drawable != mNearestHero)              { -                // focus on alt-zoom target -                LLViewerRegion* region = gAgent.getRegion(); -                if (region) +                if (drawable->mDistanceWRTCamera < distance)                  { -                    focus_point = LLVector3(gAgentCamera.getFocusGlobal() - region->getOriginGlobal()); +                    mIsInTransition = true; +                    mNearestHero = drawable;                  }              }          } -         -        probe_pos.load3(((focus_point)).mV); +    } +     +    if (mIsInTransition && mHeroProbeStrength > 0.f) +    { +        mHeroProbeStrength -= 0.05f;      }      else      { -        // Get the nearest hero. -        float distance = F32_MAX; +        if (mNearestHero.notNull()) +            probe_pos.set(mNearestHero->mXform.getPosition().mV[0], mNearestHero->mXform.getPosition().mV[1], camera_pos.mV[2]); -        for (auto drawable : mHeroList) -        { -            if (drawable.notNull()) -            { -                if (drawable->mDistanceWRTCamera < distance) -                { -                    probe_pos.load3(drawable->mXform.getPosition().mV); -                } -            } -        } +         +        if (mHeroProbeStrength < 1.f) +            mHeroProbeStrength += 0.05f;      }      static LLCachedControl<S32> sDetail(gSavedSettings, "RenderHeroReflectionProbeDetail", -1); @@ -328,7 +301,8 @@ void LLHeroProbeManager::updateProbeFace(LLReflectionMap* probe, U32 face)              mTexture->bind(channel);              gRadianceGenProgram.uniform1i(sSourceIdx, sourceIdx);              gRadianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mMaxProbeLOD); - +            gRadianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_STRENGTH, mHeroProbeStrength); +                          U32 res = mMipChain[0].getWidth();              for (int i = 0; i < mMipChain.size(); ++i) @@ -554,7 +528,6 @@ void LLHeroProbeManager::registerHeroDrawable(LLDrawable* drawablep)      if (mHeroList.find(drawablep) == mHeroList.end())      {          mHeroList.insert(drawablep); -        LL_INFOS() << "Added hero drawable." << LL_ENDL;      }  } diff --git a/indra/newview/llheroprobemanager.h b/indra/newview/llheroprobemanager.h index c6df963cfd..24246af3d3 100644 --- a/indra/newview/llheroprobemanager.h +++ b/indra/newview/llheroprobemanager.h @@ -117,15 +117,18 @@ private:      U32 mReflectionProbeCount;      // resolution of reflection probes -    U32 mProbeResolution = 128; +    U32 mProbeResolution = 1024;      // maximum LoD of reflection probes (mip levels - 1)      F32 mMaxProbeLOD = 6.f; +     +    F32 mHeroProbeStrength = 1.f; +    bool mIsInTransition = false;      // if true, reset all probe render state on the next update (for teleports and sky changes)      bool mReset = false;      LLDrawable::ordered_drawable_set_t  mHeroList; -    LLDrawable*                         mNearestHero; +    LLPointer<LLDrawable>               mNearestHero;  }; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index e855be8fbd..61143c61e8 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -714,6 +714,7 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face)              mTexture->bind(channel);              gRadianceGenProgram.uniform1i(sSourceIdx, sourceIdx);              gRadianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mMaxProbeLOD); +            gRadianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_STRENGTH, 1.f);              U32 res = mMipChain[0].getWidth(); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 6db1ae07de..3c3d8d5123 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1045,7 +1045,7 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline)          updateReflectionProbePtr();      } -    if (isMirror()) +    //if (isMirror())      {          gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable);      } | 
