diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llenvironmentmap.cpp | 116 | ||||
-rw-r--r-- | indra/newview/llenvironmentmap.h | 48 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 8 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 7 | ||||
-rw-r--r-- | indra/newview/pipeline.h | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_viewer.xml | 7 |
7 files changed, 191 insertions, 1 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 964615320d..5e50f58595 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -196,6 +196,7 @@ set(viewer_SOURCE_FILES lldynamictexture.cpp llemote.cpp llenvironment.cpp + llenvironmentmap.cpp llestateinfomodel.cpp lleventnotifier.cpp lleventpoll.cpp @@ -832,6 +833,7 @@ set(viewer_HEADER_FILES lldynamictexture.h llemote.h llenvironment.h + llenvironmentmap.h llestateinfomodel.h lleventnotifier.h lleventpoll.h diff --git a/indra/newview/llenvironmentmap.cpp b/indra/newview/llenvironmentmap.cpp new file mode 100644 index 0000000000..7f23c630f1 --- /dev/null +++ b/indra/newview/llenvironmentmap.cpp @@ -0,0 +1,116 @@ +/** + * @file llenvironmentmap.cpp + * @brief LLEnvironmentMap class implementation + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llenvironmentmap.h" +#include "pipeline.h" +#include "llviewerwindow.h" + +LLEnvironmentMap::LLEnvironmentMap() +{ + mOrigin.setVec(0, 0, 0); +} + +void LLEnvironmentMap::update(const LLVector3& origin, U32 resolution) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + + mOrigin = origin; + + // allocate images + std::vector<LLPointer<LLImageRaw> > rawimages; + rawimages.reserve(6); + + for (int i = 0; i < 6; ++i) + { + rawimages.push_back(new LLImageRaw(resolution, resolution, 3)); + } + + // ============== modified copy/paste of LLFloater360Capture::capture360Images() follows ============== + + // these are the 6 directions we will point the camera, see LLCubeMap::mTargets + LLVector3 look_dirs[6] = { + LLVector3(-1, 0, 0), + LLVector3(1, 0, 0), + LLVector3(0, -1, 0), + LLVector3(0, 1, 0), + LLVector3(0, 0, -1), + LLVector3(0, 0, 1) + }; + + LLVector3 look_upvecs[6] = { + LLVector3(0, -1, 0), + LLVector3(0, -1, 0), + LLVector3(0, 0, -1), + LLVector3(0, 0, 1), + LLVector3(0, 1, 0), + LLVector3(0, -1, 0) + }; + + // save current view/camera settings so we can restore them afterwards + S32 old_occlusion = LLPipeline::sUseOcclusion; + + // set new parameters specific to the 360 requirements + LLPipeline::sUseOcclusion = 0; + LLViewerCamera* camera = LLViewerCamera::getInstance(); + LLVector3 old_origin = camera->getOrigin(); + F32 old_fov = camera->getView(); + F32 old_aspect = camera->getAspect(); + F32 old_yaw = camera->getYaw(); + + // camera constants for the square, cube map capture image + camera->setAspect(1.0); // must set aspect ratio first to avoid undesirable clamping of vertical FoV + camera->setView(F_PI_BY_TWO); + camera->yaw(0.0); + camera->setOrigin(mOrigin); + + // for each of the 6 directions we shoot... + for (int i = 0; i < 6; i++) + { + // set up camera to look in each direction + camera->lookDir(look_dirs[i], look_upvecs[i]); + + // call the (very) simplified snapshot code that simply deals + // with a single image, no sub-images etc. but is very fast + gViewerWindow->simpleSnapshot(rawimages[i], + resolution, resolution, 1); + } + + // restore original view/camera/avatar settings settings + camera->setAspect(old_aspect); + camera->setView(old_fov); + camera->yaw(old_yaw); + camera->setOrigin(old_origin); + + LLPipeline::sUseOcclusion = old_occlusion; + + // ==================================================== + + mCubeMap = new LLCubeMap(false); + mCubeMap->initEnvironmentMap(rawimages); +} + diff --git a/indra/newview/llenvironmentmap.h b/indra/newview/llenvironmentmap.h new file mode 100644 index 0000000000..7d951eb678 --- /dev/null +++ b/indra/newview/llenvironmentmap.h @@ -0,0 +1,48 @@ +/** + * @file llenvironmentmap.h + * @brief LLEnvironmentMap class declaration + * + * $LicenseInfo:firstyear=2022&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2022, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#pragma once + +#include "llcubemap.h" + +class LLEnvironmentMap +{ +public: + // allocate an environment map of the given resolution + LLEnvironmentMap(); + + // update this environment map + // origin - position in agent space to generate environment map from in agent space + // resolution - size of cube map to generate + void update(const LLVector3& origin, U32 resolution); + + // cube map used to sample this environment map + LLPointer<LLCubeMap> mCubeMap; + + // point at which environment map was generated from (in agent space) + LLVector3 mOrigin; +}; + diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index e3de4267dc..f5ea060e82 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -8304,6 +8304,12 @@ void handle_cache_clear_immediately() LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache_immediately); } +void handle_override_environment_map() +{ + gPipeline.overrideEnvironmentMap(); +} + + void handle_web_content_test(const LLSD& param) { std::string url = param.asString(); @@ -9402,6 +9408,8 @@ void initialize_menus() view_listener_t::addMenu(new LLDevelopTextureFetchDebugger(), "Develop.SetTexFetchDebugger"); //Develop (clear cache immediately) commit.add("Develop.ClearCache", boost::bind(&handle_cache_clear_immediately) ); + //Develop (override environment map) + commit.add("Develop.OverrideEnvironmentMap", boost::bind(&handle_override_environment_map)); // Admin >Object view_listener_t::addMenu(new LLAdminForceTakeCopy(), "Admin.ForceTakeCopy"); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 20d6fe39e3..09437473d9 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8191,7 +8191,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ channel = shader.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); if (channel > -1) { - LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; + LLCubeMap* cube_map = mEnvironmentMap.mCubeMap.notNull() ? mEnvironmentMap.mCubeMap : gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; if (cube_map) { cube_map->enable(channel); @@ -11467,3 +11467,8 @@ void LLPipeline::restoreHiddenObject( const LLUUID& id ) } } +void LLPipeline::overrideEnvironmentMap() +{ + mEnvironmentMap.update(LLViewerCamera::instance().getOrigin(), 1024); +} + diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 62d3ae7a39..150d3c7d58 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -38,6 +38,7 @@ #include "llgl.h" #include "lldrawable.h" #include "llrendertarget.h" +#include "llenvironmentmap.h" #include <stack> @@ -426,6 +427,9 @@ public: void hideObject( const LLUUID& id ); void restoreHiddenObject( const LLUUID& id ); + LLEnvironmentMap mEnvironmentMap; + void overrideEnvironmentMap(); + private: void unloadShaders(); void addToQuickLookup( LLDrawPool* new_poolp ); diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 8d7cfe1116..db4e794ed4 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -3250,6 +3250,13 @@ function="World.EnvPreset" function="ToggleControl" parameter="RenderHoverGlowEnable" /> </menu_item_check> + <menu_item_call + enabled="true" + label="Override Environment Map" + name="Override Environment Map"> + <menu_item_call.on_click + function="Develop.OverrideEnvironmentMap" /> + </menu_item_call> <menu_item_separator /> <menu_item_call |