From d8dd4d9c0cd4554704cbe15b5502f4d87a4674ad Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 27 Jun 2023 20:01:52 -0700 Subject: Just about got hero reflection maps working. DRTVWR-583 --- indra/llprimitive/lltextureentry.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'indra/llprimitive/lltextureentry.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 71caff1686..d057e5ab29 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -504,6 +504,16 @@ S32 LLTextureEntry::setFullbright(U8 fullbright) return TEM_CHANGE_NONE; } +S32 LLTextureEntry::setRenderableTarget(eRenderableTarget target) +{ + if (getRenderableTarget() != target) { + mRenderableTarget = target; + return TEM_CHANGE_TEXTURE; + } + + return TEM_CHANGE_NONE; +} + S32 LLTextureEntry::setShiny(U8 shiny) { shiny &= TEM_SHINY_MASK; @@ -685,6 +695,15 @@ S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) mMaterialUpdatePending = true; } mMaterial = pMaterialParams; + + // TODO: GZ: We should avoid magic UUIDs in the future, but for development we're using one for the time being. Remove this later. + if (mMaterial->getSpecularID().asString() == "da7ecda1-e780-423f-ce27-26df7dc69cb6") + { + setRenderableTarget(RT_MIRROR); + } else { + setRenderableTarget(RT_DISABLED); + } + return TEM_CHANGE_TEXTURE; } -- cgit v1.3 From b861832102abf469963bd3c56f7b009ba4432d6a Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Sun, 6 Aug 2023 23:33:29 -0700 Subject: Making more progress, need to add the heroprobe manager. DRTVWR-583 --- indra/llprimitive/lltextureentry.cpp | 8 ------ .../shaders/class3/deferred/softenLightF.glsl | 4 ++- indra/newview/lldrawable.h | 1 + indra/newview/llreflectionmapmanager.cpp | 20 +++++++++------ indra/newview/llreflectionmapmanager.h | 4 ++- indra/newview/llviewerobject.h | 1 + indra/newview/llvovolume.cpp | 30 +++++++++++++++++++++- indra/newview/llvovolume.h | 2 ++ indra/newview/pipeline.cpp | 22 ++++++++++++++++ indra/newview/pipeline.h | 5 ++++ 10 files changed, 78 insertions(+), 19 deletions(-) (limited to 'indra/llprimitive/lltextureentry.cpp') diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index d057e5ab29..fdf3774bfa 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -696,14 +696,6 @@ S32 LLTextureEntry::setMaterialParams(const LLMaterialPtr pMaterialParams) } mMaterial = pMaterialParams; - // TODO: GZ: We should avoid magic UUIDs in the future, but for development we're using one for the time being. Remove this later. - if (mMaterial->getSpecularID().asString() == "da7ecda1-e780-423f-ce27-26df7dc69cb6") - { - setRenderableTarget(RT_MIRROR); - } else { - setRenderableTarget(RT_DISABLED); - } - return TEM_CHANGE_TEXTURE; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 0152c0612a..e485c26e9b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -217,7 +217,9 @@ void main() { color = atmosFragLightingLinear(color, additive, atten); } - color = texture(heroProbes, vec4(norm.xyz * env_mat, 0), 0).xyz; + + vec3 refnormpersp = reflect(pos.xyz, norm.xyz); + color = texture(heroProbes, vec4(env_mat * refnormpersp, 0), 0).xyz; } else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { diff --git a/indra/newview/lldrawable.h b/indra/newview/lldrawable.h index 970e8c8b2a..fc182fc2e2 100644 --- a/indra/newview/lldrawable.h +++ b/indra/newview/lldrawable.h @@ -286,6 +286,7 @@ public: ANIMATED_CHILD = 0x01000000, ACTIVE_CHILD = 0x02000000, FOR_UNLOAD = 0x04000000, //should be unload from memory + MIRROR = 0x08000000, // Used as a mirror, needs a hero probe position to be calculated. } EDrawableFlags; public: diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 99ebcf5231..ad4d3d94e2 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -140,7 +140,7 @@ void LLReflectionMapManager::update() if (mMipChain.empty()) { - U32 res = mProbeResolution; + U32 res = mHeroProbeResolution; U32 count = log2((F32)res) + 0.5f; mMipChain.resize(count); @@ -326,7 +326,7 @@ void LLReflectionMapManager::update() mRadiancePass = mRealtimeRadiancePass; for (U32 i = 0; i < 6; ++i) { - updateProbeFace(closestDynamic, i, mProbeResolution, mTexture); + updateProbeFace(closestDynamic, i, mProbeResolution, mTexture, mMipChain, mReflectionProbeCount); } mRealtimeRadiancePass = !mRealtimeRadiancePass; @@ -343,7 +343,7 @@ void LLReflectionMapManager::update() mRadiancePass = true; for (U32 i = 0; i < 6; ++i) { - updateProbeFace(mHeroProbe, i, mHeroProbeResolution, mHeroArray); + updateProbeFace(mHeroProbe, i, mHeroProbeResolution, mHeroArray, mMipChain, mHeroProbeCount); } // restore "isRadiancePass" @@ -555,7 +555,7 @@ void LLReflectionMapManager::doProbeUpdate() LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; llassert(mUpdatingProbe != nullptr); - updateProbeFace(mUpdatingProbe, mUpdatingFace, mProbeResolution, mTexture); + updateProbeFace(mUpdatingProbe, mUpdatingFace, mProbeResolution, mTexture, mMipChain, mReflectionProbeCount); if (++mUpdatingFace == 6) { @@ -582,14 +582,14 @@ void LLReflectionMapManager::doProbeUpdate() // 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 LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face, U32 probeResolution, LLPointer cubeArray) +void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face, U32 probeResolution, LLPointer cubeArray, std::vector &mipChain, U32 probeCount) { // hacky hot-swap of camera specific render targets gPipeline.mRT = &gPipeline.mAuxillaryRT; LLRenderTarget* target = &mRenderTarget; - S32 sourceIdx = mReflectionProbeCount; + S32 sourceIdx = probeCount; if (probeResolution == mHeroProbeResolution) { @@ -1327,9 +1327,13 @@ void LLReflectionMapManager::initReflectionMaps() mHeroProbeResolution = 128; - mHeroArray = new LLCubeMapArray(); // Revise when we have both water and mirrors in hero probes. - mHeroArray->allocate(mHeroProbeResolution, 3, 2, true); + mHeroProbeCount = 1; + + mHeroArray = new LLCubeMapArray(); + + // We use an extra probe for scratch space on these. + mHeroArray->allocate(mHeroProbeResolution, 3, mHeroProbeCount + 1, true); if (mHeroProbe.isNull()) { mHeroProbe = new LLReflectionMap(); diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index 81b0ef8ed8..9f48ce3cfd 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -148,7 +148,7 @@ private: void doProbeUpdate(); // update the specified face of the specified probe - void updateProbeFace(LLReflectionMap* probe, U32 face, U32 probeResolution, LLPointer cubeArray); + void updateProbeFace(LLReflectionMap* probe, U32 face, U32 probeResolution, LLPointer cubeArray, std::vector &mipChain, U32 probeCount); // list of active reflection maps std::vector > mProbes; @@ -188,6 +188,8 @@ private: // number of reflection probes to use for rendering U32 mReflectionProbeCount; + + U32 mHeroProbeCount; // resolution of reflection probes U32 mProbeResolution = 128; diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 4d49c61b23..fe33047218 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -257,6 +257,7 @@ public: virtual BOOL isRiggedMesh() const { return FALSE; } virtual BOOL hasLightTexture() const { return FALSE; } virtual BOOL isReflectionProbe() const { return FALSE; } + virtual BOOL isMirror() const { return FALSE; } // This method returns true if the object is over land owned by // the agent, one of its groups, or it encroaches and diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 556ec083a7..254e945243 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1044,7 +1044,9 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) { updateReflectionProbePtr(); } - + + gPipeline.setMirror(mDrawable, isMirror()); + updateRadius(); bool force_update = true; // avoid non-alpha mDistance update being optimized away mDrawable->updateDistance(*LLViewerCamera::getInstance(), force_update); @@ -3377,6 +3379,30 @@ F32 LLVOVolume::getLightCutoff() const } } +BOOL LLVOVolume::isMirror() const +{ + S32 faceCount = getNumFaces(); + + // Temporary hack to set the object to mirror. + for (int i = 0; i < faceCount; i++) + { + const LLTextureEntry* te = getTE(i); + + if (te->getMaterialParams().notNull()) + { + LLViewerTexture* specularp = getTESpecularMap(0); + + if (specularp && specularp->getID() == "da7ecda1-e780-423f-ce27-26df7dc69cb6") + { + LL_INFOS() << "BELLADONNA OF SADNESS" << LL_ENDL; + return TRUE; + } + } + } + + return FALSE; +} + BOOL LLVOVolume::isReflectionProbe() const { return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); @@ -4427,6 +4453,8 @@ void LLVOVolume::parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_u } updateReflectionProbePtr(); + + gPipeline.setMirror(mDrawable, isMirror()); } void LLVOVolume::updateReflectionProbePtr() diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 93aba9b8cb..cecf726763 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -308,6 +308,8 @@ public: F32 getReflectionProbeNearClip() const; bool getReflectionProbeIsBox() const; bool getReflectionProbeIsDynamic() const; + + BOOL isMirror() const override; // Flexible Objects U32 getVolumeInterfaceID() const; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d7188c0fe7..e742992c1d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2761,6 +2761,23 @@ void LLPipeline::markShift(LLDrawable *drawablep) } } +void LLPipeline::setMirror(LLDrawable *drawablep, bool is_mirror) +{ + if (drawablep && assertInitialized()) + { + if (is_mirror) + { + drawablep->setState(LLDrawable::MIRROR); + mMirrorList.insert(drawablep); + } + else + { + mMirrorList.erase(drawablep); + drawablep->clearState(LLDrawable::MIRROR); + } + } +} + void LLPipeline::shiftObjects(const LLVector3 &offset) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -5812,6 +5829,11 @@ void LLPipeline::findReferences(LLDrawable *drawablep) { LL_INFOS() << "In mRetexturedList" << LL_ENDL; } + + if (std::find(mMirrorList.begin(), mMirrorList.end(), drawablep) != mMirrorList.end()) + { + LL_INFOS() << "In mMirrorList" << LL_ENDL; + } if (std::find(mBuildQ1.begin(), mBuildQ1.end(), drawablep) != mBuildQ1.end()) { diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index c0559ce83b..f3b35e0325 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -357,6 +357,7 @@ public: void shiftObjects(const LLVector3 &offset); void setLight(LLDrawable *drawablep, bool is_light); + void setMirror(LLDrawable *drawablep, bool is_mirror); bool hasRenderBatches(const U32 type) const; LLCullResult::drawinfo_iterator beginRenderMap(U32 type); @@ -818,6 +819,10 @@ protected: LLDrawable::ordered_drawable_set_t mLights; light_set_t mNearbyLights; // lights near camera LLColor4 mHWLightColors[8]; + + + LLDrawable::ordered_drawable_set_t mMirrorList; + LLDrawable* mNearestMirror; ///////////////////////////////////////////// // -- cgit v1.3 From fbecd348f897ee91a5639e7e9fe4f0578d72b8e2 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 29 Aug 2023 03:04:04 -0700 Subject: Add protocol level mirror support, and UI. --- indra/llprimitive/llprimitive.cpp | 39 ++++++++-- indra/llprimitive/llprimitive.h | 12 ++- indra/llprimitive/llprimtexturelist.cpp | 10 --- indra/llprimitive/llprimtexturelist.h | 1 - indra/llprimitive/lltextureentry.cpp | 10 --- indra/llprimitive/lltextureentry.h | 10 --- indra/newview/llheroprobemanager.cpp | 87 +++++++++++++--------- indra/newview/llpanelface.cpp | 17 ----- indra/newview/llpanelface.h | 2 - indra/newview/llpanelvolume.cpp | 34 +++++++++ indra/newview/llpanelvolume.h | 2 + indra/newview/llselectmgr.cpp | 41 ---------- indra/newview/llselectmgr.h | 1 - indra/newview/llviewerobject.cpp | 28 ++----- indra/newview/llviewerobject.h | 1 - indra/newview/llvovolume.cpp | 60 ++++++++------- indra/newview/llvovolume.h | 5 +- .../newview/skins/default/xui/en/floater_tools.xml | 10 ++- 18 files changed, 185 insertions(+), 185 deletions(-) (limited to 'indra/llprimitive/lltextureentry.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index b45ead92d3..703584ed62 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -404,11 +404,6 @@ S32 LLPrimitive::setTEFullbright(const U8 index, const U8 fullbright) return mTextureList.setFullbright(index, fullbright); } -S32 LLPrimitive::setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget target) -{ - return mTextureList.setRenderableTarget(te, target); -} - S32 LLPrimitive::setTEMediaFlags(const U8 index, const U8 media_flags) { return mTextureList.setMediaFlags(index, media_flags); @@ -1828,6 +1823,40 @@ bool LLLightParams::fromLLSD(LLSD& sd) //============================================================================ +LLMirrorParams::LLMirrorParams() +{ + mType = PARAMS_MIRROR; +} + +BOOL LLMirrorParams::pack(LLDataPacker &dp) const +{ + return TRUE; +} + +BOOL LLMirrorParams::unpack(LLDataPacker &dp) +{ + return TRUE; +} + +bool LLMirrorParams::operator==(const LLNetworkData& data) const +{ + if (data.mType != PARAMS_REFLECTION_PROBE) + { + return false; + } + return true; +} + +void LLMirrorParams::copy(const LLNetworkData& data) +{ + const LLMirrorParams *param = (LLMirrorParams*)&data; + mType = param->mType; +} + +//============================================================================ + +//============================================================================ + LLReflectionProbeParams::LLReflectionProbeParams() { mType = PARAMS_REFLECTION_PROBE; diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 520c7c7ac8..1af9bca42e 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -109,6 +109,7 @@ public: PARAMS_EXTENDED_MESH = 0x70, PARAMS_RENDER_MATERIAL = 0x80, PARAMS_REFLECTION_PROBE = 0x90, + PARAMS_MIRROR = 0x100, }; public: @@ -172,6 +173,16 @@ public: F32 getCutoff() const { return mCutoff; } }; +class LLMirrorParams : public LLNetworkData +{ +public: + LLMirrorParams(); + /*virtual*/ BOOL pack(LLDataPacker &dp) const; + /*virtual*/ BOOL unpack(LLDataPacker &dp); + /*virtual*/ bool operator==(const LLNetworkData& data) const; + /*virtual*/ void copy(const LLNetworkData& data); +}; + extern const F32 REFLECTION_PROBE_MIN_AMBIANCE; extern const F32 REFLECTION_PROBE_MAX_AMBIANCE; extern const F32 REFLECTION_PROBE_DEFAULT_AMBIANCE; @@ -485,7 +496,6 @@ public: virtual S32 setTETexGen(const U8 te, const U8 texgen); virtual S32 setTEShiny(const U8 te, const U8 shiny); virtual S32 setTEFullbright(const U8 te, const U8 fullbright); - virtual S32 setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget target); virtual S32 setTEMediaFlags(const U8 te, const U8 flags); virtual S32 setTEGlow(const U8 te, const F32 glow); virtual S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); diff --git a/indra/llprimitive/llprimtexturelist.cpp b/indra/llprimitive/llprimtexturelist.cpp index 49b59e35cb..f4f08248b8 100644 --- a/indra/llprimitive/llprimtexturelist.cpp +++ b/indra/llprimitive/llprimtexturelist.cpp @@ -341,16 +341,6 @@ S32 LLPrimTextureList::setFullbright(const U8 index, const U8 fullbright) return TEM_CHANGE_NONE; } -S32 LLPrimTextureList::setRenderableTarget(const U8 index, const U8 target) -{ - if (index < mEntryList.size()) - { - return mEntryList[index]->setRenderableTarget((LLTextureEntry::eRenderableTarget)target); - } - - return TEM_CHANGE_NONE; -} - S32 LLPrimTextureList::setMediaFlags(const U8 index, const U8 media_flags) { if (index < mEntryList.size()) diff --git a/indra/llprimitive/llprimtexturelist.h b/indra/llprimitive/llprimtexturelist.h index 34b87d879f..49c636e40f 100644 --- a/indra/llprimitive/llprimtexturelist.h +++ b/indra/llprimitive/llprimtexturelist.h @@ -102,7 +102,6 @@ public: S32 setTexGen(const U8 index, const U8 texgen); S32 setShiny(const U8 index, const U8 shiny); S32 setFullbright(const U8 index, const U8 t); - S32 setRenderableTarget(const U8 index, const U8 target); S32 setMediaFlags(const U8 index, const U8 media_flags); S32 setGlow(const U8 index, const F32 glow); S32 setMaterialID(const U8 index, const LLMaterialID& pMaterialID); diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index fdf3774bfa..ee2a4c769a 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -504,16 +504,6 @@ S32 LLTextureEntry::setFullbright(U8 fullbright) return TEM_CHANGE_NONE; } -S32 LLTextureEntry::setRenderableTarget(eRenderableTarget target) -{ - if (getRenderableTarget() != target) { - mRenderableTarget = target; - return TEM_CHANGE_TEXTURE; - } - - return TEM_CHANGE_NONE; -} - S32 LLTextureEntry::setShiny(U8 shiny) { shiny &= TEM_SHINY_MASK; diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 2c0832e1d4..0935147688 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -80,12 +80,6 @@ public: TEX_GEN_SPHERICAL = 0x04, TEX_GEN_CYLINDRICAL = 0x06 } eTexGen; - - - typedef enum e_renderable_target { - RT_DISABLED = 0x00, - RT_MIRROR = 0x02 - } eRenderableTarget; LLTextureEntry(); LLTextureEntry(const LLUUID& tex_id); @@ -141,8 +135,6 @@ public: S32 setMaterialID(const LLMaterialID& pMaterialID); S32 setMaterialParams(const LLMaterialPtr pMaterialParams); - S32 setRenderableTarget(eRenderableTarget target); - virtual const LLUUID &getID() const { return mID; } const LLColor4 &getColor() const { return mColor; } const F32 getAlpha() const { return mColor.mV[VALPHA]; } @@ -160,7 +152,6 @@ public: U8 getBumpmap() const { return mBump & TEM_BUMP_MASK; } U8 getFullbright() const { return (mBump>>TEM_FULLBRIGHT_SHIFT) & TEM_FULLBRIGHT_MASK; } - eRenderableTarget getRenderableTarget() const { return mRenderableTarget; } U8 getShiny() const { return (mBump>>TEM_SHINY_SHIFT) & TEM_SHINY_MASK; } U8 getBumpShiny() const { return mBump & TEM_BUMP_SHINY_MASK; } U8 getBumpShinyFullbright() const { return mBump; } @@ -242,7 +233,6 @@ protected: LLColor4 mColor; U8 mBump; // Bump map, shiny, and fullbright U8 mMediaFlags; // replace with web page, movie, etc. - eRenderableTarget mRenderableTarget; F32 mGlow; bool mMaterialUpdatePending; LLMaterialID mMaterialID; diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index 729603e960..6374b10823 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -103,53 +103,71 @@ void LLHeroProbeManager::update() llassert(mProbes[0] == mDefaultProbe); - LLVector3 camera_pos = LLViewerCamera::instance().getOrigin(); - LLVector4a probe_pos; - LLVector3 focus_point; - - 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) + if (mHeroList.empty()) + { + LLVector3 focus_point; + + 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 (focus_point.isExactlyZero()) { - LLFace* face = obj->mDrawable->getFace(face_idx); - if (face) + 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 { - focus_point = face->getPositionAgent(); + // focus on alt-zoom target + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + focus_point = LLVector3(gAgentCamera.getFocusGlobal() - region->getOriginGlobal()); + } } } + + probe_pos.load3(((focus_point)).mV); } - - if (focus_point.isExactlyZero()) + else { - 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 + // Get the nearest hero. + float distance = F32_MAX; + + for (auto drawable : mHeroList) { - // focus on alt-zoom target - LLViewerRegion* region = gAgent.getRegion(); - if (region) + if (drawable.notNull()) { - focus_point = LLVector3(gAgentCamera.getFocusGlobal() - region->getOriginGlobal()); + if (drawable->mDistanceWRTCamera < distance) + { + probe_pos.load3(drawable->mXform.getPosition().mV); + } } } } - probe_pos.load3(((focus_point + camera_pos) / 2).mV); static LLCachedControl sDetail(gSavedSettings, "RenderHeroReflectionProbeDetail", -1); static LLCachedControl sLevel(gSavedSettings, "RenderHeroReflectionProbeLevel", 3); @@ -464,7 +482,7 @@ void LLHeroProbeManager::initReflectionMaps() mDefaultProbe->mCubeIndex = 0; mDefaultProbe->mCubeArray = mTexture; - mDefaultProbe->mDistance = 64.f; + mDefaultProbe->mDistance = 12.f; mDefaultProbe->mRadius = 4096.f; mDefaultProbe->mProbeIndex = 0; touch_default_probe(mDefaultProbe); @@ -536,6 +554,7 @@ 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/llpanelface.cpp b/indra/newview/llpanelface.cpp index 9233ec6277..25f42e6dae 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -596,17 +596,6 @@ void LLPanelFace::sendFullbright() LLSelectMgr::getInstance()->selectionSetFullbright( fullbright ); } -void LLPanelFace::sendMirror() -{ - LLCheckBoxCtrl* mCheckMirror = getChild("checkbox mirror"); - - if (!mCheckMirror) - return; - - LLTextureEntry::eRenderableTarget target = mCheckMirror->get() ? LLTextureEntry::RT_MIRROR : LLTextureEntry::RT_DISABLED; - LLSelectMgr::getInstance()->selectionSetRenderableTarget(target); -} - void LLPanelFace::sendColor() { @@ -3007,12 +2996,6 @@ void LLPanelFace::onCommitFullbright(LLUICtrl* ctrl, void* userdata) self->sendFullbright(); } -void LLPanelFace::onCommitMirror(LLUICtrl* ctrl, void* userdata) -{ - LLPanelFace* self = (LLPanelFace*) userdata; - self->sendMirror(); -} - // static void LLPanelFace::onCommitGlow(LLUICtrl* ctrl, void* userdata) { diff --git a/indra/newview/llpanelface.h b/indra/newview/llpanelface.h index 0b7486232d..5cad8cefcf 100644 --- a/indra/newview/llpanelface.h +++ b/indra/newview/llpanelface.h @@ -139,7 +139,6 @@ protected: void sendShiny(U32 shininess); // applies and sends shininess void sendFullbright(); // applies and sends full bright - void sendMirror(); void sendGlow(); void alignTestureLayer(); @@ -229,7 +228,6 @@ protected: static void onCommitShiny( LLUICtrl* ctrl, void* userdata); static void onCommitAlphaMode( LLUICtrl* ctrl, void* userdata); static void onCommitFullbright( LLUICtrl* ctrl, void* userdata); - static void onCommitMirror(LLUICtrl* ctrl, void* userdata); static void onCommitGlow( LLUICtrl* ctrl, void *userdata); static void onCommitPlanarAlign( LLUICtrl* ctrl, void* userdata); static void onCommitRepeatsPerMeter( LLUICtrl* ctrl, void* userinfo); diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index ed244f773c..d62a640b5c 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -114,6 +114,11 @@ BOOL LLPanelVolume::postBuild() getChild("FlexForceZ")->setValidateBeforeCommit(precommitValidate); } + // Mirror Parameters + { + childSetCommitCallback("Mirror Checkbox Ctrl", onCommitIsMirror, this); + } + // LIGHT Parameters { childSetCommitCallback("Light Checkbox Ctrl",onCommitIsLight,this); @@ -305,6 +310,10 @@ void LLPanelVolume::getState( ) getChildView("select_single")->setEnabled(true); } + BOOL is_mirror = volobjp && volobjp->isMirror(); + getChild("Mirror Checkbox Ctrl")->setValue(is_mirror); + getChildView("Mirror Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp); + // Light properties BOOL is_light = volobjp && volobjp->getIsLight(); getChild("Light Checkbox Ctrl")->setValue(is_light); @@ -737,6 +746,25 @@ void LLPanelVolume::sendIsLight() LL_INFOS() << "update light sent" << LL_ENDL; } +void LLPanelVolume::sendIsMirror() +{ + LLViewerObject* objectp = mObject; + if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME)) + { + return; + } + LLVOVolume *volobjp = (LLVOVolume *)objectp; + + // Quick hack to set the mirror locally. + + gPipeline.mHeroProbeManager.registerHeroDrawable(volobjp->mDrawable); + + BOOL value = getChild("Mirror Checkbox Ctrl")->getValue(); + volobjp->setIsMirror(value); + LL_INFOS() << "update mirror sent" << LL_ENDL; +} + + void LLPanelVolume::sendIsReflectionProbe() { LLViewerObject* objectp = mObject; @@ -1403,6 +1431,12 @@ void LLPanelVolume::onCommitIsLight( LLUICtrl* ctrl, void* userdata ) self->sendIsLight(); } +void LLPanelVolume::onCommitIsMirror( LLUICtrl* ctrl, void* userdata ) +{ + LLPanelVolume* self = (LLPanelVolume*) userdata; + self->sendIsMirror(); +} + // static void LLPanelVolume::setLightTextureID(const LLUUID &asset_id, const LLUUID &item_id, LLVOVolume* volobjp) { diff --git a/indra/newview/llpanelvolume.h b/indra/newview/llpanelvolume.h index 01b7ebb75c..a658351624 100644 --- a/indra/newview/llpanelvolume.h +++ b/indra/newview/llpanelvolume.h @@ -58,6 +58,7 @@ public: void sendIsLight(); + void sendIsMirror(); // when an object is becoming a refleciton probe, present a dialog asking for confirmation // otherwise, send the reflection probe update immediately void sendIsReflectionProbe(); @@ -71,6 +72,7 @@ public: static void onCommitIsLight( LLUICtrl* ctrl, void* userdata); static void onCommitLight( LLUICtrl* ctrl, void* userdata); + static void onCommitIsMirror( LLUICtrl* ctrl, void* userdata); static void onCommitIsReflectionProbe(LLUICtrl* ctrl, void* userdata); static void onCommitProbe(LLUICtrl* ctrl, void* userdata); void onCommitIsFlexible( LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 2b1b4b79b2..5c1a339570 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -2355,47 +2355,6 @@ void LLSelectMgr::selectionSetFullbright(U8 fullbright) getSelection()->applyToObjects(&sendfunc); } -void LLSelectMgr::selectionSetRenderableTarget(LLTextureEntry::eRenderableTarget target) -{ - struct f : public LLSelectedTEFunctor - { - LLTextureEntry::eRenderableTarget mRenderableTarget; - - f(const LLTextureEntry::eRenderableTarget& t) : mRenderableTarget(t) {} - - bool apply(LLViewerObject* object, S32 te) - { - if (object->permModify()) - { - object->setTERenderableTarget(te, mRenderableTarget); - } - - return true; - } - } setfunc(target); - - getSelection()->applyToTEs(&setfunc); - - struct g : public LLSelectedObjectFunctor - { - LLTextureEntry::eRenderableTarget mRenderableTarget; - - g(const LLTextureEntry::eRenderableTarget& t) : mRenderableTarget(t) {} - - virtual bool apply(LLViewerObject* object) - { - if (object->permModify()) - { - object->sendTEUpdate(); - } - - return true; - } - } sendfunc(target); - - getSelection()->applyToObjects(&sendfunc); -} - // This function expects media_data to be a map containing relevant // media data name/value pairs (e.g. home_url, etc.) void LLSelectMgr::selectionSetMedia(U8 media_type, const LLSD &media_data) diff --git a/indra/newview/llselectmgr.h b/indra/newview/llselectmgr.h index 8ce59c6654..327134a487 100644 --- a/indra/newview/llselectmgr.h +++ b/indra/newview/llselectmgr.h @@ -653,7 +653,6 @@ public: void selectionSetGlow(const F32 glow); void selectionSetMaterialParams(LLSelectedTEMaterialFunctor* material_func, int specific_te = -1); void selectionRemoveMaterial(); - void selectionSetRenderableTarget(LLTextureEntry::eRenderableTarget target); void selectionSetObjectPermissions(U8 perm_field, BOOL set, U32 perm_mask, BOOL override = FALSE); void selectionSetObjectName(const std::string& name); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 7871815fda..68162f83c0 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -5296,29 +5296,6 @@ S32 LLViewerObject::setTEFullbright(const U8 te, const U8 fullbright) return retval; } -S32 LLViewerObject::setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget target) -{ - S32 retval = 0; - - const LLTextureEntry *tep = getTE(te); - if (!tep) - { - LL_WARNS() << "No texture entry for te " << (S32)te << ", object " << mID << LL_ENDL; - } - else if (target != tep->getRenderableTarget()) - { - retval = LLPrimitive::setTERenderableTarget(te, target); - setChanged(TEXTURE); - if (mDrawable.notNull() && retval) - { - //gPipeline.markMirror(mDrawable); - } - } - - return retval; -} - - S32 LLViewerObject::setTEMediaFlags(const U8 te, const U8 media_flags) { // this might need work for media type @@ -6251,6 +6228,11 @@ LLViewerObject::ExtraParameter* LLViewerObject::createNewParameterEntry(U16 para { new_block = new LLReflectionProbeParams(); break; + } + case LLNetworkData::PARAMS_MIRROR: + { + new_block = new LLMirrorParams(); + break; } default: { diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index fe33047218..a87644476f 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -360,7 +360,6 @@ public: /*virtual*/ S32 setTEMediaTexGen(const U8 te, const U8 media ); // *FIXME: this confusingly acts upon a superset of setTETexGen's flags without absorbing its semantics /*virtual*/ S32 setTEShiny(const U8 te, const U8 shiny ); /*virtual*/ S32 setTEFullbright(const U8 te, const U8 fullbright ); - /*virtual*/ S32 setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget target); /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags ); /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow); /*virtual*/ S32 setTEMaterialID(const U8 te, const LLMaterialID& pMaterialID); diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 2589beefe9..175ce93b14 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1045,7 +1045,10 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) updateReflectionProbePtr(); } - gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable); + if (isMirror()) + { + gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable); + } updateRadius(); bool force_update = true; // avoid non-alpha mDistance update being optimized away @@ -2369,16 +2372,6 @@ S32 LLVOVolume::setTEFullbright(const U8 te, const U8 fullbright) return res; } -S32 LLVOVolume::setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget mirror) -{ - S32 res = LLViewerObject::setTERenderableTarget(te, mirror); - if (res) - { - //gPipeline.markMirror(mDrawable); - } - return res; -} - S32 LLVOVolume::setTEBumpShinyFullbright(const U8 te, const U8 bump) { S32 res = LLViewerObject::setTEBumpShinyFullbright(te, bump); @@ -3379,28 +3372,41 @@ F32 LLVOVolume::getLightCutoff() const } } -BOOL LLVOVolume::isMirror() const +bool LLVOVolume::setIsMirror(BOOL is_mirror) { - S32 faceCount = getNumFaces(); - - // Temporary hack to set the object to mirror. - for (int i = 0; i < faceCount; i++) + BOOL was_mirror = isMirror(); + if (is_mirror != was_mirror) { - const LLTextureEntry* te = getTE(i); - - if (te->getMaterialParams().notNull()) + if (is_mirror) { - LLViewerTexture* specularp = getTESpecularMap(0); - - if (specularp && specularp->getID() == "da7ecda1-e780-423f-ce27-26df7dc69cb6") - { - LL_INFOS() << "BELLADONNA OF SADNESS" << LL_ENDL; - return TRUE; - } + setParameterEntryInUse(LLNetworkData::PARAMS_MIRROR, TRUE, true); + } + else + { + setParameterEntryInUse(LLNetworkData::PARAMS_MIRROR, FALSE, true); } } - return FALSE; + updateMirrorDrawable(); + + return was_mirror != is_mirror; +} + +void LLVOVolume::updateMirrorDrawable() +{ + if (isMirror()) + { + gPipeline.mHeroProbeManager.registerHeroDrawable(mDrawable); + } + else + { + gPipeline.mHeroProbeManager.unregisterHeroDrawable(mDrawable); + } +} + +BOOL LLVOVolume::isMirror() const +{ + return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); } BOOL LLVOVolume::isReflectionProbe() const diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index cecf726763..32c89ddae2 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -209,7 +209,6 @@ public: /*virtual*/ S32 setTEBumpmap(const U8 te, const U8 bump) override; /*virtual*/ S32 setTEShiny(const U8 te, const U8 shiny) override; /*virtual*/ S32 setTEFullbright(const U8 te, const U8 fullbright) override; - /*virtual*/ S32 setTERenderableTarget(const U8 te, const LLTextureEntry::eRenderableTarget target) override; /*virtual*/ S32 setTEBumpShinyFullbright(const U8 te, const U8 bump) override; /*virtual*/ S32 setTEMediaFlags(const U8 te, const U8 media_flags) override; /*virtual*/ S32 setTEGlow(const U8 te, const F32 glow) override; @@ -295,6 +294,10 @@ public: F32 getLightRadius() const; F32 getLightFalloff(const F32 fudge_factor = 1.f) const; F32 getLightCutoff() const; + + // Mirrors + bool setIsMirror(BOOL is_mirror); + void updateMirrorDrawable(); // Reflection Probes bool setIsReflectionProbe(BOOL is_probe); diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 5e999ed245..4094a487a9 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -2406,7 +2406,15 @@ even though the user gets a free copy. name="object_horizontal" top_pad="10" width="278" /> - +