From 93260cfeff2382dd1ffeecaef208d37bf21c2a01 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 4 May 2022 16:07:50 +0000 Subject: SL-17283 LLReflectionMapManager prototype. Remove snapshot code related overhead from reflection map renders. Add parallax correction and support for multiple reflection maps. --- indra/newview/llreflectionmap.cpp | 64 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 indra/newview/llreflectionmap.cpp (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp new file mode 100644 index 0000000000..b75dba877e --- /dev/null +++ b/indra/newview/llreflectionmap.cpp @@ -0,0 +1,64 @@ +/** + * @file llreflectionmap.cpp + * @brief LLReflectionMap 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 "llreflectionmap.h" +#include "pipeline.h" +#include "llviewerwindow.h" + +LLReflectionMap::LLReflectionMap() +{ +} + +void LLReflectionMap::update(const LLVector3& origin, U32 resolution) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + llassert(LLPipeline::sRenderDeferred); + + // make sure resolution is < gPipeline.mDeferredScreen.getWidth() + + while (resolution > gPipeline.mDeferredScreen.getWidth() || + resolution > gPipeline.mDeferredScreen.getHeight()) + { + resolution /= 2; + } + + if (resolution == 0) + { + return; + } + + mOrigin.load3(origin.mV); + + mCubeMap = new LLCubeMap(false); + mCubeMap->initReflectionMap(resolution); + + gViewerWindow->cubeSnapshot(origin, mCubeMap); + + mCubeMap->generateMipMaps(); +} + -- cgit v1.3 From 3400e5fd302c0d9dea6386c4d5bf38876f2cc287 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 16 May 2022 17:21:08 +0000 Subject: SL-17284 Reflection probe tuning and optimization take 1 --- autobuild.xml | 4 +- indra/llrender/CMakeLists.txt | 2 + indra/llrender/llcubemap.cpp | 10 +- indra/llrender/llcubemaparray.cpp | 113 +++++ indra/llrender/llcubemaparray.h | 60 +++ indra/llrender/llgl.cpp | 33 +- indra/llrender/llgl.h | 1 + indra/llrender/llglheaders.h | 9 + indra/llrender/llglslshader.cpp | 61 ++- indra/llrender/llglslshader.h | 3 + indra/llrender/llimagegl.cpp | 51 +- indra/llrender/llrender.cpp | 4 + indra/llrender/llrender.h | 3 +- indra/llrender/llshadermgr.cpp | 13 +- indra/llrender/llshadermgr.h | 2 +- indra/newview/app_settings/settings.xml | 11 + .../shaders/class1/deferred/aoUtil.glsl | 14 +- .../shaders/class1/deferred/blurLightF.glsl | 29 +- .../shaders/class1/interface/reflectionmipF.glsl | 75 +++ .../shaders/class2/deferred/softenLightF.glsl | 274 +++++++++-- indra/newview/llagentcamera.cpp | 6 + indra/newview/lldrawpoolalpha.cpp | 4 +- indra/newview/lldrawpoolbump.cpp | 1 + indra/newview/lldrawpoolpbropaque.cpp | 2 +- indra/newview/llreflectionmap.cpp | 171 ++++++- indra/newview/llreflectionmap.h | 51 +- indra/newview/llreflectionmapmanager.cpp | 516 ++++++++++++++++++++- indra/newview/llreflectionmapmanager.h | 77 ++- indra/newview/llspatialpartition.cpp | 117 ++++- indra/newview/llspatialpartition.h | 19 + indra/newview/llviewerdisplay.cpp | 121 ++++- indra/newview/llviewermenu.cpp | 10 +- indra/newview/llviewershadermgr.cpp | 20 +- indra/newview/llviewershadermgr.h | 1 + indra/newview/llviewerwindow.cpp | 99 ++-- indra/newview/llviewerwindow.h | 6 +- indra/newview/llvovolume.cpp | 10 +- indra/newview/llworld.cpp | 3 +- indra/newview/pipeline.cpp | 505 ++++++++++---------- indra/newview/pipeline.h | 3 +- indra/newview/skins/default/xui/en/menu_viewer.xml | 16 +- 41 files changed, 2062 insertions(+), 468 deletions(-) create mode 100644 indra/llrender/llcubemaparray.cpp create mode 100644 indra/llrender/llcubemaparray.h create mode 100644 indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/autobuild.xml b/autobuild.xml index 9185b8af22..fa3f7b2743 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -1010,9 +1010,9 @@ archive hash - 1bd3214ac23474ea4c869e386970a1be + c5e9a59c7cf03c88a5cb4ab0a9c21091 url - http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/54835/510029/glext-68-darwin64-538965.tar.bz2 + https://automated-builds-secondlife-com.s3.amazonaws.com/ct2/99835/880141/glext-68-darwin64-571812.tar.bz2 name darwin64 diff --git a/indra/llrender/CMakeLists.txt b/indra/llrender/CMakeLists.txt index baab09a104..a30f47f1d9 100644 --- a/indra/llrender/CMakeLists.txt +++ b/indra/llrender/CMakeLists.txt @@ -31,6 +31,7 @@ include_directories(SYSTEM set(llrender_SOURCE_FILES llatmosphere.cpp llcubemap.cpp + llcubemaparray.cpp llfontbitmapcache.cpp llfontfreetype.cpp llfontgl.cpp @@ -58,6 +59,7 @@ set(llrender_HEADER_FILES llatmosphere.h llcubemap.h + llcubemaparray.h llfontgl.h llfontfreetype.h llfontbitmapcache.h diff --git a/indra/llrender/llcubemap.cpp b/indra/llrender/llcubemap.cpp index 6d872d0763..473447ad72 100644 --- a/indra/llrender/llcubemap.cpp +++ b/indra/llrender/llcubemap.cpp @@ -219,13 +219,17 @@ void LLCubeMap::initEnvironmentMap(const std::vector >& ra void LLCubeMap::generateMipMaps() { + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + mImages[0]->setUseMipMaps(TRUE); mImages[0]->setHasMipMaps(TRUE); enableTexture(0); bind(); - mImages[0]->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); - glGenerateMipmap(GL_TEXTURE_CUBE_MAP); + mImages[0]->setFilteringOption(LLTexUnit::TFO_BILINEAR); + { + LL_PROFILE_ZONE_NAMED_CATEGORY_TEXTURE("cmgmm - glGenerateMipmap"); + glGenerateMipmap(GL_TEXTURE_CUBE_MAP); + } gGL.getTexUnit(0)->disable(); disable(); } diff --git a/indra/llrender/llcubemaparray.cpp b/indra/llrender/llcubemaparray.cpp new file mode 100644 index 0000000000..e4081c1154 --- /dev/null +++ b/indra/llrender/llcubemaparray.cpp @@ -0,0 +1,113 @@ +/** + * @file llcubemaparray.cpp + * @brief LLCubeMap 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 "linden_common.h" + +#include "llworkerthread.h" + +#include "llcubemaparray.h" + +#include "v4coloru.h" +#include "v3math.h" +#include "v3dmath.h" +#include "m3math.h" +#include "m4math.h" + +#include "llrender.h" +#include "llglslshader.h" + +#include "llglheaders.h" + +//#pragma optimize("", off) + +// MUST match order of OpenGL face-layers +GLenum LLCubeMapArray::sTargets[6] = +{ + GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, + GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, + GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB, + GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB +}; + +LLCubeMapArray::LLCubeMapArray() + : mTextureStage(0) +{ + +} + +LLCubeMapArray::~LLCubeMapArray() +{ +} + +void LLCubeMapArray::allocate(U32 resolution, U32 components, U32 count) +{ + U32 texname = 0; + + LLImageGL::generateTextures(1, &texname); + + mImage = new LLImageGL(resolution, resolution, components, TRUE); + mImage->setTexName(texname); + mImage->setTarget(sTargets[0], LLTexUnit::TT_CUBE_MAP_ARRAY); + + mImage->setUseMipMaps(TRUE); + mImage->setHasMipMaps(TRUE); + + bind(0); + + glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY_ARB, 0, GL_RGB, resolution, resolution, count*6, 0, + GL_RGB, GL_UNSIGNED_BYTE, nullptr); + + mImage->setAddressMode(LLTexUnit::TAM_CLAMP); + + mImage->setFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + + glGenerateMipmap(GL_TEXTURE_CUBE_MAP_ARRAY_ARB); + + unbind(); +} + +void LLCubeMapArray::bind(S32 stage) +{ + mTextureStage = stage; + gGL.getTexUnit(stage)->bindManual(LLTexUnit::TT_CUBE_MAP_ARRAY, getGLName(), TRUE); +} + +void LLCubeMapArray::unbind() +{ + gGL.getTexUnit(mTextureStage)->unbind(LLTexUnit::TT_CUBE_MAP_ARRAY); + mTextureStage = -1; +} + +GLuint LLCubeMapArray::getGLName() +{ + return mImage->getTexName(); +} + +void LLCubeMapArray::destroyGL() +{ + mImage = NULL; +} diff --git a/indra/llrender/llcubemaparray.h b/indra/llrender/llcubemaparray.h new file mode 100644 index 0000000000..52e21f1dda --- /dev/null +++ b/indra/llrender/llcubemaparray.h @@ -0,0 +1,60 @@ +/** + * @file llcubemaparray.h + * @brief LLCubeMap class definition + * + * $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 "llgl.h" + +#include + +class LLVector3; + +// Environment map hack! +class LLCubeMapArray : public LLRefCount +{ +public: + LLCubeMapArray(); + + static GLenum sTargets[6]; + + // allocate a cube map array + // res - resolution of each cube face + // components - number of components per pixel + // count - number of cube maps in the array + void allocate(U32 res, U32 components, U32 count); + void bind(S32 stage); + void unbind(); + + GLuint getGLName(); + + void destroyGL(); + +protected: + friend class LLTexUnit; + ~LLCubeMapArray(); + LLPointer mImage; + S32 mTextureStage; +}; diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index 639d1fba32..6023796f7c 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -89,9 +89,10 @@ void APIENTRY gl_debug_callback(GLenum source, if (gGLDebugLoggingEnabled) { - if (severity != GL_DEBUG_SEVERITY_HIGH_ARB && - severity != GL_DEBUG_SEVERITY_MEDIUM_ARB && - severity != GL_DEBUG_SEVERITY_LOW_ARB) + if (severity != GL_DEBUG_SEVERITY_HIGH_ARB // && + //severity != GL_DEBUG_SEVERITY_MEDIUM_ARB && + //severity != GL_DEBUG_SEVERITY_LOW_ARB + ) { //suppress out-of-spec messages sent by nvidia driver (mostly vertexbuffer hints) return; } @@ -316,6 +317,15 @@ PFNGLGETUNIFORMIVARBPROC glGetUniformivARB = NULL; PFNGLGETSHADERSOURCEARBPROC glGetShaderSourceARB = NULL; PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer = NULL; +// GL_ARB_uniform_buffer_object +PFNGLGETUNIFORMINDICESPROC glGetUniformIndices = NULL; +PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv = NULL; +PFNGLGETACTIVEUNIFORMNAMEPROC glGetActiveUniformName = NULL; +PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex = NULL; +PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv = NULL; +PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName = NULL; +PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding = NULL; + #if LL_WINDOWS PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL; #endif @@ -436,6 +446,7 @@ LLGLManager::LLGLManager() : mHasTextureRectangle(FALSE), mHasTextureMultisample(FALSE), mHasTransformFeedback(FALSE), + mHasUniformBufferObject(FALSE), mMaxSampleMaskWords(0), mMaxColorTextureSamples(0), mMaxDepthTextureSamples(0), @@ -1054,6 +1065,7 @@ void LLGLManager::initExtensions() mHasTextureMultisample = ExtensionExists("GL_ARB_texture_multisample", gGLHExts.mSysExts); mHasDebugOutput = ExtensionExists("GL_ARB_debug_output", gGLHExts.mSysExts); mHasTransformFeedback = mGLVersion >= 4.f ? TRUE : FALSE; + mHasUniformBufferObject = ExtensionExists("GL_ARB_uniform_buffer_object", gGLHExts.mSysExts); #if !LL_DARWIN mHasPointParameters = ExtensionExists("GL_ARB_point_parameters", gGLHExts.mSysExts); #endif @@ -1286,6 +1298,10 @@ void LLGLManager::initExtensions() mGLMaxVertexRange = 0; mGLMaxIndexRange = 0; } + + // same with glTexImage3D et al + glTexImage3D = (PFNGLTEXIMAGE3DPROC)GLH_EXT_GET_PROC_ADDRESS("glTexImage3D"); + glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)GLH_EXT_GET_PROC_ADDRESS("glCopyTexSubImage3D"); #endif // !LL_LINUX || LL_LINUX_NV_GL_HEADERS #if LL_LINUX_NV_GL_HEADERS // nvidia headers are critically different from mesa-esque @@ -1319,6 +1335,17 @@ void LLGLManager::initExtensions() glPointParameterfvARB = (PFNGLPOINTPARAMETERFVARBPROC)GLH_EXT_GET_PROC_ADDRESS("glPointParameterfvARB"); } + if (mHasUniformBufferObject) + { + glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)GLH_EXT_GET_PROC_ADDRESS("glGetUniformIndices"); + glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetUniformIndices"); + glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)GLH_EXT_GET_PROC_ADDRESS("glGetActiveUniformName"); + glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)GLH_EXT_GET_PROC_ADDRESS("glGetUniformBlockIndex"); + glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)GLH_EXT_GET_PROC_ADDRESS("glGetActiveUniformBlockiv"); + glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)GLH_EXT_GET_PROC_ADDRESS("glGetActiveUniformBlockName"); + glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)GLH_EXT_GET_PROC_ADDRESS("glUniformBlockBinding"); + } + // Assume shader capabilities glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) GLH_EXT_GET_PROC_ADDRESS("glDeleteObjectARB"); glGetHandleARB = (PFNGLGETHANDLEARBPROC) GLH_EXT_GET_PROC_ADDRESS("glGetHandleARB"); diff --git a/indra/llrender/llgl.h b/indra/llrender/llgl.h index 52338364e6..eea53ed01e 100644 --- a/indra/llrender/llgl.h +++ b/indra/llrender/llgl.h @@ -104,6 +104,7 @@ public: BOOL mHasTextureRectangle; BOOL mHasTextureMultisample; BOOL mHasTransformFeedback; + BOOL mHasUniformBufferObject; S32 mMaxSampleMaskWords; S32 mMaxColorTextureSamples; S32 mMaxDepthTextureSamples; diff --git a/indra/llrender/llglheaders.h b/indra/llrender/llglheaders.h index 3d93cc0762..aa429505c1 100644 --- a/indra/llrender/llglheaders.h +++ b/indra/llrender/llglheaders.h @@ -564,6 +564,15 @@ extern PFNGLDEBUGMESSAGEINSERTARBPROC glDebugMessageInsertARB; extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB; extern PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB; +// GL_ARB_uniform_buffer_object +extern PFNGLGETUNIFORMINDICESPROC glGetUniformIndices; +extern PFNGLGETACTIVEUNIFORMSIVPROC glGetActiveUniformsiv; +extern PFNGLGETACTIVEUNIFORMNAMEPROC glGetActiveUniformName; +extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex; +extern PFNGLGETACTIVEUNIFORMBLOCKIVPROC glGetActiveUniformBlockiv; +extern PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glGetActiveUniformBlockName; +extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding; + #elif LL_DARWIN //---------------------------------------------------------------------------- // LL_DARWIN diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index a52dcd5aa1..0212c605c3 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -780,7 +780,8 @@ GLint LLGLSLShader::mapUniformTextureChannel(GLint location, GLenum type, GLint LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; if ((type >= GL_SAMPLER_1D_ARB && type <= GL_SAMPLER_2D_RECT_SHADOW_ARB) || - type == GL_SAMPLER_2D_MULTISAMPLE) + type == GL_SAMPLER_2D_MULTISAMPLE || + type == GL_SAMPLER_CUBE_MAP_ARRAY_ARB) { //this here is a texture GLint ret = mActiveTextureChannels; if (size == 1) @@ -1289,6 +1290,30 @@ void LLGLSLShader::uniform1iv(U32 index, U32 count, const GLint* v) } } +void LLGLSLShader::uniform4iv(U32 index, U32 count, const GLint* v) +{ + if (mProgramObject) + { + if (mUniform.size() <= index) + { + LL_SHADER_UNIFORM_ERRS() << "Uniform index out of bounds." << LL_ENDL; + return; + } + + if (mUniform[index] >= 0) + { + const auto& iter = mValue.find(mUniform[index]); + LLVector4 vec(v[0], v[1], v[2], v[3]); + if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) + { + glUniform1ivARB(mUniform[index], count, v); + mValue[mUniform[index]] = vec; + } + } + } +} + + void LLGLSLShader::uniform1fv(U32 index, U32 count, const GLfloat* v) { if (mProgramObject) @@ -1526,6 +1551,40 @@ void LLGLSLShader::uniform1i(const LLStaticHashedString& uniform, GLint v) } } +void LLGLSLShader::uniform1iv(const LLStaticHashedString& uniform, U32 count, const GLint* v) +{ + GLint location = getUniformLocation(uniform); + + if (location >= 0) + { + LLVector4 vec(v[0], 0, 0, 0); + const auto& iter = mValue.find(location); + if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; + glUniform1ivARB(location, count, v); + mValue[location] = vec; + } + } +} + +void LLGLSLShader::uniform4iv(const LLStaticHashedString& uniform, U32 count, const GLint* v) +{ + GLint location = getUniformLocation(uniform); + + if (location >= 0) + { + LLVector4 vec(v[0], v[1], v[2], v[3]); + const auto& iter = mValue.find(location); + if (iter == mValue.end() || shouldChange(iter->second, vec) || count != 1) + { + LL_PROFILE_ZONE_SCOPED_CATEGORY_SHADER; + glUniform4ivARB(location, count, v); + mValue[location] = vec; + } + } +} + void LLGLSLShader::uniform2i(const LLStaticHashedString& uniform, GLint i, GLint j) { GLint location = getUniformLocation(uniform); diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 7d6b341d3d..fe0aaae467 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -178,6 +178,7 @@ public: void uniform3f(U32 index, GLfloat x, GLfloat y, GLfloat z); void uniform4f(U32 index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); void uniform1iv(U32 index, U32 count, const GLint* i); + void uniform4iv(U32 index, U32 count, const GLint* i); void uniform1fv(U32 index, U32 count, const GLfloat* v); void uniform2fv(U32 index, U32 count, const GLfloat* v); void uniform3fv(U32 index, U32 count, const GLfloat* v); @@ -188,6 +189,8 @@ public: void uniformMatrix3x4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); void uniformMatrix4fv(U32 index, U32 count, GLboolean transpose, const GLfloat *v); void uniform1i(const LLStaticHashedString& uniform, GLint i); + void uniform1iv(const LLStaticHashedString& uniform, U32 count, const GLint* v); + void uniform4iv(const LLStaticHashedString& uniform, U32 count, const GLint* v); void uniform1f(const LLStaticHashedString& uniform, GLfloat v); void uniform2f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y); void uniform3f(const LLStaticHashedString& uniform, GLfloat x, GLfloat y, GLfloat z); diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 9bd3a0a6b0..f2da859e23 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1688,26 +1688,38 @@ void LLImageGL::syncToMainThread(LLGLuint new_tex_name) LL_PROFILE_ZONE_NAMED("cglt - sync"); if (gGLManager.mHasSync) { - // post a sync to the main thread (will execute before tex name swap lambda below) - // glFlush calls here are partly superstitious and partly backed by observation - // on AMD hardware - glFlush(); - auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - glFlush(); - LL::WorkQueue::postMaybe( - mMainQueue, - [=]() - { - LL_PROFILE_ZONE_NAMED("cglt - wait sync"); - { - LL_PROFILE_ZONE_NAMED("glWaitSync"); - glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); - } + if (gGLManager.mIsNVIDIA) + { + // wait for texture upload to finish before notifying main thread + // upload is complete + auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + glClientWaitSync(sync, 0, GL_TIMEOUT_IGNORED); + glDeleteSync(sync); + } + else + { + // post a sync to the main thread (will execute before tex name swap lambda below) + // glFlush calls here are partly superstitious and partly backed by observation + // on AMD hardware + glFlush(); + auto sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + glFlush(); + LL::WorkQueue::postMaybe( + mMainQueue, + [=]() { - LL_PROFILE_ZONE_NAMED("glDeleteSync"); - glDeleteSync(sync); - } - }); + LL_PROFILE_ZONE_NAMED("cglt - wait sync"); + { + LL_PROFILE_ZONE_NAMED("glWaitSync"); + glWaitSync(sync, 0, GL_TIMEOUT_IGNORED); + } + { + LL_PROFILE_ZONE_NAMED("glDeleteSync"); + glDeleteSync(sync); + } + }); + } } else { @@ -1726,6 +1738,7 @@ void LLImageGL::syncToMainThread(LLGLuint new_tex_name) }); } + void LLImageGL::syncTexName(LLGLuint texname) { if (texname != 0) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index a03a27cf94..3adb47f493 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -71,6 +71,7 @@ static const GLenum sGLTextureType[] = GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_CUBE_MAP_ARB, + GL_TEXTURE_CUBE_MAP_ARRAY_ARB, GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_3D }; @@ -888,6 +889,9 @@ void LLRender::init() glCullFace(GL_BACK); + // necessary for reflection maps + glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + if (sGLCoreProfile && !LLVertexBuffer::sUseVAO) { //bind a dummy vertex array object so we're core profile compliant #ifdef GL_ARB_vertex_array_object diff --git a/indra/llrender/llrender.h b/indra/llrender/llrender.h index e2489876e4..095ed400f4 100644 --- a/indra/llrender/llrender.h +++ b/indra/llrender/llrender.h @@ -52,7 +52,7 @@ class LLTexture ; #define LL_MATRIX_STACK_DEPTH 32 -class LLTexUnit +class LLTexUnit { friend class LLRender; public: @@ -63,6 +63,7 @@ public: TT_TEXTURE = 0, // Standard 2D Texture TT_RECT_TEXTURE, // Non power of 2 texture TT_CUBE_MAP, // 6-sided cube map texture + TT_CUBE_MAP_ARRAY, // Array of cube maps TT_MULTISAMPLE_TEXTURE, // see GL_ARB_texture_multisample TT_TEXTURE_3D, // standard 3D Texture TT_NONE, // No texture type is currently enabled diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index cd7ec478bb..8e8f44e99b 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -712,8 +712,15 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade { if (major_version >= 4) { - //set version to 400 - shader_code_text[shader_code_count++] = strdup("#version 400\n"); + //set version to 400 or 420 + if (minor_version >= 20) + { + shader_code_text[shader_code_count++] = strdup("#version 420\n"); + } + else + { + shader_code_text[shader_code_count++] = strdup("#version 400\n"); + } } else if (major_version == 3) { @@ -1155,7 +1162,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("bumpMap"); mReservedUniforms.push_back("bumpMap2"); mReservedUniforms.push_back("environmentMap"); - mReservedUniforms.push_back("reflectionMap"); + mReservedUniforms.push_back("reflectionProbes"); mReservedUniforms.push_back("cloud_noise_texture"); mReservedUniforms.push_back("cloud_noise_texture_next"); mReservedUniforms.push_back("fullbright"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 7ca4862ed9..663ba28b6d 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -80,7 +80,7 @@ public: BUMP_MAP, // "bumpMap" BUMP_MAP2, // "bumpMap2" ENVIRONMENT_MAP, // "environmentMap" - REFLECTION_MAP, // "reflectionMap" + REFLECTION_PROBES, // "reflectionProbes" CLOUD_NOISE_MAP, // "cloud_noise_texture" CLOUD_NOISE_MAP_NEXT, // "cloud_noise_texture_next" FULLBRIGHT, // "fullbright" diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 20b708fe99..284b779be3 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10269,6 +10269,17 @@ 2 + RenderReflectionProbeDrawDistance + + Comment + Camera far clip to use when updating reflection probes. + Persist + 1 + Type + F32 + Value + 64 + RenderReflectionRes Comment diff --git a/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl index 23adbded5e..73c125bbdc 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/aoUtil.glsl @@ -29,8 +29,6 @@ uniform sampler2DRect depthMap; uniform float ssao_radius; uniform float ssao_max_radius; -uniform float ssao_factor; -uniform float ssao_factor_inv; uniform mat4 inv_proj; uniform vec2 screen_res; @@ -83,14 +81,14 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen) { float ret = 1.0; vec3 pos_world = pos.xyz; - vec2 noise_reflect = texture2D(noiseMap, pos_screen.xy/128.0).xy; + float angle_hidden = 0.0; float points = 0; - float scale = min(ssao_radius / -pos_world.z, ssao_max_radius); - // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?) + float scale = min(ssao_radius / -pos_world.z, ssao_max_radius); + vec2 noise_reflect = texture2D(noiseMap, pos_screen.xy/128.0).xy; for (int i = 0; i < 8; i++) { vec2 samppos_screen = pos_screen + scale * reflect(getKern(i), noise_reflect); @@ -105,14 +103,14 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm, vec2 pos_screen) //(k should vary inversely with # of samples, but this is taken care of later) float funky_val = (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) ? 1.0 : 0.0; - angle_hidden = angle_hidden + funky_val * min(1.0/dist2, ssao_factor_inv); + angle_hidden = angle_hidden + funky_val * min(1.0/dist2, 1.0); // 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" float diffz_val = (diff.z > -1.0) ? 1.0 : 0.0; points = points + diffz_val; } - - angle_hidden = min(ssao_factor*angle_hidden/points, 1.0); + + angle_hidden = min(angle_hidden/points, 1.0); float points_val = (points > 0.0) ? 1.0 : 0.0; ret = (1.0 - (points_val * angle_hidden)); diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl index 596d0274af..fa3634f3b6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl @@ -69,36 +69,47 @@ void main() tc_mod *= 2.0; tc += ( (tc_mod - 0.5) * kern[1].z * dlt * 0.5 ); - for (int i = 1; i < 4; i++) + // TODO: move this to kern instead of building kernel per pixel + vec3 k[7]; + k[0] = kern[0]; + k[2] = kern[1]; + k[4] = kern[2]; + k[6] = kern[3]; + + k[1] = (k[0]+k[2])*0.5f; + k[3] = (k[2]+k[4])*0.5f; + k[5] = (k[4]+k[6])*0.5f; + + for (int i = 1; i < 7; i++) { - vec2 samptc = tc + kern[i].z*dlt; + vec2 samptc = tc + k[i].z*dlt*2.0; vec3 samppos = getPosition(samptc).xyz; float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane if (d*d <= pointplanedist_tolerance_pow2) { - col += texture2DRect(lightMap, samptc)*kern[i].xyxx; - defined_weight += kern[i].xy; + col += texture2DRect(lightMap, samptc)*k[i].xyxx; + defined_weight += k[i].xy; } } - for (int i = 1; i < 4; i++) + for (int i = 1; i < 7; i++) { - vec2 samptc = tc - kern[i].z*dlt; + vec2 samptc = tc - k[i].z*dlt*2.0; vec3 samppos = getPosition(samptc).xyz; float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane if (d*d <= pointplanedist_tolerance_pow2) { - col += texture2DRect(lightMap, samptc)*kern[i].xyxx; - defined_weight += kern[i].xy; + col += texture2DRect(lightMap, samptc)*k[i].xyxx; + defined_weight += k[i].xy; } } col /= defined_weight.xyxx; - col.y *= col.y; + //col.y *= max(col.y, 0.75); frag_color = col; diff --git a/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl new file mode 100644 index 0000000000..ea687aab4f --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/interface/reflectionmipF.glsl @@ -0,0 +1,75 @@ +/** + * @file reflectionmipF.glsl + * + * $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$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2DRect screenMap; + +VARYING vec2 vary_texcoord0; + +void main() +{ + float w[9]; + + float c = 1.0/16.0; //corner weight + float e = 1.0/8.0; //edge weight + float m = 1.0/4.0; //middle weight + + //float wsum = c*4+e*4+m; + + w[0] = c; w[1] = e; w[2] = c; + w[3] = e; w[4] = m; w[5] = e; + w[6] = c; w[7] = e; w[8] = c; + + vec2 tc[9]; + + float ed = 1; + float cd = 1; + + + tc[0] = vec2(-cd, cd); tc[1] = vec2(0, ed); tc[2] = vec2(cd, cd); + tc[3] = vec2(-ed, 0); tc[4] = vec2(0, 0); tc[5] = vec2(ed, 0); + tc[6] = vec2(-cd, -cd); tc[7] = vec2(0, -ed); tc[8] = vec2(cd, -1); + + vec3 color = vec3(0,0,0); + + for (int i = 0; i < 9; ++i) + { + color += texture2DRect(screenMap, vary_texcoord0.xy+tc[i]).rgb * w[i]; + //color += texture2DRect(screenMap, vary_texcoord0.xy+tc[i]*2.0).rgb * w[i]*0.5; + } + + //color /= wsum; + + frag_color = vec4(color, 1.0); +} diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 5bb64e18a7..3a1287e910 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -26,9 +26,10 @@ #extension GL_ARB_texture_rectangle : enable #extension GL_ARB_shader_texture_lod : enable -/*[EXTRA_CODE_HERE]*/ +#define FLT_MAX 3.402823466e+38 -#define REFMAP_COUNT 8 +#define REFMAP_COUNT 256 +#define REF_SAMPLE_COUNT 64 //maximum number of samples to consider #ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; @@ -42,12 +43,26 @@ uniform sampler2DRect normalMap; uniform sampler2DRect lightMap; uniform sampler2DRect depthMap; uniform samplerCube environmentMap; -uniform samplerCube reflectionMap[REFMAP_COUNT]; +uniform samplerCubeArray reflectionProbes; uniform sampler2D lightFunc; -uniform int refmapCount; - -uniform vec3 refOrigin[REFMAP_COUNT]; +layout (std140, binding = 1) uniform ReflectionProbes +{ + // list of sphere based reflection probes sorted by distance to camera (closest first) + vec4 refSphere[REFMAP_COUNT]; + // index of cube map in reflectionProbes for a corresponding reflection probe + // e.g. cube map channel of refSphere[2] is stored in refIndex[2] + // refIndex.x - cubemap channel in reflectionProbes + // refIndex.y - index in refNeighbor of neighbor list (index is ivec4 index, not int index) + // refIndex.z - number of neighbors + ivec4 refIndex[REFMAP_COUNT]; + + // neighbor list data (refSphere indices, not cubemap array layer) + ivec4 refNeighbor[1024]; + + // number of reflection probes present in refSphere + int refmapCount; +}; uniform float blur_size; uniform float blur_fidelity; @@ -80,7 +95,116 @@ vec3 srgb_to_linear(vec3 c); vec4 applyWaterFogView(vec3 pos, vec4 color); #endif +// list of probeIndexes shader will actually use after "getRefIndex" is called +// (stores refIndex/refSphere indices, NOT rerflectionProbes layer) +int probeIndex[REF_SAMPLE_COUNT]; + +// number of probes stored in probeIndex +int probeInfluences = 0; + + +// return true if probe at index i influences position pos +bool shouldSampleProbe(int i, vec3 pos) +{ + vec3 delta = pos.xyz - refSphere[i].xyz; + float d = dot(delta, delta); + float r2 = refSphere[i].w; + r2 *= r2; + return d < r2; +} + +// populate "probeIndex" with N probe indices that influence pos where N is REF_SAMPLE_COUNT +// overall algorithm -- +void getRefIndex(vec3 pos) +{ + // TODO: make some sort of structure that reduces the number of distance checks + for (int i = 0; i < refmapCount; ++i) + { + // found an influencing probe + if (shouldSampleProbe(i, pos)) + { + probeIndex[probeInfluences] = i; + ++probeInfluences; + + int neighborIdx = refIndex[i].y; + if (neighborIdx != -1) + { + int neighborCount = min(refIndex[i].z, REF_SAMPLE_COUNT-1); + + int count = 0; + while (count < neighborCount) + { + // check up to REF_SAMPLE_COUNT-1 neighbors (neighborIdx is ivec4 index) + + int idx = refNeighbor[neighborIdx].x; + if (shouldSampleProbe(idx, pos)) + { + probeIndex[probeInfluences++] = idx; + if (probeInfluences == REF_SAMPLE_COUNT) + { + return; + } + } + count++; + if (count == neighborCount) + { + return; + } + + idx = refNeighbor[neighborIdx].y; + if (shouldSampleProbe(idx, pos)) + { + probeIndex[probeInfluences++] = idx; + if (probeInfluences == REF_SAMPLE_COUNT) + { + return; + } + } + count++; + if (count == neighborCount) + { + return; + } + + idx = refNeighbor[neighborIdx].z; + if (shouldSampleProbe(idx, pos)) + { + probeIndex[probeInfluences++] = idx; + if (probeInfluences == REF_SAMPLE_COUNT) + { + return; + } + } + count++; + if (count == neighborCount) + { + return; + } + + idx = refNeighbor[neighborIdx].w; + if (shouldSampleProbe(idx, pos)) + { + probeIndex[probeInfluences++] = idx; + if (probeInfluences == REF_SAMPLE_COUNT) + { + return; + } + } + count++; + if (count == neighborCount) + { + return; + } + + ++neighborIdx; + } + + return; + } + } + } +} // from https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-sphere-intersection @@ -120,13 +244,10 @@ bool intersect(const Ray &ray) const } */ // adapted -- assume that origin is inside sphere, return distance from origin to edge of sphere -float sphereIntersect(vec3 origin, vec3 dir, vec4 sph ) +float sphereIntersect(vec3 origin, vec3 dir, vec3 center, float radius2) { float t0, t1; // solutions for t if the ray intersects - vec3 center = sph.xyz; - float radius2 = sph.w * sph.w; - vec3 L = center - origin; float tca = dot(L,dir); @@ -139,33 +260,78 @@ float sphereIntersect(vec3 origin, vec3 dir, vec4 sph ) return t1; } +// Tap a sphere based reflection probe +// pos - position of pixel +// dir - pixel normal +// lod - which mip to bias towards (lower is higher res, sharper reflections) +// c - center of probe +// r2 - radius of probe squared +// i - index of probe +// vi - point at which reflection vector struck the influence volume, in clip space +vec3 tapRefMap(vec3 pos, vec3 dir, float lod, vec3 c, float r2, int i, out vec3 vi) +{ + //lod = max(lod, 1); +// parallax adjustment + float d = sphereIntersect(pos, dir, c, r2); + + { + vec3 v = pos + dir * d; + vi = v; + v -= c.xyz; + v = env_mat * v; + + float min_lod = textureQueryLod(reflectionProbes,v).y; // lower is higher res + return textureLod(reflectionProbes, vec4(v.xyz, refIndex[i].x), max(min_lod, lod)).rgb; + //return texture(reflectionProbes, vec4(v.xyz, refIndex[i].x)).rgb; + } +} + vec3 sampleRefMap(vec3 pos, vec3 dir, float lod) { float wsum = 0.0; - vec3 col = vec3(0,0,0); + float vd2 = dot(pos,pos); // view distance squared - for (int i = 0; i < refmapCount; ++i) - //int i = 0; + for (int idx = 0; idx < probeInfluences; ++idx) { - float r = 16.0; - vec3 delta = pos.xyz-refOrigin[i].xyz; - if (length(delta) < r) + int i = probeIndex[idx]; + float r = refSphere[i].w; // radius of sphere volume + float rr = r*r; // radius squred + float r1 = r * 0.1; // 75% of radius (outer sphere to start interpolating down) + vec3 delta = pos.xyz-refSphere[i].xyz; + float d2 = dot(delta,delta); + float r2 = r1*r1; + { - float w = 1.0/max(dot(delta, delta), r); - w *= w; - w *= w; + vec3 vi; + vec3 refcol = tapRefMap(pos, dir, lod, refSphere[i].xyz, rr, i, vi); + + float w = 1.0/d2; - // parallax adjustment - float d = sphereIntersect(pos, dir, vec4(refOrigin[i].xyz, r)); + float atten = 1.0-max(d2-r2, 0.0)/(rr-r2); + w *= atten; - { - vec3 v = pos + dir * d; - v -= refOrigin[i].xyz; - v = env_mat * v; + col += refcol*w; + + wsum += w; + } + } - float min_lod = textureQueryLod(reflectionMap[i],v).y; // lower is higher res - col += textureLod(reflectionMap[i], v, max(min_lod, lod)).rgb*w; + if (probeInfluences <= 1) + { //edge-of-scene probe or no probe influence, mix in with embiggened version of probes closest to camera + for (int idx = 0; idx < 8; ++idx) + { + int i = idx; + vec3 delta = pos.xyz-refSphere[i].xyz; + float d2 = dot(delta,delta); + + { + vec3 vi; + vec3 refcol = tapRefMap(pos, dir, lod, refSphere[i].xyz, d2, i, vi); + + float w = 1.0/d2; + w *= w; + col += refcol*w; wsum += w; } } @@ -175,13 +341,6 @@ vec3 sampleRefMap(vec3 pos, vec3 dir, float lod) { col *= 1.0/wsum; } - else - { - // this pixel not covered by a probe, fallback to "full scene" environment map - vec3 v = env_mat * dir; - float min_lod = textureQueryLod(environmentMap, v).y; // lower is higher res - col = textureLod(environmentMap, v, max(min_lod, lod)).rgb; - } return col; } @@ -202,13 +361,26 @@ vec3 sampleAmbient(vec3 pos, vec3 dir, float lod) col *= 0.333333; - return col*0.6; // fudge darker + return col*0.8; // fudge darker } +// brighten a color so that at least one component is 1 +vec3 brighten(vec3 c) +{ + float m = max(max(c.r, c.g), c.b); + + if (m == 0) + { + return vec3(1,1,1); + } + + return c * 1.0/m; +} + void main() { - float reflection_lods = 11; // TODO -- base this on resolution of reflection map instead of hard coding + float reflection_lods = 8; // TODO -- base this on resolution of reflection map instead of hard coding vec2 tc = vary_fragcoord.xy; float depth = texture2DRect(depthMap, tc.xy).r; @@ -238,14 +410,16 @@ void main() vec3 amblit; vec3 additive; vec3 atten; + + getRefIndex(pos.xyz); + calcAtmosphericVars(pos.xyz, light_dir, ambocc, sunlit, amblit, additive, atten, true); //vec3 amb_vec = env_mat * norm.xyz; - vec3 ambenv = sampleAmbient(pos.xyz, norm.xyz, reflection_lods-1); - amblit = mix(ambenv, amblit, amblit); - color.rgb = amblit; - + vec3 ambenv = sampleAmbient(pos.xyz, norm.xyz, reflection_lods); + amblit = max(ambenv, amblit); + color.rgb = amblit*ambocc; //float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0); //ambient *= 0.5; @@ -255,6 +429,7 @@ void main() vec3 sun_contrib = min(da, scol) * sunlit; color.rgb += sun_contrib; + color.rgb = min(color.rgb, vec3(1,1,1)); color.rgb *= diffuse.rgb; vec3 refnormpersp = reflect(pos.xyz, norm.xyz); @@ -274,26 +449,23 @@ void main() float lod = (1.0-spec.a)*reflection_lods; vec3 reflected_color = sampleRefMap(pos.xyz, normalize(refnormpersp), lod); - reflected_color *= 0.5; // fudge darker, not sure where there's a multiply by two and it's late + reflected_color *= 0.35; // fudge darker float fresnel = 1.0+dot(normalize(pos.xyz), norm.xyz); - fresnel += spec.a; - fresnel *= fresnel; - //fresnel *= spec.a; + float minf = spec.a * 0.1; + fresnel = fresnel * (1.0-minf) + minf; reflected_color *= spec.rgb*min(fresnel, 1.0); - //reflected_color = srgb_to_linear(reflected_color); - vec3 mixer = clamp(color.rgb + vec3(1,1,1) - spec.rgb, vec3(0,0,0), vec3(1,1,1)); - color.rgb = mix(reflected_color, color, mixer); + color.rgb += reflected_color; } color.rgb = mix(color.rgb, diffuse.rgb, diffuse.a); if (envIntensity > 0.0) { // add environmentmap - vec3 reflected_color = sampleRefMap(pos.xyz, normalize(refnormpersp), 0.0); + vec3 reflected_color = sampleRefMap(pos.xyz, normalize(refnormpersp), 0.0)*0.5; //fudge darker float fresnel = 1.0+dot(normalize(pos.xyz), norm.xyz); fresnel *= fresnel; - fresnel = fresnel * 0.95 + 0.05; - reflected_color *= fresnel; + fresnel = min(fresnel+envIntensity, 1.0); + reflected_color *= (envIntensity*fresnel)*brighten(spec.rgb); color = mix(color.rgb, reflected_color, envIntensity); } @@ -311,5 +483,7 @@ void main() // convert to linear as fullscreen lights need to sum in linear colorspace // and will be gamma (re)corrected downstream... + //color = vec3(ambocc); + //color = ambenv; frag_color.rgb = srgb_to_linear(color.rgb); } diff --git a/indra/newview/llagentcamera.cpp b/indra/newview/llagentcamera.cpp index 84a41113be..8d02bec53e 100644 --- a/indra/newview/llagentcamera.cpp +++ b/indra/newview/llagentcamera.cpp @@ -1188,12 +1188,18 @@ void LLAgentCamera::updateLookAt(const S32 mouse_x, const S32 mouse_y) static LLTrace::BlockTimerStatHandle FTM_UPDATE_CAMERA("Camera"); +extern BOOL gCubeSnapshot; + //----------------------------------------------------------------------------- // updateCamera() //----------------------------------------------------------------------------- void LLAgentCamera::updateCamera() { LL_RECORD_BLOCK_TIME(FTM_UPDATE_CAMERA); + if (gCubeSnapshot) + { + return; + } // - changed camera_skyward to the new global "mCameraUpVector" mCameraUpVector = LLVector3::z_axis; diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index eebd89f77f..47330debd3 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -129,6 +129,8 @@ static void prepare_alpha_shader(LLGLSLShader* shader, bool textureGamma, bool d } } +extern BOOL gCubeSnapshot; + void LLDrawPoolAlpha::renderPostDeferred(S32 pass) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; @@ -155,7 +157,7 @@ void LLDrawPoolAlpha::renderPostDeferred(S32 pass) forwardRender(); // final pass, render to depth for depth of field effects - if (!LLPipeline::sImpostorRender && gSavedSettings.getBOOL("RenderDepthOfField")) + if (!LLPipeline::sImpostorRender && gSavedSettings.getBOOL("RenderDepthOfField") && !gCubeSnapshot) { //update depth buffer sampler gPipeline.mScreen.flush(); diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 2892fc6f9f..0df0137b7a 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -735,6 +735,7 @@ void LLDrawPoolBump::renderDeferred(S32 pass) void LLDrawPoolBump::renderPostDeferred(S32 pass) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL for (int i = 0; i < 2; ++i) { // two passes -- static and rigged mRigged = (i == 1); diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index 64850424f4..2478aa0cff 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -87,6 +87,6 @@ void LLDrawPoolPBROpaque::renderDeferred(S32 pass) // TODO: handle under water? // if (LLPipeline::sUnderWaterRender) // PASS_SIMPLE or PASS_MATERIAL - pushBatches(LLRenderPass::PASS_SIMPLE, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); + //pushBatches(LLRenderPass::PASS_SIMPLE, getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX, TRUE, TRUE); } diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index b75dba877e..0cf2f22822 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -29,36 +29,183 @@ #include "llreflectionmap.h" #include "pipeline.h" #include "llviewerwindow.h" +#include "llviewerregion.h" + +extern F32SecondsImplicit gFrameTimeSeconds; LLReflectionMap::LLReflectionMap() { + mLastUpdateTime = gFrameTimeSeconds; } -void LLReflectionMap::update(const LLVector3& origin, U32 resolution) +void LLReflectionMap::update(U32 resolution, U32 face) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + mLastUpdateTime = gFrameTimeSeconds; + llassert(mCubeArray.notNull()); + llassert(mCubeIndex != -1); llassert(LLPipeline::sRenderDeferred); - - // make sure resolution is < gPipeline.mDeferredScreen.getWidth() - + + // make sure we don't walk off the edge of the render target while (resolution > gPipeline.mDeferredScreen.getWidth() || resolution > gPipeline.mDeferredScreen.getHeight()) { resolution /= 2; } + gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face); +} - if (resolution == 0) - { - return; +bool LLReflectionMap::shouldUpdate() +{ + const F32 UPDATE_INTERVAL = 10.f; // update no more than this often + const F32 TIMEOUT_INTERVAL = 30.f; // update no less than this often + const F32 RENDER_TIMEOUT = 1.f; // don't update if hasn't been used for rendering for this long + + if (mLastBindTime > gFrameTimeSeconds - RENDER_TIMEOUT) + { + if (mDirty && mLastUpdateTime < gFrameTimeSeconds - UPDATE_INTERVAL) + { + return true; + } + + if (mLastUpdateTime < gFrameTimeSeconds - TIMEOUT_INTERVAL) + { + return true; + } } - mOrigin.load3(origin.mV); + return false; +} + +void LLReflectionMap::dirty() +{ + mDirty = true; + mLastUpdateTime = gFrameTimeSeconds; +} + +void LLReflectionMap::autoAdjustOrigin() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + + if (mGroup) + { + const LLVector4a* bounds = mGroup->getBounds(); + auto* node = mGroup->getOctreeNode(); + + if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_TERRAIN) + { + // for terrain, make probes float a couple meters above the highest point in the surface patch + mOrigin = bounds[0]; + mOrigin.getF32ptr()[2] += bounds[1].getF32ptr()[2] + 3.f; + + // update radius to encompass bounding box + LLVector4a d; + d.setAdd(bounds[0], bounds[1]); + d.sub(mOrigin); + mRadius = d.getLength3().getF32(); + } + else if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) + { + // cast a ray towards 8 corners of bounding box + // nudge origin towards center of empty space + + if (node->isLeaf() || node->getChildCount() > 1 || node->getData().size() > 0) + { // use center of object bounding box for leaf nodes or nodes with multiple child nodes + mOrigin = bounds[0]; - mCubeMap = new LLCubeMap(false); - mCubeMap->initReflectionMap(resolution); + LLVector4a start; + LLVector4a end; - gViewerWindow->cubeSnapshot(origin, mCubeMap); + LLVector4a size = bounds[1]; - mCubeMap->generateMipMaps(); + LLVector4a corners[] = + { + { 1, 1, 1 }, + { -1, 1, 1 }, + { 1, -1, 1 }, + { -1, -1, 1 }, + { 1, 1, -1 }, + { -1, 1, -1 }, + { 1, -1, -1 }, + { -1, -1, -1 } + }; + + for (int i = 0; i < 8; ++i) + { + corners[i].mul(size); + corners[i].add(bounds[0]); + } + + LLVector4a extents[2]; + extents[0].setAdd(bounds[0], bounds[1]); + extents[1].setSub(bounds[0], bounds[1]); + + bool hit = false; + for (int i = 0; i < 8; ++i) + { + int face = -1; + LLVector4a intersection; + LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, &face, &intersection); + if (drawable != nullptr) + { + hit = true; + update_min_max(extents[0], extents[1], intersection); + } + else + { + update_min_max(extents[0], extents[1], corners[i]); + } + } + + if (hit) + { + mOrigin.setAdd(extents[0], extents[1]); + mOrigin.mul(0.5f); + } + + // make sure radius encompasses all objects + LLSimdScalar r2 = 0.0; + for (int i = 0; i < 8; ++i) + { + LLVector4a v; + v.setSub(corners[i], mOrigin); + + LLSimdScalar d = v.dot3(v); + + if (d > r2) + { + r2 = d; + } + } + + mRadius = llmax(sqrtf(r2.getF32()), 8.f); + } + else + { + // use center of octree node volume for nodes that are just branches without data + mOrigin = node->getCenter(); + + // update radius to encompass entire octree node volume + mRadius = node->getSize().getLength3().getF32(); + + //mOrigin = bounds[0]; + //mRadius = bounds[1].getLength3().getF32(); + + } + } + } } +bool LLReflectionMap::intersects(LLReflectionMap* other) +{ + LLVector4a delta; + delta.setSub(other->mOrigin, mOrigin); + + F32 dist = delta.dot3(delta).getF32(); + + F32 r2 = mRadius + other->mRadius; + + r2 *= r2; + + return dist < r2; +} diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index 7d39e7e562..ed1c2680b6 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -26,26 +26,61 @@ #pragma once -#include "llcubemap.h" +#include "llcubemaparray.h" +#include "llmemory.h" -class LLReflectionMap : public LLRefCount +class LLSpatialGroup; + +class alignas(16) LLReflectionMap : public LLRefCount { + LL_ALIGN_NEW public: // allocate an environment map of the given resolution LLReflectionMap(); // 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); - - // point at which environment map was generated from (in agent space) - LLVector4a mOrigin; + void update(U32 resolution, U32 face); + + // return true if this probe should update *now* + bool shouldUpdate(); + // Mark this reflection map as needing an update (resets last update time, so spamming this call will cause a cube map to never update) + void dirty(); + + // for volume partition probes, try to place this probe in the best spot + void autoAdjustOrigin(); + + // return true if given Reflection Map's influence volume intersect's with this one's + bool intersects(LLReflectionMap* other); + + // point at which environment map was last generated from (in agent space) + LLVector4a mOrigin; + // distance from viewer camera F32 mDistance; + // radius of this probe's affected area + F32 mRadius = 16.f; + + // last time this probe was updated (or when its update timer got reset) + F32 mLastUpdateTime = 0.f; + + // last time this probe was bound for rendering + F32 mLastBindTime = 0.f; + // cube map used to sample this environment map - LLPointer mCubeMap; + LLPointer mCubeArray; + S32 mCubeIndex = -1; // index into cube map array or -1 if not currently stored in cube map array + + // index into array packed by LLReflectionMapManager::getReflectionMaps + // WARNING -- only valid immediately after call to getReflectionMaps + S32 mProbeIndex = -1; + + // set of any LLReflectionMaps that intersect this map (maintained by LLReflectionMapManager + std::vector mNeighbors; + + LLSpatialGroup* mGroup = nullptr; + bool mDirty = true; }; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 95b72e1d3b..a6b704d57d 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -28,30 +28,84 @@ #include "llreflectionmapmanager.h" #include "llviewercamera.h" +#include "llspatialpartition.h" +#include "llviewerregion.h" +#include "pipeline.h" +#include "llviewershadermgr.h" + +extern BOOL gCubeSnapshot; +extern BOOL gTeleportDisplay; + +//#pragma optimize("", off) LLReflectionMapManager::LLReflectionMapManager() { - + for (int i = 0; i < LL_REFLECTION_PROBE_COUNT; ++i) + { + mCubeFree[i] = true; + } } struct CompareReflectionMapDistance { - + }; struct CompareProbeDistance { - bool operator()(const LLReflectionMap& lhs, const LLReflectionMap& rhs) + bool operator()(const LLPointer& lhs, const LLPointer& rhs) { - return lhs.mDistance < rhs.mDistance; + return lhs->mDistance < rhs->mDistance; } }; // helper class to seed octree with probes void LLReflectionMapManager::update() { + if (!LLPipeline::sRenderDeferred || gTeleportDisplay) + { + return; + } + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + llassert(!gCubeSnapshot); // assert a snapshot is not in progress + if (LLAppViewer::instance()->logoutRequestSent()) + { + return; + } + + // =============== TODO -- move to an init function ================= + + if (mTexture.isNull()) + { + mTexture = new LLCubeMapArray(); + mTexture->allocate(LL_REFLECTION_PROBE_RESOLUTION, 3, LL_REFLECTION_PROBE_COUNT); + } + + if (!mRenderTarget.isComplete()) + { + U32 color_fmt = GL_RGBA; + const bool use_depth_buffer = true; + const bool use_stencil_buffer = true; + U32 targetRes = LL_REFLECTION_PROBE_RESOLUTION * 4; // super sample + mRenderTarget.allocate(targetRes, targetRes, color_fmt, use_depth_buffer, use_stencil_buffer, LLTexUnit::TT_RECT_TEXTURE); + } + + if (mMipChain.empty()) + { + U32 res = LL_REFLECTION_PROBE_RESOLUTION*2; + U32 count = log2((F32)res) + 0.5f; + + mMipChain.resize(count); + for (int i = 0; i < count; ++i) + { + mMipChain[i].allocate(res, res, GL_RGB, false, false, LLTexUnit::TT_RECT_TEXTURE); + res /= 2; + } + } + + // =============== TODO -- move to an init function ================= // naively drop probes every 16m as we move the camera around for now // later, use LLSpatialPartition to manage probes @@ -61,46 +115,462 @@ void LLReflectionMapManager::update() LLVector4a camera_pos; camera_pos.load3(LLViewerCamera::instance().getOrigin().mV); - for (auto& probe : mProbes) + // process kill list + for (int i = 0; i < mProbes.size(); ) { - LLVector4a d; - d.setSub(camera_pos, probe.mOrigin); - probe.mDistance = d.getLength3().getF32(); + auto& iter = std::find(mKillList.begin(), mKillList.end(), mProbes[i]); + if (iter != mKillList.end()) + { + deleteProbe(i); + mProbes.erase(mProbes.begin() + i); + mKillList.erase(iter); + } + else + { + ++i; + } } - if (mProbes.empty() || mProbes[0].mDistance > PROBE_SPACING) + mKillList.clear(); + + // process create list + for (auto& probe : mCreateList) { - addProbe(LLViewerCamera::instance().getOrigin()); + mProbes.push_back(probe); } - // update distance to camera for all probes - std::sort(mProbes.begin(), mProbes.end(), CompareProbeDistance()); + mCreateList.clear(); + + const F32 UPDATE_INTERVAL = 10.f; //update no more than once every 5 seconds + + bool did_update = false; + + if (mUpdatingProbe != nullptr) + { + did_update = true; + doProbeUpdate(); + } - if (mProbes.size() > MAX_PROBES) + for (int i = 0; i < mProbes.size(); ++i) { - mProbes.resize(MAX_PROBES); + LLReflectionMap* probe = mProbes[i]; + if (probe->getNumRefs() == 1) + { // no references held outside manager, delete this probe + deleteProbe(i); + --i; + continue; + } + + probe->mProbeIndex = i; + + LLVector4a d; + + if (probe->shouldUpdate() && !did_update && i < LL_REFLECTION_PROBE_COUNT) + { + if (probe->mCubeIndex == -1) + { + probe->mCubeArray = mTexture; + probe->mCubeIndex = allocateCubeIndex(); + } + + did_update = true; // only update one probe per frame + probe->autoAdjustOrigin(); + + mUpdatingProbe = probe; + doProbeUpdate(); + probe->mDirty = false; + } + + d.setSub(camera_pos, probe->mOrigin); + probe->mDistance = d.getLength3().getF32()-probe->mRadius; } + + // update distance to camera for all probes + std::sort(mProbes.begin(), mProbes.end(), CompareProbeDistance()); } void LLReflectionMapManager::addProbe(const LLVector3& pos) { - LLReflectionMap probe; - probe.update(pos, 1024); - mProbes.push_back(probe); + //LLReflectionMap* probe = new LLReflectionMap(); + //probe->update(pos, 1024); + //mProbes.push_back(probe); +} + +LLReflectionMap* LLReflectionMapManager::addProbe(LLSpatialGroup* group) +{ + LLReflectionMap* probe = new LLReflectionMap(); + probe->mGroup = group; + probe->mOrigin = group->getOctreeNode()->getCenter(); + probe->mDirty = true; + + if (gCubeSnapshot) + { //snapshot is in progress, mProbes is being iterated over, defer insertion until next update + mCreateList.push_back(probe); + } + else + { + mProbes.push_back(probe); + } + + return probe; } void LLReflectionMapManager::getReflectionMaps(std::vector& maps) { - // just null out for now - U32 i = 0; - for (i = 0; i < maps.size() && i < mProbes.size(); ++i) + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + + U32 count = 0; + U32 lastIdx = 0; + for (U32 i = 0; count < maps.size() && i < mProbes.size(); ++i) + { + mProbes[i]->mLastBindTime = gFrameTimeSeconds; // something wants to use this probe, indicate it's been requested + if (mProbes[i]->mCubeIndex != -1) + { + mProbes[i]->mProbeIndex = count; + maps[count++] = mProbes[i]; + } + else + { + mProbes[i]->mProbeIndex = -1; + } + lastIdx = i; + } + + // set remaining probe indices to -1 + for (U32 i = lastIdx+1; i < mProbes.size(); ++i) + { + mProbes[i]->mProbeIndex = -1; + } + + // null terminate list + if (count < maps.size()) + { + maps[count] = nullptr; + } +} + +LLReflectionMap* LLReflectionMapManager::registerSpatialGroup(LLSpatialGroup* group) +{ + if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) + { + OctreeNode* node = group->getOctreeNode(); + F32 size = node->getSize().getF32ptr()[0]; + if (size >= 7.f && size <= 17.f) + { + return addProbe(group); + } + } + + if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_TERRAIN) + { + OctreeNode* node = group->getOctreeNode(); + F32 size = node->getSize().getF32ptr()[0]; + if (size >= 15.f && size <= 17.f) + { + return addProbe(group); + } + } + + return nullptr; +} + +S32 LLReflectionMapManager::allocateCubeIndex() +{ + for (int i = 0; i < LL_REFLECTION_PROBE_COUNT; ++i) + { + if (mCubeFree[i]) + { + mCubeFree[i] = false; + return i; + } + } + + // no cubemaps free, steal one from the back of the probe list + for (int i = mProbes.size() - 1; i >= LL_REFLECTION_PROBE_COUNT; --i) + { + if (mProbes[i]->mCubeIndex != -1) + { + S32 ret = mProbes[i]->mCubeIndex; + mProbes[i]->mCubeIndex = -1; + return ret; + } + } + + llassert(false); // should never fail to allocate, something is probably wrong with mCubeFree + return -1; +} + +void LLReflectionMapManager::deleteProbe(U32 i) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + LLReflectionMap* probe = mProbes[i]; + + if (probe->mCubeIndex != -1) + { // mark the cube index used by this probe as being free + mCubeFree[probe->mCubeIndex] = true; + } + if (mUpdatingProbe == probe) + { + mUpdatingProbe = nullptr; + mUpdatingFace = 0; + } + + // remove from any Neighbors lists + for (auto& other : probe->mNeighbors) + { + auto& iter = std::find(other->mNeighbors.begin(), other->mNeighbors.end(), probe); + llassert(iter != other->mNeighbors.end()); + other->mNeighbors.erase(iter); + } + + mProbes.erase(mProbes.begin() + i); +} + + +void LLReflectionMapManager::doProbeUpdate() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + llassert(mUpdatingProbe != nullptr); + + mRenderTarget.bindTarget(); + mUpdatingProbe->update(mRenderTarget.getWidth(), mUpdatingFace); + mRenderTarget.flush(); + + // generate mipmaps { - maps[i] = &(mProbes[i]); + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + LLGLDisable cull(GL_CULL_FACE); + + gReflectionMipProgram.bind(); + gGL.matrixMode(gGL.MM_MODELVIEW); + gGL.pushMatrix(); + gGL.loadIdentity(); + + gGL.matrixMode(gGL.MM_PROJECTION); + gGL.pushMatrix(); + gGL.loadIdentity(); + + gGL.flush(); + U32 res = LL_REFLECTION_PROBE_RESOLUTION*4; + + S32 mips = log2((F32) LL_REFLECTION_PROBE_RESOLUTION)+0.5f; + + for (int i = 0; i < mMipChain.size(); ++i) + { + mMipChain[i].bindTarget(); + + if (i == 0) + { + gGL.getTexUnit(0)->bind(&mRenderTarget); + } + else + { + gGL.getTexUnit(0)->bind(&(mMipChain[i - 1])); + } + + gGL.begin(gGL.QUADS); + + gGL.texCoord2f(0, 0); + gGL.vertex2f(-1, -1); + + gGL.texCoord2f(res, 0); + gGL.vertex2f(1, -1); + + gGL.texCoord2f(res, res); + gGL.vertex2f(1, 1); + + gGL.texCoord2f(0, res); + gGL.vertex2f(-1, 1); + gGL.end(); + gGL.flush(); + + res /= 2; + + S32 mip = i - (mMipChain.size() - mips); + + if (mip >= 0) + { + mTexture->bind(0); + glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mip, 0, 0, mUpdatingProbe->mCubeIndex * 6 + mUpdatingFace, 0, 0, res, res); + mTexture->unbind(); + } + mMipChain[i].flush(); + } + + gGL.popMatrix(); + gGL.matrixMode(gGL.MM_MODELVIEW); + gGL.popMatrix(); + + gReflectionMipProgram.unbind(); + } + + if (++mUpdatingFace == 6) + { + updateNeighbors(mUpdatingProbe); + mUpdatingProbe = nullptr; + mUpdatingFace = 0; + } +} + +void LLReflectionMapManager::rebuild() +{ + for (auto& probe : mProbes) + { + probe->mLastUpdateTime = 0.f; } +} - for (++i; i < maps.size(); ++i) +void LLReflectionMapManager::shift(const LLVector4a& offset) +{ + for (auto& probe : mProbes) { - maps[i] = nullptr; + probe->mOrigin.add(offset); } } +void LLReflectionMapManager::updateNeighbors(LLReflectionMap* probe) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + + //remove from existing neighbors + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmun - clear"); + + for (auto& other : probe->mNeighbors) + { + auto& iter = std::find(other->mNeighbors.begin(), other->mNeighbors.end(), probe); + llassert(iter != other->mNeighbors.end()); // <--- bug davep if this ever happens, something broke badly + other->mNeighbors.erase(iter); + } + + probe->mNeighbors.clear(); + } + + // search for new neighbors + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmun - search"); + for (auto& other : mProbes) + { + if (other != probe) + { + if (probe->intersects(other)) + { + probe->mNeighbors.push_back(other); + other->mNeighbors.push_back(probe); + } + } + } + } +} + +void LLReflectionMapManager::setUniforms() +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + + // structure for packing uniform buffer object + // see class2/deferred/softenLightF.glsl + struct ReflectionProbeData + { + LLVector4 refSphere[LL_REFLECTION_PROBE_COUNT]; //origin and radius of refmaps in clip space + GLint refIndex[LL_REFLECTION_PROBE_COUNT][4]; + GLint refNeighbor[4096]; + GLint refmapCount; + }; + + mReflectionMaps.resize(LL_REFLECTION_PROBE_COUNT); + getReflectionMaps(mReflectionMaps); + + ReflectionProbeData rpd; + + // load modelview matrix into matrix 4a + LLMatrix4a modelview; + modelview.loadu(gGLModelView); + LLVector4a oa; // scratch space for transformed origin + + S32 count = 0; + U32 nc = 0; // neighbor "cursor" - index into refNeighbor to start writing the next probe's list of neighbors + + for (auto* refmap : mReflectionMaps) + { + if (refmap == nullptr) + { + break; + } + + llassert(refmap->mProbeIndex == count); + llassert(mReflectionMaps[refmap->mProbeIndex] == refmap); + + llassert(refmap->mCubeIndex >= 0); // should always be true, if not, getReflectionMaps is bugged + + { + //LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmsu - refSphere"); + + modelview.affineTransform(refmap->mOrigin, oa); + rpd.refSphere[count].set(oa.getF32ptr()); + rpd.refSphere[count].mV[3] = refmap->mRadius; + } + + rpd.refIndex[count][0] = refmap->mCubeIndex; + llassert(nc % 4 == 0); + rpd.refIndex[count][1] = nc / 4; + + S32 ni = nc; // neighbor ("index") - index into refNeighbor to write indices for current reflection probe's neighbors + { + //LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmsu - refNeighbors"); + //pack neghbor list + for (auto& neighbor : refmap->mNeighbors) + { + if (ni >= 4096) + { // out of space + break; + } + + GLint idx = neighbor->mProbeIndex; + if (idx == -1) + { + continue; + } + + // this neighbor may be sampled + rpd.refNeighbor[ni++] = idx; + } + } + + if (nc == ni) + { + //no neighbors, tag as empty + rpd.refIndex[count][1] = -1; + } + else + { + rpd.refIndex[count][2] = ni - nc; + + // move the cursor forward + nc = ni; + if (nc % 4 != 0) + { // jump to next power of 4 for compatibility with ivec4 + nc += 4 - (nc % 4); + } + } + + + count++; + } + + rpd.refmapCount = count; + + //copy rpd into uniform buffer object + if (mUBO == 0) + { + glGenBuffersARB(1, &mUBO); + } + + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmsu - update buffer"); + glBindBufferARB(GL_UNIFORM_BUFFER, mUBO); + glBufferDataARB(GL_UNIFORM_BUFFER, sizeof(ReflectionProbeData), &rpd, GL_STREAM_DRAW); + glBindBufferARB(GL_UNIFORM_BUFFER, 0); + } + + glBindBufferBase(GL_UNIFORM_BUFFER, 1, mUBO); +} diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index 40e925d916..24ac40b264 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -27,9 +27,20 @@ #pragma once #include "llreflectionmap.h" +#include "llrendertarget.h" +#include "llcubemaparray.h" -class LLReflectionMapManager +class LLSpatialGroup; + +// number of reflection probes to keep in vram +#define LL_REFLECTION_PROBE_COUNT 256 + +// reflection probe resolution +#define LL_REFLECTION_PROBE_RESOLUTION 256 + +class alignas(16) LLReflectionMapManager { + LL_ALIGN_NEW public: // allocate an environment map of the given resolution LLReflectionMapManager(); @@ -40,12 +51,74 @@ public: // drop a reflection probe at the specified position in agent space void addProbe(const LLVector3& pos); + // add a probe for the given spatial group + LLReflectionMap* addProbe(LLSpatialGroup* group); + // Populate "maps" with the N most relevant Reflection Maps where N is no more than maps.size() // If less than maps.size() ReflectionMaps are available, will assign trailing elements to nullptr. // maps -- presized array of Reflection Map pointers void getReflectionMaps(std::vector& maps); + // called by LLSpatialGroup constructor + // If spatial group should receive a Reflection Probe, will create one for the specified spatial group + LLReflectionMap* registerSpatialGroup(LLSpatialGroup* group); + + // force an update of all probes + void rebuild(); + + // called on region crossing to "shift" probes into new coordinate frame + void shift(const LLVector4a& offset); + +private: + friend class LLPipeline; + + // delete the probe with the given index in mProbes + void deleteProbe(U32 i); + + // get a free cube index + // if no cube indices are free, free one starting from the back of the probe list + S32 allocateCubeIndex(); + + // update the neighbors of the given probe + void updateNeighbors(LLReflectionMap* probe); + + void setUniforms(); + + // render target for cube snapshots + // used to generate mipmaps without doing a copy-to-texture + LLRenderTarget mRenderTarget; + + std::vector mMipChain; + + // storage for reflection probes + LLPointer mTexture; + + // array indicating if a particular cubemap is free + bool mCubeFree[LL_REFLECTION_PROBE_COUNT]; + + // start tracking the given spatial group + void trackGroup(LLSpatialGroup* group); + + // perform an update on the currently updating Probe + void doProbeUpdate(); + // list of active reflection maps - std::vector mProbes; + std::vector > mProbes; + + // list of reflection maps to kill + std::vector > mKillList; + + // list of reflection maps to create + std::vector > mCreateList; + + // handle to UBO + U32 mUBO = 0; + + // list of maps being used for rendering + std::vector mReflectionMaps; + + LLReflectionMap* mUpdatingProbe = nullptr; + U32 mUpdatingFace = 0; + }; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 5c648c11e1..5909cd1f4c 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -554,9 +554,12 @@ LLSpatialGroup::LLSpatialGroup(OctreeNode* node, LLSpatialPartition* part) : LLO sg_assert(mOctreeNode->getListenerCount() == 0); setState(SG_INITIAL_STATE_MASK); gPipeline.markRebuild(this, TRUE); + + // let the reflection map manager know about this spatial group + mReflectionProbe = gPipeline.mReflectionMapManager.registerSpatialGroup(this); - mRadius = 1; - mPixelArea = 1024.f; + mRadius = 1; + mPixelArea = 1024.f; } void LLSpatialGroup::updateDistance(LLCamera &camera) @@ -735,8 +738,17 @@ BOOL LLSpatialGroup::changeLOD() return FALSE; } +void LLSpatialGroup::dirtyReflectionProbe() +{ + if (mReflectionProbe != nullptr) + { + mReflectionProbe->dirty(); + } +} + void LLSpatialGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* entry) { + dirtyReflectionProbe(); addObject((LLDrawable*)entry->getDrawable()); unbound(); setState(OBJECT_DIRTY); @@ -744,6 +756,7 @@ void LLSpatialGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* void LLSpatialGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* entry) { + dirtyReflectionProbe(); removeObject((LLDrawable*)entry->getDrawable(), TRUE); LLViewerOctreeGroup::handleRemoval(node, entry); } @@ -780,6 +793,8 @@ void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c { LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL + dirtyReflectionProbe(); + if (child->getListenerCount() == 0) { new LLSpatialGroup(child, getSpatialPartition()); @@ -794,6 +809,11 @@ void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c assert_states_valid(this); } +void LLSpatialGroup::handleChildRemoval(const oct_node* parent, const oct_node* child) +{ + dirtyReflectionProbe(); +} + void LLSpatialGroup::destroyGL(bool keep_occlusion) { setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::IMAGE_DIRTY); @@ -1398,7 +1418,9 @@ S32 LLSpatialPartition::cull(LLCamera &camera, std::vector* result return 0; } - + +extern BOOL gCubeSnapshot; + S32 LLSpatialPartition::cull(LLCamera &camera, bool do_occlusion) { LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL; @@ -1417,7 +1439,7 @@ S32 LLSpatialPartition::cull(LLCamera &camera, bool do_occlusion) LLOctreeCullShadow culler(&camera); culler.traverse(mOctree); } - else if (mInfiniteFarClip || !LLPipeline::sUseFarClip) + else if (mInfiniteFarClip || (!LLPipeline::sUseFarClip && !gCubeSnapshot)) { LLOctreeCullNoFarClip culler(&camera); culler.traverse(mOctree); @@ -1737,12 +1759,71 @@ void renderOctree(LLSpatialGroup* group) } }*/ } - + // LLSpatialGroup::OctreeNode* node = group->mOctreeNode; // gGL.diffuseColor4f(0,1,0,1); // drawBoxOutline(LLVector3(node->getCenter()), LLVector3(node->getSize())); } +void renderReflectionProbes(LLSpatialGroup* group) +{ + if (group->mReflectionProbe) + { // draw lines from corners of object aabb to reflection probe + + const LLVector4a* bounds = group->getBounds(); + LLVector4a o = bounds[0]; + + gGL.flush(); + gGL.diffuseColor4f(0, 0, 1, 1); + F32* c = o.getF32ptr(); + + const F32* bc = bounds[0].getF32ptr(); + const F32* bs = bounds[1].getF32ptr(); + + // daaw blue lines from corners to center of node + gGL.begin(gGL.LINES); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] + bs[1], bc[2] + bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] + bs[1], bc[2] + bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] - bs[1], bc[2] + bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] - bs[1], bc[2] + bs[2]); + + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] + bs[1], bc[2] - bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] + bs[1], bc[2] - bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] - bs[1], bc[2] - bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] - bs[1], bc[2] - bs[2]); + gGL.end(); + + F32* po = group->mReflectionProbe->mOrigin.getF32ptr(); + //draw yellow line from center of node to reflection probe origin + gGL.flush(); + gGL.diffuseColor4f(1, 1, 0, 1); + gGL.begin(gGL.LINES); + gGL.vertex3fv(c); + gGL.vertex3fv(po); + gGL.end(); + gGL.flush(); + + //draw orange line from probe to neighbors + gGL.flush(); + gGL.diffuseColor4f(1, 0.5f, 0, 1); + gGL.begin(gGL.LINES); + for (auto& probe : group->mReflectionProbe->mNeighbors) + { + gGL.vertex3fv(po); + gGL.vertex3fv(probe->mOrigin.getF32ptr()); + } + gGL.end(); + gGL.flush(); + } +} std::set visible_selected_groups; void renderVisibility(LLSpatialGroup* group, LLCamera* camera) @@ -3289,6 +3370,12 @@ public: stop_glerror(); } + //draw reflection probes and links between them + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_REFLECTION_PROBES)) + { + renderReflectionProbes(group); + } + //render visibility wireframe if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION)) { @@ -3703,7 +3790,8 @@ void LLSpatialPartition::renderDebug() //LLPipeline::RENDER_DEBUG_BUILD_QUEUE | LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA | LLPipeline::RENDER_DEBUG_RENDER_COMPLEXITY | - LLPipeline::RENDER_DEBUG_TEXEL_DENSITY)) + LLPipeline::RENDER_DEBUG_TEXEL_DENSITY | + LLPipeline::RENDER_DEBUG_REFLECTION_PROBES)) { return; } @@ -3947,6 +4035,23 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, co return drawable; } +LLDrawable* LLSpatialGroup::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, + BOOL pick_transparent, + BOOL pick_rigged, + S32* face_hit, // return the face hit + LLVector4a* intersection, // return the intersection point + LLVector2* tex_coord, // return the texture coordinates of the intersection point + LLVector4a* normal, // return the surface normal at the intersection point + LLVector4a* tangent // return the surface tangent at the intersection point +) + +{ + LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, face_hit, intersection, tex_coord, normal, tangent); + LLDrawable* drawable = intersect.check(getOctreeNode()); + + return drawable; +} + LLDrawInfo::LLDrawInfo(U16 start, U16 end, U32 count, U32 offset, LLViewerTexture* texture, LLVertexBuffer* buffer, bool selected, diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index acfcd63686..a30660b2de 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -53,6 +53,7 @@ class LLSpatialPartition; class LLSpatialBridge; class LLSpatialGroup; class LLViewerRegion; +class LLReflectionMap; void pushVerts(LLFace* face, U32 mask); @@ -300,6 +301,17 @@ public: void drawObjectBox(LLColor4 col); + LLDrawable* lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, + BOOL pick_transparent, + BOOL pick_rigged, + S32* face_hit, // return the face hit + LLVector4a* intersection = NULL, // return the intersection point + LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point + LLVector4a* normal = NULL, // return the surface normal at the intersection point + LLVector4a* tangent = NULL // return the surface tangent at the intersection point + ); + + LLSpatialPartition* getSpatialPartition() {return (LLSpatialPartition*)mSpatialPartition;} //LISTENER FUNCTIONS @@ -307,6 +319,7 @@ public: virtual void handleRemoval(const TreeNode* node, LLViewerOctreeEntry* face); virtual void handleDestruction(const TreeNode* node); virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child); + virtual void handleChildRemoval(const oct_node* parent, const oct_node* child); public: LL_ALIGN_16(LLVector4a mViewAngle); @@ -314,6 +327,8 @@ public: F32 mObjectBoxSize; //cached mObjectBounds[1].getLength3() + void dirtyReflectionProbe(); + protected: virtual ~LLSpatialGroup(); @@ -338,6 +353,10 @@ public: F32 mPixelArea; F32 mRadius; + + // Reflection Probe associated with this node (if any) + LLPointer mReflectionProbe = nullptr; + } LL_ALIGN_POSTFIX(64); class LLGeometryManager diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 6a2b06d9b5..f375852dfe 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -97,6 +97,7 @@ BOOL gResizeScreenTexture = FALSE; BOOL gResizeShadowTexture = FALSE; BOOL gWindowResized = FALSE; BOOL gSnapshot = FALSE; +BOOL gCubeSnapshot = FALSE; BOOL gShaderProfileFrame = FALSE; // This is how long the sim will try to teleport you before giving up. @@ -193,15 +194,23 @@ void display_update_camera() // Cut draw distance in half when customizing avatar, // but on the viewer only. F32 final_far = gAgentCamera.mDrawDistance; - if (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode()) + if (gCubeSnapshot) + { + final_far = gSavedSettings.getF32("RenderReflectionProbeDrawDistance"); + } + else if (CAMERA_MODE_CUSTOMIZE_AVATAR == gAgentCamera.getCameraMode()) + { final_far *= 0.5f; } LLViewerCamera::getInstance()->setFar(final_far); gViewerWindow->setup3DRender(); - // Update land visibility too - LLWorld::getInstance()->setLandFarClip(final_far); + if (!gCubeSnapshot) + { + // Update land visibility too + LLWorld::getInstance()->setLandFarClip(final_far); + } } // Write some stats to LL_INFOS() @@ -1048,6 +1057,112 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) } } +// WIP simplified copy of display() that does minimal work +void display_cube_face() +{ + LL_RECORD_BLOCK_TIME(FTM_RENDER); + llassert(!gSnapshot); + llassert(!gTeleportDisplay); + llassert(LLPipeline::sRenderDeferred); + llassert(LLStartUp::getStartupState() >= STATE_PRECACHE); + llassert(!LLAppViewer::instance()->logoutRequestSent()); + llassert(!gRestoreGL); + llassert(!gUseWireframe); + + bool rebuild = false; + + LLGLSDefault gls_default; + LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE, GL_LEQUAL); + + LLVertexBuffer::unbind(); + + gPipeline.disableLights(); + + gPipeline.mBackfaceCull = TRUE; + + LLViewerCamera::getInstance()->setNear(MIN_NEAR_PLANE); + gViewerWindow->setup3DViewport(); + + if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) + { //don't draw hud objects in this frame + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); + } + + if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD_PARTICLES)) + { //don't draw hud particles in this frame + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD_PARTICLES); + } + + display_update_camera(); + + LLSpatialGroup::sNoDelete = TRUE; + + S32 occlusion = LLPipeline::sUseOcclusion; + LLPipeline::sUseOcclusion = 0; // occlusion data is from main camera point of view, don't read or write it during cube snapshots + //gDepthDirty = TRUE; //let "real" render pipe know it can't trust the depth buffer for occlusion data + + static LLCullResult result; + LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; + LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater(); + gPipeline.updateCull(*LLViewerCamera::getInstance(), result); + + gGL.setColorMask(true, true); + glClearColor(0, 0, 0, 0); + gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); + + glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + { + LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; + gPipeline.stateSort(*LLViewerCamera::getInstance(), result); + + if (rebuild) + { + ////////////////////////////////////// + // + // rebuildPools + // + // + gPipeline.rebuildPools(); + stop_glerror(); + } + } + + LLPipeline::sUseOcclusion = occlusion; + + LLAppViewer::instance()->pingMainloopTimeout("Display:RenderStart"); + + LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; + + gGL.setColorMask(true, true); + + gPipeline.mDeferredScreen.bindTarget(); + glClearColor(1, 0, 1, 1); + gPipeline.mDeferredScreen.clear(); + + gGL.setColorMask(true, false); + + LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; + + gPipeline.renderGeomDeferred(*LLViewerCamera::getInstance()); + + gGL.setColorMask(true, true); + + gPipeline.mDeferredScreen.flush(); + + gPipeline.renderDeferredLighting(&gPipeline.mScreen); + + LLPipeline::sUnderWaterRender = FALSE; + + // Finalize scene + gPipeline.renderFinalize(); + + LLSpatialGroup::sNoDelete = FALSE; + gPipeline.clearReferences(); + + gPipeline.rebuildGroups(); +} + void render_hud_attachments() { gGL.matrixMode(LLRender::MM_PROJECTION); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index f5ea060e82..8732bde35c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -1081,6 +1081,10 @@ U64 info_display_from_string(std::string info_display) { return LLPipeline::RENDER_DEBUG_IMPOSTORS; } + else if ("reflection probes" == info_display) + { + return LLPipeline::RENDER_DEBUG_REFLECTION_PROBES; + } else { LL_WARNS() << "unrecognized feature name '" << info_display << "'" << LL_ENDL; @@ -8304,9 +8308,9 @@ void handle_cache_clear_immediately() LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache_immediately); } -void handle_override_environment_map() +void handle_rebuild_reflection_probes() { - gPipeline.overrideEnvironmentMap(); + gPipeline.mReflectionMapManager.rebuild(); } @@ -9409,7 +9413,7 @@ void initialize_menus() //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)); + commit.add("Develop.RebuildReflectionProbes", boost::bind(&handle_rebuild_reflection_probes)); // Admin >Object view_listener_t::addMenu(new LLAdminForceTakeCopy(), "Admin.ForceTakeCopy"); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 50a0ff07fc..94af320a73 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -82,6 +82,7 @@ LLGLSLShader gOcclusionCubeProgram; LLGLSLShader gCustomAlphaProgram; LLGLSLShader gGlowCombineProgram; LLGLSLShader gSplatTextureRectProgram; +LLGLSLShader gReflectionMipProgram; LLGLSLShader gGlowCombineFXAAProgram; LLGLSLShader gTwoTextureAddProgram; LLGLSLShader gTwoTextureCompareProgram; @@ -635,7 +636,6 @@ void LLViewerShaderMgr::setShaders() } if (loaded) - { loaded = loadTransformShaders(); if (loaded) @@ -746,6 +746,7 @@ void LLViewerShaderMgr::unloadShaders() gCustomAlphaProgram.unload(); gGlowCombineProgram.unload(); gSplatTextureRectProgram.unload(); + gReflectionMipProgram.unload(); gGlowCombineFXAAProgram.unload(); gTwoTextureAddProgram.unload(); gTwoTextureCompareProgram.unload(); @@ -3587,7 +3588,6 @@ BOOL LLViewerShaderMgr::loadShadersInterface() } } - if (success) { gTwoTextureAddProgram.mName = "Two Texture Add Shader"; @@ -3763,6 +3763,22 @@ BOOL LLViewerShaderMgr::loadShadersInterface() success = gAlphaMaskProgram.createShader(NULL, NULL); } + if (success) + { + gReflectionMipProgram.mName = "Reflection Mip Shader"; + gReflectionMipProgram.mShaderFiles.clear(); + gReflectionMipProgram.mShaderFiles.push_back(make_pair("interface/splattexturerectV.glsl", GL_VERTEX_SHADER_ARB)); + gReflectionMipProgram.mShaderFiles.push_back(make_pair("interface/reflectionmipF.glsl", GL_FRAGMENT_SHADER_ARB)); + gReflectionMipProgram.mShaderLevel = mShaderLevel[SHADER_INTERFACE]; + success = gReflectionMipProgram.createShader(NULL, NULL); + if (success) + { + gReflectionMipProgram.bind(); + gReflectionMipProgram.uniform1i(sScreenMap, 0); + gReflectionMipProgram.unbind(); + } + } + if( !success ) { mShaderLevel[SHADER_INTERFACE] = 0; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 50a3daebaa..f0187db302 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -161,6 +161,7 @@ extern LLGLSLShader gOcclusionCubeProgram; extern LLGLSLShader gCustomAlphaProgram; extern LLGLSLShader gGlowCombineProgram; extern LLGLSLShader gSplatTextureRectProgram; +extern LLGLSLShader gReflectionMipProgram; extern LLGLSLShader gGlowCombineFXAAProgram; extern LLGLSLShader gDebugProgram; extern LLGLSLShader gClipProgram; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index f562a9458b..9bda4bbf92 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -228,6 +228,7 @@ extern BOOL gDebugClicks; extern BOOL gDisplaySwapBuffers; extern BOOL gDepthDirty; extern BOOL gResizeScreenTexture; +extern BOOL gCubeSnapshot; LLViewerWindow *gViewerWindow = NULL; @@ -5267,29 +5268,30 @@ BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_ return true; } -BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap) +void display_cube_face(); + +BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face) { // NOTE: implementation derived from LLFloater360Capture::capture360Images() and simpleSnapshot LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; llassert(LLPipeline::sRenderDeferred); + llassert(!gCubeSnapshot); //assert a snapshot isn't already in progress - U32 res = cubemap->getResolution(); + U32 res = LLRenderTarget::sCurResX; llassert(res <= gPipeline.mDeferredScreen.getWidth()); llassert(res <= gPipeline.mDeferredScreen.getHeight()); - - // 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(); + + LLViewerCamera saved_camera = LLViewerCamera::instance(); + glh::matrix4f saved_proj = get_current_projection(); + glh::matrix4f saved_mod = get_current_modelview(); // 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 @@ -5297,8 +5299,6 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap) camera->yaw(0.0); camera->setOrigin(origin); - gDisplaySwapBuffers = FALSE; - glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); BOOL prev_draw_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI) ? TRUE : FALSE; @@ -5306,55 +5306,38 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap) { LLPipeline::toggleRenderDebugFeature(LLPipeline::RENDER_DEBUG_FEATURE_UI); } - - LLPipeline::sShowHUDAttachments = FALSE; - LLRect window_rect = getWorldViewRectRaw(); - - LLRenderTarget scratch_space; // TODO: hold onto "scratch space" render target and allocate oncer per session (allocate takes > 1ms) - U32 color_fmt = GL_RGBA; - const bool use_depth_buffer = true; - const bool use_stencil_buffer = true; - if (scratch_space.allocate(res, res, color_fmt, use_depth_buffer, use_stencil_buffer)) - { - mWorldViewRectRaw.set(0, res, res, 0); - scratch_space.bindTarget(); - } - else + BOOL prev_draw_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES); + if (prev_draw_particles) { - return FALSE; + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES); } + LLPipeline::sShowHUDAttachments = FALSE; + LLRect window_rect = getWorldViewRectRaw(); - // "target" parameter of glCopyTexImage2D for each side of cubemap - U32 targets[6] = { - GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB, - GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB, - GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB, - GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB, - GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB - }; + mWorldViewRectRaw.set(0, res, res, 0); - // these are the 6 directions we will point the camera, see LLCubeMap::mTargets + // these are the 6 directions we will point the camera, see LLCubeMapArray::sTargets LLVector3 look_dirs[6] = { - LLVector3(-1, 0, 0), LLVector3(1, 0, 0), - LLVector3(0, -1, 0), + LLVector3(-1, 0, 0), LLVector3(0, 1, 0), - LLVector3(0, 0, -1), - LLVector3(0, 0, 1) + 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, 0, -1), LLVector3(0, -1, 0), LLVector3(0, -1, 0) }; // for each of six sides of cubemap - for (int i = 0; i < 6; ++i) + //for (int i = 0; i < 6; ++i) + int i = face; { // set up camera to look in each direction camera->lookDir(look_dirs[i], look_upvecs[i]); @@ -5368,22 +5351,12 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap) gDisplaySwapBuffers = FALSE; // actually render the scene - const U32 subfield = 0; - const bool do_rebuild = true; - const F32 zoom = 1.0; - const bool for_snapshot = TRUE; - display(do_rebuild, zoom, subfield, for_snapshot); - - // copy results to cube map face - cubemap->enable(0); - cubemap->bind(); - glCopyTexImage2D(targets[i], 0, GL_RGB, 0, 0, res, res, 0); - gGL.getTexUnit(0)->disable(); - cubemap->disable(); + gCubeSnapshot = TRUE; + display_cube_face(); + gCubeSnapshot = FALSE; } - gDisplaySwapBuffers = FALSE; - gDepthDirty = TRUE; + gDisplaySwapBuffers = TRUE; if (!gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI)) { @@ -5393,23 +5366,23 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap) } } + if (prev_draw_particles) + { + gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES); + } + LLPipeline::sShowHUDAttachments = TRUE; gPipeline.resetDrawOrders(); mWorldViewRectRaw = window_rect; - scratch_space.flush(); - scratch_space.release(); // restore original view/camera/avatar settings settings - camera->setAspect(old_aspect); - camera->setView(old_fov); - camera->yaw(old_yaw); - camera->setOrigin(old_origin); - + *camera = saved_camera; + set_current_modelview(saved_mod); + set_current_projection(saved_proj); LLPipeline::sUseOcclusion = old_occlusion; // ==================================================== - return true; } diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index be4e9a17a5..ac7f8b2e39 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -69,6 +69,7 @@ class LLViewerWindowListener; class LLVOPartGroup; class LLPopupView; class LLCubeMap; +class LLCubeMapArray; #define PICK_HALF_WIDTH 5 #define PICK_DIAMETER (2 * PICK_HALF_WIDTH + 1) @@ -365,8 +366,9 @@ public: // take a cubemap snapshot // origin - vantage point to take the snapshot from - // cubemap - cubemap to store the results - BOOL cubeSnapshot(const LLVector3& origin, LLCubeMap* cubemap); + // cubearray - cubemap array for storing the results + // index - cube index in the array to use (cube index, not face-layer) + BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face); // special implementation of simpleSnapshot for reflection maps diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 17d92fda38..ef6ee4b910 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -106,6 +106,7 @@ LLPointer LLVOVolume::sObjectMediaClient = NULL; LLPointer LLVOVolume::sObjectMediaNavigateClient = NULL; extern BOOL gGLDebugLoggingEnabled; +extern BOOL gCubeSnapshot; // Implementation class of LLMediaDataClientObject. See llmediadataclient.h class LLMediaDataClientObjectImpl : public LLMediaDataClientObject @@ -718,7 +719,7 @@ void LLVOVolume::updateTextureVirtualSize(bool forced) LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; // Update the pixel area of all faces - if (mDrawable.isNull()) + if (mDrawable.isNull() || gCubeSnapshot) { return; } @@ -3388,6 +3389,11 @@ F32 LLVOVolume::getSpotLightPriority() const void LLVOVolume::updateSpotLightPriority() { + if (gCubeSnapshot) + { + return; + } + F32 r = getLightRadius(); LLVector3 pos = mDrawable->getPositionAgent(); @@ -5497,6 +5503,8 @@ static inline void add_face(T*** list, U32* count, T* face) void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; + llassert(!gCubeSnapshot); + if (group->changeLOD()) { group->mLastUpdateDistance = group->mDistance; diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 8abb49fba8..8837038d02 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -820,7 +820,7 @@ void LLWorld::updateNetStats() void LLWorld::printPacketsLost() { - LL_INFOS() << "Simulators:" << LL_ENDL; + LL_INFOS() << "Simulators:" << LL_ENDL; LL_INFOS() << "----------" << LL_ENDL; LLCircuitData *cdp = NULL; @@ -855,6 +855,7 @@ F32 LLWorld::getLandFarClip() const void LLWorld::setLandFarClip(const F32 far_clip) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_ENVIRONMENT; static S32 const rwidth = (S32)REGION_WIDTH_U32; S32 const n1 = (llceil(mLandFarClip) - 1) / rwidth; S32 const n2 = (llceil(far_clip) - 1) / rwidth; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index ef616f5d83..5eb9817fc4 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -227,6 +227,7 @@ extern S32 gBoxFrame; //extern BOOL gHideSelectedObjects; extern BOOL gDisplaySwapBuffers; extern BOOL gDebugGL; +extern BOOL gCubeSnapshot; bool gAvatarBacklight = false; @@ -2006,6 +2007,7 @@ void LLPipeline::updateMove() //static F32 LLPipeline::calcPixelArea(LLVector3 center, LLVector3 size, LLCamera &camera) { + llassert(!gCubeSnapshot); // shouldn't be doing ANY of this during cube snap shots LLVector3 lookAt = center - camera.getOrigin(); F32 dist = lookAt.length(); @@ -2475,7 +2477,7 @@ void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera) group->setVisible(); - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { group->updateDistance(camera); } @@ -2581,6 +2583,8 @@ void LLPipeline::downsampleDepthBuffer(LLRenderTarget& source, LLRenderTarget& d void LLPipeline::doOcclusion(LLCamera& camera, LLRenderTarget& source, LLRenderTarget& dest, LLRenderTarget* scratch_space) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + llassert(!gCubeSnapshot); downsampleDepthBuffer(source, dest, scratch_space); dest.bindTarget(); doOcclusion(camera); @@ -2823,7 +2827,7 @@ void LLPipeline::rebuildPriorityGroups() void LLPipeline::rebuildGroups() { - if (mGroupQ2.empty()) + if (mGroupQ2.empty() || gCubeSnapshot) { return; } @@ -2873,6 +2877,10 @@ void LLPipeline::updateGeom(F32 max_dtime) LLPointer drawablep; LL_RECORD_BLOCK_TIME(FTM_GEO_UPDATE); + if (gCubeSnapshot) + { + return; + } assertInitialized(); @@ -3112,6 +3120,8 @@ void LLPipeline::shiftObjects(const LLVector3 &offset) } } + mReflectionMapManager.shift(offseta); + LLHUDText::shiftAll(offset); LLHUDNameTag::shiftAll(offset); @@ -3292,7 +3302,7 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result) } } - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { LLSpatialGroup* last_group = NULL; BOOL fov_changed = LLViewerCamera::getInstance()->isDefaultFOVChanged(); @@ -3374,7 +3384,7 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera) stateSort(drawablep, camera); } - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { //avoid redundant stateSort calls group->mLastUpdateDistance = group->mDistance; } @@ -3443,7 +3453,7 @@ void LLPipeline::stateSort(LLDrawable* drawablep, LLCamera& camera) } } - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { //if (drawablep->isVisible()) isVisible() check here is redundant, if it wasn't visible, it wouldn't be here { @@ -3721,21 +3731,26 @@ void LLPipeline::postSort(LLCamera& camera) assertInitialized(); LL_PUSH_CALLSTACKS(); - //rebuild drawable geometry - for (LLCullResult::sg_iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i) - { - LLSpatialGroup* group = *i; - if (!sUseOcclusion || - !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) - { - group->rebuildGeom(); - } - } - LL_PUSH_CALLSTACKS(); - //rebuild groups - sCull->assertDrawMapsEmpty(); - rebuildPriorityGroups(); + if (!gCubeSnapshot) + { + //rebuild drawable geometry + for (LLCullResult::sg_iterator i = sCull->beginDrawableGroups(); i != sCull->endDrawableGroups(); ++i) + { + LLSpatialGroup* group = *i; + if (!sUseOcclusion || + !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) + { + group->rebuildGeom(); + } + } + LL_PUSH_CALLSTACKS(); + //rebuild groups + sCull->assertDrawMapsEmpty(); + + rebuildPriorityGroups(); + } + LL_PUSH_CALLSTACKS(); @@ -3751,7 +3766,7 @@ void LLPipeline::postSort(LLCamera& camera) continue; } - if (group->hasState(LLSpatialGroup::NEW_DRAWINFO) && group->hasState(LLSpatialGroup::GEOM_DIRTY)) + if (group->hasState(LLSpatialGroup::NEW_DRAWINFO) && group->hasState(LLSpatialGroup::GEOM_DIRTY) && !gCubeSnapshot) { //no way this group is going to be drawable without a rebuild group->rebuildGeom(); } @@ -3769,7 +3784,7 @@ void LLPipeline::postSort(LLCamera& camera) LLDrawInfo* info = *k; sCull->pushDrawInfo(j->first, info); - if (!sShadowRender && !sReflectionRender) + if (!sShadowRender && !sReflectionRender && !gCubeSnapshot) { touchTextures(info); addTrianglesDrawn(info->mCount, info->mDrawMode); @@ -3784,7 +3799,7 @@ void LLPipeline::postSort(LLCamera& camera) if (alpha != group->mDrawMap.end()) { //store alpha groups for sorting LLSpatialBridge* bridge = group->getSpatialPartition()->asBridge(); - if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD) + if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD && !gCubeSnapshot) { if (bridge) { @@ -4411,7 +4426,7 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) gGL.loadMatrix(gGLModelView); if (occlude) - { + { // catch uncommon condition where pools at drawpool grass and later are disabled occlude = false; gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); @@ -4607,6 +4622,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) if (occlude && cur_type >= LLDrawPool::POOL_GRASS) { + llassert(!gCubeSnapshot); // never do occlusion culling on cube snapshots occlude = false; gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); @@ -5925,6 +5941,7 @@ void LLPipeline::setupAvatarLights(bool for_edit) static F32 calc_light_dist(LLVOVolume* light, const LLVector3& cam_pos, F32 max_dist) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; F32 inten = light->getLightIntensity(); if (inten < .001f) { @@ -5948,9 +5965,10 @@ static F32 calc_light_dist(LLVOVolume* light, const LLVector3& cam_pos, F32 max_ void LLPipeline::calcNearbyLights(LLCamera& camera) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; assertInitialized(); - if (LLPipeline::sReflectionRender) + if (LLPipeline::sReflectionRender || gCubeSnapshot) { return; } @@ -6133,6 +6151,7 @@ void LLPipeline::calcNearbyLights(LLCamera& camera) void LLPipeline::setupHWLights(LLDrawPool* pool) { + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; assertInitialized(); LLEnvironment& environment = LLEnvironment::instance(); @@ -7608,7 +7627,8 @@ void LLPipeline::renderFinalize() bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && - RenderDepthOfField; + RenderDepthOfField && + !gCubeSnapshot; bool multisample = RenderFSAASamples > 1 && mFXAABuffer.isComplete(); @@ -8196,45 +8216,13 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ } } - channel = shader.enableTexture(LLShaderMgr::REFLECTION_MAP, LLTexUnit::TT_CUBE_MAP); - if (channel > -1) + channel = shader.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY); + if (channel > -1 && mReflectionMapManager.mTexture.notNull()) { - mReflectionMaps.resize(8); //TODO -- declare the number of reflection maps the shader knows about somewhere sane - mReflectionMapManager.getReflectionMaps(mReflectionMaps); - LLVector3 origin[8]; //origin of refmaps in clip space - - // load modelview matrix into matrix 4a - LLMatrix4a modelview; - modelview.loadu(gGLModelView); - LLVector4a oa; // scratch space for transformed origin - - S32 count = 0; - for (auto* refmap : mReflectionMaps) - { - if (refmap) - { - LLCubeMap* cubemap = refmap->mCubeMap; - if (cubemap) - { - cubemap->enable(channel + count); - cubemap->bind(); - - modelview.affineTransform(refmap->mOrigin, oa); - origin[count].set(oa.getF32ptr()); - - count++; - } - } - } - - if (count > 0) - { - LLStaticHashedString refmapCount("refmapCount"); - LLStaticHashedString refOrigin("refOrigin"); - shader.uniform1i(refmapCount, count); - shader.uniform3fv(refOrigin, count, (F32*)origin); - setup_env_mat = true; - } + // see comments in class2/deferred/softenLightF.glsl for what these uniforms mean + mReflectionMapManager.mTexture->bind(channel); + mReflectionMapManager.setUniforms(); + setup_env_mat = true; } if (setup_env_mat) @@ -8276,7 +8264,14 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ } } - shader.uniform4fv(LLShaderMgr::DEFERRED_SHADOW_CLIP, 1, mSunClipPlanes.mV); + /*if (gCubeSnapshot) + { // we only really care about the first two values, but the shader needs increasing separation between clip planes + shader.uniform4f(LLShaderMgr::DEFERRED_SHADOW_CLIP, 1.f, 64.f, 128.f, 256.f); + } + else*/ + { + shader.uniform4fv(LLShaderMgr::DEFERRED_SHADOW_CLIP, 1, mSunClipPlanes.mV); + } shader.uniform1f(LLShaderMgr::DEFERRED_SUN_WASH, RenderDeferredSunWash); shader.uniform1f(LLShaderMgr::DEFERRED_SHADOW_NOISE, RenderShadowNoise); shader.uniform1f(LLShaderMgr::DEFERRED_BLUR_SIZE, RenderShadowBlurSize); @@ -8469,66 +8464,78 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) } if (RenderDeferredSSAO) - { // soften direct lighting lightmap - LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow"); - // blur lightmap - screen_target->bindTarget(); - glClearColor(1, 1, 1, 1); - screen_target->clear(GL_COLOR_BUFFER_BIT); - glClearColor(0, 0, 0, 0); - - bindDeferredShader(gDeferredBlurLightProgram); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - LLVector3 go = RenderShadowGaussian; - const U32 kern_length = 4; - F32 blur_size = RenderShadowBlurSize; - F32 dist_factor = RenderShadowBlurDistFactor; - - // sample symmetrically with the middle sample falling exactly on 0.0 - F32 x = 0.f; - - LLVector3 gauss[32]; // xweight, yweight, offset - - for (U32 i = 0; i < kern_length; i++) - { - gauss[i].mV[0] = llgaussian(x, go.mV[0]); - gauss[i].mV[1] = llgaussian(x, go.mV[1]); - gauss[i].mV[2] = x; - x += 1.f; + { + /*if (gCubeSnapshot) + { // SSAO and shadows disabled in reflection maps + deferred_light_target->bindTarget(); + glClearColor(1, 1, 1, 1); + deferred_light_target->clear(); + glClearColor(0, 0, 0, 0); + deferred_light_target->flush(); } + else*/ + { + // soften direct lighting lightmap + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow"); + // blur lightmap + screen_target->bindTarget(); + glClearColor(1, 1, 1, 1); + screen_target->clear(GL_COLOR_BUFFER_BIT); + glClearColor(0, 0, 0, 0); - gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f); - gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor); - gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV); - gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length / 2.f - 0.5f)); + bindDeferredShader(gDeferredBlurLightProgram); + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + LLVector3 go = RenderShadowGaussian; + const U32 kern_length = 4; + F32 blur_size = RenderShadowBlurSize; + F32 dist_factor = RenderShadowBlurDistFactor; - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); - } + // sample symmetrically with the middle sample falling exactly on 0.0 + F32 x = 0.f; + + LLVector3 gauss[32]; // xweight, yweight, offset - screen_target->flush(); - unbindDeferredShader(gDeferredBlurLightProgram); + for (U32 i = 0; i < kern_length; i++) + { + gauss[i].mV[0] = llgaussian(x, go.mV[0]); + gauss[i].mV[1] = llgaussian(x, go.mV[1]); + gauss[i].mV[2] = x; + x += 1.f; + } - bindDeferredShader(gDeferredBlurLightProgram, screen_target); + gDeferredBlurLightProgram.uniform2f(sDelta, 1.f, 0.f); + gDeferredBlurLightProgram.uniform1f(sDistFactor, dist_factor); + gDeferredBlurLightProgram.uniform3fv(sKern, kern_length, gauss[0].mV); + gDeferredBlurLightProgram.uniform1f(sKernScale, blur_size * (kern_length / 2.f - 0.5f)); - mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - deferred_light_target->bindTarget(); + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + stop_glerror(); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + stop_glerror(); + } - gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); + screen_target->flush(); + unbindDeferredShader(gDeferredBlurLightProgram); - { - LLGLDisable blend(GL_BLEND); - LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); - stop_glerror(); - mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); - stop_glerror(); + bindDeferredShader(gDeferredBlurLightProgram, screen_target); + + mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); + deferred_light_target->bindTarget(); + + gDeferredBlurLightProgram.uniform2f(sDelta, 0.f, 1.f); + + { + LLGLDisable blend(GL_BLEND); + LLGLDepthTest depth(GL_TRUE, GL_FALSE, GL_ALWAYS); + stop_glerror(); + mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); + stop_glerror(); + } + deferred_light_target->flush(); + unbindDeferredShader(gDeferredBlurLightProgram); } - deferred_light_target->flush(); - unbindDeferredShader(gDeferredBlurLightProgram); } stop_glerror(); @@ -8595,7 +8602,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) gPipeline.popRenderTypeMask(); } - bool render_local = RenderLocalLights; + bool render_local = RenderLocalLights; // && !gCubeSnapshot; if (render_local) { @@ -8604,9 +8611,12 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) LLDrawable::drawable_list_t spot_lights; LLDrawable::drawable_list_t fullscreen_spot_lights; - for (U32 i = 0; i < 2; i++) + if (!gCubeSnapshot) { - mTargetShadowSpotLight[i] = NULL; + for (U32 i = 0; i < 2; i++) + { + mTargetShadowSpotLight[i] = NULL; + } } std::list light_colors; @@ -8942,6 +8952,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) popRenderTypeMask(); } + if (!gCubeSnapshot) { // render highlights, etc. renderHighlights(); @@ -9053,6 +9064,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) shader.uniform1f(LLShaderMgr::PROJECTOR_SHADOW_FADE, 1.f); } + if (!gCubeSnapshot) { LLDrawable* potential = drawablep; //determine if this is a good light for casting shadows @@ -9146,14 +9158,10 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) } } - channel = shader.disableTexture(LLShaderMgr::REFLECTION_MAP, LLTexUnit::TT_CUBE_MAP); - if (channel > -1) + channel = shader.disableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP); + if (channel > -1 && mReflectionMapManager.mTexture.notNull()) { - for (int i = 0; i < mReflectionMaps.size(); ++i) - { - gGL.getTexUnit(channel + i)->disable(); - } - + mReflectionMapManager.mTexture->unbind(); if (channel == 0) { gGL.getTexUnit(channel)->enable(LLTexUnit::TT_TEXTURE); @@ -9176,7 +9184,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - if (!assertInitialized()) + if (!assertInitialized() || gCubeSnapshot) { return; } @@ -9767,7 +9775,10 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera LLRenderTarget& occlusion_source = mShadow[LLViewerCamera::sCurCameraID - 1]; - doOcclusion(shadow_cam, occlusion_source, occlusion_target); + if (occlude > 1) + { + doOcclusion(shadow_cam, occlusion_source, occlusion_target); + } if (use_shader) { @@ -10163,6 +10174,12 @@ void LLPipeline::generateSunShadow(LLCamera& camera) clip = RenderShadowOrthoClipPlanes; mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]); + //if (gCubeSnapshot) + { //always do a single 64m shadow in reflection maps + mSunClipPlanes.set(64.f, 128.f, 256.f); + mSunOrthoClipPlanes.set(64.f, 128.f, 256.f); + } + //currently used for amount to extrude frusta corners for constructing shadow frusta //LLVector3 n = RenderShadowNearDist; //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; @@ -10279,9 +10296,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) // convenience array of 4 near clip plane distances F32 dist[] = { near_clip, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] }; - if (mSunDiffuse == LLColor4::black) - { //sun diffuse is totally black, shadows don't matter + { //sun diffuse is totally shadows don't matter LLGLDepthTest depth(GL_TRUE); for (S32 j = 0; j < 4; j++) @@ -10293,7 +10309,21 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } else { - for (S32 j = 0; j < 4; j++) + /*if (gCubeSnapshot) + { + // do one shadow split for cube snapshots, clear the rest + mSunClipPlanes.set(64.f, 64.f, 64.f); + dist[1] = dist[2] = dist[3] = dist[4] = 64.f; + for (S32 j = 1; j < 4; j++) + { + mShadow[j].bindTarget(); + mShadow[j].clear(); + mShadow[j].flush(); + } + }*/ + + //for (S32 j = 0; j < (gCubeSnapshot ? 1 : 4); j++) + for (S32 j = 0; j < 4; j++) { if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA)) { @@ -10672,142 +10702,145 @@ void LLPipeline::generateSunShadow(LLCamera& camera) if (gen_shadow) { - LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); - F32 fade_amt = gFrameIntervalSeconds.value() - * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); - - //update shadow targets - for (U32 i = 0; i < 2; i++) - { //for each current shadow - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i); - - if (mShadowSpotLight[i].notNull() && - (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || - mShadowSpotLight[i] == mTargetShadowSpotLight[1])) - { //keep this spotlight - mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f); - } - else - { //fade out this light - mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f); + if (!gCubeSnapshot) //skip updating spot shadow maps during cubemap updates + { + LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); + F32 fade_amt = gFrameIntervalSeconds.value() + * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); + + //update shadow targets + for (U32 i = 0; i < 2; i++) + { //for each current shadow + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i); + + if (mShadowSpotLight[i].notNull() && + (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || + mShadowSpotLight[i] == mTargetShadowSpotLight[1])) + { //keep this spotlight + mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f); + } + else + { //fade out this light + mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f); - if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) - { //faded out, grab one of the pending spots (whichever one isn't already taken) - if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2]) - { - mShadowSpotLight[i] = mTargetShadowSpotLight[0]; - } - else - { - mShadowSpotLight[i] = mTargetShadowSpotLight[1]; - } - } - } - } + if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) + { //faded out, grab one of the pending spots (whichever one isn't already taken) + if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2]) + { + mShadowSpotLight[i] = mTargetShadowSpotLight[0]; + } + else + { + mShadowSpotLight[i] = mTargetShadowSpotLight[1]; + } + } + } + } + + for (S32 i = 0; i < 2; i++) + { + set_current_modelview(saved_view); + set_current_projection(saved_proj); - for (S32 i = 0; i < 2; i++) - { - set_current_modelview(saved_view); - set_current_projection(saved_proj); + if (mShadowSpotLight[i].isNull()) + { + continue; + } - if (mShadowSpotLight[i].isNull()) - { - continue; - } + LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); - LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); + if (!volume) + { + mShadowSpotLight[i] = NULL; + continue; + } - if (!volume) - { - mShadowSpotLight[i] = NULL; - continue; - } + LLDrawable* drawable = mShadowSpotLight[i]; - LLDrawable* drawable = mShadowSpotLight[i]; + LLVector3 params = volume->getSpotLightParams(); + F32 fov = params.mV[0]; - LLVector3 params = volume->getSpotLightParams(); - F32 fov = params.mV[0]; + //get agent->light space matrix (modelview) + LLVector3 center = drawable->getPositionAgent(); + LLQuaternion quat = volume->getRenderRotation(); - //get agent->light space matrix (modelview) - LLVector3 center = drawable->getPositionAgent(); - LLQuaternion quat = volume->getRenderRotation(); + //get near clip plane + LLVector3 scale = volume->getScale(); + LLVector3 at_axis(0, 0, -scale.mV[2] * 0.5f); + at_axis *= quat; - //get near clip plane - LLVector3 scale = volume->getScale(); - LLVector3 at_axis(0,0,-scale.mV[2]*0.5f); - at_axis *= quat; + LLVector3 np = center + at_axis; + at_axis.normVec(); - LLVector3 np = center+at_axis; - at_axis.normVec(); + //get origin that has given fov for plane np, at_axis, and given scale + F32 dist = (scale.mV[1] * 0.5f) / tanf(fov * 0.5f); - //get origin that has given fov for plane np, at_axis, and given scale - F32 dist = (scale.mV[1]*0.5f)/tanf(fov*0.5f); + LLVector3 origin = np - at_axis * dist; - LLVector3 origin = np - at_axis*dist; + LLMatrix4 mat(quat, LLVector4(origin, 1.f)); - LLMatrix4 mat(quat, LLVector4(origin, 1.f)); + view[i + 4] = glh::matrix4f((F32*)mat.mMatrix); - view[i+4] = glh::matrix4f((F32*) mat.mMatrix); + view[i + 4] = view[i + 4].inverse(); - view[i+4] = view[i+4].inverse(); + //get perspective matrix + F32 near_clip = dist + 0.01f; + F32 width = scale.mV[VX]; + F32 height = scale.mV[VY]; + F32 far_clip = dist + volume->getLightRadius() * 1.5f; - //get perspective matrix - F32 near_clip = dist+0.01f; - F32 width = scale.mV[VX]; - F32 height = scale.mV[VY]; - F32 far_clip = dist+volume->getLightRadius()*1.5f; + F32 fovy = fov * RAD_TO_DEG; + F32 aspect = width / height; - F32 fovy = fov * RAD_TO_DEG; - F32 aspect = width/height; - - proj[i+4] = gl_perspective(fovy, aspect, near_clip, far_clip); + proj[i + 4] = gl_perspective(fovy, aspect, near_clip, far_clip); - //translate and scale to from [-1, 1] to [0, 1] - glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, - 0.f, 0.5f, 0.f, 0.5f, - 0.f, 0.f, 0.5f, 0.5f, - 0.f, 0.f, 0.f, 1.f); + //translate and scale to from [-1, 1] to [0, 1] + glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, + 0.f, 0.5f, 0.f, 0.5f, + 0.f, 0.f, 0.5f, 0.5f, + 0.f, 0.f, 0.f, 1.f); - set_current_modelview(view[i+4]); - set_current_projection(proj[i+4]); + set_current_modelview(view[i + 4]); + set_current_projection(proj[i + 4]); - mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view; - - for (U32 j = 0; j < 16; j++) - { - gGLLastModelView[j] = mShadowModelview[i+4].m[j]; - gGLLastProjection[j] = mShadowProjection[i+4].m[j]; - } + mSunShadowMatrix[i + 4] = trans * proj[i + 4] * view[i + 4] * inv_view; - mShadowModelview[i+4] = view[i+4]; - mShadowProjection[i+4] = proj[i+4]; + for (U32 j = 0; j < 16; j++) + { + gGLLastModelView[j] = mShadowModelview[i + 4].m[j]; + gGLLastProjection[j] = mShadowProjection[i + 4].m[j]; + } - LLCamera shadow_cam = camera; - shadow_cam.setFar(far_clip); - shadow_cam.setOrigin(origin); + mShadowModelview[i + 4] = view[i + 4]; + mShadowProjection[i + 4] = proj[i + 4]; - LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); + LLCamera shadow_cam = camera; + shadow_cam.setFar(far_clip); + shadow_cam.setOrigin(origin); - stop_glerror(); + LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); - mShadow[i+4].bindTarget(); - mShadow[i+4].getViewport(gGLViewport); - mShadow[i+4].clear(); + stop_glerror(); + + mShadow[i + 4].bindTarget(); + mShadow[i + 4].getViewport(gGLViewport); + mShadow[i + 4].clear(); - U32 target_width = mShadow[i+4].getWidth(); + U32 target_width = mShadow[i + 4].getWidth(); - static LLCullResult result[2]; + static LLCullResult result[2]; - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4); + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4); - RenderSpotLight = drawable; + RenderSpotLight = drawable; - renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE, target_width); + renderShadow(view[i + 4], proj[i + 4], shadow_cam, result[i], FALSE, FALSE, target_width); - RenderSpotLight = nullptr; + RenderSpotLight = nullptr; - mShadow[i+4].flush(); - } + mShadow[i + 4].flush(); + } + } } else { //no spotlight shadows @@ -11526,7 +11559,7 @@ void LLPipeline::restoreHiddenObject( const LLUUID& id ) void LLPipeline::overrideEnvironmentMap() { - mReflectionMapManager.mProbes.clear(); - mReflectionMapManager.addProbe(LLViewerCamera::instance().getOrigin()); + //mReflectionMapManager.mProbes.clear(); + //mReflectionMapManager.addProbe(LLViewerCamera::instance().getOrigin()); } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 975380929d..88eaca558a 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -578,7 +578,8 @@ public: RENDER_DEBUG_ATTACHMENT_BYTES = 0x20000000, // not used RENDER_DEBUG_TEXEL_DENSITY = 0x40000000, RENDER_DEBUG_TRIANGLE_COUNT = 0x80000000, - RENDER_DEBUG_IMPOSTORS = 0x100000000 + RENDER_DEBUG_IMPOSTORS = 0x100000000, + RENDER_DEBUG_REFLECTION_PROBES = 0x200000000 }; public: diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index db4e794ed4..0b0f8e17bc 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -2911,6 +2911,16 @@ function="World.EnvPreset" function="Advanced.ToggleInfoDisplay" parameter="lights" /> + + + + @@ -3252,10 +3262,10 @@ function="World.EnvPreset" + label="Rebuild Reflection Probes" + name="Rebuild Reflection Probes"> + function="Develop.RebuildReflectionProbes" /> -- cgit v1.3 From 53c692c9597551c9a1ba8eee346432de51d9d22d Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 17 May 2022 14:32:07 -0500 Subject: SL-17416 Quick 'n dirty reflection probe override hack. --- indra/newview/app_settings/settings.xml | 14 ++- .../shaders/class2/deferred/softenLightF.glsl | 4 +- indra/newview/llreflectionmap.cpp | 5 + indra/newview/llreflectionmap.h | 6 ++ indra/newview/llreflectionmapmanager.cpp | 101 +++++++++++++++++++++ indra/newview/llreflectionmapmanager.h | 14 +++ indra/newview/llspatialpartition.cpp | 69 +------------- indra/newview/llviewerobject.cpp | 9 +- indra/newview/llviewerobject.h | 8 +- indra/newview/llvovolume.cpp | 20 +++- indra/newview/pipeline.cpp | 7 +- 11 files changed, 183 insertions(+), 74 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 9f39ea9c8c..aa2f1e9192 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10280,7 +10280,19 @@ Value 64 - RenderReflectionRes + RenderReflectionProbeTextureHackID + + Comment + HACK -- Any object with a diffuse texture with this ID will be treated as a user override reflection probe. (default is "Violet Info Hub" photo from Library) + Persist + 1 + Type + String + Value + 6b186931-05da-eafa-a3ed-a012a33bbfb6 + + + RenderReflectionRes Comment Reflection map resolution. diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 3a1287e910..3607c325a4 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -55,6 +55,7 @@ layout (std140, binding = 1) uniform ReflectionProbes // refIndex.x - cubemap channel in reflectionProbes // refIndex.y - index in refNeighbor of neighbor list (index is ivec4 index, not int index) // refIndex.z - number of neighbors + // refIndex.w - priority ivec4 refIndex[REFMAP_COUNT]; // neighbor list data (refSphere indices, not cubemap array layer) @@ -296,6 +297,7 @@ vec3 sampleRefMap(vec3 pos, vec3 dir, float lod) { int i = probeIndex[idx]; float r = refSphere[i].w; // radius of sphere volume + float p = float(refIndex[i].w); // priority float rr = r*r; // radius squred float r1 = r * 0.1; // 75% of radius (outer sphere to start interpolating down) vec3 delta = pos.xyz-refSphere[i].xyz; @@ -310,7 +312,7 @@ vec3 sampleRefMap(vec3 pos, vec3 dir, float lod) float atten = 1.0-max(d2-r2, 0.0)/(rr-r2); w *= atten; - + w *= p; // boost weight based on priority col += refcol*w; wsum += w; diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 0cf2f22822..c146a888cf 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -194,6 +194,11 @@ void LLReflectionMap::autoAdjustOrigin() } } } + else if (mViewerObject) + { + mOrigin.load3(mViewerObject->getPositionAgent().mV); + mRadius = mViewerObject->getScale().mV[0]; + } } bool LLReflectionMap::intersects(LLReflectionMap* other) diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index ed1c2680b6..305f33af4b 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -30,6 +30,7 @@ #include "llmemory.h" class LLSpatialGroup; +class LLViewerObject; class alignas(16) LLReflectionMap : public LLRefCount { @@ -80,7 +81,12 @@ public: // set of any LLReflectionMaps that intersect this map (maintained by LLReflectionMapManager std::vector mNeighbors; + // spatial group this probe is tracking (if any) LLSpatialGroup* mGroup = nullptr; + + // viewer object this probe is tracking (if any) + LLViewerObject* mViewerObject = nullptr; + bool mDirty = true; }; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index a6b704d57d..53c4857b0f 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -274,6 +274,28 @@ LLReflectionMap* LLReflectionMapManager::registerSpatialGroup(LLSpatialGroup* gr return nullptr; } +LLReflectionMap* LLReflectionMapManager::registerViewerObject(LLViewerObject* vobj) +{ + llassert(vobj != nullptr); + + LLReflectionMap* probe = new LLReflectionMap(); + probe->mViewerObject = vobj; + probe->mOrigin.load3(vobj->getPositionAgent().mV); + probe->mDirty = true; + + if (gCubeSnapshot) + { //snapshot is in progress, mProbes is being iterated over, defer insertion until next update + mCreateList.push_back(probe); + } + else + { + mProbes.push_back(probe); + } + + return probe; +} + + S32 LLReflectionMapManager::allocateCubeIndex() { for (int i = 0; i < LL_REFLECTION_PROBE_COUNT; ++i) @@ -513,6 +535,7 @@ void LLReflectionMapManager::setUniforms() rpd.refIndex[count][0] = refmap->mCubeIndex; llassert(nc % 4 == 0); rpd.refIndex[count][1] = nc / 4; + rpd.refIndex[count][3] = refmap->mViewerObject ? 10 : 1; S32 ni = nc; // neighbor ("index") - index into refNeighbor to write indices for current reflection probe's neighbors { @@ -574,3 +597,81 @@ void LLReflectionMapManager::setUniforms() glBindBufferBase(GL_UNIFORM_BUFFER, 1, mUBO); } + + +void renderReflectionProbe(LLReflectionMap* probe) +{ + + F32* po = probe->mOrigin.getF32ptr(); + + //draw orange line from probe to neighbors + gGL.flush(); + gGL.diffuseColor4f(1, 0.5f, 0, 1); + gGL.begin(gGL.LINES); + for (auto& neighbor : probe->mNeighbors) + { + gGL.vertex3fv(po); + gGL.vertex3fv(neighbor->mOrigin.getF32ptr()); + } + gGL.end(); + gGL.flush(); + +#if 0 + LLSpatialGroup* group = probe->mGroup; + if (group) + { // draw lines from corners of object aabb to reflection probe + + const LLVector4a* bounds = group->getBounds(); + LLVector4a o = bounds[0]; + + gGL.flush(); + gGL.diffuseColor4f(0, 0, 1, 1); + F32* c = o.getF32ptr(); + + const F32* bc = bounds[0].getF32ptr(); + const F32* bs = bounds[1].getF32ptr(); + + // daaw blue lines from corners to center of node + gGL.begin(gGL.LINES); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] + bs[1], bc[2] + bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] + bs[1], bc[2] + bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] - bs[1], bc[2] + bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] - bs[1], bc[2] + bs[2]); + + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] + bs[1], bc[2] - bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] + bs[1], bc[2] - bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] + bs[0], bc[1] - bs[1], bc[2] - bs[2]); + gGL.vertex3fv(c); + gGL.vertex3f(bc[0] - bs[0], bc[1] - bs[1], bc[2] - bs[2]); + gGL.end(); + + //draw yellow line from center of node to reflection probe origin + gGL.flush(); + gGL.diffuseColor4f(1, 1, 0, 1); + gGL.begin(gGL.LINES); + gGL.vertex3fv(c); + gGL.vertex3fv(po); + gGL.end(); + gGL.flush(); + } +#endif +} + +void LLReflectionMapManager::renderDebug() +{ + gDebugProgram.bind(); + + for (auto& probe : mProbes) + { + renderReflectionProbe(probe); + } + + gDebugProgram.unbind(); +} diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index 24ac40b264..f7feabbf66 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -31,6 +31,7 @@ #include "llcubemaparray.h" class LLSpatialGroup; +class LLViewerObject; // number of reflection probes to keep in vram #define LL_REFLECTION_PROBE_COUNT 256 @@ -38,6 +39,9 @@ class LLSpatialGroup; // reflection probe resolution #define LL_REFLECTION_PROBE_RESOLUTION 256 +// reflection probe mininum scale +#define LL_REFLECTION_PROBE_MINIMUM_SCALE 1.f; + class alignas(16) LLReflectionMapManager { LL_ALIGN_NEW @@ -63,12 +67,21 @@ public: // If spatial group should receive a Reflection Probe, will create one for the specified spatial group LLReflectionMap* registerSpatialGroup(LLSpatialGroup* group); + // presently hacked into LLViewerObject::setTE + // Used by LLViewerObjects that are Reflection Probes + // Guaranteed to not return null + LLReflectionMap* registerViewerObject(LLViewerObject* vobj); + // force an update of all probes void rebuild(); // called on region crossing to "shift" probes into new coordinate frame void shift(const LLVector4a& offset); + // debug display, called from llspatialpartition if reflection + // probe debug display is active + void renderDebug(); + private: friend class LLPipeline; @@ -82,6 +95,7 @@ private: // update the neighbors of the given probe void updateNeighbors(LLReflectionMap* probe); + // update UBO used for rendering void setUniforms(); // render target for cube snapshots diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 642b1c964f..b6bd07085b 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -1766,65 +1766,6 @@ void renderOctree(LLSpatialGroup* group) // drawBoxOutline(LLVector3(node->getCenter()), LLVector3(node->getSize())); } -void renderReflectionProbes(LLSpatialGroup* group) -{ - if (group->mReflectionProbe) - { // draw lines from corners of object aabb to reflection probe - - const LLVector4a* bounds = group->getBounds(); - LLVector4a o = bounds[0]; - - gGL.flush(); - gGL.diffuseColor4f(0, 0, 1, 1); - F32* c = o.getF32ptr(); - - const F32* bc = bounds[0].getF32ptr(); - const F32* bs = bounds[1].getF32ptr(); - - // daaw blue lines from corners to center of node - gGL.begin(gGL.LINES); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] + bs[0], bc[1] + bs[1], bc[2] + bs[2]); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] - bs[0], bc[1] + bs[1], bc[2] + bs[2]); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] + bs[0], bc[1] - bs[1], bc[2] + bs[2]); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] - bs[0], bc[1] - bs[1], bc[2] + bs[2]); - - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] + bs[0], bc[1] + bs[1], bc[2] - bs[2]); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] - bs[0], bc[1] + bs[1], bc[2] - bs[2]); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] + bs[0], bc[1] - bs[1], bc[2] - bs[2]); - gGL.vertex3fv(c); - gGL.vertex3f(bc[0] - bs[0], bc[1] - bs[1], bc[2] - bs[2]); - gGL.end(); - - F32* po = group->mReflectionProbe->mOrigin.getF32ptr(); - //draw yellow line from center of node to reflection probe origin - gGL.flush(); - gGL.diffuseColor4f(1, 1, 0, 1); - gGL.begin(gGL.LINES); - gGL.vertex3fv(c); - gGL.vertex3fv(po); - gGL.end(); - gGL.flush(); - - //draw orange line from probe to neighbors - gGL.flush(); - gGL.diffuseColor4f(1, 0.5f, 0, 1); - gGL.begin(gGL.LINES); - for (auto& probe : group->mReflectionProbe->mNeighbors) - { - gGL.vertex3fv(po); - gGL.vertex3fv(probe->mOrigin.getF32ptr()); - } - gGL.end(); - gGL.flush(); - } -} std::set visible_selected_groups; void renderVisibility(LLSpatialGroup* group, LLCamera* camera) @@ -3371,12 +3312,6 @@ public: stop_glerror(); } - //draw reflection probes and links between them - if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_REFLECTION_PROBES)) - { - renderReflectionProbes(group); - } - //render visibility wireframe if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION)) { @@ -3791,8 +3726,7 @@ void LLSpatialPartition::renderDebug() //LLPipeline::RENDER_DEBUG_BUILD_QUEUE | LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA | LLPipeline::RENDER_DEBUG_RENDER_COMPLEXITY | - LLPipeline::RENDER_DEBUG_TEXEL_DENSITY | - LLPipeline::RENDER_DEBUG_REFLECTION_PROBES)) + LLPipeline::RENDER_DEBUG_TEXEL_DENSITY)) { return; } @@ -3826,7 +3760,6 @@ void LLSpatialPartition::renderDebug() LLOctreeRenderNonOccluded render_debug(camera); render_debug.traverse(mOctree); - if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_OCCLUSION)) { { diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 16b294b8e9..6ecf9dd0c4 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -343,6 +343,13 @@ LLViewerObject::~LLViewerObject() { deleteTEImages(); + // unhook from reflection probe manager + if (mReflectionProbe.notNull()) + { + mReflectionProbe->mViewerObject = nullptr; + mReflectionProbe = nullptr; + } + if(mInventory) { mInventory->clear(); // will deref and delete entries @@ -4862,7 +4869,7 @@ void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry) LLPrimitive::setTE(te, texture_entry); - const LLUUID& image_id = getTE(te)->getID(); + const LLUUID& image_id = getTE(te)->getID(); LLViewerTexture* bakedTexture = getBakedTextureForMagicId(image_id); mTEImages[te] = bakedTexture ? bakedTexture : LLViewerTextureManager::getFetchedTexture(image_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE); diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index bef8e3e7e3..5b6d24887c 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -43,6 +43,7 @@ #include "llvertexbuffer.h" #include "llbbox.h" #include "llrigginginfo.h" +#include "llreflectionmap.h" class LLAgent; // TODO: Get rid of this. class LLAudioSource; @@ -845,7 +846,7 @@ protected: F32 mLinksetCost; F32 mPhysicsCost; F32 mLinksetPhysicsCost; - + bool mCostStale; mutable bool mPhysicsShapeUnknown; @@ -904,6 +905,11 @@ private: LLUUID mAttachmentItemID; // ItemID of the associated object is in user inventory. EObjectUpdateType mLastUpdateType; BOOL mLastUpdateCached; + +public: + // reflection probe state + bool mIsReflectionProbe = false; // if true, this object should register itself with LLReflectionProbeManager + LLPointer mReflectionProbe = nullptr; // reflection probe coupled to this viewer object. If not null, should be deregistered when this object is destroyed }; /////////////////// diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index ef6ee4b910..784c0350fc 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2157,7 +2157,7 @@ void LLVOVolume::setNumTEs(const U8 num_tes) return ; } -//virtual +//virtual void LLVOVolume::changeTEImage(S32 index, LLViewerTexture* imagep) { BOOL changed = (mTEImages[index] != imagep); @@ -5690,6 +5690,24 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) bool is_pbr = false; #endif + // HACK - make this object a Reflection Probe if a certain UUID is detected + static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); + if (facep->getTextureEntry()->getID() == LLUUID(reflection_probe_id)) + { + if (!vobj->mIsReflectionProbe) + { + vobj->mIsReflectionProbe = true; + vobj->mReflectionProbe = gPipeline.mReflectionMapManager.registerViewerObject(vobj); + } + } + else + { + // not a refleciton probe any more + vobj->mIsReflectionProbe = false; + vobj->mReflectionProbe = nullptr; + } + // END HACK + //ALWAYS null out vertex buffer on rebuild -- if the face lands in a render // batch, it will recover its vertex buffer reference from the spatial group facep->setVertexBuffer(NULL); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 5eb9817fc4..4cf8157623 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -5150,7 +5150,6 @@ void LLPipeline::renderDebug() glPointSize(1.f); } - // Debug stuff. for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) @@ -5204,6 +5203,12 @@ void LLPipeline::renderDebug() visible_selected_groups.clear(); + //draw reflection probes and links between them + if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_REFLECTION_PROBES) && !hud_only) + { + mReflectionMapManager.renderDebug(); + } + gUIProgram.bind(); if (hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST) && !hud_only) -- cgit v1.3 From 63878a60eb8ab6884ed3aeec63a28e5089636092 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 18 May 2022 23:09:57 -0500 Subject: SL-17416 Box reflection probe influence volumes --- .../shaders/class2/deferred/softenLightF.glsl | 130 +++++++++++++++++---- indra/newview/llreflectionmap.cpp | 61 +++++++++- indra/newview/llreflectionmap.h | 9 ++ indra/newview/llreflectionmapmanager.cpp | 44 +++++-- indra/newview/llreflectionmapmanager.h | 3 - 5 files changed, 212 insertions(+), 35 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 3607c325a4..d188233a8d 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -48,14 +48,20 @@ uniform sampler2D lightFunc; layout (std140, binding = 1) uniform ReflectionProbes { - // list of sphere based reflection probes sorted by distance to camera (closest first) + // list of OBBs for user override probes + // box is a set of 3 planes outward facing planes and the depth of the box along that plane + // for each box refBox[i]... + /// box[0..2] - plane 0 .. 2 in [A,B,C,D] notation + // box[3][0..2] - plane thickness + mat4 refBox[REFMAP_COUNT]; + // list of bounding spheres for reflection probes sorted by distance to camera (closest first) vec4 refSphere[REFMAP_COUNT]; // index of cube map in reflectionProbes for a corresponding reflection probe // e.g. cube map channel of refSphere[2] is stored in refIndex[2] // refIndex.x - cubemap channel in reflectionProbes // refIndex.y - index in refNeighbor of neighbor list (index is ivec4 index, not int index) // refIndex.z - number of neighbors - // refIndex.w - priority + // refIndex.w - priority, if negative, this probe has a box influence ivec4 refIndex[REFMAP_COUNT]; // neighbor list data (refSphere indices, not cubemap array layer) @@ -103,15 +109,38 @@ int probeIndex[REF_SAMPLE_COUNT]; // number of probes stored in probeIndex int probeInfluences = 0; +bool isAbove(vec3 pos, vec4 plane) +{ + return (dot(plane.xyz, pos) + plane.w) > 0; +} // return true if probe at index i influences position pos bool shouldSampleProbe(int i, vec3 pos) { - vec3 delta = pos.xyz - refSphere[i].xyz; - float d = dot(delta, delta); - float r2 = refSphere[i].w; - r2 *= r2; - return d < r2; + if (refIndex[i].w < 0) + { + vec4 v = refBox[i] * vec4(pos, 1.0); + if (abs(v.x) > 1 || + abs(v.y) > 1 || + abs(v.z) > 1) + { + return false; + } + } + else + { + vec3 delta = pos.xyz - refSphere[i].xyz; + float d = dot(delta, delta); + float r2 = refSphere[i].w; + r2 *= r2; + + if (d > r2) + { //outside bounding sphere + return false; + } + } + + return true; } // populate "probeIndex" with N probe indices that influence pos where N is REF_SAMPLE_COUNT @@ -245,7 +274,7 @@ bool intersect(const Ray &ray) const } */ // adapted -- assume that origin is inside sphere, return distance from origin to edge of sphere -float sphereIntersect(vec3 origin, vec3 dir, vec3 center, float radius2) +vec3 sphereIntersect(vec3 origin, vec3 dir, vec3 center, float radius2) { float t0, t1; // solutions for t if the ray intersects @@ -258,9 +287,60 @@ float sphereIntersect(vec3 origin, vec3 dir, vec3 center, float radius2) t0 = tca - thc; t1 = tca + thc; - return t1; + vec3 v = origin + dir * t1; + return v; } +// from https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ +/* +vec3 DirectionWS = normalize(PositionWS - CameraWS); +vec3 ReflDirectionWS = reflect(DirectionWS, NormalWS); + +// Intersection with OBB convertto unit box space +// Transform in local unit parallax cube space (scaled and rotated) +vec3 RayLS = MulMatrix( float(3x3)WorldToLocal, ReflDirectionWS); +vec3 PositionLS = MulMatrix( WorldToLocal, PositionWS); + +vec3 Unitary = vec3(1.0f, 1.0f, 1.0f); +vec3 FirstPlaneIntersect = (Unitary - PositionLS) / RayLS; +vec3 SecondPlaneIntersect = (-Unitary - PositionLS) / RayLS; +vec3 FurthestPlane = max(FirstPlaneIntersect, SecondPlaneIntersect); +float Distance = min(FurthestPlane.x, min(FurthestPlane.y, FurthestPlane.z)); + +// Use Distance in WS directly to recover intersection +vec3 IntersectPositionWS = PositionWS + ReflDirectionWS * Distance; +vec3 ReflDirectionWS = IntersectPositionWS - CubemapPositionWS; + +return texCUBE(envMap, ReflDirectionWS); +*/ + +// get point of intersection with given probe's box influence volume +// origin - ray origin in clip space +// dir - ray direction in clip space +// i - probe index in refBox/refSphere +vec3 boxIntersect(vec3 origin, vec3 dir, int i) +{ + // Intersection with OBB convertto unit box space + // Transform in local unit parallax cube space (scaled and rotated) + mat4 clipToLocal = refBox[i]; + + vec3 RayLS = mat3(clipToLocal) * dir; + vec3 PositionLS = (clipToLocal * vec4(origin, 1.0)).xyz; + + vec3 Unitary = vec3(1.0f, 1.0f, 1.0f); + vec3 FirstPlaneIntersect = (Unitary - PositionLS) / RayLS; + vec3 SecondPlaneIntersect = (-Unitary - PositionLS) / RayLS; + vec3 FurthestPlane = max(FirstPlaneIntersect, SecondPlaneIntersect); + float Distance = min(FurthestPlane.x, min(FurthestPlane.y, FurthestPlane.z)); + + // Use Distance in CS directly to recover intersection + vec3 IntersectPositionCS = origin + dir * Distance; + + return IntersectPositionCS; +} + + + // Tap a sphere based reflection probe // pos - position of pixel // dir - pixel normal @@ -269,18 +349,24 @@ float sphereIntersect(vec3 origin, vec3 dir, vec3 center, float radius2) // r2 - radius of probe squared // i - index of probe // vi - point at which reflection vector struck the influence volume, in clip space -vec3 tapRefMap(vec3 pos, vec3 dir, float lod, vec3 c, float r2, int i, out vec3 vi) +vec3 tapRefMap(vec3 pos, vec3 dir, float lod, vec3 c, float r2, int i) { //lod = max(lod, 1); -// parallax adjustment - float d = sphereIntersect(pos, dir, c, r2); + // parallax adjustment + vec3 v; + if (refIndex[i].w < 0) + { + v = boxIntersect(pos, dir, i); + } + else { - vec3 v = pos + dir * d; - vi = v; - v -= c.xyz; - v = env_mat * v; + v = sphereIntersect(pos, dir, c, r2); + } + v -= c; + v = env_mat * v; + { float min_lod = textureQueryLod(reflectionProbes,v).y; // lower is higher res return textureLod(reflectionProbes, vec4(v.xyz, refIndex[i].x), max(min_lod, lod)).rgb; //return texture(reflectionProbes, vec4(v.xyz, refIndex[i].x)).rgb; @@ -297,7 +383,7 @@ vec3 sampleRefMap(vec3 pos, vec3 dir, float lod) { int i = probeIndex[idx]; float r = refSphere[i].w; // radius of sphere volume - float p = float(refIndex[i].w); // priority + float p = float(abs(refIndex[i].w)); // priority float rr = r*r; // radius squred float r1 = r * 0.1; // 75% of radius (outer sphere to start interpolating down) vec3 delta = pos.xyz-refSphere[i].xyz; @@ -305,8 +391,7 @@ vec3 sampleRefMap(vec3 pos, vec3 dir, float lod) float r2 = r1*r1; { - vec3 vi; - vec3 refcol = tapRefMap(pos, dir, lod, refSphere[i].xyz, rr, i, vi); + vec3 refcol = tapRefMap(pos, dir, lod, refSphere[i].xyz, rr, i); float w = 1.0/d2; @@ -323,13 +408,16 @@ vec3 sampleRefMap(vec3 pos, vec3 dir, float lod) { //edge-of-scene probe or no probe influence, mix in with embiggened version of probes closest to camera for (int idx = 0; idx < 8; ++idx) { + if (refIndex[idx].w < 0) + { // don't fallback to box probes, they are *very* specific + continue; + } int i = idx; vec3 delta = pos.xyz-refSphere[i].xyz; float d2 = dot(delta,delta); { - vec3 vi; - vec3 refcol = tapRefMap(pos, dir, lod, refSphere[i].xyz, d2, i, vi); + vec3 refcol = tapRefMap(pos, dir, lod, refSphere[i].xyz, d2, i); float w = 1.0/d2; w *= w; diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index c146a888cf..4ac2803208 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -106,6 +106,7 @@ void LLReflectionMap::autoAdjustOrigin() } else if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) { + mPriority = 8; // cast a ray towards 8 corners of bounding box // nudge origin towards center of empty space @@ -182,6 +183,9 @@ void LLReflectionMap::autoAdjustOrigin() } else { + // user placed probe + mPriority = 64; + // use center of octree node volume for nodes that are just branches without data mOrigin = node->getCenter(); @@ -196,13 +200,15 @@ void LLReflectionMap::autoAdjustOrigin() } else if (mViewerObject) { + mPriority = 64; mOrigin.load3(mViewerObject->getPositionAgent().mV); - mRadius = mViewerObject->getScale().mV[0]; + mRadius = mViewerObject->getScale().mV[0]*0.5f; } } bool LLReflectionMap::intersects(LLReflectionMap* other) { + // TODO: incorporate getBox LLVector4a delta; delta.setSub(other->mOrigin, mOrigin); @@ -214,3 +220,56 @@ bool LLReflectionMap::intersects(LLReflectionMap* other) return dist < r2; } + +bool LLReflectionMap::getBox(LLMatrix4& box) +{ + if (mViewerObject) + { + LLVolume* volume = mViewerObject->getVolume(); + if (volume) + { + LLVOVolume* vobjp = (LLVOVolume*)mViewerObject; + + U8 profile = volume->getProfileType(); + U8 path = volume->getPathType(); + + if (profile == LL_PCODE_PROFILE_SQUARE && + path == LL_PCODE_PATH_LINE) + { + // nope + /*box = vobjp->getRelativeXform(); + box *= vobjp->mDrawable->getRenderMatrix(); + LLMatrix4 modelview(gGLModelView); + box *= modelview; + box.invert();*/ + + // nope + /*box = LLMatrix4(gGLModelView); + box *= vobjp->mDrawable->getRenderMatrix(); + box *= vobjp->getRelativeXform(); + box.invert();*/ + + glh::matrix4f mv(gGLModelView); + glh::matrix4f scale; + LLVector3 s = vobjp->getScale().scaledVec(LLVector3(0.5f, 0.5f, 0.5f)); + mRadius = s.magVec(); + scale.set_scale(glh::vec3f(s.mV)); + if (vobjp->mDrawable != nullptr) + { + glh::matrix4f rm((F32*)vobjp->mDrawable->getWorldMatrix().mMatrix); + + glh::matrix4f rt((F32*)vobjp->getRelativeXform().mMatrix); + + mv = mv * rm * scale; // *rt; + mv = mv.inverse(); + + box = LLMatrix4(mv.m); + + return true; + } + } + } + } + + return false; +} diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index 305f33af4b..4f0f124118 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -55,6 +55,12 @@ public: // return true if given Reflection Map's influence volume intersect's with this one's bool intersects(LLReflectionMap* other); + // get the encoded bounding box of this probe's influence volume + // will only return a box if this probe has a volume with a square + // profile and a linear path + // return false if no bounding box (treat as sphere influence volume) + bool getBox(LLMatrix4& box); + // point at which environment map was last generated from (in agent space) LLVector4a mOrigin; @@ -87,6 +93,9 @@ public: // viewer object this probe is tracking (if any) LLViewerObject* mViewerObject = nullptr; + // what priority should this probe have (higher is higher priority) + U32 mPriority = 1; + bool mDirty = true; }; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 53c4857b0f..f4fdc3993f 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -141,10 +141,16 @@ void LLReflectionMapManager::update() mCreateList.clear(); - const F32 UPDATE_INTERVAL = 10.f; //update no more than once every 5 seconds + if (mProbes.empty()) + { + return; + } + const F32 UPDATE_INTERVAL = 5.f; //update no more than once every 5 seconds bool did_update = false; + LLReflectionMap* oldestProbe = mProbes[0]; + if (mUpdatingProbe != nullptr) { did_update = true; @@ -181,21 +187,30 @@ void LLReflectionMapManager::update() probe->mDirty = false; } + if (probe->mCubeArray.notNull() && + probe->mCubeIndex != -1 && + probe->mLastUpdateTime < oldestProbe->mLastUpdateTime) + { + oldestProbe = probe; + } + d.setSub(camera_pos, probe->mOrigin); probe->mDistance = d.getLength3().getF32()-probe->mRadius; } +#if 0 + if (mUpdatingProbe == nullptr && + oldestProbe->mCubeArray.notNull() && + oldestProbe->mCubeIndex != -1) + { // didn't find any probes to update, update the most out of date probe that's currently in use on next frame + mUpdatingProbe = oldestProbe; + } +#endif + // update distance to camera for all probes std::sort(mProbes.begin(), mProbes.end(), CompareProbeDistance()); } -void LLReflectionMapManager::addProbe(const LLVector3& pos) -{ - //LLReflectionMap* probe = new LLReflectionMap(); - //probe->update(pos, 1024); - //mProbes.push_back(probe); -} - LLReflectionMap* LLReflectionMapManager::addProbe(LLSpatialGroup* group) { LLReflectionMap* probe = new LLReflectionMap(); @@ -251,6 +266,7 @@ void LLReflectionMapManager::getReflectionMaps(std::vector& ma LLReflectionMap* LLReflectionMapManager::registerSpatialGroup(LLSpatialGroup* group) { +#if 1 if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) { OctreeNode* node = group->getOctreeNode(); @@ -270,7 +286,7 @@ LLReflectionMap* LLReflectionMapManager::registerSpatialGroup(LLSpatialGroup* gr return addProbe(group); } } - +#endif return nullptr; } @@ -493,6 +509,7 @@ void LLReflectionMapManager::setUniforms() // see class2/deferred/softenLightF.glsl struct ReflectionProbeData { + LLMatrix4 refBox[LL_REFLECTION_PROBE_COUNT]; // object bounding box as needed LLVector4 refSphere[LL_REFLECTION_PROBE_COUNT]; //origin and radius of refmaps in clip space GLint refIndex[LL_REFLECTION_PROBE_COUNT][4]; GLint refNeighbor[4096]; @@ -535,7 +552,14 @@ void LLReflectionMapManager::setUniforms() rpd.refIndex[count][0] = refmap->mCubeIndex; llassert(nc % 4 == 0); rpd.refIndex[count][1] = nc / 4; - rpd.refIndex[count][3] = refmap->mViewerObject ? 10 : 1; + rpd.refIndex[count][3] = refmap->mPriority; + + // for objects that are reflection probes, use the volume as the influence volume of the probe + // only possibile influence volumes are boxes and spheres, so detect boxes and treat everything else as spheres + if (refmap->getBox(rpd.refBox[count])) + { // negate priority to indicate this probe has a box influence volume + rpd.refIndex[count][3] = -rpd.refIndex[count][3]; + } S32 ni = nc; // neighbor ("index") - index into refNeighbor to write indices for current reflection probe's neighbors { diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index f7feabbf66..9417fe2416 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -52,9 +52,6 @@ public: // maintain reflection probes void update(); - // drop a reflection probe at the specified position in agent space - void addProbe(const LLVector3& pos); - // add a probe for the given spatial group LLReflectionMap* addProbe(LLSpatialGroup* group); -- cgit v1.3 From 6eaf8521abae0deeb1162f9c61747183110176b0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 20 May 2022 19:05:28 -0500 Subject: SL-17287 Instrument and optimize cubemap render. Fix for cubemap snapshots doing a full resolution render instead of a 512x512 render. --- indra/llrender/llimagegl.cpp | 4 + indra/llrender/llrendertarget.cpp | 2 + indra/llwindow/llwindowwin32.cpp | 5 +- indra/newview/lldrawpoolalpha.cpp | 12 +- indra/newview/llfloatermodelpreview.cpp | 4 +- indra/newview/llreflectionmap.cpp | 10 +- indra/newview/llreflectionmapmanager.cpp | 65 ++++---- indra/newview/llreflectionmapmanager.h | 2 +- indra/newview/llviewerdisplay.cpp | 32 ++-- indra/newview/llviewerwindow.cpp | 12 +- indra/newview/pipeline.cpp | 264 ++++++++++++++++--------------- indra/newview/pipeline.h | 42 +++-- 12 files changed, 245 insertions(+), 209 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index f2da859e23..89dd68da76 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -812,6 +812,7 @@ BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32 if (LLRender::sGLCoreProfile) { + LL_PROFILE_GPU_ZONE("generate mip map"); glGenerateMipmap(mTarget); } stop_glerror(); @@ -1519,6 +1520,7 @@ BOOL LLImageGL::createGLTexture(S32 discard_level, const U8* data_in, BOOL data_ // Call with void data, vmem is allocated but unitialized { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + LL_PROFILE_GPU_ZONE("createGLTexture"); checkActiveThread(); bool main_thread = on_main_thread(); @@ -1736,6 +1738,8 @@ void LLImageGL::syncToMainThread(LLGLuint new_tex_name) syncTexName(new_tex_name); unref(); }); + + LL_PROFILER_GPU_COLLECT; } diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index 85c2a48279..85d6209964 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -513,6 +513,7 @@ void LLRenderTarget::bindTarget() void LLRenderTarget::clear(U32 mask_in) { + LL_PROFILE_GPU_ZONE("clear"); U32 mask = GL_COLOR_BUFFER_BIT; if (mUseDepth) { @@ -677,6 +678,7 @@ void LLRenderTarget::copyContentsToFramebuffer(LLRenderTarget& source, S32 srcX0 } { + LL_PROFILE_GPU_ZONE("copyContentsToFramebuffer"); GLboolean write_depth = mask & GL_DEPTH_BUFFER_BIT ? TRUE : FALSE; LLGLDepthTest depth(write_depth, write_depth); diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp index 02b3c25129..67c50294e1 100644 --- a/indra/llwindow/llwindowwin32.cpp +++ b/indra/llwindow/llwindowwin32.cpp @@ -3575,7 +3575,10 @@ void LLWindowWin32::swapBuffers() { LL_PROFILE_ZONE_SCOPED_CATEGORY_WIN32; ASSERT_MAIN_THREAD(); - glFlush(); //superstitious flush for maybe frame stall removal? + { + LL_PROFILE_GPU_ZONE("flush"); + glFlush(); //superstitious flush for maybe frame stall removal? + } SwapBuffers(mhDC); LL_PROFILER_GPU_COLLECT; diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index a43b30465b..89b8ec1ba2 100644 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -160,10 +160,10 @@ void LLDrawPoolAlpha::renderPostDeferred(S32 pass) if (!LLPipeline::sImpostorRender && gSavedSettings.getBOOL("RenderDepthOfField") && !gCubeSnapshot) { //update depth buffer sampler - gPipeline.mScreen.flush(); - gPipeline.mDeferredDepth.copyContents(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(), - 0, 0, gPipeline.mDeferredDepth.getWidth(), gPipeline.mDeferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); - gPipeline.mDeferredDepth.bindTarget(); + gPipeline.mRT->screen.flush(); + gPipeline.mRT->deferredDepth.copyContents(gPipeline.mRT->deferredScreen, 0, 0, gPipeline.mRT->deferredScreen.getWidth(), gPipeline.mRT->deferredScreen.getHeight(), + 0, 0, gPipeline.mRT->deferredDepth.getWidth(), gPipeline.mRT->deferredDepth.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); + gPipeline.mRT->deferredDepth.bindTarget(); simple_shader = fullbright_shader = &gObjectFullbrightAlphaMaskProgram; simple_shader->bind(); @@ -177,8 +177,8 @@ void LLDrawPoolAlpha::renderPostDeferred(S32 pass) renderAlpha(getVertexDataMask() | LLVertexBuffer::MAP_TEXTURE_INDEX | LLVertexBuffer::MAP_TANGENT | LLVertexBuffer::MAP_TEXCOORD1 | LLVertexBuffer::MAP_TEXCOORD2, true); // <--- discard mostly transparent faces - gPipeline.mDeferredDepth.flush(); - gPipeline.mScreen.bindTarget(); + gPipeline.mRT->deferredDepth.flush(); + gPipeline.mRT->screen.bindTarget(); gGL.setColorMask(true, false); } diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index fe5120376c..7279e1ad6d 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -330,8 +330,8 @@ void LLFloaterModelPreview::initModelPreview() S32 tex_width = 512; S32 tex_height = 512; - S32 max_width = llmin(PREVIEW_RENDER_SIZE, (S32)gPipeline.mScreenWidth); - S32 max_height = llmin(PREVIEW_RENDER_SIZE, (S32)gPipeline.mScreenHeight); + S32 max_width = llmin(PREVIEW_RENDER_SIZE, (S32)gPipeline.mRT->width); + S32 max_height = llmin(PREVIEW_RENDER_SIZE, (S32)gPipeline.mRT->height); while ((tex_width << 1) < max_width) { diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 4ac2803208..54a627efd4 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -47,8 +47,8 @@ void LLReflectionMap::update(U32 resolution, U32 face) llassert(LLPipeline::sRenderDeferred); // make sure we don't walk off the edge of the render target - while (resolution > gPipeline.mDeferredScreen.getWidth() || - resolution > gPipeline.mDeferredScreen.getHeight()) + while (resolution > gPipeline.mRT->deferredScreen.getWidth() || + resolution > gPipeline.mRT->deferredScreen.getHeight()) { resolution /= 2; } @@ -57,17 +57,11 @@ void LLReflectionMap::update(U32 resolution, U32 face) bool LLReflectionMap::shouldUpdate() { - const F32 UPDATE_INTERVAL = 10.f; // update no more than this often const F32 TIMEOUT_INTERVAL = 30.f; // update no less than this often const F32 RENDER_TIMEOUT = 1.f; // don't update if hasn't been used for rendering for this long if (mLastBindTime > gFrameTimeSeconds - RENDER_TIMEOUT) { - if (mDirty && mLastUpdateTime < gFrameTimeSeconds - UPDATE_INTERVAL) - { - return true; - } - if (mLastUpdateTime < gFrameTimeSeconds - TIMEOUT_INTERVAL) { return true; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index fb98a2a6d4..db6622239d 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -39,6 +39,9 @@ extern BOOL gTeleportDisplay; //#pragma optimize("", off) +// experimental pipeline render target override, if this works, do something less hacky +LLPipeline::RenderTargetPack gProbeRT; + LLReflectionMapManager::LLReflectionMapManager() { for (int i = 0; i < LL_REFLECTION_PROBE_COUNT; ++i) @@ -89,13 +92,20 @@ void LLReflectionMapManager::update() U32 color_fmt = GL_RGBA; const bool use_depth_buffer = true; const bool use_stencil_buffer = true; - U32 targetRes = LL_REFLECTION_PROBE_RESOLUTION * 4; // super sample + U32 targetRes = LL_REFLECTION_PROBE_RESOLUTION * 2; // super sample mRenderTarget.allocate(targetRes, targetRes, color_fmt, use_depth_buffer, use_stencil_buffer, LLTexUnit::TT_RECT_TEXTURE); + + // hack to allocate render targets using gPipeline code + auto* old_rt = gPipeline.mRT; + gPipeline.mRT = &gProbeRT; + gPipeline.allocateScreenBuffer(targetRes, targetRes); + gPipeline.allocateShadowBuffer(targetRes, targetRes); + gPipeline.mRT = old_rt; } if (mMipChain.empty()) { - U32 res = LL_REFLECTION_PROBE_RESOLUTION*2; + U32 res = LL_REFLECTION_PROBE_RESOLUTION; U32 count = log2((F32)res) + 0.5f; mMipChain.resize(count); @@ -150,7 +160,7 @@ void LLReflectionMapManager::update() bool did_update = false; - LLReflectionMap* oldestProbe = mProbes[0]; + LLReflectionMap* oldestProbe = nullptr; if (mUpdatingProbe != nullptr) { @@ -172,25 +182,9 @@ void LLReflectionMapManager::update() LLVector4a d; - if (probe->shouldUpdate() && !did_update && i < LL_REFLECTION_PROBE_COUNT) - { - if (probe->mCubeIndex == -1) - { - probe->mCubeArray = mTexture; - probe->mCubeIndex = allocateCubeIndex(); - } - - did_update = true; // only update one probe per frame - probe->autoAdjustOrigin(); - - mUpdatingProbe = probe; - doProbeUpdate(); - probe->mDirty = false; - } - - if (probe->mCubeArray.notNull() && - probe->mCubeIndex != -1 && - probe->mLastUpdateTime < oldestProbe->mLastUpdateTime) + if (!did_update && + i < LL_REFLECTION_PROBE_COUNT && + (oldestProbe == nullptr || probe->mLastUpdateTime < oldestProbe->mLastUpdateTime)) { oldestProbe = probe; } @@ -199,12 +193,21 @@ void LLReflectionMapManager::update() probe->mDistance = d.getLength3().getF32()-probe->mRadius; } -#if 0 - if (mUpdatingProbe == nullptr && - oldestProbe->mCubeArray.notNull() && - oldestProbe->mCubeIndex != -1) - { // didn't find any probes to update, update the most out of date probe that's currently in use on next frame - mUpdatingProbe = oldestProbe; +#if 1 + if (!did_update && oldestProbe != nullptr) + { + LLReflectionMap* probe = oldestProbe; + if (probe->mCubeIndex == -1) + { + probe->mCubeArray = mTexture; + probe->mCubeIndex = allocateCubeIndex(); + } + + probe->autoAdjustOrigin(); + + mUpdatingProbe = probe; + doProbeUpdate(); + probe->mDirty = false; } #endif @@ -372,7 +375,10 @@ void LLReflectionMapManager::doProbeUpdate() llassert(mUpdatingProbe != nullptr); mRenderTarget.bindTarget(); + auto* old_rt = gPipeline.mRT; + gPipeline.mRT = &gProbeRT; mUpdatingProbe->update(mRenderTarget.getWidth(), mUpdatingFace); + gPipeline.mRT = old_rt; mRenderTarget.flush(); // generate mipmaps @@ -390,12 +396,13 @@ void LLReflectionMapManager::doProbeUpdate() gGL.loadIdentity(); gGL.flush(); - U32 res = LL_REFLECTION_PROBE_RESOLUTION*4; + U32 res = LL_REFLECTION_PROBE_RESOLUTION*2; S32 mips = log2((F32) LL_REFLECTION_PROBE_RESOLUTION)+0.5f; for (int i = 0; i < mMipChain.size(); ++i) { + LL_PROFILE_GPU_ZONE("probe mip"); mMipChain[i].bindTarget(); if (i == 0) diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index e3942beaae..bf963f3486 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -48,7 +48,7 @@ class alignas(16) LLReflectionMapManager public: // allocate an environment map of the given resolution LLReflectionMapManager(); - + // maintain reflection probes void update(); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index f375852dfe..1b8e53e667 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -916,19 +916,19 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (LLPipeline::sRenderDeferred) { - gPipeline.mDeferredScreen.bindTarget(); + gPipeline.mRT->deferredScreen.bindTarget(); glClearColor(1, 0, 1, 1); - gPipeline.mDeferredScreen.clear(); + gPipeline.mRT->deferredScreen.clear(); } else { - gPipeline.mScreen.bindTarget(); + gPipeline.mRT->screen.bindTarget(); if (LLPipeline::sUnderWaterRender && !gPipeline.canUseWindLightShaders()) { const LLColor4 &col = LLEnvironment::instance().getCurrentWater()->getWaterFogColor(); glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); } - gPipeline.mScreen.clear(); + gPipeline.mRT->screen.clear(); } gGL.setColorMask(true, false); @@ -998,7 +998,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLAppViewer::instance()->pingMainloopTimeout("Display:RenderFlush"); - LLRenderTarget &rt = (gPipeline.sRenderDeferred ? gPipeline.mDeferredScreen : gPipeline.mScreen); + LLRenderTarget &rt = (gPipeline.sRenderDeferred ? gPipeline.mRT->deferredScreen : gPipeline.mRT->screen); rt.flush(); if (rt.sUseFBO) @@ -1010,7 +1010,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) if (LLPipeline::sRenderDeferred) { - gPipeline.renderDeferredLighting(&gPipeline.mScreen); + gPipeline.renderDeferredLighting(&gPipeline.mRT->screen); } LLPipeline::sUnderWaterRender = FALSE; @@ -1061,6 +1061,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) void display_cube_face() { LL_RECORD_BLOCK_TIME(FTM_RENDER); + LL_PROFILE_GPU_ZONE("display cube face"); + llassert(!gSnapshot); llassert(!gTeleportDisplay); llassert(LLPipeline::sRenderDeferred); @@ -1136,9 +1138,9 @@ void display_cube_face() gGL.setColorMask(true, true); - gPipeline.mDeferredScreen.bindTarget(); + gPipeline.mRT->deferredScreen.bindTarget(); glClearColor(1, 0, 1, 1); - gPipeline.mDeferredScreen.clear(); + gPipeline.mRT->deferredScreen.clear(); gGL.setColorMask(true, false); @@ -1148,9 +1150,9 @@ void display_cube_face() gGL.setColorMask(true, true); - gPipeline.mDeferredScreen.flush(); + gPipeline.mRT->deferredScreen.flush(); - gPipeline.renderDeferredLighting(&gPipeline.mScreen); + gPipeline.renderDeferredLighting(&gPipeline.mRT->screen); LLPipeline::sUnderWaterRender = FALSE; @@ -1357,7 +1359,7 @@ bool setup_hud_matrices(const LLRect& screen_region) void render_ui(F32 zoom_factor, int subfield) { LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; //LL_RECORD_BLOCK_TIME(FTM_RENDER_UI); - + LL_PROFILE_GPU_ZONE("ui"); LLGLState::checkStates(); glh::matrix4f saved_view = get_current_modelview(); @@ -1440,7 +1442,7 @@ static LLTrace::BlockTimerStatHandle FTM_SWAP("Swap"); void swap() { LL_RECORD_BLOCK_TIME(FTM_SWAP); - + LL_PROFILE_GPU_ZONE("swap"); if (gDisplaySwapBuffers) { gViewerWindow->getWindow()->swapBuffers(); @@ -1602,7 +1604,7 @@ void render_ui_2d() LLView::sIsRectDirty = false; LLRect t_rect; - gPipeline.mUIScreen.bindTarget(); + gPipeline.mRT->uiScreen.bindTarget(); gGL.setColorMask(true, true); { static const S32 pad = 8; @@ -1634,7 +1636,7 @@ void render_ui_2d() gViewerWindow->draw(); } - gPipeline.mUIScreen.flush(); + gPipeline.mRT->uiScreen.flush(); gGL.setColorMask(true, false); LLView::sDirtyRect = t_rect; @@ -1644,7 +1646,7 @@ void render_ui_2d() LLGLDisable blend(GL_BLEND); S32 width = gViewerWindow->getWindowWidthScaled(); S32 height = gViewerWindow->getWindowHeightScaled(); - gGL.getTexUnit(0)->bind(&gPipeline.mUIScreen); + gGL.getTexUnit(0)->bind(&gPipeline.mRT->uiScreen); gGL.begin(LLRender::TRIANGLE_STRIP); gGL.color4f(1,1,1,1); gGL.texCoord2f(0, 0); gGL.vertex2i(0, 0); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index ad57fcd802..a6597e3233 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4927,8 +4927,8 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei U32 color_fmt = type == LLSnapshotModel::SNAPSHOT_TYPE_DEPTH ? GL_DEPTH_COMPONENT : GL_RGBA; if (scratch_space.allocate(image_width, image_height, color_fmt, true, true)) { - original_width = gPipeline.mDeferredScreen.getWidth(); - original_height = gPipeline.mDeferredScreen.getHeight(); + original_width = gPipeline.mRT->deferredScreen.getWidth(); + original_height = gPipeline.mRT->deferredScreen.getHeight(); if (gPipeline.allocateScreenBuffer(image_width, image_height)) { @@ -5186,8 +5186,8 @@ BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_ LLPipeline::sShowHUDAttachments = FALSE; LLRect window_rect = getWorldViewRectRaw(); - S32 original_width = LLPipeline::sRenderDeferred ? gPipeline.mDeferredScreen.getWidth() : gViewerWindow->getWorldViewWidthRaw(); - S32 original_height = LLPipeline::sRenderDeferred ? gPipeline.mDeferredScreen.getHeight() : gViewerWindow->getWorldViewHeightRaw(); + S32 original_width = LLPipeline::sRenderDeferred ? gPipeline.mRT->deferredScreen.getWidth() : gViewerWindow->getWorldViewWidthRaw(); + S32 original_height = LLPipeline::sRenderDeferred ? gPipeline.mRT->deferredScreen.getHeight() : gViewerWindow->getWorldViewHeightRaw(); LLRenderTarget scratch_space; U32 color_fmt = GL_RGBA; @@ -5280,8 +5280,8 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubea U32 res = LLRenderTarget::sCurResX; - llassert(res <= gPipeline.mDeferredScreen.getWidth()); - llassert(res <= gPipeline.mDeferredScreen.getHeight()); + llassert(res <= gPipeline.mRT->deferredScreen.getWidth()); + llassert(res <= gPipeline.mRT->deferredScreen.getHeight()); // save current view/camera settings so we can restore them afterwards S32 old_occlusion = LLPipeline::sUseOcclusion; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 8f38f7a8f4..2790628a46 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -406,9 +406,7 @@ LLPipeline::LLPipeline() : mWLSkyPool(NULL), mLightMask(0), mLightMovingMask(0), - mLightingDetail(0), - mScreenWidth(0), - mScreenHeight(0) + mLightingDetail(0) { mNoiseMap = 0; mTrueNoiseMap = 0; @@ -437,6 +435,8 @@ void LLPipeline::init() { refreshCachedSettings(); + mRT = new RenderTargetPack(); + gOctreeMaxCapacity = gSavedSettings.getU32("OctreeMaxNodeCapacity"); gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); @@ -694,6 +694,9 @@ void LLPipeline::cleanup() mDeferredVB = NULL; mCubeVB = NULL; + + delete mRT; + mRT = nullptr; } //============================================================================ @@ -735,7 +738,7 @@ void LLPipeline::requestResizeShadowTexture() void LLPipeline::resizeShadowTexture() { releaseShadowTargets(); - allocateShadowBuffer(mScreenWidth, mScreenHeight); + allocateShadowBuffer(mRT->width, mRT->height); gResizeShadowTexture = FALSE; } @@ -746,7 +749,7 @@ void LLPipeline::resizeScreenTexture() GLuint resX = gViewerWindow->getWorldViewWidthRaw(); GLuint resY = gViewerWindow->getWorldViewHeightRaw(); - if (gResizeScreenTexture || (resX != mScreen.getWidth()) || (resY != mScreen.getHeight())) + if (gResizeScreenTexture || (resX != mRT->screen.getWidth()) || (resY != mRT->screen.getHeight())) { releaseScreenBuffers(); releaseShadowTargets(); @@ -834,8 +837,8 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; // remember these dimensions - mScreenWidth = resX; - mScreenHeight = resY; + mRT->width = resX; + mRT->height = resY; U32 res_mod = RenderResolutionDivisor; @@ -847,7 +850,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) if (RenderUIBuffer) { - if (!mUIScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) + if (!mRT->uiScreen.allocate(resX,resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) { return false; } @@ -861,10 +864,10 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) const U32 occlusion_divisor = 3; //allocate deferred rendering color buffers - if (!mDeferredScreen.allocate(resX, resY, GL_SRGB8_ALPHA8, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; - if (!mDeferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; - if (!mOcclusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; - if (!addDeferredAttachments(mDeferredScreen)) return false; + if (!mRT->deferredScreen.allocate(resX, resY, GL_SRGB8_ALPHA8, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!mRT->deferredDepth.allocate(resX, resY, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!mRT->occlusionDepth.allocate(resX/occlusion_divisor, resY/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!addDeferredAttachments(mRT->deferredScreen)) return false; GLuint screenFormat = GL_RGBA16; if (gGLManager.mIsAMD) @@ -877,23 +880,23 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) screenFormat = GL_RGBA16F_ARB; } - if (!mScreen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; + if (!mRT->screen.allocate(resX, resY, screenFormat, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE, samples)) return false; if (samples > 0) { - if (!mFXAABuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; + if (!mRT->fxaaBuffer.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_TEXTURE, FALSE, samples)) return false; } else { - mFXAABuffer.release(); + mRT->fxaaBuffer.release(); } if (shadow_detail > 0 || ssao || RenderDepthOfField || samples > 0) - { //only need mDeferredLight for shadows OR ssao OR dof OR fxaa - if (!mDeferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; + { //only need mRT->deferredLight for shadows OR ssao OR dof OR fxaa + if (!mRT->deferredLight.allocate(resX, resY, GL_RGBA, FALSE, FALSE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; } else { - mDeferredLight.release(); + mRT->deferredLight.release(); } allocateShadowBuffer(resX, resY); @@ -906,22 +909,22 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) } else { - mDeferredLight.release(); + mRT->deferredLight.release(); releaseShadowTargets(); - mFXAABuffer.release(); - mScreen.release(); - mDeferredScreen.release(); //make sure to release any render targets that share a depth buffer with mDeferredScreen first - mDeferredDepth.release(); - mOcclusionDepth.release(); + mRT->fxaaBuffer.release(); + mRT->screen.release(); + mRT->deferredScreen.release(); //make sure to release any render targets that share a depth buffer with mRT->deferredScreen first + mRT->deferredDepth.release(); + mRT->occlusionDepth.release(); - if (!mScreen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; + if (!mRT->screen.allocate(resX, resY, GL_RGBA, TRUE, TRUE, LLTexUnit::TT_RECT_TEXTURE, FALSE)) return false; } if (LLPipeline::sRenderDeferred) { //share depth buffer between deferred targets - mDeferredScreen.shareDepthBuffer(mScreen); + mRT->deferredScreen.shareDepthBuffer(mRT->screen); } gGL.getTexUnit(0)->disable(); @@ -951,12 +954,12 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) { //allocate 4 sun shadow maps for (U32 i = 0; i < 4; i++) { - if (!mShadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) { return false; } - if (!mShadowOcclusion[i].allocate(sun_shadow_map_width/occlusion_divisor, sun_shadow_map_height/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (!mRT->shadowOcclusion[i].allocate(sun_shadow_map_width/occlusion_divisor, sun_shadow_map_height/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) { return false; } @@ -979,11 +982,11 @@ bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) U32 spot_shadow_map_height = height; for (U32 i = 4; i < 6; i++) { - if (!mShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) + if (!mRT->shadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) { return false; } - if (!mShadowOcclusion[i].allocate(spot_shadow_map_width/occlusion_divisor, height/occlusion_divisor, 0, TRUE, FALSE)) + if (!mRT->shadowOcclusion[i].allocate(spot_shadow_map_width/occlusion_divisor, height/occlusion_divisor, 0, TRUE, FALSE)) { return false; } @@ -1174,21 +1177,21 @@ void LLPipeline::releaseShadowBuffers() void LLPipeline::releaseScreenBuffers() { - mUIScreen.release(); - mScreen.release(); - mFXAABuffer.release(); + mRT->uiScreen.release(); + mRT->screen.release(); + mRT->fxaaBuffer.release(); mPhysicsDisplay.release(); - mDeferredScreen.release(); - mDeferredDepth.release(); - mDeferredLight.release(); - mOcclusionDepth.release(); + mRT->deferredScreen.release(); + mRT->deferredDepth.release(); + mRT->deferredLight.release(); + mRT->occlusionDepth.release(); } void LLPipeline::releaseShadowTarget(U32 index) { - mShadow[index].release(); - mShadowOcclusion[index].release(); + mRT->shadow[index].release(); + mRT->shadowOcclusion[index].release(); } void LLPipeline::releaseShadowTargets() @@ -1231,8 +1234,8 @@ void LLPipeline::createGLBuffers() } allocateScreenBuffer(resX, resY); - mScreenWidth = 0; - mScreenHeight = 0; + mRT->width = 0; + mRT->height = 0; if (sRenderDeferred) { @@ -2333,11 +2336,11 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* pla { if (LLPipeline::sRenderDeferred && can_use_occlusion) { - mOcclusionDepth.bindTarget(); + mRT->occlusionDepth.bindTarget(); } else { - mScreen.bindTarget(); + mRT->screen.bindTarget(); } } @@ -2459,11 +2462,11 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* pla { if (LLPipeline::sRenderDeferred && can_use_occlusion) { - mOcclusionDepth.flush(); + mRT->occlusionDepth.flush(); } else { - mScreen.flush(); + mRT->screen.flush(); } } } @@ -4631,7 +4634,7 @@ void LLPipeline::renderGeomPostDeferred(LLCamera& camera, bool do_occlusion) gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); LLGLSLShader::bindNoShader(); - doOcclusion(camera, mScreen, mOcclusionDepth, &mDeferredDepth); + doOcclusion(camera, mRT->screen, mRT->occlusionDepth, &mRT->deferredDepth); gGL.setColorMask(true, false); } @@ -7484,9 +7487,11 @@ void LLPipeline::renderFinalize() } LLVector2 tc1(0, 0); - LLVector2 tc2((F32) mScreen.getWidth() * 2, (F32) mScreen.getHeight() * 2); + LLVector2 tc2((F32) mRT->screen.getWidth() * 2, (F32) mRT->screen.getHeight() * 2); LL_RECORD_BLOCK_TIME(FTM_RENDER_BLOOM); + LL_PROFILE_GPU_ZONE("renderFinalize"); + gGL.color4f(1, 1, 1, 1); LLGLDepthTest depth(GL_FALSE); LLGLDisable blend(GL_BLEND); @@ -7508,6 +7513,7 @@ void LLPipeline::renderFinalize() if (sRenderGlow) { + LL_PROFILE_GPU_ZONE("glow"); mGlow[2].bindTarget(); mGlow[2].clear(); @@ -7532,7 +7538,7 @@ void LLPipeline::renderFinalize() gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - mScreen.bindTexture(0, 0, LLTexUnit::TFO_POINT); + mRT->screen.bindTexture(0, 0, LLTexUnit::TFO_POINT); gGL.color4f(1, 1, 1, 1); gPipeline.enableLightsFullbright(); @@ -7548,7 +7554,7 @@ void LLPipeline::renderFinalize() gGL.end(); - gGL.getTexUnit(0)->unbind(mScreen.getUsage()); + gGL.getTexUnit(0)->unbind(mRT->screen.getUsage()); mGlow[2].flush(); @@ -7626,7 +7632,7 @@ void LLPipeline::renderFinalize() gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - tc2.setVec((F32) mScreen.getWidth(), (F32) mScreen.getHeight()); + tc2.setVec((F32) mRT->screen.getWidth(), (F32) mRT->screen.getHeight()); gGL.flush(); @@ -7634,18 +7640,18 @@ void LLPipeline::renderFinalize() if (LLPipeline::sRenderDeferred) { - bool dof_enabled = !LLViewerCamera::getInstance()->cameraUnderWater() && (RenderDepthOfFieldInEditMode || !LLToolMgr::getInstance()->inBuildMode()) && RenderDepthOfField && !gCubeSnapshot; - bool multisample = RenderFSAASamples > 1 && mFXAABuffer.isComplete(); + bool multisample = RenderFSAASamples > 1 && mRT->fxaaBuffer.isComplete(); gViewerWindow->setup3DViewport(); if (dof_enabled) { + LL_PROFILE_GPU_ZONE("dof"); LLGLSLShader *shader = &gDeferredPostProgram; LLGLDisable blend(GL_BLEND); @@ -7730,7 +7736,7 @@ void LLPipeline::renderFinalize() const F32 default_fov = CameraFieldOfView * F_PI / 180.f; - // F32 aspect_ratio = (F32) mScreen.getWidth()/(F32)mScreen.getHeight(); + // F32 aspect_ratio = (F32) mRT->screen.getWidth()/(F32)mRT->screen.getHeight(); F32 dv = 2.f * default_focal_length * tanf(default_fov / 2.f); @@ -7750,15 +7756,15 @@ void LLPipeline::renderFinalize() F32 magnification = focal_length / (subject_distance - focal_length); { // build diffuse+bloom+CoF - mDeferredLight.bindTarget(); + mRT->deferredLight.bindTarget(); shader = &gDeferredCoFProgram; bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); if (channel > -1) { - mScreen.bindTexture(0, channel); + mRT->screen.bindTexture(0, channel); } shader->uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance / 1000.f); @@ -7781,23 +7787,23 @@ void LLPipeline::renderFinalize() gGL.end(); unbindDeferredShader(*shader); - mDeferredLight.flush(); + mRT->deferredLight.flush(); } - U32 dof_width = (U32)(mScreen.getWidth() * CameraDoFResScale); - U32 dof_height = (U32)(mScreen.getHeight() * CameraDoFResScale); + U32 dof_width = (U32)(mRT->screen.getWidth() * CameraDoFResScale); + U32 dof_height = (U32)(mRT->screen.getHeight() * CameraDoFResScale); { // perform DoF sampling at half-res (preserve alpha channel) - mScreen.bindTarget(); + mRT->screen.bindTarget(); glViewport(0, 0, dof_width, dof_height); gGL.setColorMask(true, false); shader = &gDeferredPostProgram; bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredLight.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); if (channel > -1) { - mDeferredLight.bindTexture(0, channel); + mRT->deferredLight.bindTexture(0, channel); } shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); @@ -7816,15 +7822,15 @@ void LLPipeline::renderFinalize() gGL.end(); unbindDeferredShader(*shader); - mScreen.flush(); + mRT->screen.flush(); gGL.setColorMask(true, true); } { // combine result based on alpha if (multisample) { - mDeferredLight.bindTarget(); - glViewport(0, 0, mDeferredScreen.getWidth(), mDeferredScreen.getHeight()); + mRT->deferredLight.bindTarget(); + glViewport(0, 0, mRT->deferredScreen.getWidth(), mRT->deferredScreen.getHeight()); } else { @@ -7838,10 +7844,10 @@ void LLPipeline::renderFinalize() shader = &gDeferredDoFCombineProgram; bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); if (channel > -1) { - mScreen.bindTexture(0, channel); + mRT->screen.bindTexture(0, channel); } shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); @@ -7865,24 +7871,25 @@ void LLPipeline::renderFinalize() if (multisample) { - mDeferredLight.flush(); + mRT->deferredLight.flush(); } } } else { + LL_PROFILE_GPU_ZONE("no dof"); if (multisample) { - mDeferredLight.bindTarget(); + mRT->deferredLight.bindTarget(); } LLGLSLShader *shader = &gDeferredPostNoDoFProgram; bindDeferredShader(*shader); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->screen.getUsage()); if (channel > -1) { - mScreen.bindTexture(0, channel); + mRT->screen.bindTexture(0, channel); } gGL.begin(LLRender::TRIANGLE_STRIP); @@ -7901,17 +7908,18 @@ void LLPipeline::renderFinalize() if (multisample) { - mDeferredLight.flush(); + mRT->deferredLight.flush(); } } if (multisample) { + LL_PROFILE_GPU_ZONE("aa"); // bake out texture2D with RGBL for FXAA shader - mFXAABuffer.bindTarget(); + mRT->fxaaBuffer.bindTarget(); - S32 width = mScreen.getWidth(); - S32 height = mScreen.getHeight(); + S32 width = mRT->screen.getWidth(); + S32 height = mRT->screen.getHeight(); glViewport(0, 0, width, height); LLGLSLShader *shader = &gGlowCombineFXAAProgram; @@ -7919,10 +7927,10 @@ void LLPipeline::renderFinalize() shader->bind(); shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, width, height); - S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredLight.getUsage()); + S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); if (channel > -1) { - mDeferredLight.bindTexture(0, channel); + mRT->deferredLight.bindTexture(0, channel); } gGL.begin(LLRender::TRIANGLE_STRIP); @@ -7933,18 +7941,18 @@ void LLPipeline::renderFinalize() gGL.flush(); - shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredLight.getUsage()); + shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mRT->deferredLight.getUsage()); shader->unbind(); - mFXAABuffer.flush(); + mRT->fxaaBuffer.flush(); shader = &gFXAAProgram; shader->bind(); - channel = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP, mFXAABuffer.getUsage()); + channel = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP, mRT->fxaaBuffer.getUsage()); if (channel > -1) { - mFXAABuffer.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + mRT->fxaaBuffer.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; @@ -7953,8 +7961,8 @@ void LLPipeline::renderFinalize() gGLViewport[3] = gViewerWindow->getWorldViewRectRaw().getHeight(); glViewport(gGLViewport[0], gGLViewport[1], gGLViewport[2], gGLViewport[3]); - F32 scale_x = (F32) width / mFXAABuffer.getWidth(); - F32 scale_y = (F32) height / mFXAABuffer.getHeight(); + F32 scale_x = (F32) width / mRT->fxaaBuffer.getWidth(); + F32 scale_y = (F32) height / mRT->fxaaBuffer.getHeight(); shader->uniform2f(LLShaderMgr::FXAA_TC_SCALE, scale_x, scale_y); shader->uniform2f(LLShaderMgr::FXAA_RCP_SCREEN_RES, 1.f / width * scale_x, 1.f / height * scale_y); shader->uniform4f(LLShaderMgr::FXAA_RCP_FRAME_OPT, -0.5f / width * scale_x, -0.5f / height * scale_y, @@ -8005,7 +8013,7 @@ void LLPipeline::renderFinalize() gGlowCombineProgram.bind(); gGL.getTexUnit(0)->bind(&mGlow[1]); - gGL.getTexUnit(1)->bind(&mScreen); + gGL.getTexUnit(1)->bind(&mRT->screen); LLGLEnable multisample(RenderFSAASamples > 0 ? GL_MULTISAMPLE_ARB : 0); @@ -8048,10 +8056,10 @@ void LLPipeline::renderFinalize() gSplatTextureRectProgram.unbind(); } - if (LLRenderTarget::sUseFBO) - { // copy depth buffer from mScreen to framebuffer - LLRenderTarget::copyContentsToFramebuffer(mScreen, 0, 0, mScreen.getWidth(), mScreen.getHeight(), 0, 0, - mScreen.getWidth(), mScreen.getHeight(), + if (LLRenderTarget::sUseFBO && !gCubeSnapshot) + { // copy depth buffer from mRT->screen to framebuffer + LLRenderTarget::copyContentsToFramebuffer(mRT->screen, 0, 0, mRT->screen.getWidth(), mRT->screen.getHeight(), 0, 0, + mRT->screen.getWidth(), mRT->screen.getHeight(), GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); } @@ -8069,10 +8077,10 @@ void LLPipeline::renderFinalize() void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_target) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; - - LLRenderTarget* deferred_target = &mDeferredScreen; - LLRenderTarget* deferred_depth_target = &mDeferredDepth; - LLRenderTarget* deferred_light_target = &mDeferredLight; + LL_PROFILE_GPU_ZONE("bindDeferredShader"); + LLRenderTarget* deferred_target = &mRT->deferredScreen; + LLRenderTarget* deferred_depth_target = &mRT->deferredDepth; + LLRenderTarget* deferred_light_target = &mRT->deferredLight; shader.bind(); S32 channel = 0; @@ -8304,8 +8312,8 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, mTransformedSunDir.mV); shader.uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, mTransformedMoonDir.mV); - shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mShadow[0].getWidth(), mShadow[0].getHeight()); - shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mShadow[4].getWidth(), mShadow[4].getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mRT->shadow[0].getWidth(), mRT->shadow[0].getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mRT->shadow[4].getWidth(), mRT->shadow[4].getHeight()); shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); @@ -8341,14 +8349,15 @@ LLVector4 pow4fsrgb(LLVector4 v, F32 f) void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + LL_PROFILE_GPU_ZONE("renderDeferredLighting"); if (!sCull) { return; } - LLRenderTarget *deferred_target = &mDeferredScreen; - LLRenderTarget *deferred_depth_target = &mDeferredDepth; - LLRenderTarget *deferred_light_target = &mDeferredLight; + LLRenderTarget *deferred_target = &mRT->deferredScreen; + LLRenderTarget *deferred_depth_target = &mRT->deferredDepth; + LLRenderTarget *deferred_light_target = &mRT->deferredLight; { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("deferred"); //LL_RECORD_BLOCK_TIME(FTM_RENDER_DEFERRED); @@ -8415,6 +8424,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) if (RenderDeferredSSAO || RenderShadowDetail > 0) { + LL_PROFILE_GPU_ZONE("sun program"); deferred_light_target->bindTarget(); { // paint shadow/SSAO light map (direct lighting lightmap) LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - sun shadow"); @@ -8475,6 +8485,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) { // soften direct lighting lightmap LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - soften shadow"); + LL_PROFILE_GPU_ZONE("soften shadow"); // blur lightmap screen_target->bindTarget(); glClearColor(1, 1, 1, 1); @@ -8554,6 +8565,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) LLGLSLShader &soften_shader = LLPipeline::sUnderWaterRender ? gDeferredSoftenWaterProgram : gDeferredSoftenProgram; LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - atmospherics"); + LL_PROFILE_GPU_ZONE("atmospherics"); bindDeferredShader(soften_shader); LLEnvironment &environment = LLEnvironment::instance(); @@ -8623,6 +8635,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - local lights"); + LL_PROFILE_GPU_ZONE("local lights"); bindDeferredShader(gDeferredLightProgram); if (mCubeVB.isNull()) @@ -8729,6 +8742,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) if (!spot_lights.empty()) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - projectors"); + LL_PROFILE_GPU_ZONE("projectors"); LLGLDepthTest depth(GL_TRUE, GL_FALSE); bindDeferredShader(gDeferredSpotLightProgram); @@ -8775,7 +8789,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) { LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("renderDeferredLighting - fullscreen lights"); LLGLDepthTest depth(GL_FALSE); - + LL_PROFILE_GPU_ZONE("fullscreen lights"); // full screen blit gGL.pushMatrix(); gGL.loadIdentity(); @@ -8871,6 +8885,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget *screen_target) gGL.loadIdentity(); { + LL_PROFILE_GPU_ZONE("gamma correct"); LLGLDepthTest depth(GL_FALSE, GL_FALSE); LLVector2 tc1(0, 0); @@ -9114,9 +9129,9 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) { - LLRenderTarget* deferred_target = &mDeferredScreen; - LLRenderTarget* deferred_depth_target = &mDeferredDepth; - LLRenderTarget* deferred_light_target = &mDeferredLight; + LLRenderTarget* deferred_target = &mRT->deferredScreen; + LLRenderTarget* deferred_depth_target = &mRT->deferredDepth; + LLRenderTarget* deferred_light_target = &mRT->deferredLight; stop_glerror(); shader.disableTexture(LLShaderMgr::DEFERRED_NORMAL, deferred_target->getUsage()); @@ -9653,7 +9668,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gDeferredShadowCubeProgram.bind(); } - LLRenderTarget& occlusion_target = mShadowOcclusion[LLViewerCamera::sCurCameraID - 1]; + LLRenderTarget& occlusion_target = mRT->shadowOcclusion[LLViewerCamera::sCurCameraID - 1]; occlusion_target.bindTarget(); updateCull(shadow_cam, result); @@ -9797,7 +9812,7 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); - LLRenderTarget& occlusion_source = mShadow[LLViewerCamera::sCurCameraID - 1]; + LLRenderTarget& occlusion_source = mRT->shadow[LLViewerCamera::sCurCameraID - 1]; if (occlude > 1) { @@ -10023,7 +10038,8 @@ void LLPipeline::generateHighlight(LLCamera& camera) { mHighlightSet.insert(HighlightItem(mHighlightObject)); } - + llassert(!gCubeSnapshot); + if (!mHighlightSet.empty()) { F32 transition = gFrameIntervalSeconds.value()/RenderHighlightFadeTime; @@ -10073,7 +10089,7 @@ void LLPipeline::generateHighlight(LLCamera& camera) LLRenderTarget* LLPipeline::getShadowTarget(U32 i) { - return &mShadow[i]; + return &mRT->shadow[i]; } static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW("Gen Sun Shadow"); @@ -10327,9 +10343,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) for (S32 j = 0; j < 4; j++) { - mShadow[j].bindTarget(); - mShadow[j].clear(); - mShadow[j].flush(); + mRT->shadow[j].bindTarget(); + mRT->shadow[j].clear(); + mRT->shadow[j].flush(); } } else @@ -10341,9 +10357,9 @@ void LLPipeline::generateSunShadow(LLCamera& camera) dist[1] = dist[2] = dist[3] = dist[4] = 64.f; for (S32 j = 1; j < 4; j++) { - mShadow[j].bindTarget(); - mShadow[j].clear(); - mShadow[j].flush(); + mRT->shadow[j].bindTarget(); + mRT->shadow[j].clear(); + mRT->shadow[j].flush(); } }*/ @@ -10409,12 +10425,12 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mShadowCamera[j+4] = shadow_cam; } - mShadow[j].bindTarget(); + mRT->shadow[j].bindTarget(); { LLGLDepthTest depth(GL_TRUE); - mShadow[j].clear(); + mRT->shadow[j].clear(); } - mShadow[j].flush(); + mRT->shadow[j].flush(); mShadowError.mV[j] = 0.f; mShadowFOV.mV[j] = 0.f; @@ -10701,18 +10717,18 @@ void LLPipeline::generateSunShadow(LLCamera& camera) stop_glerror(); - mShadow[j].bindTarget(); - mShadow[j].getViewport(gGLViewport); - mShadow[j].clear(); + mRT->shadow[j].bindTarget(); + mRT->shadow[j].getViewport(gGLViewport); + mRT->shadow[j].clear(); - U32 target_width = mShadow[j].getWidth(); + U32 target_width = mRT->shadow[j].getWidth(); { static LLCullResult result[4]; renderShadow(view[j], proj[j], shadow_cam, result[j], TRUE, FALSE, target_width); } - mShadow[j].flush(); + mRT->shadow[j].flush(); if (!gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_SHADOW_FRUSTA)) { @@ -10847,11 +10863,11 @@ void LLPipeline::generateSunShadow(LLCamera& camera) stop_glerror(); - mShadow[i + 4].bindTarget(); - mShadow[i + 4].getViewport(gGLViewport); - mShadow[i + 4].clear(); + mRT->shadow[i + 4].bindTarget(); + mRT->shadow[i + 4].getViewport(gGLViewport); + mRT->shadow[i + 4].clear(); - U32 target_width = mShadow[i + 4].getWidth(); + U32 target_width = mRT->shadow[i + 4].getWidth(); static LLCullResult result[2]; @@ -10863,7 +10879,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) RenderSpotLight = nullptr; - mShadow[i + 4].flush(); + mRT->shadow[i + 4].flush(); } } } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 5cbd1eb550..c0b55906d6 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -641,20 +641,31 @@ public: static LLTrace::EventStatHandle sStatBatchSize; - //screen texture - U32 mScreenWidth; - U32 mScreenHeight; - - LLRenderTarget mScreen; - LLRenderTarget mUIScreen; - LLRenderTarget mDeferredScreen; - LLRenderTarget mFXAABuffer; - LLRenderTarget mEdgeMap; - LLRenderTarget mDeferredDepth; - LLRenderTarget mOcclusionDepth; - LLRenderTarget mDeferredLight; - LLRenderTarget mHighlight; - LLRenderTarget mPhysicsDisplay; + class RenderTargetPack + { + public: + U32 width = 0; + U32 height = 0; + + //screen texture + LLRenderTarget screen; + LLRenderTarget uiScreen; + LLRenderTarget deferredScreen; + LLRenderTarget fxaaBuffer; + LLRenderTarget edgeMap; + LLRenderTarget deferredDepth; + LLRenderTarget occlusionDepth; + LLRenderTarget deferredLight; + + //sun shadow map + LLRenderTarget shadow[6]; + LLRenderTarget shadowOcclusion[6]; + }; + + RenderTargetPack* mRT; + + LLRenderTarget mHighlight; + LLRenderTarget mPhysicsDisplay; LLCullResult mSky; LLCullResult mReflectedObjects; @@ -669,9 +680,6 @@ public: //list of currently bound reflection maps std::vector mReflectionMaps; - //sun shadow map - LLRenderTarget mShadow[6]; - LLRenderTarget mShadowOcclusion[6]; std::vector mShadowFrustPoints[4]; LLVector4 mShadowError; LLVector4 mShadowFOV; -- cgit v1.3 From 220afbcda0961df86ad08bbd51d96b8c868b2e62 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 2 Jun 2022 18:42:38 -0500 Subject: SL-17285 Add proper reflection probe support to LLVOVolume, LLPrimitive, and LLPanelVolume --- indra/llprimitive/llprimitive.cpp | 95 +++++++++++++ indra/llprimitive/llprimitive.h | 44 ++++++ .../shaders/class3/deferred/reflectionProbeF.glsl | 21 ++- indra/newview/llpanelvolume.cpp | 100 +++++++++++++ indra/newview/llpanelvolume.h | 3 + indra/newview/llreflectionmap.cpp | 51 ++++--- indra/newview/llreflectionmap.h | 10 +- indra/newview/llreflectionmapmanager.cpp | 25 ++-- indra/newview/lltexturefetch.cpp | 1 + indra/newview/llviewerdisplay.cpp | 1 - indra/newview/llviewerobject.cpp | 5 + indra/newview/llviewerwindow.cpp | 3 +- indra/newview/llviewerwindow.h | 4 +- indra/newview/llvovolume.cpp | 157 ++++++++++++++++++--- indra/newview/llvovolume.h | 14 ++ .../newview/skins/default/xui/en/floater_tools.xml | 58 +++++++- 16 files changed, 519 insertions(+), 73 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index c46e5fb3c5..87a78eb447 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -81,6 +81,14 @@ const F32 LIGHT_MIN_CUTOFF = 0.0f; const F32 LIGHT_DEFAULT_CUTOFF = 0.0f; const F32 LIGHT_MAX_CUTOFF = 180.f; +// reflection probes +const F32 REFLECTION_PROBE_MIN_AMBIANCE = 0.f; +const F32 REFLECTION_PROBE_MAX_AMBIANCE = 1.f; +const F32 REFLECTION_PROBE_DEFAULT_AMBIANCE = 0.f; +const F32 REFLECTION_PROBE_MIN_CLIP_DISTANCE = 0.f; +const F32 REFLECTION_PROBE_MAX_CLIP_DISTANCE = 1024.f; +const F32 REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE = 0.f; + // "Tension" => [0,10], increments of 0.1 const F32 FLEXIBLE_OBJECT_MIN_TENSION = 0.0f; const F32 FLEXIBLE_OBJECT_DEFAULT_TENSION = 1.0f; @@ -1811,6 +1819,93 @@ bool LLLightParams::fromLLSD(LLSD& sd) //============================================================================ +LLReflectionProbeParams::LLReflectionProbeParams() +{ + mType = PARAMS_REFLECTION_PROBE; +} + +BOOL LLReflectionProbeParams::pack(LLDataPacker& dp) const +{ + dp.packF32(mAmbiance, "ambiance"); + dp.packF32(mClipDistance, "clip_distance"); + dp.packU8(mVolumeType, "volume_type"); + return TRUE; +} + +BOOL LLReflectionProbeParams::unpack(LLDataPacker& dp) +{ + F32 ambiance; + F32 clip_distance; + U8 volume_type; + + dp.unpackF32(ambiance, "ambiance"); + setAmbiance(ambiance); + + dp.unpackF32(clip_distance, "clip_distance"); + setClipDistance(clip_distance); + + dp.unpackU8(volume_type, "volume_type"); + setVolumeType((EInfluenceVolumeType)volume_type); + + return TRUE; +} + +bool LLReflectionProbeParams::operator==(const LLNetworkData& data) const +{ + if (data.mType != PARAMS_REFLECTION_PROBE) + { + return false; + } + const LLReflectionProbeParams* param = (const LLReflectionProbeParams*)&data; + if (param->mAmbiance != mAmbiance) + { + return false; + } + if (param->mClipDistance != mClipDistance) + { + return false; + } + if (param->mVolumeType != mVolumeType) + { + return false; + } + return true; +} + +void LLReflectionProbeParams::copy(const LLNetworkData& data) +{ + const LLReflectionProbeParams* param = (LLReflectionProbeParams*)&data; + mType = param->mType; + mAmbiance = param->mAmbiance; + mClipDistance = param->mClipDistance; + mVolumeType = param->mVolumeType; +} + +LLSD LLReflectionProbeParams::asLLSD() const +{ + LLSD sd; + sd["ambiance"] = getAmbiance(); + sd["clip_distance"] = getClipDistance(); + sd["volume_type"] = getVolumeType(); + return sd; +} + +bool LLReflectionProbeParams::fromLLSD(LLSD& sd) +{ + if (!sd.has("ambiance") || + !sd.has("clip_distance") || + !sd.has("volume_type")) + { + return false; + } + + setAmbiance((F32)sd["ambiance"].asReal()); + setClipDistance((F32)sd["clip_distance"].asReal()); + setVolumeType((EInfluenceVolumeType)sd["volume_type"].asInteger()); + + return true; +} +//============================================================================ LLFlexibleObjectData::LLFlexibleObjectData() { mSimulateLOD = FLEXIBLE_OBJECT_DEFAULT_NUM_SECTIONS; diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index e23ddd2916..2215133e16 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -108,6 +108,7 @@ public: PARAMS_MESH = 0x60, PARAMS_EXTENDED_MESH = 0x70, PARAMS_RENDER_MATERIAL = 0x80, + PARAMS_REFLECTION_PROBE = 0x90, }; public: @@ -171,6 +172,49 @@ public: F32 getCutoff() const { return mCutoff; } }; +extern const F32 REFLECTION_PROBE_MIN_AMBIANCE; +extern const F32 REFLECTION_PROBE_MAX_AMBIANCE; +extern const F32 REFLECTION_PROBE_DEFAULT_AMBIANCE; +extern const F32 REFLECTION_PROBE_MIN_CLIP_DISTANCE; +extern const F32 REFLECTION_PROBE_MAX_CLIP_DISTANCE; +extern const F32 REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE; + +class LLReflectionProbeParams : public LLNetworkData +{ +public: + enum EInfluenceVolumeType : U8 + { + VOLUME_TYPE_SPHERE = 0, // use a sphere influence volume + VOLUME_TYPE_BOX = 1, // use a box influence volume + DEFAULT_VOLUME_TYPE = VOLUME_TYPE_SPHERE + }; + +protected: + F32 mAmbiance = REFLECTION_PROBE_DEFAULT_AMBIANCE; + F32 mClipDistance = REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE; + EInfluenceVolumeType mVolumeType = DEFAULT_VOLUME_TYPE; + +public: + LLReflectionProbeParams(); + /*virtual*/ BOOL pack(LLDataPacker& dp) const; + /*virtual*/ BOOL unpack(LLDataPacker& dp); + /*virtual*/ bool operator==(const LLNetworkData& data) const; + /*virtual*/ void copy(const LLNetworkData& data); + // LLSD implementations here are provided by Eddy Stryker. + // NOTE: there are currently unused in protocols + LLSD asLLSD() const; + operator LLSD() const { return asLLSD(); } + bool fromLLSD(LLSD& sd); + + void setAmbiance(F32 ambiance) { mAmbiance = llclamp(ambiance, REFLECTION_PROBE_MIN_AMBIANCE, REFLECTION_PROBE_MAX_AMBIANCE); } + void setClipDistance(F32 distance) { mClipDistance = llclamp(distance, REFLECTION_PROBE_MIN_CLIP_DISTANCE, REFLECTION_PROBE_MAX_CLIP_DISTANCE); } + void setVolumeType(EInfluenceVolumeType type) { mVolumeType = llclamp(type, VOLUME_TYPE_SPHERE, VOLUME_TYPE_BOX); } + + F32 getAmbiance() const { return mAmbiance; } + F32 getClipDistance() const { return mClipDistance; } + EInfluenceVolumeType getVolumeType() const { return mVolumeType; } +}; + //------------------------------------------------- // This structure is also used in the part of the // code that creates new flexible objects. diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 8c1323ba1a..eb9d3f485b 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -1,5 +1,5 @@ /** - * @file class2/deferred/reflectionProbeF.glsl + * @file class3/deferred/reflectionProbeF.glsl * * $LicenseInfo:firstyear=2022&license=viewerlgpl$ * Second Life Viewer Source Code @@ -42,6 +42,8 @@ layout (std140, binding = 1) uniform ReflectionProbes mat4 refBox[REFMAP_COUNT]; // list of bounding spheres for reflection probes sorted by distance to camera (closest first) vec4 refSphere[REFMAP_COUNT]; + // extra parameters (currently only .x used for probe ambiance) + vec4 refParams[REFMAP_COUNT]; // index of cube map in reflectionProbes for a corresponding reflection probe // e.g. cube map channel of refSphere[2] is stored in refIndex[2] // refIndex.x - cubemap channel in reflectionProbes @@ -55,9 +57,6 @@ layout (std140, binding = 1) uniform ReflectionProbes // number of reflection probes present in refSphere int refmapCount; - - // intensity of ambient light from reflection probes - float reflectionAmbiance; }; // Inputs @@ -335,7 +334,7 @@ vec3 tapRefMap(vec3 pos, vec3 dir, float lod, vec3 c, float r2, int i) } } -vec3 sampleProbes(vec3 pos, vec3 dir, float lod) +vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) { float wsum = 0.0; vec3 col = vec3(0,0,0); @@ -360,7 +359,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod) float atten = 1.0-max(d2-r2, 0.0)/(rr-r2); w *= atten; w *= p; // boost weight based on priority - col += refcol*w; + col += refcol*w*max(minweight, refParams[i].x); wsum += w; } @@ -383,7 +382,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod) float w = 1.0/d2; w *= w; - col += refcol*w; + col += refcol*w*max(minweight, refParams[i].x); wsum += w; } } @@ -399,7 +398,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod) vec3 sampleProbeAmbient(vec3 pos, vec3 dir, float lod) { - vec3 col = sampleProbes(pos, dir, lod); + vec3 col = sampleProbes(pos, dir, lod, 0.f); //desaturate vec3 hcol = col *0.5; @@ -413,7 +412,7 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir, float lod) col *= 0.333333; - return col*reflectionAmbiance; + return col; } @@ -445,12 +444,12 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, inout vec3 l if (glossiness > 0.0) { float lod = (1.0-glossiness)*reflection_lods; - glossenv = sampleProbes(pos, normalize(refnormpersp), lod); + glossenv = sampleProbes(pos, normalize(refnormpersp), lod, 1.f); } if (envIntensity > 0.0) { - legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0); + legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0, 1.f); } } diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index 89c558e4f8..e7bbe266e5 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -145,6 +145,16 @@ BOOL LLPanelVolume::postBuild() getChild("Light Ambiance")->setValidateBeforeCommit( precommitValidate); } + // REFLECTION PROBE Parameters + { + childSetCommitCallback("Reflection Probe Checkbox Ctrl", onCommitIsReflectionProbe, this); + childSetCommitCallback("Probe Shape Type Combo Ctrl", onCommitProbe, this); + childSetCommitCallback("Probe Ambiance", onCommitProbe, this); + childSetCommitCallback("Probe Near Clip", onCommitProbe, this); + + + } + // PHYSICS Parameters { // PhysicsShapeType combobox @@ -360,6 +370,40 @@ void LLPanelVolume::getState( ) getChildView("Light Ambiance")->setEnabled(false); } + // Reflection Probe + BOOL is_probe = volobjp && volobjp->getIsReflectionProbe(); + getChild("Reflection Probe Checkbox Ctrl")->setValue(is_probe); + getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp); + + bool probe_enabled = is_probe && editable && single_volume; + + getChildView("Probe Volume Type Ctrl")->setEnabled(probe_enabled); + getChildView("Probe Ambiance")->setEnabled(probe_enabled); + getChildView("Probe Near Clip")->setEnabled(probe_enabled); + + if (!probe_enabled) + { + getChild("Probe Volume Type Ctrl", true)->clear(); + getChild("Probe Ambiance", true)->clear(); + getChild("Probe Near Clip", true)->clear(); + } + else + { + std::string volume_type; + if (volobjp->getReflectionProbeVolumeType() == LLReflectionProbeParams::VOLUME_TYPE_BOX) + { + volume_type = "Box"; + } + else + { + volume_type = "Sphere"; + } + + getChild("Probe Volume Type Ctrl", true)->setValue(volume_type); + getChild("Probe Ambiance", true)->setValue(volobjp->getReflectionProbeAmbiance()); + getChild("Probe Near Clip", true)->setValue(volobjp->getReflectionProbeNearClip()); + } + // Animated Mesh BOOL is_animated_mesh = single_root_volume && root_volobjp && root_volobjp->isAnimatedObject(); getChild("Animated Mesh Checkbox Ctrl")->setValue(is_animated_mesh); @@ -647,6 +691,10 @@ void LLPanelVolume::clearCtrls() getChildView("Light Radius")->setEnabled(false); getChildView("Light Falloff")->setEnabled(false); + getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(false);; + getChildView("Probe Volume Type Ctrl")->setEnabled(false); + getChildView("Probe Ambiance")->setEnabled(false); + getChildView("Probe Near Clip")->setEnabled(false); getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(false); getChildView("Flexible1D Checkbox Ctrl")->setEnabled(false); getChildView("FlexNumSections")->setEnabled(false); @@ -684,6 +732,20 @@ void LLPanelVolume::sendIsLight() LL_INFOS() << "update light sent" << LL_ENDL; } +void LLPanelVolume::sendIsReflectionProbe() +{ + LLViewerObject* objectp = mObject; + if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME)) + { + return; + } + LLVOVolume* volobjp = (LLVOVolume*)objectp; + + BOOL value = getChild("Reflection Probe Checkbox Ctrl")->getValue(); + volobjp->setIsReflectionProbe(value); + LL_INFOS() << "update reflection probe sent" << LL_ENDL; +} + void LLPanelVolume::sendIsFlexible() { LLViewerObject* objectp = mObject; @@ -927,6 +989,35 @@ void LLPanelVolume::onCommitLight( LLUICtrl* ctrl, void* userdata ) } +//static +void LLPanelVolume::onCommitProbe(LLUICtrl* ctrl, void* userdata) +{ + LLPanelVolume* self = (LLPanelVolume*)userdata; + LLViewerObject* objectp = self->mObject; + if (!objectp || (objectp->getPCode() != LL_PCODE_VOLUME)) + { + return; + } + LLVOVolume* volobjp = (LLVOVolume*)objectp; + + + volobjp->setReflectionProbeAmbiance((F32)self->getChild("Probe Ambiance")->getValue().asReal()); + volobjp->setReflectionProbeNearClip((F32)self->getChild("Probe Near Clip")->getValue().asReal()); + + std::string shape_type = self->getChild("Probe Volume Type Ctrl")->getValue().asString(); + LLReflectionProbeParams::EInfluenceVolumeType volume_type = LLReflectionProbeParams::DEFAULT_VOLUME_TYPE; + + if (shape_type == "Sphere") + { + volume_type = LLReflectionProbeParams::VOLUME_TYPE_SPHERE; + } + else if (shape_type == "Box") + { + volume_type = LLReflectionProbeParams::VOLUME_TYPE_BOX; + } + volobjp->setReflectionProbeVolumeType(volume_type); +} + // static void LLPanelVolume::onCommitIsLight( LLUICtrl* ctrl, void* userdata ) { @@ -949,6 +1040,15 @@ void LLPanelVolume::setLightTextureID(const LLUUID &asset_id, const LLUUID &item } //---------------------------------------------------------------------------- +// static +void LLPanelVolume::onCommitIsReflectionProbe(LLUICtrl* ctrl, void* userdata) +{ + LLPanelVolume* self = (LLPanelVolume*)userdata; + self->sendIsReflectionProbe(); +} + +//---------------------------------------------------------------------------- + // static void LLPanelVolume::onCommitFlexible( LLUICtrl* ctrl, void* userdata ) { diff --git a/indra/newview/llpanelvolume.h b/indra/newview/llpanelvolume.h index 6e49ccb742..16d9ac292d 100644 --- a/indra/newview/llpanelvolume.h +++ b/indra/newview/llpanelvolume.h @@ -56,12 +56,15 @@ public: void refresh(); void sendIsLight(); + void sendIsReflectionProbe(); void sendIsFlexible(); static bool precommitValidate(const LLSD& data); static void onCommitIsLight( LLUICtrl* ctrl, void* userdata); static void onCommitLight( LLUICtrl* ctrl, void* userdata); + static void onCommitIsReflectionProbe(LLUICtrl* ctrl, void* userdata); + static void onCommitProbe(LLUICtrl* ctrl, void* userdata); void onCommitIsFlexible( LLUICtrl* ctrl, void* userdata); static void onCommitFlexible( LLUICtrl* ctrl, void* userdata); void onCommitAnimatedMeshCheckbox(LLUICtrl* ctrl, void* userdata); diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 54a627efd4..f8a2020ccb 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -35,7 +35,6 @@ extern F32SecondsImplicit gFrameTimeSeconds; LLReflectionMap::LLReflectionMap() { - mLastUpdateTime = gFrameTimeSeconds; } void LLReflectionMap::update(U32 resolution, U32 face) @@ -52,7 +51,7 @@ void LLReflectionMap::update(U32 resolution, U32 face) { resolution /= 2; } - gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face); + gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip()); } bool LLReflectionMap::shouldUpdate() @@ -215,6 +214,35 @@ bool LLReflectionMap::intersects(LLReflectionMap* other) return dist < r2; } +extern LLControlGroup gSavedSettings; + +F32 LLReflectionMap::getAmbiance() +{ + static LLCachedControl minimum_ambiance(gSavedSettings, "RenderReflectionProbeAmbiance", 0.f); + + F32 ret = 0.f; + if (mViewerObject && mViewerObject->getVolume()) + { + ret = ((LLVOVolume*)mViewerObject)->getReflectionProbeAmbiance(); + } + + return llmax(ret, minimum_ambiance()); +} + +F32 LLReflectionMap::getNearClip() +{ + const F32 MINIMUM_NEAR_CLIP = 0.1f; + + F32 ret = 0.f; + + if (mViewerObject && mViewerObject->getVolume()) + { + ret = ((LLVOVolume*)mViewerObject)->getReflectionProbeNearClip(); + } + + return llmax(ret, MINIMUM_NEAR_CLIP); +} + bool LLReflectionMap::getBox(LLMatrix4& box) { if (mViewerObject) @@ -224,25 +252,8 @@ bool LLReflectionMap::getBox(LLMatrix4& box) { LLVOVolume* vobjp = (LLVOVolume*)mViewerObject; - U8 profile = volume->getProfileType(); - U8 path = volume->getPathType(); - - if (profile == LL_PCODE_PROFILE_SQUARE && - path == LL_PCODE_PATH_LINE) + if (vobjp->getReflectionProbeVolumeType() == LLReflectionProbeParams::VOLUME_TYPE_BOX) { - // nope - /*box = vobjp->getRelativeXform(); - box *= vobjp->mDrawable->getRenderMatrix(); - LLMatrix4 modelview(gGLModelView); - box *= modelview; - box.invert();*/ - - // nope - /*box = LLMatrix4(gGLModelView); - box *= vobjp->mDrawable->getRenderMatrix(); - box *= vobjp->getRelativeXform(); - box.invert();*/ - glh::matrix4f mv(gGLModelView); glh::matrix4f scale; LLVector3 s = vobjp->getScale().scaledVec(LLVector3(0.5f, 0.5f, 0.5f)); diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index 4f0f124118..a358bf5fdf 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -55,9 +55,15 @@ public: // return true if given Reflection Map's influence volume intersect's with this one's bool intersects(LLReflectionMap* other); + // Get the ambiance value to use for this probe + F32 getAmbiance(); + + // Get the near clip plane distance to use for this probe + F32 getNearClip(); + // get the encoded bounding box of this probe's influence volume - // will only return a box if this probe has a volume with a square - // profile and a linear path + // will only return a box if this probe is associated with a VOVolume + // with its reflection probe influence volume to to VOLUME_TYPE_BOX // return false if no bounding box (treat as sphere influence volume) bool getBox(LLMatrix4& box); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 34055653d4..60396b6c60 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -127,18 +127,12 @@ void LLReflectionMapManager::update() camera_pos.load3(LLViewerCamera::instance().getOrigin().mV); // process kill list - for (int i = 0; i < mProbes.size(); ) + for (auto& probe : mKillList) { - auto& iter = std::find(mKillList.begin(), mKillList.end(), mProbes[i]); - if (iter != mKillList.end()) + auto& iter = std::find(mProbes.begin(), mProbes.end(), probe); + if (iter != mProbes.end()) { - deleteProbe(i); - mProbes.erase(mProbes.begin() + i); - mKillList.erase(iter); - } - else - { - ++i; + deleteProbe(iter - mProbes.begin()); } } @@ -275,7 +269,7 @@ LLReflectionMap* LLReflectionMapManager::registerSpatialGroup(LLSpatialGroup* gr { OctreeNode* node = group->getOctreeNode(); F32 size = node->getSize().getF32ptr()[0]; - if (size >= 7.f && size <= 17.f) + if (size >= 15.f && size <= 17.f) { return addProbe(group); } @@ -514,15 +508,15 @@ void LLReflectionMapManager::updateUniforms() LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; // structure for packing uniform buffer object - // see class2/deferred/softenLightF.glsl + // see class3/deferred/reflectionProbeF.glsl struct ReflectionProbeData { LLMatrix4 refBox[LL_REFLECTION_PROBE_COUNT]; // object bounding box as needed LLVector4 refSphere[LL_REFLECTION_PROBE_COUNT]; //origin and radius of refmaps in clip space + LLVector4 refParams[LL_REFLECTION_PROBE_COUNT]; //extra parameters (currently only ambiance) GLint refIndex[LL_REFLECTION_PROBE_COUNT][4]; GLint refNeighbor[4096]; GLint refmapCount; - GLfloat reflectionAmbiance; }; mReflectionMaps.resize(LL_REFLECTION_PROBE_COUNT); @@ -530,9 +524,6 @@ void LLReflectionMapManager::updateUniforms() ReflectionProbeData rpd; - static LLCachedControl ambiance(gSavedSettings, "RenderReflectionProbeAmbiance", 0.f); - rpd.reflectionAmbiance = ambiance; - // load modelview matrix into matrix 4a LLMatrix4a modelview; modelview.loadu(gGLModelView); @@ -573,6 +564,8 @@ void LLReflectionMapManager::updateUniforms() rpd.refIndex[count][3] = -rpd.refIndex[count][3]; } + rpd.refParams[count].set(refmap->getAmbiance(), 0.f, 0.f, 0.f); + S32 ni = nc; // neighbor ("index") - index into refNeighbor to write indices for current reflection probe's neighbors { //LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmsu - refNeighbors"); diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 0edaf40c66..35e4bb03ac 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -3400,6 +3400,7 @@ void LLTextureFetch::sendRequestListToSimulators() gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); } S32 packet = req->mLastPacket + 1; + LL_INFOS() << req->mID << ": " << req->mImagePriority << LL_ENDL; gMessageSystem->nextBlockFast(_PREHASH_RequestImage); gMessageSystem->addUUIDFast(_PREHASH_Image, req->mID); gMessageSystem->addS8Fast(_PREHASH_DiscardLevel, (S8)req->mDesiredDiscard); diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 1b8e53e667..6d98d9b10e 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -1082,7 +1082,6 @@ void display_cube_face() gPipeline.mBackfaceCull = TRUE; - LLViewerCamera::getInstance()->setNear(MIN_NEAR_PLANE); gViewerWindow->setup3DViewport(); if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 6ecf9dd0c4..732beab448 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -6028,6 +6028,11 @@ LLViewerObject::ExtraParameter* LLViewerObject::createNewParameterEntry(U16 para { new_block = new LLRenderMaterialParams(); break; + } + case LLNetworkData::PARAMS_REFLECTION_PROBE: + { + new_block = new LLReflectionProbeParams(); + break; } default: { diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index a6597e3233..6a60671040 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5270,7 +5270,7 @@ BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_ void display_cube_face(); -BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face) +BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face, F32 near_clip) { // NOTE: implementation derived from LLFloater360Capture::capture360Images() and simpleSnapshot LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; @@ -5299,6 +5299,7 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubea camera->setView(F_PI_BY_TWO); camera->yaw(0.0); camera->setOrigin(origin); + camera->setNear(near_clip); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index ac7f8b2e39..c9cf7da8c7 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -368,7 +368,9 @@ public: // origin - vantage point to take the snapshot from // cubearray - cubemap array for storing the results // index - cube index in the array to use (cube index, not face-layer) - BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face); + // face - which cube face to update + // near_clip - near clip setting to use + BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face, F32 near_clip); // special implementation of simpleSnapshot for reflection maps diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 784c0350fc..6aef9ee7c0 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -985,7 +985,12 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) // Add it to the pipeline mLightSet gPipeline.setLight(mDrawable, TRUE); } - + + if (getIsReflectionProbe()) + { + updateReflectionProbePtr(); + } + updateRadius(); bool force_update = true; // avoid non-alpha mDistance update being optimized away mDrawable->updateDistance(*LLViewerCamera::getInstance(), force_update); @@ -3496,6 +3501,121 @@ F32 LLVOVolume::getLightCutoff() const } } +void LLVOVolume::setIsReflectionProbe(BOOL is_probe) +{ + BOOL was_probe = getIsReflectionProbe(); + if (is_probe != was_probe) + { + if (is_probe) + { + setParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE, TRUE, true); + } + else + { + setParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE, FALSE, true); + } + } + + updateReflectionProbePtr(); +} + +void LLVOVolume::setReflectionProbeAmbiance(F32 ambiance) +{ + LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getAmbiance() != ambiance) + { + param_block->setAmbiance(ambiance); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + } + } +} + +void LLVOVolume::setReflectionProbeNearClip(F32 near_clip) +{ + LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getClipDistance() != near_clip) + { + param_block->setClipDistance(near_clip); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + } + } +} + +void LLVOVolume::setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type) +{ + LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getVolumeType() != volume_type) + { + param_block->setVolumeType(volume_type); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + } + } +} + + +BOOL LLVOVolume::getIsReflectionProbe() const +{ + // HACK - make this object a Reflection Probe if a certain UUID is detected + static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); + LLUUID probe_id(reflection_probe_id); + + for (U8 i = 0; i < getNumTEs(); ++i) + { + if (getTE(i)->getID() == probe_id) + { + return true; + } + } + // END HACK + + return getParameterEntryInUse(LLNetworkData::PARAMS_REFLECTION_PROBE); +} + +F32 LLVOVolume::getReflectionProbeAmbiance() const +{ + const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + return param_block->getAmbiance(); + } + else + { + return 0.f; + } +} + +F32 LLVOVolume::getReflectionProbeNearClip() const +{ + const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + return param_block->getClipDistance(); + } + else + { + return 0.f; + } +} + +LLReflectionProbeParams::EInfluenceVolumeType LLVOVolume::getReflectionProbeVolumeType() const +{ + const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + return param_block->getVolumeType(); + } + else + { + return LLReflectionProbeParams::DEFAULT_VOLUME_TYPE; + } +} + U32 LLVOVolume::getVolumeInterfaceID() const { if (mVolumeImpl) @@ -4381,6 +4501,23 @@ void LLVOVolume::parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_u gPipeline.setLight(mDrawable, is_light); } } + + updateReflectionProbePtr(); +} + +void LLVOVolume::updateReflectionProbePtr() +{ + if (getIsReflectionProbe()) + { + if (mReflectionProbe.isNull()) + { + mReflectionProbe = gPipeline.mReflectionMapManager.registerViewerObject(this); + } + } + else if (mReflectionProbe.notNull()) + { + mReflectionProbe = nullptr; + } } void LLVOVolume::setSelected(BOOL sel) @@ -5690,24 +5827,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) bool is_pbr = false; #endif - // HACK - make this object a Reflection Probe if a certain UUID is detected - static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); - if (facep->getTextureEntry()->getID() == LLUUID(reflection_probe_id)) - { - if (!vobj->mIsReflectionProbe) - { - vobj->mIsReflectionProbe = true; - vobj->mReflectionProbe = gPipeline.mReflectionMapManager.registerViewerObject(vobj); - } - } - else - { - // not a refleciton probe any more - vobj->mIsReflectionProbe = false; - vobj->mReflectionProbe = nullptr; - } - // END HACK - //ALWAYS null out vertex buffer on rebuild -- if the face lands in a render // batch, it will recover its vertex buffer reference from the spatial group facep->setVertexBuffer(NULL); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 4cb7a5481c..93a10781c2 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -178,6 +178,9 @@ public: /*virtual*/ void parameterChanged(U16 param_type, bool local_origin); /*virtual*/ void parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_use, bool local_origin); + // update mReflectionProbe based on isReflectionProbe() + void updateReflectionProbePtr(); + /*virtual*/ U32 processUpdateMessage(LLMessageSystem *mesgsys, void **user_data, U32 block_num, const EObjectUpdateType update_type, @@ -281,6 +284,17 @@ public: F32 getLightFalloff(const F32 fudge_factor = 1.f) const; F32 getLightCutoff() const; + // Reflection Probes + void setIsReflectionProbe(BOOL is_probe); + void setReflectionProbeAmbiance(F32 ambiance); + void setReflectionProbeNearClip(F32 near_clip); + void setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type); + + BOOL getIsReflectionProbe() const; + F32 getReflectionProbeAmbiance() const; + F32 getReflectionProbeNearClip() const; + LLReflectionProbeParams::EInfluenceVolumeType getReflectionProbeVolumeType() const; + // Flexible Objects U32 getVolumeInterfaceID() const; virtual BOOL isFlexible() const; diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 44bdcd86f9..ae4eb64264 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -2353,7 +2353,7 @@ even though the user gets a free copy. layout="topleft" left="10" name="Light Intensity" - top_pad="3" + top_delta="32" width="128" /> - + + + + + + + Date: Thu, 9 Jun 2022 14:09:33 -0500 Subject: SL-17551 Add "Select Reflection Probes" menu option and make invisible objects less annoying when alt-zooming in edit mode. --- indra/newview/app_settings/settings.xml | 11 ++++++++ indra/newview/llcontrolavatar.cpp | 5 ++-- indra/newview/llcontrolavatar.h | 1 + indra/newview/llpanelvolume.cpp | 2 +- indra/newview/llreflectionmap.cpp | 2 +- indra/newview/llselectmgr.cpp | 8 +++--- indra/newview/llspatialpartition.cpp | 16 +++++++----- indra/newview/llspatialpartition.h | 2 ++ indra/newview/lltoolselect.cpp | 5 +++- indra/newview/llviewermenu.cpp | 13 ++++++++++ indra/newview/llviewerobject.cpp | 13 +--------- indra/newview/llviewerobject.h | 6 ++--- indra/newview/llviewerobjectlist.cpp | 6 +++++ indra/newview/llviewerwindow.cpp | 29 ++++++++++------------ indra/newview/llviewerwindow.h | 3 ++- indra/newview/llvoavatar.cpp | 4 ++- indra/newview/llvoavatar.h | 2 ++ indra/newview/llvograss.cpp | 2 +- indra/newview/llvograss.h | 1 + indra/newview/llvopartgroup.cpp | 1 + indra/newview/llvopartgroup.h | 1 + indra/newview/llvosurfacepatch.cpp | 2 +- indra/newview/llvosurfacepatch.h | 1 + indra/newview/llvotree.cpp | 2 +- indra/newview/llvotree.h | 1 + indra/newview/llvovolume.cpp | 18 ++++++++++---- indra/newview/llvovolume.h | 3 ++- indra/newview/pipeline.cpp | 11 ++++---- indra/newview/pipeline.h | 1 + indra/newview/skins/default/xui/en/menu_viewer.xml | 9 +++++++ 30 files changed, 120 insertions(+), 61 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index f6c5d46c33..6df71e1019 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11191,6 +11191,17 @@ Value 0 + SelectReflectionProbes + + Comment + Select reflection probes + Persist + 1 + Type + Boolean + Value + 1 + SelectOwnedOnly Comment diff --git a/indra/newview/llcontrolavatar.cpp b/indra/newview/llcontrolavatar.cpp index 4a87273372..d4d4f641cf 100644 --- a/indra/newview/llcontrolavatar.cpp +++ b/indra/newview/llcontrolavatar.cpp @@ -610,6 +610,7 @@ LLViewerObject* LLControlAvatar::lineSegmentIntersectRiggedAttachments(const LLV S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, @@ -627,7 +628,7 @@ LLViewerObject* LLControlAvatar::lineSegmentIntersectRiggedAttachments(const LLV { LLVector4a local_end = end; LLVector4a local_intersection; - if (mRootVolp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, face_hit, &local_intersection, tex_coord, normal, tangent)) + if (mRootVolp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, pick_unselectable, face_hit, &local_intersection, tex_coord, normal, tangent)) { local_end = local_intersection; if (intersection) @@ -644,7 +645,7 @@ LLViewerObject* LLControlAvatar::lineSegmentIntersectRiggedAttachments(const LLV for (std::vector::iterator vol_it = volumes.begin(); vol_it != volumes.end(); ++vol_it) { LLVOVolume *volp = *vol_it; - if (mRootVolp != volp && volp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, face_hit, &local_intersection, tex_coord, normal, tangent)) + if (mRootVolp != volp && volp->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, pick_unselectable, face_hit, &local_intersection, tex_coord, normal, tangent)) { local_end = local_intersection; if (intersection) diff --git a/indra/newview/llcontrolavatar.h b/indra/newview/llcontrolavatar.h index 8e87299f3e..ea91d70e69 100644 --- a/indra/newview/llcontrolavatar.h +++ b/indra/newview/llcontrolavatar.h @@ -68,6 +68,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index f456ee4d4b..fb2cf484f5 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -371,7 +371,7 @@ void LLPanelVolume::getState( ) } // Reflection Probe - BOOL is_probe = volobjp && volobjp->getIsReflectionProbe(); + BOOL is_probe = volobjp && volobjp->isReflectionProbe(); getChild("Reflection Probe Checkbox Ctrl")->setValue(is_probe); getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp); diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index f8a2020ccb..5991d7a170 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -139,7 +139,7 @@ void LLReflectionMap::autoAdjustOrigin() { int face = -1; LLVector4a intersection; - LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, &face, &intersection); + LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, true, &face, &intersection); if (drawable != nullptr) { hit = true; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 82a165cb35..7b4ba51859 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1066,8 +1066,9 @@ void LLSelectMgr::highlightObjectOnly(LLViewerObject* objectp) return; } - if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !objectp->permYouOwner()) - || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced()))) + if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !objectp->permYouOwner()) + || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced())) + || (!gSavedSettings.getBOOL("SelectReflectionProbes") && !objectp->isReflectionProbe())) { // only select my own objects return; @@ -7127,7 +7128,8 @@ BOOL LLSelectMgr::canSelectObject(LLViewerObject* object, BOOL ignore_select_own if(!ignore_select_owned) { if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !object->permYouOwner()) || - (gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() || object->isPermanentEnforced()))) + (gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() || object->isPermanentEnforced())) || + (!gSavedSettings.getBOOL("SelectReflectionProbes") && object->isReflectionProbe())) { // only select my own objects return FALSE; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index 39bb46e6fa..a9e807e0f6 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -3819,8 +3819,9 @@ public: LLDrawable* mHit; BOOL mPickTransparent; BOOL mPickRigged; + BOOL mPickUnselectable; - LLOctreeIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + LLOctreeIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) : mStart(start), mEnd(end), @@ -3831,7 +3832,8 @@ public: mTangent(tangent), mHit(NULL), mPickTransparent(pick_transparent), - mPickRigged(pick_rigged) + mPickRigged(pick_rigged), + mPickUnselectable(pick_unselectable) { } @@ -3916,7 +3918,7 @@ public: LLVOAvatar* avatar = (LLVOAvatar*) vobj; if ((mPickRigged) || ((avatar->isSelf()) && (LLFloater::isVisible(gFloaterTools)))) { - LLViewerObject* hit = avatar->lineSegmentIntersectRiggedAttachments(mStart, mEnd, -1, mPickTransparent, mPickRigged, mFaceHit, &intersection, mTexCoord, mNormal, mTangent); + LLViewerObject* hit = avatar->lineSegmentIntersectRiggedAttachments(mStart, mEnd, -1, mPickTransparent, mPickRigged, mPickUnselectable, mFaceHit, &intersection, mTexCoord, mNormal, mTangent); if (hit) { mEnd = intersection; @@ -3932,7 +3934,7 @@ public: } } - if (!skip_check && vobj->lineSegmentIntersect(mStart, mEnd, -1, mPickTransparent, mPickRigged, mFaceHit, &intersection, mTexCoord, mNormal, mTangent)) + if (!skip_check && vobj->lineSegmentIntersect(mStart, mEnd, -1, mPickTransparent, mPickRigged, mPickUnselectable, mFaceHit, &intersection, mTexCoord, mNormal, mTangent)) { mEnd = intersection; // shorten ray so we only find CLOSER hits if (mIntersection) @@ -3952,6 +3954,7 @@ public: LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -3960,7 +3963,7 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, co ) { - LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, face_hit, intersection, tex_coord, normal, tangent); + LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, tex_coord, normal, tangent); LLDrawable* drawable = intersect.check(mOctree); return drawable; @@ -3969,6 +3972,7 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, co LLDrawable* LLSpatialGroup::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -3977,7 +3981,7 @@ LLDrawable* LLSpatialGroup::lineSegmentIntersect(const LLVector4a& start, const ) { - LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, face_hit, intersection, tex_coord, normal, tangent); + LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, tex_coord, normal, tangent); LLDrawable* drawable = intersect.check(getOctreeNode()); return drawable; diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index e9d84ecf06..bebd8aec85 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -317,6 +317,7 @@ public: LLDrawable* lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -400,6 +401,7 @@ public: LLDrawable* lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index e52bc0b015..790d9a8ec5 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -84,12 +84,14 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi } BOOL select_owned = gSavedSettings.getBOOL("SelectOwnedOnly"); BOOL select_movable = gSavedSettings.getBOOL("SelectMovableOnly"); - + BOOL select_probe = gSavedSettings.getBOOL("SelectReflectionProbes"); + // *NOTE: These settings must be cleaned up at bottom of function. if (temp_select || LLSelectMgr::getInstance()->mAllowSelectAvatar) { gSavedSettings.setBOOL("SelectOwnedOnly", FALSE); gSavedSettings.setBOOL("SelectMovableOnly", FALSE); + gSavedSettings.setBOOL("SelectReflectionProbes", FALSE); LLSelectMgr::getInstance()->setForceSelection(TRUE); } @@ -241,6 +243,7 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi { gSavedSettings.setBOOL("SelectOwnedOnly", select_owned); gSavedSettings.setBOOL("SelectMovableOnly", select_movable); + gSavedSettings.setBOOL("SelectReflectionProbes", select_probe); LLSelectMgr::getInstance()->setForceSelection(FALSE); } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 9c8a666185..b99299528c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7971,6 +7971,18 @@ class LLToolsSelectOnlyMovableObjects : public view_listener_t } }; +class LLToolsSelectReflectionProbes : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + BOOL cur_val = gSavedSettings.getBOOL("SelectReflectionProbes"); + + gSavedSettings.setBOOL("SelectReflectionProbes", !cur_val); + + return true; + } +}; + class LLToolsSelectBySurrounding : public view_listener_t { bool handleEvent(const LLSD& userdata) @@ -9200,6 +9212,7 @@ void initialize_menus() view_listener_t::addMenu(new LLToolsSelectTool(), "Tools.SelectTool"); view_listener_t::addMenu(new LLToolsSelectOnlyMyObjects(), "Tools.SelectOnlyMyObjects"); view_listener_t::addMenu(new LLToolsSelectOnlyMovableObjects(), "Tools.SelectOnlyMovableObjects"); + view_listener_t::addMenu(new LLToolsSelectReflectionProbes(), "Tools.SelectReflectionProbes"); view_listener_t::addMenu(new LLToolsSelectBySurrounding(), "Tools.SelectBySurrounding"); view_listener_t::addMenu(new LLToolsShowHiddenSelection(), "Tools.ShowHiddenSelection"); view_listener_t::addMenu(new LLToolsShowSelectionLightRadius(), "Tools.ShowSelectionLightRadius"); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 732beab448..d60fccdee3 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4573,6 +4573,7 @@ BOOL LLViewerObject::lineSegmentIntersect(const LLVector4a& start, const LLVecto S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, @@ -5509,18 +5510,6 @@ S32 LLViewerObject::countInventoryContents(LLAssetType::EType type) return count; } - -void LLViewerObject::setCanSelect(BOOL canSelect) -{ - mbCanSelect = canSelect; - for (child_list_t::iterator iter = mChildList.begin(); - iter != mChildList.end(); iter++) - { - LLViewerObject* child = *iter; - child->mbCanSelect = canSelect; - } -} - void LLViewerObject::setDebugText(const std::string &utf8text) { if (utf8text.empty() && !mText) diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 5b6d24887c..ddb0adaa23 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -239,6 +239,7 @@ public: virtual BOOL isMesh() const { return FALSE; } virtual BOOL isRiggedMesh() const { return FALSE; } virtual BOOL hasLightTexture() const { return FALSE; } + virtual BOOL isReflectionProbe() 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 @@ -280,6 +281,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -421,8 +423,6 @@ public: void sendMaterialUpdate() const; - void setCanSelect(BOOL canSelect); - void setDebugText(const std::string &utf8text); void initHudText(); void restoreHudText(); @@ -678,7 +678,7 @@ public: // Selection, picking and rendering variables U32 mGLName; // GL "name" used by selection code - BOOL mbCanSelect; // true if user can select this object by clicking + BOOL mbCanSelect; // true if user can select this object by clicking under any circumstances (even if pick_unselectable is true) private: // Grabbed from UPDATE_FLAGS diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index 0e585f13fc..593f593a0f 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1838,6 +1838,8 @@ void LLViewerObjectList::renderObjectBounds(const LLVector3 ¢er) void LLViewerObjectList::generatePickList(LLCamera &camera) { + llassert(false); +#if 0 //deprecated LL_PROFILE_ZONE_SCOPED_CATEGORY_UI; LLViewerObject *objectp; @@ -1961,10 +1963,13 @@ void LLViewerObjectList::generatePickList(LLCamera &camera) LLHUDIcon::generatePickIDs(i * step, step); } +#endif } LLViewerObject *LLViewerObjectList::getSelectedObject(const U32 object_id) { + llassert(false); +#if 0 std::set::iterator pick_it; for (pick_it = mSelectPickList.begin(); pick_it != mSelectPickList.end(); ++pick_it) { @@ -1973,6 +1978,7 @@ LLViewerObject *LLViewerObjectList::getSelectedObject(const U32 object_id) return (*pick_it); } } +#endif return NULL; } diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 6a60671040..6613c8ac01 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3371,7 +3371,7 @@ void LLViewerWindow::updateUI() if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST)) { gDebugRaycastFaceHit = -1; - gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, + gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, &gDebugRaycastFaceHit, &gDebugRaycastIntersection, &gDebugRaycastTexCoord, @@ -4195,13 +4195,11 @@ void LLViewerWindow::pickAsync( S32 x, BOOL pick_rigged, BOOL pick_unselectable) { - BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); - if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) - { - // build mode allows interaction with all transparent objects - // "Show Debug Alpha" means no object actually transparent - pick_transparent = TRUE; - } + // "Show Debug Alpha" means no object actually transparent + if (LLDrawPoolAlpha::sShowDebugAlpha) + { + pick_transparent = TRUE; + } LLPickInfo pick_info(LLCoordGL(x, y_from_bot), mask, pick_transparent, pick_rigged, FALSE, TRUE, pick_unselectable, callback); schedulePick(pick_info); @@ -4259,7 +4257,7 @@ void LLViewerWindow::returnEmptyPicks() } // Performs the GL object/land pick. -LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_particle) +LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_particle, BOOL pick_unselectable) { BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) @@ -4308,6 +4306,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de S32 this_face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a *intersection, LLVector2 *uv, @@ -4378,7 +4377,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de { if (this_object->isHUDAttachment()) // is a HUD object? { - if (this_object->lineSegmentIntersect(mh_start, mh_end, this_face, pick_transparent, pick_rigged, + if (this_object->lineSegmentIntersect(mh_start, mh_end, this_face, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, uv, normal, tangent)) { found = this_object; @@ -4386,7 +4385,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de } else // is a world object { - if (this_object->lineSegmentIntersect(mw_start, mw_end, this_face, pick_transparent, pick_rigged, + if (this_object->lineSegmentIntersect(mw_start, mw_end, this_face, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, uv, normal, tangent)) { found = this_object; @@ -4400,7 +4399,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de if (!found) // if not found in HUD, look in world: { - found = gPipeline.lineSegmentIntersectInWorld(mw_start, mw_end, pick_transparent, pick_rigged, + found = gPipeline.lineSegmentIntersectInWorld(mw_start, mw_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, uv, normal, tangent); if (found && !pick_transparent) { @@ -5007,8 +5006,6 @@ BOOL LLViewerWindow::rawSnapshot(LLImageRaw *raw, S32 image_width, S32 image_hei F32 depth_conversion_factor_1 = (LLViewerCamera::getInstance()->getFar() + LLViewerCamera::getInstance()->getNear()) / (2.f * LLViewerCamera::getInstance()->getFar() * LLViewerCamera::getInstance()->getNear()); F32 depth_conversion_factor_2 = (LLViewerCamera::getInstance()->getFar() - LLViewerCamera::getInstance()->getNear()) / (2.f * LLViewerCamera::getInstance()->getFar() * LLViewerCamera::getInstance()->getNear()); - gObjectList.generatePickList(*LLViewerCamera::getInstance()); - // Subimages are in fact partial rendering of the final view. This happens when the final view is bigger than the screen. // In most common cases, scale_factor is 1 and there's no more than 1 iteration on x and y for (int subimage_y = 0; subimage_y < scale_factor; ++subimage_y) @@ -6060,7 +6057,7 @@ void LLPickInfo::fetchResults() } LLViewerObject* hit_object = gViewerWindow->cursorIntersect(mMousePt.mX, mMousePt.mY, 512.f, - NULL, -1, mPickTransparent, mPickRigged, &face_hit, + NULL, -1, mPickTransparent, mPickRigged, mPickUnselectable, &face_hit, &intersection, &uv, &normal, &tangent, &start, &end); mPickPt = mMousePt; @@ -6205,7 +6202,7 @@ void LLPickInfo::getSurfaceInfo() if (objectp) { if (gViewerWindow->cursorIntersect(ll_round((F32)mMousePt.mX), ll_round((F32)mMousePt.mY), 1024.f, - objectp, -1, mPickTransparent, mPickRigged, + objectp, -1, mPickTransparent, mPickRigged, mPickUnselectable, &mObjectFace, &intersection, &mSTCoords, diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index c9cf7da8c7..38ec0e1ac8 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -405,7 +405,7 @@ public: BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, BOOL pick_unselectable = FALSE); - LLPickInfo pickImmediate(S32 x, S32 y, BOOL pick_transparent, BOOL pick_rigged = FALSE, BOOL pick_particle = FALSE); + LLPickInfo pickImmediate(S32 x, S32 y, BOOL pick_transparent, BOOL pick_rigged = FALSE, BOOL pick_particle = FALSE, BOOL pick_unselectable = TRUE); LLHUDIcon* cursorIntersectIcon(S32 mouse_x, S32 mouse_y, F32 depth, LLVector4a* intersection); @@ -414,6 +414,7 @@ public: S32 this_face = -1, BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, LLVector4a *intersection = NULL, LLVector2 *uv = NULL, diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 314c22eb6c..4ec5c999ac 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -1777,6 +1777,7 @@ BOOL LLVOAvatar::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, @@ -1883,6 +1884,7 @@ LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, @@ -1913,7 +1915,7 @@ LLViewerObject* LLVOAvatar::lineSegmentIntersectRiggedAttachments(const LLVector { LLViewerObject* attached_object = attachment_iter->get(); - if (attached_object->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, face_hit, &local_intersection, tex_coord, normal, tangent)) + if (attached_object->lineSegmentIntersect(start, local_end, face, pick_transparent, pick_rigged, pick_unselectable, face_hit, &local_intersection, tex_coord, normal, tangent)) { local_end = local_intersection; if (intersection) diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h index 3c3decaad6..a085d773dc 100644 --- a/indra/newview/llvoavatar.h +++ b/indra/newview/llvoavatar.h @@ -164,6 +164,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -174,6 +175,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llvograss.cpp b/indra/newview/llvograss.cpp index 9a41eedb54..d109b7b34f 100644 --- a/indra/newview/llvograss.cpp +++ b/indra/newview/llvograss.cpp @@ -758,7 +758,7 @@ void LLVOGrass::updateDrawable(BOOL force_damped) } // virtual -BOOL LLVOGrass::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, S32 *face_hitp, +BOOL LLVOGrass::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32 *face_hitp, LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) { diff --git a/indra/newview/llvograss.h b/indra/newview/llvograss.h index 5634e048eb..63876dc099 100644 --- a/indra/newview/llvograss.h +++ b/indra/newview/llvograss.h @@ -79,6 +79,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llvopartgroup.cpp b/indra/newview/llvopartgroup.cpp index 04e9a4f179..cb4315a774 100644 --- a/indra/newview/llvopartgroup.cpp +++ b/indra/newview/llvopartgroup.cpp @@ -485,6 +485,7 @@ BOOL LLVOPartGroup::lineSegmentIntersect(const LLVector4a& start, const LLVector S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, diff --git a/indra/newview/llvopartgroup.h b/indra/newview/llvopartgroup.h index 4e4d6e609d..a45d381dfa 100644 --- a/indra/newview/llvopartgroup.h +++ b/indra/newview/llvopartgroup.h @@ -74,6 +74,7 @@ public: S32 face, BOOL pick_transparent, BOOL pick_rigged, + BOOL pick_unselectable, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, diff --git a/indra/newview/llvosurfacepatch.cpp b/indra/newview/llvosurfacepatch.cpp index b0af565867..6b56eaeb4a 100644 --- a/indra/newview/llvosurfacepatch.cpp +++ b/indra/newview/llvosurfacepatch.cpp @@ -880,7 +880,7 @@ void LLVOSurfacePatch::getGeomSizesEast(const S32 stride, const S32 east_stride, } } -BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, S32 *face_hitp, +BOOL LLVOSurfacePatch::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32 *face_hitp, LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) { diff --git a/indra/newview/llvosurfacepatch.h b/indra/newview/llvosurfacepatch.h index 884dbb3be3..aed67162d1 100644 --- a/indra/newview/llvosurfacepatch.h +++ b/indra/newview/llvosurfacepatch.h @@ -85,6 +85,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llvotree.cpp b/indra/newview/llvotree.cpp index 493162b47b..e26791aa29 100644 --- a/indra/newview/llvotree.cpp +++ b/indra/newview/llvotree.cpp @@ -1170,7 +1170,7 @@ void LLVOTree::updateSpatialExtents(LLVector4a& newMin, LLVector4a& newMax) mDrawable->setPositionGroup(pos); } -BOOL LLVOTree::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, S32 *face_hitp, +BOOL LLVOTree::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32 *face_hitp, LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) { diff --git a/indra/newview/llvotree.h b/indra/newview/llvotree.h index 93c22d2da3..996e970cf8 100644 --- a/indra/newview/llvotree.h +++ b/indra/newview/llvotree.h @@ -111,6 +111,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 6aef9ee7c0..8f5d2d1c29 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -986,7 +986,7 @@ LLDrawable *LLVOVolume::createDrawable(LLPipeline *pipeline) gPipeline.setLight(mDrawable, TRUE); } - if (getIsReflectionProbe()) + if (isReflectionProbe()) { updateReflectionProbePtr(); } @@ -3503,7 +3503,7 @@ F32 LLVOVolume::getLightCutoff() const void LLVOVolume::setIsReflectionProbe(BOOL is_probe) { - BOOL was_probe = getIsReflectionProbe(); + BOOL was_probe = isReflectionProbe(); if (is_probe != was_probe) { if (is_probe) @@ -3559,7 +3559,7 @@ void LLVOVolume::setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenc } -BOOL LLVOVolume::getIsReflectionProbe() const +BOOL LLVOVolume::isReflectionProbe() const { // HACK - make this object a Reflection Probe if a certain UUID is detected static LLCachedControl reflection_probe_id(gSavedSettings, "RenderReflectionProbeTextureHackID", ""); @@ -4507,7 +4507,7 @@ void LLVOVolume::parameterChanged(U16 param_type, LLNetworkData* data, BOOL in_u void LLVOVolume::updateReflectionProbePtr() { - if (getIsReflectionProbe()) + if (isReflectionProbe()) { if (mReflectionProbe.isNull()) { @@ -4717,7 +4717,7 @@ LLVector3 LLVOVolume::volumeDirectionToAgent(const LLVector3& dir) const } -BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, S32 *face_hitp, +BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end, S32 face, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, S32 *face_hitp, LLVector4a* intersection,LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) { @@ -4728,6 +4728,14 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& return FALSE; } + if (!pick_unselectable) + { + if (!LLSelectMgr::instance().canSelectObject(this)) + { + return FALSE; + } + } + BOOL ret = FALSE; LLVolume* volume = getVolume(); diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 93a10781c2..ad7a2c5606 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -151,6 +151,7 @@ public: S32 face = -1, // which face to check, -1 = ALL_SIDES BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, + BOOL pick_unselectable = TRUE, S32* face_hit = NULL, // which face was hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -290,7 +291,7 @@ public: void setReflectionProbeNearClip(F32 near_clip); void setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type); - BOOL getIsReflectionProbe() const; + BOOL isReflectionProbe() const override; F32 getReflectionProbeAmbiance() const; F32 getReflectionProbeNearClip() const; LLReflectionProbeParams::EInfluenceVolumeType getReflectionProbeVolumeType() const; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 3332185bfd..20a21a685c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6988,7 +6988,7 @@ LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_PARTICLE); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, TRUE, FALSE, face_hit, &position, NULL, NULL, NULL); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, TRUE, FALSE, TRUE, face_hit, &position, NULL, NULL, NULL); if (hit) { drawable = hit; @@ -7016,6 +7016,7 @@ LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start, LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, const LLVector4a& end, bool pick_transparent, bool pick_rigged, + bool pick_unselectable, S32* face_hit, LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -7049,7 +7050,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(j); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, face_hit, &position, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, &position, tex_coord, normal, tangent); if (hit) { drawable = hit; @@ -7106,7 +7107,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_AVATAR); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, face_hit, &position, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, &position, tex_coord, normal, tangent); if (hit) { LLVector4a delta; @@ -7194,7 +7195,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector4a& start, c LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_HUD); if (part) { - LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, FALSE, face_hit, intersection, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, FALSE, TRUE, face_hit, intersection, tex_coord, normal, tangent); if (hit) { drawable = hit; @@ -7695,7 +7696,7 @@ void LLPipeline::renderFinalize() LLVector4a result; result.clear(); - gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, NULL, &result); + gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); focus_point.set(result.getF32ptr()); } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index bb2e1d65ae..f4c55bde7d 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -188,6 +188,7 @@ public: LLViewerObject* lineSegmentIntersectInWorld(const LLVector4a& start, const LLVector4a& end, bool pick_transparent, bool pick_rigged, + bool pick_unselectable, S32* face_hit, // return the face hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 0b0f8e17bc..159b9aebd0 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -1417,6 +1417,15 @@ function="World.EnvPreset" function="Tools.SelectOnlyMovableObjects" parameter="movable" /> + + + + -- cgit v1.3 From 03d85bfb33f53e658256d8bedcf0b4262226cf90 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 9 Jun 2022 19:43:21 -0500 Subject: SL-17573 Add "dynamic" checkbox, also followup on SL-17551 and do "Select Invisible Objects" checkbox instead of "Select Reflection Probes" --- indra/llprimitive/llprimitive.cpp | 103 +++++++++++++-------- indra/llprimitive/llprimitive.h | 15 +-- indra/newview/app_settings/settings.xml | 4 +- indra/newview/llpanelvolume.cpp | 37 ++++---- indra/newview/llreflectionmap.cpp | 14 ++- indra/newview/llreflectionmap.h | 3 + indra/newview/llselectmgr.cpp | 6 +- indra/newview/lltoolselect.cpp | 10 +- indra/newview/llviewermenu.cpp | 8 +- indra/newview/llviewerwindow.cpp | 46 +++++++-- indra/newview/llviewerwindow.h | 2 +- indra/newview/llvovolume.cpp | 36 +++++-- indra/newview/llvovolume.h | 6 +- indra/newview/pipeline.cpp | 9 -- .../newview/skins/default/xui/en/floater_tools.xml | 17 +++- indra/newview/skins/default/xui/en/menu_viewer.xml | 10 +- 16 files changed, 205 insertions(+), 121 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 6044048d09..9e0a079fd9 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -1819,92 +1819,117 @@ bool LLLightParams::fromLLSD(LLSD& sd) //============================================================================ +//============================================================================ + LLReflectionProbeParams::LLReflectionProbeParams() { mType = PARAMS_REFLECTION_PROBE; } -BOOL LLReflectionProbeParams::pack(LLDataPacker& dp) const +BOOL LLReflectionProbeParams::pack(LLDataPacker &dp) const { - dp.packF32(mAmbiance, "ambiance"); + dp.packF32(mAmbiance, "ambiance"); dp.packF32(mClipDistance, "clip_distance"); - dp.packU8(mVolumeType, "volume_type"); - return TRUE; + dp.packU8(mFlags, "flags"); + return TRUE; } -BOOL LLReflectionProbeParams::unpack(LLDataPacker& dp) +BOOL LLReflectionProbeParams::unpack(LLDataPacker &dp) { - F32 ambiance; + F32 ambiance; F32 clip_distance; - U8 volume_type; - - dp.unpackF32(ambiance, "ambiance"); - setAmbiance(ambiance); + dp.unpackF32(ambiance, "ambiance"); + setAmbiance(ambiance); + dp.unpackF32(clip_distance, "clip_distance"); - setClipDistance(clip_distance); - - dp.unpackU8(volume_type, "volume_type"); - setVolumeType((EInfluenceVolumeType)volume_type); - - return TRUE; + setClipDistance(clip_distance); + + dp.unpackU8(mFlags, "flags"); + + return TRUE; } bool LLReflectionProbeParams::operator==(const LLNetworkData& data) const { - if (data.mType != PARAMS_REFLECTION_PROBE) - { - return false; - } - const LLReflectionProbeParams* param = (const LLReflectionProbeParams*)&data; - if (param->mAmbiance != mAmbiance) - { - return false; - } + if (data.mType != PARAMS_REFLECTION_PROBE) + { + return false; + } + const LLReflectionProbeParams *param = (const LLReflectionProbeParams*)&data; + if (param->mAmbiance != mAmbiance) + { + return false; + } if (param->mClipDistance != mClipDistance) { return false; } - if (param->mVolumeType != mVolumeType) + if (param->mFlags != mFlags) { return false; } - return true; + return true; } void LLReflectionProbeParams::copy(const LLNetworkData& data) { - const LLReflectionProbeParams* param = (LLReflectionProbeParams*)&data; - mType = param->mType; - mAmbiance = param->mAmbiance; + const LLReflectionProbeParams *param = (LLReflectionProbeParams*)&data; + mType = param->mType; + mAmbiance = param->mAmbiance; mClipDistance = param->mClipDistance; - mVolumeType = param->mVolumeType; + mFlags = param->mFlags; } LLSD LLReflectionProbeParams::asLLSD() const { - LLSD sd; - sd["ambiance"] = getAmbiance(); + LLSD sd; + sd["ambiance"] = getAmbiance(); sd["clip_distance"] = getClipDistance(); - sd["volume_type"] = (U8) getVolumeType(); - return sd; + sd["flags"] = mFlags; + return sd; } bool LLReflectionProbeParams::fromLLSD(LLSD& sd) { if (!sd.has("ambiance") || !sd.has("clip_distance") || - !sd.has("volume_type")) + !sd.has("flags")) { return false; } - setAmbiance((F32)sd["ambiance"].asReal()); + setAmbiance((F32)sd["ambiance"].asReal()); setClipDistance((F32)sd["clip_distance"].asReal()); - setVolumeType((EInfluenceVolumeType)sd["volume_type"].asInteger()); - + mFlags = (U8) sd["flags"].asInteger(); + return true; } + +void LLReflectionProbeParams::setIsBox(bool is_box) +{ + if (is_box) + { + mFlags |= FLAG_BOX_VOLUME; + } + else + { + mFlags &= ~FLAG_BOX_VOLUME; + } +} + +void LLReflectionProbeParams::setIsDynamic(bool is_dynamic) +{ + if (is_dynamic) + { + mFlags |= FLAG_DYNAMIC; + } + else + { + mFlags &= ~FLAG_DYNAMIC; + } +} + //============================================================================ LLFlexibleObjectData::LLFlexibleObjectData() { diff --git a/indra/llprimitive/llprimitive.h b/indra/llprimitive/llprimitive.h index 2215133e16..25196fb894 100644 --- a/indra/llprimitive/llprimitive.h +++ b/indra/llprimitive/llprimitive.h @@ -182,17 +182,16 @@ extern const F32 REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE; class LLReflectionProbeParams : public LLNetworkData { public: - enum EInfluenceVolumeType : U8 + enum EFlags : U8 { - VOLUME_TYPE_SPHERE = 0, // use a sphere influence volume - VOLUME_TYPE_BOX = 1, // use a box influence volume - DEFAULT_VOLUME_TYPE = VOLUME_TYPE_SPHERE + FLAG_BOX_VOLUME = 0x01, // use a box influence volume + FLAG_DYNAMIC = 0x02, // render dynamic objects (avatars) into this Reflection Probe }; protected: F32 mAmbiance = REFLECTION_PROBE_DEFAULT_AMBIANCE; F32 mClipDistance = REFLECTION_PROBE_DEFAULT_CLIP_DISTANCE; - EInfluenceVolumeType mVolumeType = DEFAULT_VOLUME_TYPE; + U8 mFlags = 0; public: LLReflectionProbeParams(); @@ -208,11 +207,13 @@ public: void setAmbiance(F32 ambiance) { mAmbiance = llclamp(ambiance, REFLECTION_PROBE_MIN_AMBIANCE, REFLECTION_PROBE_MAX_AMBIANCE); } void setClipDistance(F32 distance) { mClipDistance = llclamp(distance, REFLECTION_PROBE_MIN_CLIP_DISTANCE, REFLECTION_PROBE_MAX_CLIP_DISTANCE); } - void setVolumeType(EInfluenceVolumeType type) { mVolumeType = llclamp(type, VOLUME_TYPE_SPHERE, VOLUME_TYPE_BOX); } + void setIsBox(bool is_box); + void setIsDynamic(bool is_dynamic); F32 getAmbiance() const { return mAmbiance; } F32 getClipDistance() const { return mClipDistance; } - EInfluenceVolumeType getVolumeType() const { return mVolumeType; } + bool getIsBox() const { return (mFlags & FLAG_BOX_VOLUME) != 0; } + bool getIsDynamic() const { return (mFlags & FLAG_DYNAMIC) != 0; } }; //------------------------------------------------- diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 6df71e1019..327dfe6955 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -11191,10 +11191,10 @@ Value 0 - SelectReflectionProbes + SelectInvisibleObjects Comment - Select reflection probes + Select invisible objects Persist 1 Type diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index fb2cf484f5..ddce22fa20 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -147,8 +147,9 @@ BOOL LLPanelVolume::postBuild() // REFLECTION PROBE Parameters { - childSetCommitCallback("Reflection Probe Checkbox Ctrl", onCommitIsReflectionProbe, this); - childSetCommitCallback("Probe Volume Type Ctrl", onCommitProbe, this); + childSetCommitCallback("Reflection Probe", onCommitIsReflectionProbe, this); + childSetCommitCallback("Probe Dynamic", onCommitProbe, this); + childSetCommitCallback("Probe Volume Type", onCommitProbe, this); childSetCommitCallback("Probe Ambiance", onCommitProbe, this); childSetCommitCallback("Probe Near Clip", onCommitProbe, this); @@ -372,25 +373,27 @@ void LLPanelVolume::getState( ) // Reflection Probe BOOL is_probe = volobjp && volobjp->isReflectionProbe(); - getChild("Reflection Probe Checkbox Ctrl")->setValue(is_probe); - getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(editable && single_volume && volobjp); + getChild("Reflection Probe")->setValue(is_probe); + getChildView("Reflection Probe")->setEnabled(editable && single_volume && volobjp); bool probe_enabled = is_probe && editable && single_volume; - getChildView("Probe Volume Type Ctrl")->setEnabled(probe_enabled); + getChildView("Probe Dynamic")->setEnabled(probe_enabled); + getChildView("Probe Volume Type")->setEnabled(probe_enabled); getChildView("Probe Ambiance")->setEnabled(probe_enabled); getChildView("Probe Near Clip")->setEnabled(probe_enabled); if (!probe_enabled) { - getChild("Probe Volume Type Ctrl", true)->clear(); + getChild("Probe Volume Type", true)->clear(); getChild("Probe Ambiance", true)->clear(); getChild("Probe Near Clip", true)->clear(); + getChild("Probe Dynamic", true)->clear(); } else { std::string volume_type; - if (volobjp->getReflectionProbeVolumeType() == LLReflectionProbeParams::VOLUME_TYPE_BOX) + if (volobjp->getReflectionProbeIsBox()) { volume_type = "Box"; } @@ -399,9 +402,10 @@ void LLPanelVolume::getState( ) volume_type = "Sphere"; } - getChild("Probe Volume Type Ctrl", true)->setValue(volume_type); + getChild("Probe Volume Type", true)->setValue(volume_type); getChild("Probe Ambiance", true)->setValue(volobjp->getReflectionProbeAmbiance()); getChild("Probe Near Clip", true)->setValue(volobjp->getReflectionProbeNearClip()); + getChild("Probe Dynamic", true)->setValue(volobjp->getReflectionProbeIsDynamic()); } // Animated Mesh @@ -692,7 +696,8 @@ void LLPanelVolume::clearCtrls() getChildView("Light Falloff")->setEnabled(false); getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(false);; - getChildView("Probe Volume Type Ctrl")->setEnabled(false); + getChildView("Probe Volume Type")->setEnabled(false); + getChildView("Probe Dynamic")->setEnabled(false); getChildView("Probe Ambiance")->setEnabled(false); getChildView("Probe Near Clip")->setEnabled(false); getChildView("Animated Mesh Checkbox Ctrl")->setEnabled(false); @@ -1003,19 +1008,11 @@ void LLPanelVolume::onCommitProbe(LLUICtrl* ctrl, void* userdata) volobjp->setReflectionProbeAmbiance((F32)self->getChild("Probe Ambiance")->getValue().asReal()); volobjp->setReflectionProbeNearClip((F32)self->getChild("Probe Near Clip")->getValue().asReal()); + volobjp->setReflectionProbeIsDynamic(self->getChild("Probe Dynamic")->getValue().asBoolean()); - std::string shape_type = self->getChild("Probe Volume Type Ctrl")->getValue().asString(); - LLReflectionProbeParams::EInfluenceVolumeType volume_type = LLReflectionProbeParams::DEFAULT_VOLUME_TYPE; + std::string shape_type = self->getChild("Probe Volume Type")->getValue().asString(); - if (shape_type == "Sphere") - { - volume_type = LLReflectionProbeParams::VOLUME_TYPE_SPHERE; - } - else if (shape_type == "Box") - { - volume_type = LLReflectionProbeParams::VOLUME_TYPE_BOX; - } - volobjp->setReflectionProbeVolumeType(volume_type); + volobjp->setReflectionProbeIsBox(shape_type == "Box"); } // static diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 5991d7a170..39e0841fc5 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -51,7 +51,7 @@ void LLReflectionMap::update(U32 resolution, U32 face) { resolution /= 2; } - gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip()); + gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip(), getIsDynamic()); } bool LLReflectionMap::shouldUpdate() @@ -243,6 +243,16 @@ F32 LLReflectionMap::getNearClip() return llmax(ret, MINIMUM_NEAR_CLIP); } +bool LLReflectionMap::getIsDynamic() +{ + if (mViewerObject && mViewerObject->getVolume()) + { + return ((LLVOVolume*)mViewerObject)->getReflectionProbeIsDynamic(); + } + + return false; +} + bool LLReflectionMap::getBox(LLMatrix4& box) { if (mViewerObject) @@ -252,7 +262,7 @@ bool LLReflectionMap::getBox(LLMatrix4& box) { LLVOVolume* vobjp = (LLVOVolume*)mViewerObject; - if (vobjp->getReflectionProbeVolumeType() == LLReflectionProbeParams::VOLUME_TYPE_BOX) + if (vobjp->getReflectionProbeIsBox()) { glh::matrix4f mv(gGLModelView); glh::matrix4f scale; diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index a358bf5fdf..071568e53c 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -61,6 +61,9 @@ public: // Get the near clip plane distance to use for this probe F32 getNearClip(); + // Return true if this probe should include avatars in its reflection map + bool getIsDynamic(); + // get the encoded bounding box of this probe's influence volume // will only return a box if this probe is associated with a VOVolume // with its reflection probe influence volume to to VOLUME_TYPE_BOX diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 7b4ba51859..853703b4d5 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -1067,8 +1067,7 @@ void LLSelectMgr::highlightObjectOnly(LLViewerObject* objectp) } if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !objectp->permYouOwner()) - || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced())) - || (!gSavedSettings.getBOOL("SelectReflectionProbes") && !objectp->isReflectionProbe())) + || (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() || objectp->isPermanentEnforced()))) { // only select my own objects return; @@ -7128,8 +7127,7 @@ BOOL LLSelectMgr::canSelectObject(LLViewerObject* object, BOOL ignore_select_own if(!ignore_select_owned) { if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !object->permYouOwner()) || - (gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() || object->isPermanentEnforced())) || - (!gSavedSettings.getBOOL("SelectReflectionProbes") && object->isReflectionProbe())) + (gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() || object->isPermanentEnforced()))) { // only select my own objects return FALSE; diff --git a/indra/newview/lltoolselect.cpp b/indra/newview/lltoolselect.cpp index 790d9a8ec5..c6f3905ddc 100644 --- a/indra/newview/lltoolselect.cpp +++ b/indra/newview/lltoolselect.cpp @@ -65,7 +65,8 @@ BOOL LLToolSelect::handleMouseDown(S32 x, S32 y, MASK mask) { // do immediate pick query BOOL pick_rigged = false; //gSavedSettings.getBOOL("AnimatedObjectsAllowLeftClick"); - mPick = gViewerWindow->pickImmediate(x, y, TRUE, pick_rigged); + BOOL pick_transparent = gSavedSettings.getBOOL("SelectInvisibleObjects"); + mPick = gViewerWindow->pickImmediate(x, y, pick_transparent, pick_rigged); // Pass mousedown to agent LLTool::handleMouseDown(x, y, mask); @@ -84,15 +85,13 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi } BOOL select_owned = gSavedSettings.getBOOL("SelectOwnedOnly"); BOOL select_movable = gSavedSettings.getBOOL("SelectMovableOnly"); - BOOL select_probe = gSavedSettings.getBOOL("SelectReflectionProbes"); - // *NOTE: These settings must be cleaned up at bottom of function. + // *NOTE: These settings must be cleaned up at bottom of function. if (temp_select || LLSelectMgr::getInstance()->mAllowSelectAvatar) { gSavedSettings.setBOOL("SelectOwnedOnly", FALSE); gSavedSettings.setBOOL("SelectMovableOnly", FALSE); - gSavedSettings.setBOOL("SelectReflectionProbes", FALSE); - LLSelectMgr::getInstance()->setForceSelection(TRUE); + LLSelectMgr::getInstance()->setForceSelection(TRUE); } BOOL extend_select = (pick.mKeyMask == MASK_SHIFT) || (pick.mKeyMask == MASK_CONTROL); @@ -243,7 +242,6 @@ LLObjectSelectionHandle LLToolSelect::handleObjectSelection(const LLPickInfo& pi { gSavedSettings.setBOOL("SelectOwnedOnly", select_owned); gSavedSettings.setBOOL("SelectMovableOnly", select_movable); - gSavedSettings.setBOOL("SelectReflectionProbes", select_probe); LLSelectMgr::getInstance()->setForceSelection(FALSE); } diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index b99299528c..b7f94a7e0c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -7971,13 +7971,13 @@ class LLToolsSelectOnlyMovableObjects : public view_listener_t } }; -class LLToolsSelectReflectionProbes : public view_listener_t +class LLToolsSelectInvisibleObjects : public view_listener_t { bool handleEvent(const LLSD& userdata) { - BOOL cur_val = gSavedSettings.getBOOL("SelectReflectionProbes"); + BOOL cur_val = gSavedSettings.getBOOL("SelectInvisibleObjects"); - gSavedSettings.setBOOL("SelectReflectionProbes", !cur_val); + gSavedSettings.setBOOL("SelectInvisibleObjects", !cur_val); return true; } @@ -9212,7 +9212,7 @@ void initialize_menus() view_listener_t::addMenu(new LLToolsSelectTool(), "Tools.SelectTool"); view_listener_t::addMenu(new LLToolsSelectOnlyMyObjects(), "Tools.SelectOnlyMyObjects"); view_listener_t::addMenu(new LLToolsSelectOnlyMovableObjects(), "Tools.SelectOnlyMovableObjects"); - view_listener_t::addMenu(new LLToolsSelectReflectionProbes(), "Tools.SelectReflectionProbes"); + view_listener_t::addMenu(new LLToolsSelectInvisibleObjects(), "Tools.SelectInvisibleObjects"); view_listener_t::addMenu(new LLToolsSelectBySurrounding(), "Tools.SelectBySurrounding"); view_listener_t::addMenu(new LLToolsShowHiddenSelection(), "Tools.ShowHiddenSelection"); view_listener_t::addMenu(new LLToolsShowSelectionLightRadius(), "Tools.ShowSelectionLightRadius"); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 6613c8ac01..1230a6d327 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -4196,10 +4196,15 @@ void LLViewerWindow::pickAsync( S32 x, BOOL pick_unselectable) { // "Show Debug Alpha" means no object actually transparent + BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); if (LLDrawPoolAlpha::sShowDebugAlpha) { pick_transparent = TRUE; } + else if (in_build_mode && !gSavedSettings.getBOOL("SelectInvisibleObjects")) + { + pick_transparent = FALSE; + } LLPickInfo pick_info(LLCoordGL(x, y_from_bot), mask, pick_transparent, pick_rigged, FALSE, TRUE, pick_unselectable, callback); schedulePick(pick_info); @@ -4260,7 +4265,7 @@ void LLViewerWindow::returnEmptyPicks() LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_particle, BOOL pick_unselectable) { BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); - if (in_build_mode || LLDrawPoolAlpha::sShowDebugAlpha) + if ((in_build_mode && gSavedSettings.getBOOL("SelectInvisibleObjects")) || LLDrawPoolAlpha::sShowDebugAlpha) { // build mode allows interaction with all transparent objects // "Show Debug Alpha" means no object actually transparent @@ -5267,7 +5272,7 @@ BOOL LLViewerWindow::simpleSnapshot(LLImageRaw* raw, S32 image_width, S32 image_ void display_cube_face(); -BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face, F32 near_clip) +BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 cubeIndex, S32 face, F32 near_clip, bool dynamic_render) { // NOTE: implementation derived from LLFloater360Capture::capture360Images() and simpleSnapshot LL_PROFILE_ZONE_SCOPED_CATEGORY_APP; @@ -5300,16 +5305,33 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubea glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + U32 dynamic_render_types[] = { + LLPipeline::RENDER_TYPE_AVATAR, + LLPipeline::RENDER_TYPE_CONTROL_AV, + LLPipeline::RENDER_TYPE_PARTICLES + }; + constexpr U32 dynamic_render_type_count = sizeof(dynamic_render_types) / sizeof(U32); + bool prev_dynamic_render_type[dynamic_render_type_count]; + + + if (!dynamic_render) + { + for (int i = 0; i < dynamic_render_type_count; ++i) + { + prev_dynamic_render_type[i] = gPipeline.hasRenderType(dynamic_render_types[i]); + if (prev_dynamic_render_type[i]) + { + gPipeline.toggleRenderType(dynamic_render_types[i]); + } + } + } + BOOL prev_draw_ui = gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_UI) ? TRUE : FALSE; if (prev_draw_ui != false) { LLPipeline::toggleRenderDebugFeature(LLPipeline::RENDER_DEBUG_FEATURE_UI); } - BOOL prev_draw_particles = gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES); - if (prev_draw_particles) - { - gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES); - } + LLPipeline::sShowHUDAttachments = FALSE; LLRect window_rect = getWorldViewRectRaw(); @@ -5365,9 +5387,15 @@ BOOL LLViewerWindow::cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubea } } - if (prev_draw_particles) + if (!dynamic_render) { - gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_PARTICLES); + for (int i = 0; i < dynamic_render_type_count; ++i) + { + if (prev_dynamic_render_type[i]) + { + gPipeline.toggleRenderType(dynamic_render_types[i]); + } + } } LLPipeline::sShowHUDAttachments = TRUE; diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 38ec0e1ac8..387a2cb06f 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -370,7 +370,7 @@ public: // index - cube index in the array to use (cube index, not face-layer) // face - which cube face to update // near_clip - near clip setting to use - BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face, F32 near_clip); + BOOL cubeSnapshot(const LLVector3& origin, LLCubeMapArray* cubearray, S32 index, S32 face, F32 near_clip, bool render_avatars); // special implementation of simpleSnapshot for reflection maps diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8f5d2d1c29..3a619b4fcc 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -3545,14 +3545,27 @@ void LLVOVolume::setReflectionProbeNearClip(F32 near_clip) } } -void LLVOVolume::setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type) +void LLVOVolume::setReflectionProbeIsBox(bool is_box) { LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); if (param_block) { - if (param_block->getVolumeType() != volume_type) + if (param_block->getIsBox() != is_box) { - param_block->setVolumeType(volume_type); + param_block->setIsBox(is_box); + parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); + } + } +} + +void LLVOVolume::setReflectionProbeIsDynamic(bool is_dynamic) +{ + LLReflectionProbeParams* param_block = (LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) + { + if (param_block->getIsDynamic() != is_dynamic) + { + param_block->setIsDynamic(is_dynamic); parameterChanged(LLNetworkData::PARAMS_REFLECTION_PROBE, true); } } @@ -3603,17 +3616,26 @@ F32 LLVOVolume::getReflectionProbeNearClip() const } } -LLReflectionProbeParams::EInfluenceVolumeType LLVOVolume::getReflectionProbeVolumeType() const +bool LLVOVolume::getReflectionProbeIsBox() const { const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); if (param_block) { - return param_block->getVolumeType(); + return param_block->getIsBox(); } - else + + return false; +} + +bool LLVOVolume::getReflectionProbeIsDynamic() const +{ + const LLReflectionProbeParams* param_block = (const LLReflectionProbeParams*)getParameterEntry(LLNetworkData::PARAMS_REFLECTION_PROBE); + if (param_block) { - return LLReflectionProbeParams::DEFAULT_VOLUME_TYPE; + return param_block->getIsDynamic(); } + + return false; } U32 LLVOVolume::getVolumeInterfaceID() const diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index ad7a2c5606..1ca6b49c7d 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -289,12 +289,14 @@ public: void setIsReflectionProbe(BOOL is_probe); void setReflectionProbeAmbiance(F32 ambiance); void setReflectionProbeNearClip(F32 near_clip); - void setReflectionProbeVolumeType(LLReflectionProbeParams::EInfluenceVolumeType volume_type); + void setReflectionProbeIsBox(bool is_box); + void setReflectionProbeIsDynamic(bool is_dynamic); BOOL isReflectionProbe() const override; F32 getReflectionProbeAmbiance() const; F32 getReflectionProbeNearClip() const; - LLReflectionProbeParams::EInfluenceVolumeType getReflectionProbeVolumeType() const; + bool getReflectionProbeIsBox() const; + bool getReflectionProbeIsDynamic() const; // Flexible Objects U32 getVolumeInterfaceID() const; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 20a21a685c..28dc3781ba 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6734,15 +6734,6 @@ void LLPipeline::toggleRenderType(U32 type) //static void LLPipeline::toggleRenderTypeControl(U32 type) { - U32 bit = (1< + + label="Select Invisible Objects" + name="Select Invisible Objects"> + control="SelectInvisibleObjects" /> + function="Tools.SelectInvisibleObjects" + parameter="invisible" /> Date: Fri, 10 Jun 2022 01:13:41 -0500 Subject: SL-17574 Add probe detail combo box to advanced graphics preferences. Fix spot light shadows not working in probes. --- indra/llrender/llrendertarget.cpp | 4 + indra/newview/app_settings/settings.xml | 11 + .../shaders/class3/deferred/reflectionProbeF.glsl | 13 +- indra/newview/llpanelvolume.cpp | 6 +- indra/newview/llreflectionmap.cpp | 26 +- indra/newview/llreflectionmap.h | 8 - indra/newview/llreflectionmapmanager.cpp | 63 +++- indra/newview/llreflectionmapmanager.h | 11 +- indra/newview/llspatialpartition.cpp | 17 - indra/newview/llspatialpartition.h | 3 - indra/newview/llviewercamera.h | 13 +- indra/newview/pipeline.cpp | 387 +++++++++++---------- indra/newview/pipeline.h | 16 +- .../en/floater_preferences_graphics_advanced.xml | 38 +- 14 files changed, 350 insertions(+), 266 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/llrender/llrendertarget.cpp b/indra/llrender/llrendertarget.cpp index 85d6209964..fa46e0f7d0 100644 --- a/indra/llrender/llrendertarget.cpp +++ b/indra/llrender/llrendertarget.cpp @@ -473,6 +473,8 @@ void LLRenderTarget::release() void LLRenderTarget::bindTarget() { + llassert(mFBO); + if (mFBO) { stop_glerror(); @@ -514,6 +516,7 @@ void LLRenderTarget::bindTarget() void LLRenderTarget::clear(U32 mask_in) { LL_PROFILE_GPU_ZONE("clear"); + llassert(mFBO); U32 mask = GL_COLOR_BUFFER_BIT; if (mUseDepth) { @@ -579,6 +582,7 @@ void LLRenderTarget::bindTexture(U32 index, S32 channel, LLTexUnit::eTextureFilt void LLRenderTarget::flush(bool fetch_depth) { gGL.flush(); + llassert(mFBO); if (!mFBO) { gGL.getTexUnit(0)->bind(this); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 327dfe6955..35a79f12de 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10280,6 +10280,17 @@ Value 2 + RenderReflectionProbeDetail + + Comment + Detail of reflections. + Persist + 1 + Type + S32 + Value + 1 + RenderReflectionProbeDrawDistance diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 3fd001e7f5..b3396baeba 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -74,6 +74,8 @@ bool isAbove(vec3 pos, vec4 plane) return (dot(plane.xyz, pos) + plane.w) > 0; } +int max_priority = 0; + // return true if probe at index i influences position pos bool shouldSampleProbe(int i, vec3 pos) { @@ -86,6 +88,8 @@ bool shouldSampleProbe(int i, vec3 pos) { return false; } + + max_priority = max(max_priority, -refIndex[i].w); } else { @@ -98,6 +102,8 @@ bool shouldSampleProbe(int i, vec3 pos) { //outside bounding sphere return false; } + + max_priority = max(max_priority, refIndex[i].w); } return true; @@ -343,8 +349,13 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) for (int idx = 0; idx < probeInfluences; ++idx) { int i = probeIndex[idx]; + if (refIndex[i].w < max_priority) + { + continue; + } float r = refSphere[i].w; // radius of sphere volume float p = float(abs(refIndex[i].w)); // priority + float rr = r*r; // radius squred float r1 = r * 0.1; // 75% of radius (outer sphere to start interpolating down) vec3 delta = pos.xyz-refSphere[i].xyz; @@ -358,7 +369,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, float minweight) float atten = 1.0-max(d2-r2, 0.0)/(rr-r2); w *= atten; - w *= p; // boost weight based on priority + //w *= p; // boost weight based on priority col += refcol*w*max(minweight, refParams[i].x); wsum += w; diff --git a/indra/newview/llpanelvolume.cpp b/indra/newview/llpanelvolume.cpp index ddce22fa20..956539cd98 100644 --- a/indra/newview/llpanelvolume.cpp +++ b/indra/newview/llpanelvolume.cpp @@ -152,8 +152,6 @@ BOOL LLPanelVolume::postBuild() childSetCommitCallback("Probe Volume Type", onCommitProbe, this); childSetCommitCallback("Probe Ambiance", onCommitProbe, this); childSetCommitCallback("Probe Near Clip", onCommitProbe, this); - - } // PHYSICS Parameters @@ -695,7 +693,7 @@ void LLPanelVolume::clearCtrls() getChildView("Light Radius")->setEnabled(false); getChildView("Light Falloff")->setEnabled(false); - getChildView("Reflection Probe Checkbox Ctrl")->setEnabled(false);; + getChildView("Reflection Probe")->setEnabled(false);; getChildView("Probe Volume Type")->setEnabled(false); getChildView("Probe Dynamic")->setEnabled(false); getChildView("Probe Ambiance")->setEnabled(false); @@ -746,7 +744,7 @@ void LLPanelVolume::sendIsReflectionProbe() } LLVOVolume* volobjp = (LLVOVolume*)objectp; - BOOL value = getChild("Reflection Probe Checkbox Ctrl")->getValue(); + BOOL value = getChild("Reflection Probe")->getValue(); volobjp->setIsReflectionProbe(value); LL_INFOS() << "update reflection probe sent" << LL_ENDL; } diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 39e0841fc5..500485fc70 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -54,28 +54,6 @@ void LLReflectionMap::update(U32 resolution, U32 face) gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip(), getIsDynamic()); } -bool LLReflectionMap::shouldUpdate() -{ - const F32 TIMEOUT_INTERVAL = 30.f; // update no less than this often - const F32 RENDER_TIMEOUT = 1.f; // don't update if hasn't been used for rendering for this long - - if (mLastBindTime > gFrameTimeSeconds - RENDER_TIMEOUT) - { - if (mLastUpdateTime < gFrameTimeSeconds - TIMEOUT_INTERVAL) - { - return true; - } - } - - return false; -} - -void LLReflectionMap::dirty() -{ - mDirty = true; - mLastUpdateTime = gFrameTimeSeconds; -} - void LLReflectionMap::autoAdjustOrigin() { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; @@ -245,7 +223,9 @@ F32 LLReflectionMap::getNearClip() bool LLReflectionMap::getIsDynamic() { - if (mViewerObject && mViewerObject->getVolume()) + if (gSavedSettings.getS32("RenderReflectionProbeDetail") > (S32) LLReflectionMapManager::DetailLevel::STATIC_ONLY && + mViewerObject && + mViewerObject->getVolume()) { return ((LLVOVolume*)mViewerObject)->getReflectionProbeIsDynamic(); } diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index 071568e53c..cf0bc2ff27 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -43,12 +43,6 @@ public: // resolution - size of cube map to generate void update(U32 resolution, U32 face); - // return true if this probe should update *now* - bool shouldUpdate(); - - // Mark this reflection map as needing an update (resets last update time, so spamming this call will cause a cube map to never update) - void dirty(); - // for volume partition probes, try to place this probe in the best spot void autoAdjustOrigin(); @@ -104,7 +98,5 @@ public: // what priority should this probe have (higher is higher priority) U32 mPriority = 1; - - bool mDirty = true; }; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 60396b6c60..dc733687c3 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -96,11 +96,13 @@ void LLReflectionMapManager::update() mRenderTarget.allocate(targetRes, targetRes, color_fmt, use_depth_buffer, use_stencil_buffer, LLTexUnit::TT_RECT_TEXTURE); // hack to allocate render targets using gPipeline code + gCubeSnapshot = TRUE; auto* old_rt = gPipeline.mRT; gPipeline.mRT = &gProbeRT; gPipeline.allocateScreenBuffer(targetRes, targetRes); gPipeline.allocateShadowBuffer(targetRes, targetRes); gPipeline.mRT = old_rt; + gCubeSnapshot = FALSE; } if (mMipChain.empty()) @@ -154,6 +156,10 @@ void LLReflectionMapManager::update() bool did_update = false; + bool realtime = gSavedSettings.getS32("RenderReflectionProbeDetail") >= (S32)LLReflectionMapManager::DetailLevel::REALTIME; + + LLReflectionMap* closestDynamic = nullptr; + LLReflectionMap* oldestProbe = nullptr; if (mUpdatingProbe != nullptr) @@ -183,11 +189,30 @@ void LLReflectionMapManager::update() oldestProbe = probe; } + if (realtime && + closestDynamic == nullptr && + probe->mCubeArray.notNull() && + probe->getIsDynamic()) + { + closestDynamic = probe; + } + d.setSub(camera_pos, probe->mOrigin); probe->mDistance = d.getLength3().getF32()-probe->mRadius; } -#if 1 + if (realtime && closestDynamic != nullptr) + { + LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmu - realtime"); + // update the closest dynamic probe realtime + closestDynamic->autoAdjustOrigin(); + for (U32 i = 0; i < 6; ++i) + { + updateProbeFace(closestDynamic, i); + } + } + + // switch to updating the next oldest probe if (!did_update && oldestProbe != nullptr) { LLReflectionMap* probe = oldestProbe; @@ -201,9 +226,7 @@ void LLReflectionMapManager::update() mUpdatingProbe = probe; doProbeUpdate(); - probe->mDirty = false; } -#endif // update distance to camera for all probes std::sort(mProbes.begin(), mProbes.end(), CompareProbeDistance()); @@ -214,7 +237,6 @@ LLReflectionMap* LLReflectionMapManager::addProbe(LLSpatialGroup* group) LLReflectionMap* probe = new LLReflectionMap(); probe->mGroup = group; probe->mOrigin = group->getOctreeNode()->getCenter(); - probe->mDirty = true; if (gCubeSnapshot) { //snapshot is in progress, mProbes is being iterated over, defer insertion until next update @@ -295,7 +317,6 @@ LLReflectionMap* LLReflectionMapManager::registerViewerObject(LLViewerObject* vo LLReflectionMap* probe = new LLReflectionMap(); probe->mViewerObject = vobj; probe->mOrigin.load3(vobj->getPositionAgent().mV); - probe->mDirty = true; if (gCubeSnapshot) { //snapshot is in progress, mProbes is being iterated over, defer insertion until next update @@ -368,10 +389,23 @@ void LLReflectionMapManager::doProbeUpdate() LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; llassert(mUpdatingProbe != nullptr); + updateProbeFace(mUpdatingProbe, mUpdatingFace); + + if (++mUpdatingFace == 6) + { + updateNeighbors(mUpdatingProbe); + mUpdatingProbe = nullptr; + mUpdatingFace = 0; + } +} + +void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) +{ mRenderTarget.bindTarget(); + // hacky hot-swap of camera specific render targets auto* old_rt = gPipeline.mRT; gPipeline.mRT = &gProbeRT; - mUpdatingProbe->update(mRenderTarget.getWidth(), mUpdatingFace); + probe->update(mRenderTarget.getWidth(), face); gPipeline.mRT = old_rt; mRenderTarget.flush(); @@ -390,9 +424,9 @@ void LLReflectionMapManager::doProbeUpdate() gGL.loadIdentity(); gGL.flush(); - U32 res = LL_REFLECTION_PROBE_RESOLUTION*2; + U32 res = LL_REFLECTION_PROBE_RESOLUTION * 2; - S32 mips = log2((F32) LL_REFLECTION_PROBE_RESOLUTION)+0.5f; + S32 mips = log2((F32)LL_REFLECTION_PROBE_RESOLUTION) + 0.5f; for (int i = 0; i < mMipChain.size(); ++i) { @@ -409,10 +443,10 @@ void LLReflectionMapManager::doProbeUpdate() } gGL.begin(gGL.QUADS); - + gGL.texCoord2f(0, 0); gGL.vertex2f(-1, -1); - + gGL.texCoord2f(res, 0); gGL.vertex2f(1, -1); @@ -431,7 +465,7 @@ void LLReflectionMapManager::doProbeUpdate() if (mip >= 0) { mTexture->bind(0); - glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mip, 0, 0, mUpdatingProbe->mCubeIndex * 6 + mUpdatingFace, 0, 0, res, res); + glCopyTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, mip, 0, 0, probe->mCubeIndex * 6 + face, 0, 0, res, res); mTexture->unbind(); } mMipChain[i].flush(); @@ -443,13 +477,6 @@ void LLReflectionMapManager::doProbeUpdate() gReflectionMipProgram.unbind(); } - - if (++mUpdatingFace == 6) - { - updateNeighbors(mUpdatingProbe); - mUpdatingProbe = nullptr; - mUpdatingFace = 0; - } } void LLReflectionMapManager::rebuild() diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index bf963f3486..3b5cdc5520 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -46,6 +46,13 @@ class alignas(16) LLReflectionMapManager { LL_ALIGN_NEW public: + enum class DetailLevel + { + STATIC_ONLY = 0, + STATIC_AND_DYNAMIC, + REALTIME = 2 + }; + // allocate an environment map of the given resolution LLReflectionMapManager(); @@ -115,6 +122,9 @@ private: // perform an update on the currently updating Probe void doProbeUpdate(); + + // update the specified face of the specified probe + void updateProbeFace(LLReflectionMap* probe, U32 face); // list of active reflection maps std::vector > mProbes; @@ -133,6 +143,5 @@ private: LLReflectionMap* mUpdatingProbe = nullptr; U32 mUpdatingFace = 0; - }; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index a9e807e0f6..f445bc98eb 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -738,17 +738,8 @@ BOOL LLSpatialGroup::changeLOD() return FALSE; } -void LLSpatialGroup::dirtyReflectionProbe() -{ - if (mReflectionProbe != nullptr) - { - mReflectionProbe->dirty(); - } -} - void LLSpatialGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* entry) { - dirtyReflectionProbe(); addObject((LLDrawable*)entry->getDrawable()); unbound(); setState(OBJECT_DIRTY); @@ -756,7 +747,6 @@ void LLSpatialGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* void LLSpatialGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* entry) { - dirtyReflectionProbe(); removeObject((LLDrawable*)entry->getDrawable(), TRUE); LLViewerOctreeGroup::handleRemoval(node, entry); } @@ -793,8 +783,6 @@ void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c { LL_PROFILE_ZONE_SCOPED_CATEGORY_SPATIAL - dirtyReflectionProbe(); - if (child->getListenerCount() == 0) { new LLSpatialGroup(child, getSpatialPartition()); @@ -809,11 +797,6 @@ void LLSpatialGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* c assert_states_valid(this); } -void LLSpatialGroup::handleChildRemoval(const oct_node* parent, const oct_node* child) -{ - dirtyReflectionProbe(); -} - void LLSpatialGroup::destroyGL(bool keep_occlusion) { setState(LLSpatialGroup::GEOM_DIRTY | LLSpatialGroup::IMAGE_DIRTY); diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index bebd8aec85..07d62be7af 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -333,7 +333,6 @@ public: virtual void handleRemoval(const TreeNode* node, LLViewerOctreeEntry* face); virtual void handleDestruction(const TreeNode* node); virtual void handleChildAddition(const OctreeNode* parent, OctreeNode* child); - virtual void handleChildRemoval(const oct_node* parent, const oct_node* child); public: LL_ALIGN_16(LLVector4a mViewAngle); @@ -341,8 +340,6 @@ public: F32 mObjectBoxSize; //cached mObjectBounds[1].getLength3() - void dirtyReflectionProbe(); - protected: virtual ~LLSpatialGroup(); diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h index 549778a841..b5841772ed 100644 --- a/indra/newview/llviewercamera.h +++ b/indra/newview/llviewercamera.h @@ -47,15 +47,14 @@ public: typedef enum { CAMERA_WORLD = 0, - CAMERA_SHADOW0, - CAMERA_SHADOW1, - CAMERA_SHADOW2, - CAMERA_SHADOW3, - CAMERA_SHADOW4, - CAMERA_SHADOW5, + CAMERA_SUN_SHADOW0, + CAMERA_SUN_SHADOW1, + CAMERA_SUN_SHADOW2, + CAMERA_SUN_SHADOW3, + CAMERA_SPOT_SHADOW0, + CAMERA_SPOT_SHADOW1, CAMERA_WATER0, CAMERA_WATER1, - CAMERA_GI_SOURCE, NUM_CAMERAS } eCameraID; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 28dc3781ba..8bac5131cf 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -739,7 +739,8 @@ void LLPipeline::requestResizeShadowTexture() void LLPipeline::resizeShadowTexture() { - releaseShadowTargets(); + releaseSunShadowTargets(); + releaseSpotShadowTargets(); allocateShadowBuffer(mRT->width, mRT->height); gResizeShadowTexture = FALSE; } @@ -754,7 +755,8 @@ void LLPipeline::resizeScreenTexture() if (gResizeScreenTexture || (resX != mRT->screen.getWidth()) || (resY != mRT->screen.getHeight())) { releaseScreenBuffers(); - releaseShadowTargets(); + releaseSunShadowTargets(); + releaseSpotShadowTargets(); allocateScreenBuffer(resX,resY); gResizeScreenTexture = FALSE; } @@ -913,7 +915,8 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) { mRT->deferredLight.release(); - releaseShadowTargets(); + releaseSunShadowTargets(); + releaseSpotShadowTargets(); mRT->fxaaBuffer.release(); mRT->screen.release(); @@ -942,66 +945,66 @@ inline U32 BlurHappySize(U32 x, F32 scale) { return U32( x * scale + 16.0f) & ~0 bool LLPipeline::allocateShadowBuffer(U32 resX, U32 resY) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; - if (LLPipeline::sRenderDeferred) - { - S32 shadow_detail = RenderShadowDetail; + if (LLPipeline::sRenderDeferred) + { + S32 shadow_detail = RenderShadowDetail; - const U32 occlusion_divisor = 3; + const U32 occlusion_divisor = 3; - F32 scale = llmax(0.f,RenderShadowResolutionScale); - U32 sun_shadow_map_width = BlurHappySize(resX, scale); - U32 sun_shadow_map_height = BlurHappySize(resY, scale); + F32 scale = llmax(0.f, RenderShadowResolutionScale); + U32 sun_shadow_map_width = BlurHappySize(resX, scale); + U32 sun_shadow_map_height = BlurHappySize(resY, scale); - if (shadow_detail > 0) - { //allocate 4 sun shadow maps - for (U32 i = 0; i < 4; i++) - { - if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (shadow_detail > 0) + { //allocate 4 sun shadow maps + for (U32 i = 0; i < 4; i++) + { + if (!mRT->shadow[i].allocate(sun_shadow_map_width, sun_shadow_map_height, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) { return false; } - if (!mRT->shadowOcclusion[i].allocate(sun_shadow_map_width/occlusion_divisor, sun_shadow_map_height/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) + if (!mRT->shadowOcclusion[i].allocate(sun_shadow_map_width / occlusion_divisor, sun_shadow_map_height / occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) { return false; } - } - } - else - { - for (U32 i = 0; i < 4; i++) - { - releaseShadowTarget(i); - } - } + } + } + else + { + for (U32 i = 0; i < 4; i++) + { + releaseSunShadowTarget(i); + } + } - U32 width = (U32) (resX*scale); - U32 height = width; + if (!gCubeSnapshot) // hack to not allocate spot shadow maps during ReflectionMapManager init + { + U32 width = (U32)(resX * scale); + U32 height = width; - if (shadow_detail > 1) - { //allocate two spot shadow maps - U32 spot_shadow_map_width = width; - U32 spot_shadow_map_height = height; - for (U32 i = 4; i < 6; i++) - { - if (!mRT->shadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) - { - return false; - } - if (!mRT->shadowOcclusion[i].allocate(spot_shadow_map_width/occlusion_divisor, height/occlusion_divisor, 0, TRUE, FALSE)) - { - return false; - } - } + if (shadow_detail > 1) + { //allocate two spot shadow maps + U32 spot_shadow_map_width = width; + U32 spot_shadow_map_height = height; + for (U32 i = 0; i < 2; i++) + { + if (!mSpotShadow[i].allocate(spot_shadow_map_width, spot_shadow_map_height, 0, TRUE, FALSE)) + { + return false; + } + if (!mSpotShadowOcclusion[i].allocate(spot_shadow_map_width / occlusion_divisor, height / occlusion_divisor, 0, TRUE, FALSE)) + { + return false; + } + } + } + else + { + releaseSpotShadowTargets(); + } } - else - { - for (U32 i = 4; i < 6; i++) - { - releaseShadowTarget(i); - } - } - } + } return true; } @@ -1175,7 +1178,8 @@ void LLPipeline::releaseLUTBuffers() void LLPipeline::releaseShadowBuffers() { - releaseShadowTargets(); + releaseSunShadowTargets(); + releaseSpotShadowTargets(); } void LLPipeline::releaseScreenBuffers() @@ -1191,20 +1195,33 @@ void LLPipeline::releaseScreenBuffers() } -void LLPipeline::releaseShadowTarget(U32 index) +void LLPipeline::releaseSunShadowTarget(U32 index) { + llassert(index < 4); mRT->shadow[index].release(); mRT->shadowOcclusion[index].release(); } -void LLPipeline::releaseShadowTargets() +void LLPipeline::releaseSunShadowTargets() { - for (U32 i = 0; i < 6; i++) + for (U32 i = 0; i < 4; i++) { - releaseShadowTarget(i); + releaseSunShadowTarget(i); } } +void LLPipeline::releaseSpotShadowTargets() +{ + if (!gCubeSnapshot) // hack to avoid freeing spot shadows during ReflectionMapManager init + { + for (U32 i = 0; i < 2; i++) + { + mSpotShadow[i].release(); + mSpotShadowOcclusion[i].release(); + } + } +} + void LLPipeline::createGLBuffers() { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; @@ -8162,7 +8179,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ for (U32 i = 0; i < 4; i++) { - LLRenderTarget* shadow_target = getShadowTarget(i); + LLRenderTarget* shadow_target = getSunShadowTarget(i); if (shadow_target) { channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i, LLTexUnit::TT_TEXTURE); @@ -8170,7 +8187,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ if (channel > -1) { stop_glerror(); - gGL.getTexUnit(channel)->bind(getShadowTarget(i), TRUE); + gGL.getTexUnit(channel)->bind(getSunShadowTarget(i), TRUE); gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); stop_glerror(); @@ -8182,27 +8199,27 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ } } - for (U32 i = 4; i < 6; i++) - { - channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0+i); - stop_glerror(); - if (channel > -1) - { - stop_glerror(); - LLRenderTarget* shadow_target = getShadowTarget(i); - if (shadow_target) - { - gGL.getTexUnit(channel)->bind(shadow_target, TRUE); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); - gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); - stop_glerror(); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); - stop_glerror(); - } - } - } + for (U32 i = 4; i < 6; i++) + { + channel = shader.enableTexture(LLShaderMgr::DEFERRED_SHADOW0 + i); + stop_glerror(); + if (channel > -1) + { + stop_glerror(); + LLRenderTarget* shadow_target = getSpotShadowTarget(i-4); + if (shadow_target) + { + gGL.getTexUnit(channel)->bind(shadow_target, TRUE); + gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_ANISOTROPIC); + gGL.getTexUnit(channel)->setTextureAddressMode(LLTexUnit::TAM_CLAMP); + stop_glerror(); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL); + stop_glerror(); + } + } + } stop_glerror(); @@ -8313,7 +8330,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, mTransformedSunDir.mV); shader.uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, mTransformedMoonDir.mV); shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mRT->shadow[0].getWidth(), mRT->shadow[0].getHeight()); - shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mRT->shadow[4].getWidth(), mRT->shadow[4].getHeight()); + shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mSpotShadow[0].getWidth(), mSpotShadow[0].getHeight()); shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); shader.uniform1f(LLShaderMgr::DEFERRED_NORM_CUTOFF, RenderEdgeNormCutoff); @@ -9077,7 +9094,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) shader.uniform1f(LLShaderMgr::PROJECTOR_SHADOW_FADE, 1.f); } - if (!gCubeSnapshot) + //if (!gCubeSnapshot) { LLDrawable* potential = drawablep; //determine if this is a good light for casting shadows @@ -9668,7 +9685,9 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gDeferredShadowCubeProgram.bind(); } - LLRenderTarget& occlusion_target = mRT->shadowOcclusion[LLViewerCamera::sCurCameraID - 1]; + LLRenderTarget& occlusion_target = LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_SPOT_SHADOW0 ? + mSpotShadowOcclusion[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SPOT_SHADOW0] : + mRT->shadowOcclusion[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SUN_SHADOW0]; occlusion_target.bindTarget(); updateCull(shadow_cam, result); @@ -9812,7 +9831,9 @@ void LLPipeline::renderShadow(glh::matrix4f& view, glh::matrix4f& proj, LLCamera gGLLastMatrix = NULL; gGL.loadMatrix(gGLModelView); - LLRenderTarget& occlusion_source = mRT->shadow[LLViewerCamera::sCurCameraID - 1]; + LLRenderTarget& occlusion_source = LLViewerCamera::sCurCameraID >= LLViewerCamera::CAMERA_SPOT_SHADOW0 ? + mSpotShadow[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SPOT_SHADOW0] : + mRT->shadow[LLViewerCamera::sCurCameraID - LLViewerCamera::CAMERA_SUN_SHADOW0]; if (occlude > 1) { @@ -10087,11 +10108,18 @@ void LLPipeline::generateHighlight(LLCamera& camera) } } -LLRenderTarget* LLPipeline::getShadowTarget(U32 i) +LLRenderTarget* LLPipeline::getSunShadowTarget(U32 i) { + llassert(i < 4); return &mRT->shadow[i]; } +LLRenderTarget* LLPipeline::getSpotShadowTarget(U32 i) +{ + llassert(i < 2); + return &mSpotShadow[i]; +} + static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW("Gen Sun Shadow"); static LLTrace::BlockTimerStatHandle FTM_GEN_SUN_SHADOW_SPOT_RENDER("Spot Shadow Render"); @@ -10371,7 +10399,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mShadowFrustPoints[j].clear(); } - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0+j); + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SUN_SHADOW0+j); //restore render matrices set_current_modelview(saved_view); @@ -10745,116 +10773,119 @@ void LLPipeline::generateSunShadow(LLCamera& camera) { if (!gCubeSnapshot) //skip updating spot shadow maps during cubemap updates { - LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); - F32 fade_amt = gFrameIntervalSeconds.value() - * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); - - //update shadow targets - for (U32 i = 0; i < 2; i++) - { //for each current shadow - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW4+i); - - if (mShadowSpotLight[i].notNull() && - (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || - mShadowSpotLight[i] == mTargetShadowSpotLight[1])) - { //keep this spotlight - mSpotLightFade[i] = llmin(mSpotLightFade[i]+fade_amt, 1.f); - } - else - { //fade out this light - mSpotLightFade[i] = llmax(mSpotLightFade[i]-fade_amt, 0.f); - - if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) - { //faded out, grab one of the pending spots (whichever one isn't already taken) - if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i+1)%2]) - { - mShadowSpotLight[i] = mTargetShadowSpotLight[0]; - } - else - { - mShadowSpotLight[i] = mTargetShadowSpotLight[1]; - } - } - } - } - - for (S32 i = 0; i < 2; i++) - { - set_current_modelview(saved_view); - set_current_projection(saved_proj); + LLTrace::CountStatHandle<>* velocity_stat = LLViewerCamera::getVelocityStat(); + F32 fade_amt = gFrameIntervalSeconds.value() + * llmax(LLTrace::get_frame_recording().getLastRecording().getSum(*velocity_stat) / LLTrace::get_frame_recording().getLastRecording().getDuration().value(), 1.0); + + //update shadow targets + for (U32 i = 0; i < 2; i++) + { //for each current shadow + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SPOT_SHADOW0 + i); + + if (mShadowSpotLight[i].notNull() && + (mShadowSpotLight[i] == mTargetShadowSpotLight[0] || + mShadowSpotLight[i] == mTargetShadowSpotLight[1])) + { //keep this spotlight + mSpotLightFade[i] = llmin(mSpotLightFade[i] + fade_amt, 1.f); + } + else + { //fade out this light + mSpotLightFade[i] = llmax(mSpotLightFade[i] - fade_amt, 0.f); - if (mShadowSpotLight[i].isNull()) - { - continue; + if (mSpotLightFade[i] == 0.f || mShadowSpotLight[i].isNull()) + { //faded out, grab one of the pending spots (whichever one isn't already taken) + if (mTargetShadowSpotLight[0] != mShadowSpotLight[(i + 1) % 2]) + { + mShadowSpotLight[i] = mTargetShadowSpotLight[0]; + } + else + { + mShadowSpotLight[i] = mTargetShadowSpotLight[1]; + } + } } + } + } - LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); + for (S32 i = 0; i < 2; i++) + { + set_current_modelview(saved_view); + set_current_projection(saved_proj); - if (!volume) - { - mShadowSpotLight[i] = NULL; - continue; - } + if (mShadowSpotLight[i].isNull()) + { + continue; + } - LLDrawable* drawable = mShadowSpotLight[i]; + LLVOVolume* volume = mShadowSpotLight[i]->getVOVolume(); - LLVector3 params = volume->getSpotLightParams(); - F32 fov = params.mV[0]; + if (!volume) + { + mShadowSpotLight[i] = NULL; + continue; + } - //get agent->light space matrix (modelview) - LLVector3 center = drawable->getPositionAgent(); - LLQuaternion quat = volume->getRenderRotation(); + LLDrawable* drawable = mShadowSpotLight[i]; - //get near clip plane - LLVector3 scale = volume->getScale(); - LLVector3 at_axis(0, 0, -scale.mV[2] * 0.5f); - at_axis *= quat; + LLVector3 params = volume->getSpotLightParams(); + F32 fov = params.mV[0]; - LLVector3 np = center + at_axis; - at_axis.normVec(); + //get agent->light space matrix (modelview) + LLVector3 center = drawable->getPositionAgent(); + LLQuaternion quat = volume->getRenderRotation(); - //get origin that has given fov for plane np, at_axis, and given scale - F32 dist = (scale.mV[1] * 0.5f) / tanf(fov * 0.5f); + //get near clip plane + LLVector3 scale = volume->getScale(); + LLVector3 at_axis(0, 0, -scale.mV[2] * 0.5f); + at_axis *= quat; - LLVector3 origin = np - at_axis * dist; + LLVector3 np = center + at_axis; + at_axis.normVec(); - LLMatrix4 mat(quat, LLVector4(origin, 1.f)); + //get origin that has given fov for plane np, at_axis, and given scale + F32 dist = (scale.mV[1] * 0.5f) / tanf(fov * 0.5f); - view[i + 4] = glh::matrix4f((F32*)mat.mMatrix); + LLVector3 origin = np - at_axis * dist; - view[i + 4] = view[i + 4].inverse(); + LLMatrix4 mat(quat, LLVector4(origin, 1.f)); - //get perspective matrix - F32 near_clip = dist + 0.01f; - F32 width = scale.mV[VX]; - F32 height = scale.mV[VY]; - F32 far_clip = dist + volume->getLightRadius() * 1.5f; + view[i + 4] = glh::matrix4f((F32*)mat.mMatrix); - F32 fovy = fov * RAD_TO_DEG; - F32 aspect = width / height; + view[i + 4] = view[i + 4].inverse(); - proj[i + 4] = gl_perspective(fovy, aspect, near_clip, far_clip); + //get perspective matrix + F32 near_clip = dist + 0.01f; + F32 width = scale.mV[VX]; + F32 height = scale.mV[VY]; + F32 far_clip = dist + volume->getLightRadius() * 1.5f; - //translate and scale to from [-1, 1] to [0, 1] - glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, - 0.f, 0.5f, 0.f, 0.5f, - 0.f, 0.f, 0.5f, 0.5f, - 0.f, 0.f, 0.f, 1.f); + F32 fovy = fov * RAD_TO_DEG; + F32 aspect = width / height; - set_current_modelview(view[i + 4]); - set_current_projection(proj[i + 4]); + proj[i + 4] = gl_perspective(fovy, aspect, near_clip, far_clip); - mSunShadowMatrix[i + 4] = trans * proj[i + 4] * view[i + 4] * inv_view; + //translate and scale to from [-1, 1] to [0, 1] + glh::matrix4f trans(0.5f, 0.f, 0.f, 0.5f, + 0.f, 0.5f, 0.f, 0.5f, + 0.f, 0.f, 0.5f, 0.5f, + 0.f, 0.f, 0.f, 1.f); - for (U32 j = 0; j < 16; j++) - { - gGLLastModelView[j] = mShadowModelview[i + 4].m[j]; - gGLLastProjection[j] = mShadowProjection[i + 4].m[j]; - } + set_current_modelview(view[i + 4]); + set_current_projection(proj[i + 4]); - mShadowModelview[i + 4] = view[i + 4]; - mShadowProjection[i + 4] = proj[i + 4]; + mSunShadowMatrix[i + 4] = trans * proj[i + 4] * view[i + 4] * inv_view; + for (U32 j = 0; j < 16; j++) + { + gGLLastModelView[j] = mShadowModelview[i + 4].m[j]; + gGLLastProjection[j] = mShadowProjection[i + 4].m[j]; + } + + mShadowModelview[i + 4] = view[i + 4]; + mShadowProjection[i + 4] = proj[i + 4]; + + if (!gCubeSnapshot) //skip updating spot shadow maps during cubemap updates + { LLCamera shadow_cam = camera; shadow_cam.setFar(far_clip); shadow_cam.setOrigin(origin); @@ -10863,15 +10894,17 @@ void LLPipeline::generateSunShadow(LLCamera& camera) stop_glerror(); - mRT->shadow[i + 4].bindTarget(); - mRT->shadow[i + 4].getViewport(gGLViewport); - mRT->shadow[i + 4].clear(); + // + + mSpotShadow[i].bindTarget(); + mSpotShadow[i].getViewport(gGLViewport); + mSpotShadow[i].clear(); - U32 target_width = mRT->shadow[i + 4].getWidth(); + U32 target_width = mSpotShadow[i].getWidth(); static LLCullResult result[2]; - LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0 + i + 4); + LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SPOT_SHADOW0 + i); RenderSpotLight = drawable; @@ -10879,7 +10912,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) RenderSpotLight = nullptr; - mRT->shadow[i + 4].flush(); + mSpotShadow[i].flush(); } } } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index f4c55bde7d..f05b7aec8e 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -218,8 +218,9 @@ public: U32 addObject(LLViewerObject *obj); void enableShadows(const bool enable_shadows); - void releaseShadowTargets(); - void releaseShadowTarget(U32 index); + void releaseSpotShadowTargets(); + void releaseSunShadowTargets(); + void releaseSunShadowTarget(U32 index); // void setLocalLighting(const bool local_lighting); // bool isLocalLightingEnabled() const; @@ -304,7 +305,8 @@ public: void generateWaterReflection(LLCamera& camera); void generateSunShadow(LLCamera& camera); - LLRenderTarget* getShadowTarget(U32 i); + LLRenderTarget* getSunShadowTarget(U32 i); + LLRenderTarget* getSpotShadowTarget(U32 i); void generateHighlight(LLCamera& camera); void renderHighlight(const LLViewerObject* obj, F32 fade); @@ -660,12 +662,15 @@ public: LLRenderTarget deferredLight; //sun shadow map - LLRenderTarget shadow[6]; - LLRenderTarget shadowOcclusion[6]; + LLRenderTarget shadow[4]; + LLRenderTarget shadowOcclusion[4]; }; RenderTargetPack* mRT; + LLRenderTarget mSpotShadow[2]; + LLRenderTarget mSpotShadowOcclusion[2]; + LLRenderTarget mHighlight; LLRenderTarget mPhysicsDisplay; @@ -688,6 +693,7 @@ public: LLVector3 mShadowFrustOrigin[4]; LLCamera mShadowCamera[8]; LLVector3 mShadowExtents[4][2]; + // TODO : separate Sun Shadow and Spot Shadow matrices glh::matrix4f mSunShadowMatrix[6]; glh::matrix4f mShadowModelview[6]; glh::matrix4f mShadowProjection[6]; diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index d1e167df64..8e12a01c6f 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -863,8 +863,42 @@ name="2" value="2"/> - - + + Reflections: + + + + + + + + Date: Fri, 10 Jun 2022 16:36:38 -0500 Subject: SL-17523 Add reflection probe ambiance to windlight settings and integrate with UI and ReflectionMapManager --- indra/llinventory/llsettingssky.cpp | 17 ++++++++++++++++ indra/llinventory/llsettingssky.h | 6 ++++++ indra/llrender/llshadermgr.cpp | 1 + indra/llrender/llshadermgr.h | 1 + indra/newview/llpaneleditsky.cpp | 15 ++++++++++++++ indra/newview/llpaneleditsky.h | 1 + indra/newview/llreflectionmap.cpp | 4 +--- indra/newview/llreflectionmapmanager.cpp | 8 +++++++- indra/newview/llsettingsvo.cpp | 1 + .../default/xui/en/panel_settings_sky_atmos.xml | 23 ++++++++++++++++++++++ 10 files changed, 73 insertions(+), 4 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 83a92f08d0..d4e616abc2 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -131,6 +131,8 @@ const std::string LLSettingsSky::SETTING_SKY_MOISTURE_LEVEL("moisture_level"); const std::string LLSettingsSky::SETTING_SKY_DROPLET_RADIUS("droplet_radius"); const std::string LLSettingsSky::SETTING_SKY_ICE_LEVEL("ice_level"); +const std::string LLSettingsSky::SETTING_REFLECTION_PROBE_AMBIANCE("reflection_probe_ambiance"); + const LLUUID LLSettingsSky::DEFAULT_ASSET_ID("3ae23978-ac82-bcf3-a9cb-ba6e52dcb9ad"); static const LLUUID DEFAULT_SUN_ID("32bfbcea-24b1-fb9d-1ef9-48a28a63730f"); // dataserver @@ -630,6 +632,9 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList() validation.push_back(Validator(SETTING_SKY_ICE_LEVEL, false, LLSD::TypeReal, boost::bind(&Validator::verifyFloatRange, _1, _2, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_REFLECTION_PROBE_AMBIANCE, false, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, _2, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_RAYLEIGH_CONFIG, true, LLSD::TypeArray, &validateRayleighLayers)); validation.push_back(Validator(SETTING_ABSORPTION_CONFIG, true, LLSD::TypeArray, &validateAbsorptionLayers)); validation.push_back(Validator(SETTING_MIE_CONFIG, true, LLSD::TypeArray, &validateMieLayers)); @@ -755,6 +760,8 @@ LLSD LLSettingsSky::defaults(const LLSettingsBase::TrackPosition& position) dfltsetting[SETTING_SKY_DROPLET_RADIUS] = 800.0f; dfltsetting[SETTING_SKY_ICE_LEVEL] = 0.0f; + dfltsetting[SETTING_REFLECTION_PROBE_AMBIANCE] = 0.0f; + dfltsetting[SETTING_RAYLEIGH_CONFIG] = rayleighConfigDefault(); dfltsetting[SETTING_MIE_CONFIG] = mieConfigDefault(); dfltsetting[SETTING_ABSORPTION_CONFIG] = absorptionConfigDefault(); @@ -1132,6 +1139,11 @@ void LLSettingsSky::setSkyIceLevel(F32 ice_level) setValue(SETTING_SKY_ICE_LEVEL, ice_level); } +void LLSettingsSky::setReflectionProbeAmbiance(F32 ambiance) +{ + setValue(SETTING_REFLECTION_PROBE_AMBIANCE, ambiance); +} + void LLSettingsSky::setAmbientColor(const LLColor3 &val) { mSettings[SETTING_LEGACY_HAZE][SETTING_AMBIENT] = val.getValue(); @@ -1420,6 +1432,11 @@ F32 LLSettingsSky::getSkyIceLevel() const return mSettings[SETTING_SKY_ICE_LEVEL].asReal(); } +F32 LLSettingsSky::getReflectionProbeAmbiance() const +{ + return mSettings[SETTING_REFLECTION_PROBE_AMBIANCE].asReal(); +} + F32 LLSettingsSky::getSkyBottomRadius() const { return mSettings[SETTING_SKY_BOTTOM_RADIUS].asReal(); diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index fa9326f006..715d31518b 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -97,6 +97,8 @@ public: static const std::string SETTING_SKY_DROPLET_RADIUS; static const std::string SETTING_SKY_ICE_LEVEL; + static const std::string SETTING_REFLECTION_PROBE_AMBIANCE; + static const std::string SETTING_LEGACY_HAZE; static const LLUUID DEFAULT_ASSET_ID; @@ -131,6 +133,8 @@ public: F32 getSkyDropletRadius() const; F32 getSkyIceLevel() const; + F32 getReflectionProbeAmbiance() const; + // Return first (only) profile layer represented in LLSD LLSD getRayleighConfig() const; LLSD getMieConfig() const; @@ -159,6 +163,8 @@ public: void setSkyDropletRadius(F32 radius); void setSkyIceLevel(F32 ice_level); + void setReflectionProbeAmbiance(F32 ambiance); + //--------------------------------------------------------------------- LLColor3 getAmbientColor() const; void setAmbientColor(const LLColor3 &val); diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index bdc1f78201..e2e1ff9714 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1342,6 +1342,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("halo_map"); mReservedUniforms.push_back("moon_brightness"); mReservedUniforms.push_back("cloud_variance"); + mReservedUniforms.push_back("reflection_probe_ambiance"); 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 663ba28b6d..d3bb2b9db4 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -243,6 +243,7 @@ public: CLOUD_VARIANCE, // "cloud_variance" + REFLECTION_PROBE_AMBIANCE, // "reflection_probe_ambiance" SH_INPUT_L1R, // "sh_input_r" SH_INPUT_L1G, // "sh_input_g" SH_INPUT_L1B, // "sh_input_b" diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index a169712bd8..d17845ebc5 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -108,6 +108,8 @@ namespace const std::string FIELD_SKY_DENSITY_DROPLET_RADIUS("droplet_radius"); const std::string FIELD_SKY_DENSITY_ICE_LEVEL("ice_level"); + const std::string FIELD_REFLECTION_PROBE_AMBIANCE("probe_ambiance"); + const F32 SLIDER_SCALE_SUN_AMBIENT(3.0f); const F32 SLIDER_SCALE_BLUE_HORIZON_DENSITY(2.0f); const F32 SLIDER_SCALE_GLOW_R(20.0f); @@ -150,6 +152,7 @@ BOOL LLPanelSettingsSkyAtmosTab::postBuild() getChild(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoistureLevelChanged(); }); getChild(FIELD_SKY_DENSITY_DROPLET_RADIUS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onDropletRadiusChanged(); }); getChild(FIELD_SKY_DENSITY_ICE_LEVEL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onIceLevelChanged(); }); + getChild(FIELD_REFLECTION_PROBE_AMBIANCE)->setCommitCallback([this](LLUICtrl*, const LLSD&) { onReflectionProbeAmbianceChanged(); }); refresh(); return TRUE; @@ -172,6 +175,7 @@ void LLPanelSettingsSkyAtmosTab::setEnabled(BOOL enabled) getChild(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_DROPLET_RADIUS)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_ICE_LEVEL)->setEnabled(enabled); + getChild(FIELD_REFLECTION_PROBE_AMBIANCE)->setEnabled(enabled); } } @@ -203,10 +207,12 @@ void LLPanelSettingsSkyAtmosTab::refresh() F32 moisture_level = mSkySettings->getSkyMoistureLevel(); F32 droplet_radius = mSkySettings->getSkyDropletRadius(); F32 ice_level = mSkySettings->getSkyIceLevel(); + F32 rp_ambiance = mSkySettings->getReflectionProbeAmbiance(); getChild(FIELD_SKY_DENSITY_MOISTURE_LEVEL)->setValue(moisture_level); getChild(FIELD_SKY_DENSITY_DROPLET_RADIUS)->setValue(droplet_radius); getChild(FIELD_SKY_DENSITY_ICE_LEVEL)->setValue(ice_level); + getChild(FIELD_REFLECTION_PROBE_AMBIANCE)->setValue(rp_ambiance); } //------------------------------------------------------------------------- @@ -311,6 +317,15 @@ void LLPanelSettingsSkyAtmosTab::onIceLevelChanged() setIsDirty(); } +void LLPanelSettingsSkyAtmosTab::onReflectionProbeAmbianceChanged() +{ + if (!mSkySettings) return; + F32 ambiance = getChild(FIELD_REFLECTION_PROBE_AMBIANCE)->getValue().asReal(); + mSkySettings->setReflectionProbeAmbiance(ambiance); + mSkySettings->update(); + setIsDirty(); +} + //========================================================================== LLPanelSettingsSkyCloudTab::LLPanelSettingsSkyCloudTab() : LLPanelSettingsSky() diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h index cb63d40b0c..cd89e02eea 100644 --- a/indra/newview/llpaneleditsky.h +++ b/indra/newview/llpaneleditsky.h @@ -79,6 +79,7 @@ private: void onMoistureLevelChanged(); void onDropletRadiusChanged(); void onIceLevelChanged(); + void onReflectionProbeAmbianceChanged(); }; diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 500485fc70..4d4eb802f1 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -196,15 +196,13 @@ extern LLControlGroup gSavedSettings; F32 LLReflectionMap::getAmbiance() { - static LLCachedControl minimum_ambiance(gSavedSettings, "RenderReflectionProbeAmbiance", 0.f); - F32 ret = 0.f; if (mViewerObject && mViewerObject->getVolume()) { ret = ((LLVOVolume*)mViewerObject)->getReflectionProbeAmbiance(); } - return llmax(ret, minimum_ambiance()); + return ret; } F32 LLReflectionMap::getNearClip() diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index dc733687c3..48ed22d79f 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -33,6 +33,7 @@ #include "pipeline.h" #include "llviewershadermgr.h" #include "llviewercontrol.h" +#include "llenvironment.h" extern BOOL gCubeSnapshot; extern BOOL gTeleportDisplay; @@ -559,6 +560,11 @@ void LLReflectionMapManager::updateUniforms() S32 count = 0; U32 nc = 0; // neighbor "cursor" - index into refNeighbor to start writing the next probe's list of neighbors + LLEnvironment& environment = LLEnvironment::instance(); + LLSettingsSky::ptr_t psky = environment.getCurrentSky(); + + F32 minimum_ambiance = psky->getReflectionProbeAmbiance(); + for (auto* refmap : mReflectionMaps) { if (refmap == nullptr) @@ -591,7 +597,7 @@ void LLReflectionMapManager::updateUniforms() rpd.refIndex[count][3] = -rpd.refIndex[count][3]; } - rpd.refParams[count].set(refmap->getAmbiance(), 0.f, 0.f, 0.f); + rpd.refParams[count].set(llmax(minimum_ambiance, refmap->getAmbiance()), 0.f, 0.f, 0.f); S32 ni = nc; // neighbor ("index") - index into refNeighbor to write indices for current reflection probe's neighbors { diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 14a9f4aa30..ed823fbba4 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -758,6 +758,7 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); param_map[SETTING_SKY_ICE_LEVEL] = DefaultParam(LLShaderMgr::ICE_LEVEL, sky_defaults[SETTING_SKY_ICE_LEVEL]); + param_map[SETTING_REFLECTION_PROBE_AMBIANCE] = DefaultParam(LLShaderMgr::REFLECTION_PROBE_AMBIANCE, sky_defaults[SETTING_REFLECTION_PROBE_AMBIANCE]); // AdvancedAtmospherics TODO // Provide mappings for new shader params here } diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml index 6f82a0efa1..094be36b01 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml @@ -315,6 +315,29 @@ top_delta="20" width="219" can_edit_text="true"/> + + Reflection Probe Ambiance: + + -- cgit v1.3 From 8b4347cb10ab922f5001306912983cdd73a68309 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 21 Jun 2022 11:58:58 -0500 Subject: SL-17600 Revise reflection probe priorities --- indra/newview/llreflectionmap.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 4d4eb802f1..2a7ab84501 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -74,10 +74,11 @@ void LLReflectionMap::autoAdjustOrigin() d.setAdd(bounds[0], bounds[1]); d.sub(mOrigin); mRadius = d.getLength3().getF32(); + mPriority = 1; } else if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) { - mPriority = 8; + mPriority = 1; // cast a ray towards 8 corners of bounding box // nudge origin towards center of empty space @@ -155,7 +156,7 @@ void LLReflectionMap::autoAdjustOrigin() else { // user placed probe - mPriority = 64; + mPriority = 2; // use center of octree node volume for nodes that are just branches without data mOrigin = node->getCenter(); -- cgit v1.3 From 5034c565bf627b4ecaac44376566212f432d97ff Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Wed, 14 Sep 2022 00:28:28 +0300 Subject: SL-18044 (PBR) No-copy textures not applying to objects --- indra/newview/llreflectionmap.cpp | 5 ++ indra/newview/llselectmgr.cpp | 138 ++++++++++++++++++++++++++++++++---- indra/newview/lltexturectrl.cpp | 51 +------------ indra/newview/lltooldraganddrop.cpp | 5 ++ indra/newview/llviewerobject.cpp | 7 +- 5 files changed, 141 insertions(+), 65 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 2a7ab84501..d9dd1e9381 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -82,6 +82,11 @@ void LLReflectionMap::autoAdjustOrigin() // cast a ray towards 8 corners of bounding box // nudge origin towards center of empty space + if (!node) + { + return; + } + if (node->isLeaf() || node->getChildCount() > 1 || node->getData().size() > 0) { // use center of object bounding box for leaf nodes or nodes with multiple child nodes mOrigin = bounds[0]; diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index 12ba29466d..7d994f1d05 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -63,6 +63,7 @@ #include "llfloatertools.h" #include "llframetimer.h" #include "llfocusmgr.h" +#include "llgltfmateriallist.h" #include "llhudeffecttrail.h" #include "llhudmanager.h" #include "llinventorymodel.h" @@ -1792,16 +1793,56 @@ void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id) asset_id = mItem->getAssetUUID(); } + if (asset_id.notNull() && !objectp->hasRenderMaterialParams()) + { + // make sure param section exists + objectp->setParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL, TRUE, false /*prevent an update*/); + } + if (te != -1) { - objectp->setRenderMaterialID(te, asset_id); + LLTextureEntry* tep = objectp->getTE(te); + if (asset_id.notNull()) + { + tep->setGLTFMaterial(gGLTFMaterialList.getMaterial(asset_id)); + } + else + { + tep->setGLTFMaterial(nullptr); + } + + objectp->faceMappingChanged(); + gPipeline.markTextured(objectp->mDrawable); + + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)objectp->getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) + { + param_block->setMaterial(te, asset_id); + } } - else + else // Shouldn't happen? { S32 num_faces = objectp->getNumTEs(); for (S32 face = 0; face < num_faces; face++) { - objectp->setRenderMaterialID(face, asset_id); + LLTextureEntry* tep = objectp->getTE(face); + if (asset_id.notNull()) + { + tep->setGLTFMaterial(gGLTFMaterialList.getMaterial(asset_id)); + } + else + { + tep->setGLTFMaterial(nullptr); + } + + objectp->faceMappingChanged(); + gPipeline.markTextured(objectp->mDrawable); + + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)objectp->getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) + { + param_block->setMaterial(face, asset_id); + } } } @@ -1809,26 +1850,43 @@ void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id) } }; - if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) + // TODO: once PBR starts supporting permissions, implement/figure this out + /*if (item && !item->getPermissions().allowOperationBy(PERM_COPY, gAgent.getID())) { getSelection()->applyNoCopyTextureToTEs(item); } - else + else*/ { f setfunc(item, mat_id); getSelection()->applyToTEs(&setfunc); } - struct g : public LLSelectedObjectFunctor { LLViewerInventoryItem* mItem; g(LLViewerInventoryItem* item) : mItem(item) {} virtual bool apply(LLViewerObject* object) { + if (object && !object->permModify()) + { + return false; + } + + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)object->getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) + { + if (param_block->isEmpty()) + { + object->setHasRenderMaterialParams(false); + } + else + { + object->parameterChanged(LLNetworkData::PARAMS_RENDER_MATERIAL, true); + } + } + if (!mItem) { - object->sendTEUpdate(); // 1 particle effect per object LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE); effectp->setSourceObject(gAgentAvatarp); @@ -1836,6 +1894,8 @@ void LLSelectMgr::selectionSetGLTFMaterial(const LLUUID& mat_id) effectp->setDuration(LL_HUD_DUR_SHORT); effectp->setColor(LLColor4U(gAgent.getEffectColor())); } + + object->sendTEUpdate(); return true; } } sendfunc(item); @@ -2025,15 +2085,40 @@ void LLSelectMgr::selectionRevertGLTFMaterials() { LLObjectSelectionHandle mSelectedObjects; f(LLObjectSelectionHandle sel) : mSelectedObjects(sel) {} - bool apply(LLViewerObject* object, S32 te) + bool apply(LLViewerObject* objectp, S32 te) { - if (object->permModify()) + if (objectp && !objectp->permModify()) { - LLSelectNode* nodep = mSelectedObjects->findNode(object); - if (nodep && te < (S32)nodep->mSavedGLTFMaterials.size()) + return false; + } + + LLSelectNode* nodep = mSelectedObjects->findNode(objectp); + if (nodep && te < (S32)nodep->mSavedGLTFMaterials.size()) + { + LLUUID asset_id = nodep->mSavedGLTFMaterials[te]; + LLTextureEntry* tep = objectp->getTE(te); + if (asset_id.notNull()) + { + tep->setGLTFMaterial(gGLTFMaterialList.getMaterial(asset_id)); + + if (!objectp->hasRenderMaterialParams()) + { + // make sure param section exists + objectp->setParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL, TRUE, false /*prevent an immediate update*/); + } + } + else + { + tep->setGLTFMaterial(nullptr); + } + + objectp->faceMappingChanged(); + gPipeline.markTextured(objectp->mDrawable); + + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)objectp->getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) { - LLUUID id = nodep->mSavedGLTFMaterials[te]; - object->setRenderMaterialID(te, id); + param_block->setMaterial(te, asset_id); } } return true; @@ -2041,7 +2126,32 @@ void LLSelectMgr::selectionRevertGLTFMaterials() } setfunc(mSelectedObjects); getSelection()->applyToTEs(&setfunc); - LLSelectMgrSendFunctor sendfunc; + struct g : public LLSelectedObjectFunctor + { + virtual bool apply(LLViewerObject* object) + { + if (object && !object->permModify()) + { + return false; + } + + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)object->getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) + { + if (param_block->isEmpty()) + { + object->setHasRenderMaterialParams(false); + } + else + { + object->parameterChanged(LLNetworkData::PARAMS_RENDER_MATERIAL, true); + } + } + + object->sendTEUpdate(); + return true; + } + } sendfunc; getSelection()->applyToObjects(&sendfunc); } diff --git a/indra/newview/lltexturectrl.cpp b/indra/newview/lltexturectrl.cpp index b887b079ce..c167fcc717 100644 --- a/indra/newview/lltexturectrl.cpp +++ b/indra/newview/lltexturectrl.cpp @@ -1665,56 +1665,7 @@ void LLTextureCtrl::onFloaterCommit(ETexturePickOp op, LLUUID id) if (op == TEXTURE_SELECT && mOnSelectCallback) { - // determine if the selected item in inventory is a material - // by finding the item in inventory and inspecting its (IT_) type - LLUUID item_id = floaterp->findItemID(floaterp->getAssetID(), FALSE); - LLInventoryItem* item = gInventory.getItem(item_id); - if (item) - { - if (item->getInventoryType() == LLInventoryType::IT_MATERIAL) - { - // ask the selection manager for the list of selected objects - // to which the material will be applied. - LLObjectSelectionHandle selectedObjectsHandle = LLSelectMgr::getInstance()->getSelection(); - if (selectedObjectsHandle.notNull()) - { - LLObjectSelection* selectedObjects = selectedObjectsHandle.get(); - if (!selectedObjects->isEmpty()) - { - // we have a selection - iterate over it - for (LLObjectSelection::valid_iterator obj_iter = selectedObjects->valid_begin(); - obj_iter != selectedObjects->valid_end(); - ++obj_iter) - { - LLSelectNode* object = *obj_iter; - LLViewerObject* viewer_object = object->getObject(); - if (viewer_object) - { - // the asset ID of the material we want to apply - // the the selected objects - LLUUID asset_id = item->getAssetUUID(); - - // iterate over the faces in the object - // TODO: consider the case where user has - // selected only certain faces - S32 num_faces = viewer_object->getNumTEs(); - for (S32 face = 0; face < num_faces; face++) - { - viewer_object->setRenderMaterialID(face, asset_id); - dialog_refresh_all(); - } - viewer_object->sendTEUpdate(); - } - } - } - } - } - } - else - // original behavior for textures, not materials - { - mOnSelectCallback(this, LLSD()); - } + mOnSelectCallback(this, LLSD()); } else if (op == TEXTURE_CANCEL && mOnCancelCallback) { diff --git a/indra/newview/lltooldraganddrop.cpp b/indra/newview/lltooldraganddrop.cpp index ab54e2afc6..282c84d7fc 100644 --- a/indra/newview/lltooldraganddrop.cpp +++ b/indra/newview/lltooldraganddrop.cpp @@ -1114,6 +1114,11 @@ void LLToolDragAndDrop::dropMaterialAllFaces(LLViewerObject* hit_obj, for (S32 face = 0; face < num_faces; face++) { // update viewer side material in anticipation of update from simulator + + // TODO: fix this! + // Calling setRenderMaterialID multiple times sends material param + // updates multiple times and can create race condition. + // Send update only once! hit_obj->setRenderMaterialID(face, asset_id); dialog_refresh_all(); } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index bdc47e0c50..d0bd0f45a2 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -7057,7 +7057,12 @@ void LLViewerObject::setRenderMaterialID(U8 te, const LLUUID& id) if (id.notNull()) { getTE(te)->setGLTFMaterial(gGLTFMaterialList.getMaterial(id)); - setHasRenderMaterialParams(true); + + if (!hasRenderMaterialParams()) + { + // make sure param section exists + setParameterEntryInUse(LLNetworkData::PARAMS_RENDER_MATERIAL, TRUE, false /*prevent an immediate update*/); + } } else { -- cgit v1.3 From f887f65830c05d15517cbd8f15ca0e59210dfbee Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 28 Sep 2022 16:49:11 -0500 Subject: SL-18190 WIP - Linear space atmospherics take 2 --- .../shaders/class1/deferred/deferredUtil.glsl | 4 +- .../shaders/class2/deferred/pbralphaF.glsl | 9 +- .../shaders/class2/windlight/atmosphericsF.glsl | 2 +- .../class2/windlight/atmosphericsFuncs.glsl | 96 +++++++++++++++++++++- .../shaders/class3/deferred/reflectionProbeF.glsl | 4 +- .../shaders/class3/deferred/softenLightF.glsl | 21 +++-- indra/newview/llreflectionmap.cpp | 2 +- 7 files changed, 115 insertions(+), 23 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index 49f85af53b..50bf497605 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -370,9 +370,7 @@ vec3 pbrIbl(vec3 diffuseColor, vec3 diffuse = diffuseLight * diffuseColor; vec3 specular = specularLight * (specularColor * brdf.x + brdf.y); - //specular *= 1.5; - - return (diffuse + specular) * ao; + return (diffuse + specular) * ao * 0.5; //reduce by half to place in appropriate color space for atmospherics } // Encapsulate the various inputs used by the various functions in the shading equation diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index 93c51ba313..e6cb8f37c7 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -196,7 +196,7 @@ void main() vec3 irradiance = vec3(0); vec3 radiance = vec3(0); sampleReflectionProbes(irradiance, radiance, pos.xyz, norm.xyz, gloss); - irradiance = max(amblit,irradiance); + irradiance = max(amblit*2.0,irradiance); vec3 f0 = vec3(0.04); @@ -212,6 +212,9 @@ void main() color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm.xyz, v, light_dir) * sunlit*2.75 * scol; color += colorEmissive; + color = atmosFragLightingLinear(color, additive, atten); + color = scaleSoftClipFragLinear(color); + vec3 light = vec3(0); // Punctual lights @@ -227,8 +230,6 @@ void main() color.rgb += light.rgb; - color = atmosFragLightingLinear(color, additive, atten); - color = scaleSoftClipFragLinear(color); - + frag_color = vec4(color.rgb,albedo.a * vertex_color.a); } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index e578f618da..20b1e3513e 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -52,7 +52,7 @@ vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten) light *= atten.r; light += additive; - return light; + return light*2.0; } vec3 atmosLighting(vec3 light) diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index e7e1938a11..516550be1c 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -22,15 +22,24 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ + +vec3 srgb_to_linear(vec3 col); + uniform vec4 lightnorm; uniform vec4 sunlight_color; +vec3 sunlight_linear = srgb_to_linear(sunlight_color.rgb); uniform vec4 moonlight_color; +vec3 moonlight_linear = srgb_to_linear(moonlight_color.rgb); uniform int sun_up_factor; uniform vec4 ambient_color; +vec3 ambient_linear = srgb_to_linear(ambient_color.rgb); uniform vec4 blue_horizon; +vec3 blue_horizon_linear = srgb_to_linear(blue_horizon.rgb); uniform vec4 blue_density; +vec3 blue_density_linear = srgb_to_linear(blue_density.rgb); uniform float haze_horizon; uniform float haze_density; +vec3 haze_density_linear = srgb_to_linear(vec3(haze_density)); uniform float cloud_shadow; uniform float density_multiplier; uniform float distance_multiplier; @@ -41,8 +50,6 @@ uniform mat3 ssao_effect_mat; uniform int no_atmo; uniform float sun_moon_glow_factor; -vec3 srgb_to_linear(vec3 col); - float getAmbientClamp() { return 1.0f; } // return colors in sRGB space @@ -136,13 +143,96 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou additive *= vec3(1.0 - combined_haze); } + + + // return colors in linear space void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao) { - calcAtmosphericVars(inPositionEye, light_dir, ambFactor, sunlit, amblit, additive, atten, use_ao); +#if 0 + calcAtmosphericVars(inPositionEye, light_dir, 1.0, sunlit, amblit, additive, atten, false); sunlit = srgb_to_linear(sunlit)*2.25; amblit = srgb_to_linear(amblit)*0.15; additive = srgb_to_linear(additive); atten = srgb_to_linear(atten); +#else + vec3 rel_pos = inPositionEye; + + //(TERRAIN) limit altitude + if (abs(rel_pos.y) > max_y) rel_pos *= (max_y / rel_pos.y); + + vec3 rel_pos_norm = normalize(rel_pos); + float rel_pos_len = length(rel_pos); + vec3 sunlight = (sun_up_factor == 1) ? sunlight_linear : moonlight_linear; + + // sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes + vec3 light_atten = (blue_density_linear + (haze_density_linear * 0.25)) * (density_multiplier * max_y); + // I had thought blue_density and haze_density should have equal weighting, + // but attenuation due to haze_density tends to seem too strong + + + vec3 combined_haze_linear = blue_density_linear + haze_density_linear; + vec3 combined_haze = blue_density.rgb + vec3(haze_density); + vec3 blue_weight = blue_density_linear / combined_haze_linear; + vec3 haze_weight = haze_density_linear / combined_haze_linear; + + //(TERRAIN) compute sunlight from lightnorm y component. Factor is roughly cosecant(sun elevation) (for short rays like terrain) + float above_horizon_factor = 1.0 / max(1e-6, lightnorm.y); + sunlight *= exp(-light_atten * above_horizon_factor); // for sun [horizon..overhead] this maps to an exp curve [0..1] + + // main atmospheric scattering line integral + float density_dist = rel_pos_len * density_multiplier; + + // Transparency (-> combined_haze) + // ATI Bugfix -- can't store combined_haze*density_dist*distance_multiplier in a variable because the ati + // compiler gets confused. + combined_haze = exp(-combined_haze * density_dist * distance_multiplier); + combined_haze_linear = exp(-combined_haze_linear * density_dist * distance_multiplier); + // final atmosphere attenuation factor + atten = combined_haze.rgb; + + // compute haze glow + float haze_glow = dot(rel_pos_norm, lightnorm.xyz); + + // dampen sun additive contrib when not facing it... + // SL-13539: This "if" clause causes an "additive" white artifact at roughly 77 degreees. + // if (length(light_dir) > 0.01) + haze_glow *= max(0.0f, dot(light_dir, rel_pos_norm)); + + haze_glow = 1. - haze_glow; + // haze_glow is 0 at the sun and increases away from sun + haze_glow = max(haze_glow, .001); // set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + haze_glow *= glow.x; + // higher glow.x gives dimmer glow (because next step is 1 / "angle") + haze_glow = pow(haze_glow, glow.z); + // glow.z should be negative, so we're doing a sort of (1 / "angle") function + + // add "minimum anti-solar illumination" + haze_glow += .25; + + haze_glow *= sun_moon_glow_factor; + + vec3 amb_color = ambient_linear; + + // increase ambient when there are more clouds + vec3 tmpAmbient = amb_color + (vec3(1.) - amb_color) * cloud_shadow * 0.5; + + // Similar/Shared Algorithms: + // indra\llinventory\llsettingssky.cpp -- LLSettingsSky::calculateLightSettings() + // indra\newview\app_settings\shaders\class1\windlight\atmosphericsFuncs.glsl -- calcAtmosphericVars() + // haze color + vec3 cs = sunlight.rgb * (1. - cloud_shadow); + additive = (blue_horizon_linear.rgb * blue_weight.rgb) * (cs + tmpAmbient.rgb) + (haze_horizon * haze_weight.rgb) * (cs * haze_glow + tmpAmbient.rgb); + + // brightness of surface both sunlight and ambient + sunlit = sunlight.rgb; + amblit = tmpAmbient.rgb; + additive *= vec3(1.0 - combined_haze_linear); + + sunlit *= 0.8; + amblit *= 0.05; + additive *= 0.25; +#endif } diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index de18251dc4..a1125cc1dd 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -551,7 +551,7 @@ void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 no fresnel *= spec.a; glossenv *= spec.rgb*fresnel; glossenv *= vec3(1.0) - color; // fake energy conservation - color.rgb += glossenv; + color.rgb += glossenv*0.5; } void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity) @@ -562,6 +562,6 @@ void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 no fresnel *= fresnel; fresnel = min(fresnel+envIntensity, 1.0); reflected_color *= (envIntensity*fresnel); - color = mix(color.rgb, reflected_color, envIntensity); + color = mix(color.rgb, reflected_color*0.5, envIntensity); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index c7ec1ddde9..1795f3fd1a 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -140,8 +140,7 @@ void main() vec3 glossenv; vec3 legacyenv; - bool hasPBR = GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR); - if (hasPBR) + if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) { norm.xyz = getNorm(tc); vec3 orm = texture2DRect(specularRect, tc).rgb; @@ -157,7 +156,7 @@ void main() vec3 radiance = vec3(0); sampleReflectionProbes(irradiance, radiance, pos.xyz, norm.xyz, gloss); - irradiance = max(amblit*ao,irradiance); + irradiance = max(amblit*2.0*ao,irradiance); vec3 f0 = vec3(0.04); vec3 baseColor = diffuse.rgb; @@ -170,13 +169,19 @@ void main() vec3 v = -normalize(pos.xyz); float NdotV = clamp(abs(dot(norm.xyz, v)), 0.001, 1.0); - color.rgb += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness); color.rgb += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm.xyz, v, normalize(light_dir)) * sunlit*2.75 * scol; color.rgb += colorEmissive; + + color.rgb += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness); color = atmosFragLightingLinear(color, additive, atten); color = scaleSoftClipFragLinear(color); } + else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) + { + //should only be true of WL sky, just port over diffuse value + color = srgb_to_linear(diffuse.rgb); + } else { // legacy shaders are still writng sRGB to gbuffer @@ -223,12 +228,10 @@ void main() if (envIntensity > 0.0) { // add environment map applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity); - } - if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) - { - color = mix(atmosFragLightingLinear(color, additive, atten), fullbrightAtmosTransportFragLinear(color, additive, atten), diffuse.a); - color = scaleSoftClipFragLinear(color); } + + color = mix(atmosFragLightingLinear(color, additive, atten), fullbrightAtmosTransportFragLinear(color, additive, atten), diffuse.a); + color = scaleSoftClipFragLinear(color); } #ifdef WATER_FOG diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index d9dd1e9381..9bf1174742 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -43,7 +43,7 @@ void LLReflectionMap::update(U32 resolution, U32 face) mLastUpdateTime = gFrameTimeSeconds; llassert(mCubeArray.notNull()); llassert(mCubeIndex != -1); - llassert(LLPipeline::sRenderDeferred); + //llassert(LLPipeline::sRenderDeferred); // make sure we don't walk off the edge of the render target while (resolution > gPipeline.mRT->deferredScreen.getWidth() || -- cgit v1.3 From 70f249fbfbcae080aff3db72bf62e0643b342236 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 11 Nov 2022 13:48:51 -0600 Subject: SL-18630 Fix for probes often ending up under the terrain. --- indra/newview/llreflectionmap.cpp | 138 ++++++++++++++------------------------ 1 file changed, 52 insertions(+), 86 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index ef611966ed..f346531bfd 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -63,20 +63,7 @@ void LLReflectionMap::autoAdjustOrigin() const LLVector4a* bounds = mGroup->getBounds(); auto* node = mGroup->getOctreeNode(); - if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_TERRAIN) - { - // for terrain, make probes float a couple meters above the highest point in the surface patch - mOrigin = bounds[0]; - mOrigin.getF32ptr()[2] += bounds[1].getF32ptr()[2] + 3.f; - - // update radius to encompass bounding box - LLVector4a d; - d.setAdd(bounds[0], bounds[1]); - d.sub(mOrigin); - mRadius = d.getLength3().getF32(); - mPriority = 1; - } - else if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) + if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) { mPriority = 1; // cast a ray towards 8 corners of bounding box @@ -87,92 +74,71 @@ void LLReflectionMap::autoAdjustOrigin() return; } - if (node->isLeaf() || node->getChildCount() > 1 || node->getElementCount() > 0) - { // use center of object bounding box for leaf nodes or nodes with multiple child nodes - mOrigin = bounds[0]; - - LLVector4a start; - LLVector4a end; - - LLVector4a size = bounds[1]; + mOrigin = bounds[0]; - LLVector4a corners[] = - { - { 1, 1, 1 }, - { -1, 1, 1 }, - { 1, -1, 1 }, - { -1, -1, 1 }, - { 1, 1, -1 }, - { -1, 1, -1 }, - { 1, -1, -1 }, - { -1, -1, -1 } - }; - - for (int i = 0; i < 8; ++i) - { - corners[i].mul(size); - corners[i].add(bounds[0]); - } + LLVector4a size = bounds[1]; - LLVector4a extents[2]; - extents[0].setAdd(bounds[0], bounds[1]); - extents[1].setSub(bounds[0], bounds[1]); + LLVector4a corners[] = + { + { 1, 1, 1 }, + { -1, 1, 1 }, + { 1, -1, 1 }, + { -1, -1, 1 }, + { 1, 1, -1 }, + { -1, 1, -1 }, + { 1, -1, -1 }, + { -1, -1, -1 } + }; + + for (int i = 0; i < 8; ++i) + { + corners[i].mul(size); + corners[i].add(bounds[0]); + } - bool hit = false; - for (int i = 0; i < 8; ++i) - { - int face = -1; - LLVector4a intersection; - LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, true, &face, &intersection); - if (drawable != nullptr) - { - hit = true; - update_min_max(extents[0], extents[1], intersection); - } - else - { - update_min_max(extents[0], extents[1], corners[i]); - } - } + LLVector4a extents[2]; + extents[0].setAdd(bounds[0], bounds[1]); + extents[1].setSub(bounds[0], bounds[1]); - if (hit) + bool hit = false; + for (int i = 0; i < 8; ++i) + { + int face = -1; + LLVector4a intersection; + LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, true, &face, &intersection); + if (drawable != nullptr) { - mOrigin.setAdd(extents[0], extents[1]); - mOrigin.mul(0.5f); + hit = true; + update_min_max(extents[0], extents[1], intersection); } - - // make sure radius encompasses all objects - LLSimdScalar r2 = 0.0; - for (int i = 0; i < 8; ++i) + else { - LLVector4a v; - v.setSub(corners[i], mOrigin); - - LLSimdScalar d = v.dot3(v); - - if (d > r2) - { - r2 = d; - } + update_min_max(extents[0], extents[1], corners[i]); } - - mRadius = llmax(sqrtf(r2.getF32()), 8.f); } - else - { - // user placed probe - mPriority = 2; - // use center of octree node volume for nodes that are just branches without data - mOrigin = node->getCenter(); + if (hit) + { + mOrigin.setAdd(extents[0], extents[1]); + mOrigin.mul(0.5f); + } - // update radius to encompass entire octree node volume - mRadius = node->getSize().getLength3().getF32(); + // make sure radius encompasses all objects + LLSimdScalar r2 = 0.0; + for (int i = 0; i < 8; ++i) + { + LLVector4a v; + v.setSub(corners[i], mOrigin); - //mOrigin = bounds[0]; - //mRadius = bounds[1].getLength3().getF32(); + LLSimdScalar d = v.dot3(v); + if (d > r2) + { + r2 = d; + } } + + mRadius = llmax(sqrtf(r2.getF32()), 8.f); } } else if (mViewerObject) -- cgit v1.3 From be9e4f186db1b3612a26e27a0294114ca66c539c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 7 Feb 2023 13:59:10 -0600 Subject: SL-18630 Nudge underground automatic reflection probes to 2m above ground. --- indra/newview/llreflectionmap.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index f346531bfd..ce749a96c7 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -30,6 +30,7 @@ #include "pipeline.h" #include "llviewerwindow.h" #include "llviewerregion.h" +#include "llworld.h" extern F32SecondsImplicit gFrameTimeSeconds; @@ -123,6 +124,12 @@ void LLReflectionMap::autoAdjustOrigin() mOrigin.mul(0.5f); } + // make sure origin isn't under ground + F32* fp = mOrigin.getF32ptr(); + LLVector3 origin(fp); + F32 height = LLWorld::instance().resolveLandHeightAgent(origin) + 2.f; + fp[2] = llmax(fp[2], height); + // make sure radius encompasses all objects LLSimdScalar r2 = 0.0; for (int i = 0; i < 8; ++i) -- cgit v1.3 From 50c57b6be72541b92340c6230d417c508a4fa6f9 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 17 Feb 2023 10:34:27 -0600 Subject: SL-19128 Soften the transition between manual and automatic sphere probes. --- .../shaders/class3/deferred/reflectionProbeF.glsl | 174 ++++++++++++++------- .../shaders/class3/environment/waterF.glsl | 4 +- indra/newview/llreflectionmap.cpp | 4 +- indra/newview/llreflectionmap.h | 5 +- 4 files changed, 122 insertions(+), 65 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 8b1d41776f..24539c3c3a 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -80,7 +80,7 @@ bool isAbove(vec3 pos, vec4 plane) return (dot(plane.xyz, pos) + plane.w) > 0; } -int max_priority = 0; +bool sample_automatic = true; // return true if probe at index i influences position pos bool shouldSampleProbe(int i, vec3 pos) @@ -95,24 +95,24 @@ bool shouldSampleProbe(int i, vec3 pos) return false; } - max_priority = max(max_priority, -refIndex[i].w); + sample_automatic = false; } else { - if (refSphere[i].w > 0.0) // zero is special indicator to always sample this probe + if (refIndex[i].w == 0 && !sample_automatic) { - vec3 delta = pos.xyz - refSphere[i].xyz; - float d = dot(delta, delta); - float r2 = refSphere[i].w; - r2 *= r2; - - if (d > r2) - { //outside bounding sphere - return false; - } + return false; } - max_priority = max(max_priority, refIndex[i].w); + vec3 delta = pos.xyz - refSphere[i].xyz; + float d = dot(delta, delta); + float r2 = refSphere[i].w; + r2 *= r2; + + if (d > r2) + { // outside bounding sphere + return false; + } } return true; @@ -120,7 +120,6 @@ bool shouldSampleProbe(int i, vec3 pos) // call before sampleRef // populate "probeIndex" with N probe indices that influence pos where N is REF_SAMPLE_COUNT -// overall algorithm -- void preProbeSample(vec3 pos) { // TODO: make some sort of structure that reduces the number of distance checks @@ -210,7 +209,7 @@ void preProbeSample(vec3 pos) } } - if (max_priority <= 1) + if (sample_automatic) { // probe at index 0 is a special probe for smoothing out automatic probes probeIndex[probeInfluences++] = 0; } @@ -342,7 +341,7 @@ return texCUBE(envMap, ReflDirectionWS); // d - distance to nearest wall in clip space vec3 boxIntersect(vec3 origin, vec3 dir, int i, out float d) { - // Intersection with OBB convertto unit box space + // Intersection with OBB convert to unit box space // Transform in local unit parallax cube space (scaled and rotated) mat4 clipToLocal = refBox[i]; @@ -431,18 +430,24 @@ void boxIntersectDebug(vec3 origin, vec3 pos, int i, inout vec4 col) // origin - center of sphere probe // r - radius of probe influence volume // min_da - minimum angular attenuation coefficient -float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, float min_da) +// i - index of probe in refSphere +// dw - distance weight +float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, float min_da, int i, out float dw) { float r1 = r * 0.5; // 50% of radius (outer sphere to start interpolating down) vec3 delta = pos.xyz - origin; float d2 = max(length(delta), 0.001); + float r2 = r1; //r1 * r1; //float atten = 1.0 - max(d2 - r2, 0.0) / max((rr - r2), 0.001); float atten = 1.0 - max(d2 - r2, 0.0) / max((r - r2), 0.001); + float w = 1.0 / d2; + + dw = w * atten * max(r, 1.0)*4; atten *= max(dot(normalize(-delta), dir), min_da); - float w = 1.0 / d2; + w *= atten; return w; @@ -451,13 +456,15 @@ float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, float min_da) // Tap a reflection probe // pos - position of pixel // dir - pixel normal +// w - weight of sample (distance and angular attenuation) +// dw - weight of sample (distance only) // vi - return value of intersection point with influence volume // wi - return value of approximate world space position of sampled pixel // lod - which mip to bias towards (lower is higher res, sharper reflections) // c - center of probe // r2 - radius of probe squared // i - index of probe -vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out vec3 vi, out vec3 wi, float lod, vec3 c, int i) +vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, out vec3 vi, out vec3 wi, float lod, vec3 c, int i) { //lod = max(lod, 1); // parallax adjustment @@ -473,14 +480,15 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out vec3 vi, out vec3 wi, float } else { - float r = refSphere[i].w; // radius of sphere volume - float rr = r * r; // radius squared + float r = refSphere[i].w; + + float rr = r * r; v = sphereIntersect(pos, dir, c, - refIndex[i].w <= 1 ? 4096.0*4096.0 : // <== effectively disable parallax correction for automatically placed probes to keep from bombing the world with obvious spheres + refIndex[i].w < 1 ? 4096.0*4096.0 : // <== effectively disable parallax correction for automatically placed probes to keep from bombing the world with obvious spheres rr); - w = sphereWeight(pos, dir, refSphere[i].xyz, r, 0.25); + w = sphereWeight(pos, dir, refSphere[i].xyz, r, 0.25, i, dw); } vi = v; @@ -500,10 +508,10 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out vec3 vi, out vec3 wi, float // Tap an irradiance map // pos - position of pixel // dir - pixel normal -// c - center of probe -// r2 - radius of probe squared +// w - weight of sample (distance and angular attenuation) +// dw - weight of sample (distance only) // i - index of probe -vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, vec3 c, int i) +vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int i) { // parallax adjustment vec3 v; @@ -516,14 +524,15 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, vec3 c, int i) else { float r = refSphere[i].w; // radius of sphere volume - float p = float(abs(refIndex[i].w)); // priority - float rr = r * r; // radius squred + + // pad sphere for manual probe extending into automatic probe space + float rr = r * r; v = sphereIntersect(pos, dir, c, - refIndex[i].w <= 1 ? 4096.0*4096.0 : // <== effectively disable parallax correction for automatically placed probes to keep from bombing the world with obvious spheres + refIndex[i].w < 1 ? 4096.0*4096.0 : // <== effectively disable parallax correction for automatically placed probes to keep from bombing the world with obvious spheres rr); - w = sphereWeight(pos, dir, refSphere[i].xyz, r, 0.001); + w = sphereWeight(pos, dir, refSphere[i].xyz, r, 0.001, i, dw); } v -= c; @@ -535,19 +544,30 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, vec3 c, int i) vec3 sampleProbes(vec3 pos, vec3 dir, float lod, bool errorCorrect) { - float wsum = 0.0; - vec3 col = vec3(0,0,0); - float vd2 = dot(pos,pos); // view distance squared + float wsum[2]; + wsum[0] = 0; + wsum[1] = 0; + + float dwsum[2]; + dwsum[0] = 0; + dwsum[1] = 0; + + vec3 col[2]; + col[0] = vec3(0); + col[1] = vec3(0); for (int idx = 0; idx < probeInfluences; ++idx) { int i = probeIndex[idx]; - if (abs(refIndex[i].w) < max_priority) + int p = clamp(abs(refIndex[i].w), 0, 1); + + if (p == 0 && !sample_automatic) { continue; } - float w; + float w = 0; + float dw = 0; vec3 vi, wi; vec3 refcol; @@ -556,7 +576,7 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, bool errorCorrect) if (errorCorrect && refIndex[i].w >= 0) { // error correction is on and this probe is a sphere //take a sample to get depth value, then error correct - refcol = tapRefMap(pos, dir, w, vi, wi, abs(lod + 2), refSphere[i].xyz, i); + refcol = tapRefMap(pos, dir, w, dw, vi, wi, abs(lod + 2), refSphere[i].xyz, i); //adjust lookup by distance result float d = length(vi - wi); @@ -571,61 +591,96 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod, bool errorCorrect) // weight by vector correctness vec3 pi = normalize(wi - pos); w *= max(dot(pi, dir), 0.1); - //w = pow(w, 32.0); } else { - refcol = tapRefMap(pos, dir, w, vi, wi, lod, refSphere[i].xyz, i); + refcol = tapRefMap(pos, dir, w, dw, vi, wi, lod, refSphere[i].xyz, i); } - col += refcol.rgb*w; - - wsum += w; + col[p] += refcol.rgb*w; + wsum[p] += w; + dwsum[p] += dw; } } - if (wsum > 0.0) + // mix automatic and manual probes + if (sample_automatic && wsum[0] > 0.0) + { // some automatic probes were sampled + col[0] *= 1.0/wsum[0]; + if (wsum[1] > 0.0) + { //some manual probes were sampled, mix between the two + col[1] *= 1.0/wsum[1]; + col[1] = mix(col[0], col[1], min(dwsum[1], 1.0)); + col[0] = vec3(0); + } + } + else if (wsum[1] > 0.0) { - col *= 1.0/wsum; + // manual probes were sampled but no automatic probes were + col[1] *= 1.0/wsum[1]; + col[0] = vec3(0); } - return col; + return col[1]+col[0]; } vec3 sampleProbeAmbient(vec3 pos, vec3 dir) { // modified copy/paste of sampleProbes follows, will likely diverge from sampleProbes further // as irradiance map mixing is tuned independently of radiance map mixing - float wsum = 0.0; - vec3 col = vec3(0,0,0); - float vd2 = dot(pos,pos); // view distance squared + float wsum[2]; + wsum[0] = 0; + wsum[1] = 0; - float minweight = 1.0; + float dwsum[2]; + dwsum[0] = 0; + dwsum[1] = 0; + + vec3 col[2]; + col[0] = vec3(0); + col[1] = vec3(0); for (int idx = 0; idx < probeInfluences; ++idx) { int i = probeIndex[idx]; - if (abs(refIndex[i].w) < max_priority) + int p = clamp(abs(refIndex[i].w), 0, 1); + + if (p == 0 && !sample_automatic) { continue; } { - float w; - vec3 refcol = tapIrradianceMap(pos, dir, w, refSphere[i].xyz, i); + float w = 0; + float dw = 0; - col += refcol*w; - - wsum += w; + vec3 refcol = tapIrradianceMap(pos, dir, w, dw, refSphere[i].xyz, i); + + col[p] += refcol*w; + wsum[p] += w; + dwsum[p] += dw; } } - if (wsum > 0.0) + // mix automatic and manual probes + if (sample_automatic && wsum[0] > 0.0) + { // some automatic probes were sampled + col[0] *= 1.0/wsum[0]; + if (wsum[1] > 0.0) + { //some manual probes were sampled, mix between the two + col[1] *= 1.0/wsum[1]; + col[1] = mix(col[0], col[1], min(dwsum[1], 1.0)); + col[0] = vec3(0); + } + } + else if (wsum[1] > 0.0) { - col *= 1.0/wsum; + // manual probes were sampled but no automatic probes were + col[1] *= 1.0/wsum[1]; + col[0] = vec3(0); } - - return col; + + return col[1]+col[0]; } void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, @@ -658,7 +713,7 @@ void debugTapRefMap(vec3 pos, vec3 dir, float depth, int i, inout vec4 col) { vec3 origin = vec3(0,0,0); - bool manual_probe = abs(refIndex[i].w) > 2; + bool manual_probe = abs(refIndex[i].w) > 0; if (manual_probe) { @@ -705,7 +760,6 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv, vec2 tc, vec3 pos, vec3 norm, float glossiness, float envIntensity) { - // TODO - don't hard code lods float reflection_lods = max_probe_lod; preProbeSample(pos); diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl index 3d721cd048..631d2c04d0 100644 --- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl @@ -232,8 +232,8 @@ void main() irradiance = vec3(0); - vec3 diffuseColor; - vec3 specularColor; + vec3 diffuseColor = vec3(0); + vec3 specularColor = vec3(0); calcDiffuseSpecular(vec3(1), metallic, diffuseColor, specularColor); vec3 v = -normalize(pos.xyz); diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index ce749a96c7..394596feea 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -66,7 +66,7 @@ void LLReflectionMap::autoAdjustOrigin() if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) { - mPriority = 1; + mPriority = 0; // cast a ray towards 8 corners of bounding box // nudge origin towards center of empty space @@ -150,7 +150,7 @@ void LLReflectionMap::autoAdjustOrigin() } else if (mViewerObject) { - mPriority = 64; + mPriority = 1; mOrigin.load3(mViewerObject->getPositionAgent().mV); mRadius = mViewerObject->getScale().mV[0]*0.5f; } diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index cf0bc2ff27..04bc8d824c 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -97,6 +97,9 @@ public: LLViewerObject* mViewerObject = nullptr; // what priority should this probe have (higher is higher priority) - U32 mPriority = 1; + // currently only 0 or 1 + // 0 - automatic probe + // 1 - manual probe + U32 mPriority = 0; }; -- cgit v1.3 From 19f7497d9a01731cbd82be4b522d8b879cdcb8a0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 21 Feb 2023 20:42:25 -0600 Subject: DRTVWR-559 WIP -- occlusion culling for reflection probes -- has a defect for objects close to the camera at some angles and leaks query objects, will follow up. --- indra/newview/lldrawpool.cpp | 3 ++ indra/newview/lldrawpool.h | 5 +- indra/newview/lldrawpoolpbropaque.cpp | 31 ++++++------ indra/newview/lldrawpoolpbropaque.h | 16 +------ indra/newview/llreflectionmap.cpp | 81 ++++++++++++++++++++++++++++++++ indra/newview/llreflectionmap.h | 11 +++++ indra/newview/llreflectionmapmanager.cpp | 54 ++++++++++++++++++--- indra/newview/llreflectionmapmanager.h | 3 ++ indra/newview/pipeline.cpp | 42 +++++++++++++++++ indra/newview/pipeline.h | 2 + 10 files changed, 210 insertions(+), 38 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 56377069bb..c61618c056 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -116,6 +116,9 @@ LLDrawPool *LLDrawPool::createPool(const U32 type, LLViewerTexture *tex0) break; case POOL_GLTF_PBR: poolp = new LLDrawPoolGLTFPBR(); + break; + case POOL_GLTF_PBR_ALPHA_MASK: + poolp = new LLDrawPoolGLTFPBR(LLDrawPool::POOL_GLTF_PBR_ALPHA_MASK); break; default: LL_ERRS() << "Unknown draw pool type!" << LL_ENDL; diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index 2c5e31f579..5e741b2b95 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -58,8 +58,9 @@ public: POOL_BUMP, POOL_TERRAIN, POOL_MATERIALS, - POOL_GRASS, POOL_GLTF_PBR, + POOL_GRASS, + POOL_GLTF_PBR_ALPHA_MASK, POOL_TREE, POOL_ALPHA_MASK, POOL_FULLBRIGHT_ALPHA_MASK, @@ -109,7 +110,7 @@ public: virtual void render(S32 pass = 0) {}; virtual void prerender() {}; - virtual U32 getVertexDataMask() = 0; + virtual U32 getVertexDataMask() { return 0; } // DEPRECATED -- draw pool doesn't actually determine vertex data mask any more virtual BOOL verify() const { return TRUE; } // Verify that all data in the draw pool is correct! virtual S32 getShaderLevel() const { return mShaderLevel; } diff --git a/indra/newview/lldrawpoolpbropaque.cpp b/indra/newview/lldrawpoolpbropaque.cpp index d30fc22393..b75c83e73a 100644 --- a/indra/newview/lldrawpoolpbropaque.cpp +++ b/indra/newview/lldrawpoolpbropaque.cpp @@ -33,9 +33,17 @@ static const U32 gltf_render_types[] = { LLPipeline::RENDER_TYPE_PASS_GLTF_PBR, LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK }; -LLDrawPoolGLTFPBR::LLDrawPoolGLTFPBR() : - LLRenderPass(POOL_GLTF_PBR) +LLDrawPoolGLTFPBR::LLDrawPoolGLTFPBR(U32 type) : + LLRenderPass(type) { + if (type == LLDrawPool::POOL_GLTF_PBR_ALPHA_MASK) + { + mRenderType = LLPipeline::RENDER_TYPE_PASS_GLTF_PBR_ALPHA_MASK; + } + else + { + mRenderType = LLPipeline::RENDER_TYPE_PASS_GLTF_PBR; + } } S32 LLDrawPoolGLTFPBR::getNumDeferredPasses() @@ -47,14 +55,11 @@ void LLDrawPoolGLTFPBR::renderDeferred(S32 pass) { llassert(!LLPipeline::sRenderingHUDs); - for (U32 type : gltf_render_types) - { - gDeferredPBROpaqueProgram.bind(); - pushGLTFBatches(type); + gDeferredPBROpaqueProgram.bind(); + pushGLTFBatches(mRenderType); - gDeferredPBROpaqueProgram.bind(true); - pushRiggedGLTFBatches(type + 1); - } + gDeferredPBROpaqueProgram.bind(true); + pushRiggedGLTFBatches(mRenderType + 1); } S32 LLDrawPoolGLTFPBR::getNumPostDeferredPasses() @@ -67,12 +72,9 @@ void LLDrawPoolGLTFPBR::renderPostDeferred(S32 pass) if (LLPipeline::sRenderingHUDs) { gHUDPBROpaqueProgram.bind(); - for (U32 type : gltf_render_types) - { - pushGLTFBatches(type); - } + pushGLTFBatches(mRenderType); } - else + else if (mRenderType == LLPipeline::RENDER_TYPE_PASS_GLTF_PBR) // HACK -- don't render glow except for the non-alpha masked implementation { gGL.setColorMask(false, true); gPBRGlowProgram.bind(); @@ -85,4 +87,3 @@ void LLDrawPoolGLTFPBR::renderPostDeferred(S32 pass) } } - diff --git a/indra/newview/lldrawpoolpbropaque.h b/indra/newview/lldrawpoolpbropaque.h index 69e063b322..c8a28461fa 100644 --- a/indra/newview/lldrawpoolpbropaque.h +++ b/indra/newview/lldrawpoolpbropaque.h @@ -32,21 +32,9 @@ class LLDrawPoolGLTFPBR final : public LLRenderPass { public: - enum - { - // See: DEFERRED_VB_MASK - VERTEX_DATA_MASK = 0 - | LLVertexBuffer::MAP_VERTEX - | LLVertexBuffer::MAP_NORMAL - | LLVertexBuffer::MAP_TEXCOORD0 // Diffuse - | LLVertexBuffer::MAP_TEXCOORD1 // Normal - | LLVertexBuffer::MAP_TEXCOORD2 // Spec <-- ORM Occlusion Roughness Metal - | LLVertexBuffer::MAP_TANGENT - | LLVertexBuffer::MAP_COLOR - }; - U32 getVertexDataMask() override { return VERTEX_DATA_MASK; } + LLDrawPoolGLTFPBR(U32 type = LLDrawPool::POOL_GLTF_PBR); - LLDrawPoolGLTFPBR(); + U32 mRenderType = 0; S32 getNumDeferredPasses() override; void renderDeferred(S32 pass) override; diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 394596feea..9fcc6ae902 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -31,9 +31,12 @@ #include "llviewerwindow.h" #include "llviewerregion.h" #include "llworld.h" +#include "llshadermgr.h" extern F32SecondsImplicit gFrameTimeSeconds; +extern U32 get_box_fan_indices(LLCamera* camera, const LLVector4a& center); + LLReflectionMap::LLReflectionMap() { } @@ -245,3 +248,81 @@ bool LLReflectionMap::getBox(LLMatrix4& box) return false; } + +bool LLReflectionMap::isActive() +{ + return mCubeIndex != -1; +} + +void LLReflectionMap::doOcclusion(const LLVector4a& eye) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; +#if 1 + // super sloppy, but we're doing an occlusion cull against a bounding cube of + // a bounding sphere, pad radius so we assume if the eye is within + // the bounding sphere of the bounding cube, the node is not culled + F32 dist = mRadius * F_SQRT3 + 1.f; + + LLVector4a o; + o.setSub(mOrigin, eye); + + bool do_query = false; + + if (o.getLength3().getF32() < dist) + { // eye is inside radius, don't attempt to occlude + mOccluded = false; + if (mViewerObject) + { + mViewerObject->setDebugText("Camera Non-Occluded"); + } + return; + } + + if (mOcclusionQuery == 0) + { // no query was previously issued, allocate one and issue + glGenQueries(1, &mOcclusionQuery); + do_query = true; + } + else + { // query was previously issued, check it and only issue a new query + // if previous query is available + GLuint result = (GLuint) 0xFFFFFFFF; + glGetQueryObjectuiv(mOcclusionQuery, GL_QUERY_RESULT_NO_WAIT, &result); + + if (result != (GLuint) 0xFFFFFFFF) + { + do_query = true; + mOccluded = result == 0; + mOcclusionPendingFrames = 0; + } + else + { + mOcclusionPendingFrames++; + if (mViewerObject) + { + mViewerObject->setDebugText(llformat("Query Pending - %d", mOcclusionPendingFrames)); + } + } + } + + if (do_query) + { + glBeginQuery(GL_ANY_SAMPLES_PASSED, mOcclusionQuery); + + LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; + + shader->uniform3fv(LLShaderMgr::BOX_CENTER, 1, mOrigin.getF32ptr()); + F32 r = mRadius + 0.25f; // pad by 1/4m for near clip plane etc + shader->uniform3f(LLShaderMgr::BOX_SIZE, mRadius, mRadius, mRadius); + + gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(LLViewerCamera::getInstance(), mOrigin)); + + glEndQuery(GL_ANY_SAMPLES_PASSED); + + if (mViewerObject) + { + mViewerObject->setDebugText(llformat("Query Issued - %.2f, %.2f, %.2f", o.getLength3().getF32(), dist, mRadius)); + } + } +#endif +} diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index 04bc8d824c..0405d06eb5 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -64,6 +64,12 @@ public: // return false if no bounding box (treat as sphere influence volume) bool getBox(LLMatrix4& box); + // return true if this probe is active for rendering + bool isActive(); + + // perform occlusion query/readback + void doOcclusion(const LLVector4a& eye); + // point at which environment map was last generated from (in agent space) LLVector4a mOrigin; @@ -101,5 +107,10 @@ public: // 0 - automatic probe // 1 - manual probe U32 mPriority = 0; + + // occlusion culling state + GLuint mOcclusionQuery = 0; + bool mOccluded = false; + U32 mOcclusionPendingFrames = 0; }; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index e760bc794c..bfc8b595c2 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -157,6 +157,7 @@ void LLReflectionMapManager::update() LLReflectionMap* closestDynamic = nullptr; LLReflectionMap* oldestProbe = nullptr; + LLReflectionMap* oldestOccluded = nullptr; if (mUpdatingProbe != nullptr) { @@ -179,12 +180,27 @@ void LLReflectionMapManager::update() probe->mProbeIndex = i; LLVector4a d; - - if (!did_update && - i < mReflectionProbeCount && - (oldestProbe == nullptr || probe->mLastUpdateTime < oldestProbe->mLastUpdateTime)) + + if (probe->mOccluded) { - oldestProbe = probe; + if (oldestOccluded == nullptr) + { + oldestOccluded = probe; + } + else if (probe->mLastUpdateTime < oldestOccluded->mLastUpdateTime) + { + oldestOccluded = probe; + } + } + else + { + if (!did_update && + i < mReflectionProbeCount && + (oldestProbe == nullptr || + probe->mLastUpdateTime < oldestProbe->mLastUpdateTime)) + { + oldestProbe = probe; + } } if (realtime && @@ -240,6 +256,13 @@ void LLReflectionMapManager::update() doProbeUpdate(); } + if (oldestOccluded) + { + // as far as this occluded probe is concerned, an origin/radius update is as good as a full update + oldestOccluded->autoAdjustOrigin(); + oldestOccluded->mLastUpdateTime = gFrameTimeSeconds; + } + // update distance to camera for all probes std::sort(mProbes.begin(), mProbes.end(), CompareProbeDistance()); } @@ -277,8 +300,11 @@ void LLReflectionMapManager::getReflectionMaps(std::vector& ma mProbes[i]->mLastBindTime = gFrameTimeSeconds; // something wants to use this probe, indicate it's been requested if (mProbes[i]->mCubeIndex != -1) { - mProbes[i]->mProbeIndex = count; - maps[count++] = mProbes[i]; + if (!mProbes[i]->mOccluded) + { + mProbes[i]->mProbeIndex = count; + maps[count++] = mProbes[i]; + } } else { @@ -1038,3 +1064,17 @@ void LLReflectionMapManager::cleanup() // note: also called on teleport (not just shutdown), so make sure we're in a good "starting" state initCubeFree(); } + +void LLReflectionMapManager::doOcclusion() +{ + LLVector4a eye; + eye.load3(LLViewerCamera::instance().getOrigin().mV); + + for (auto& probe : mProbes) + { + if (probe != nullptr) + { + probe->doOcclusion(eye); + } + } +} diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index 85f428d75b..fef308541d 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -96,6 +96,9 @@ public: // True if currently updating a radiance map, false if currently updating an irradiance map bool isRadiancePass() { return mRadiancePass; } + // perform occlusion culling on all active reflection probes + void doOcclusion(); + private: friend class LLPipeline; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 69b149f82d..d0688d26a9 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -432,6 +432,7 @@ void LLPipeline::init() getPool(LLDrawPool::POOL_MATERIALS); getPool(LLDrawPool::POOL_GLOW); getPool(LLDrawPool::POOL_GLTF_PBR); + getPool(LLDrawPool::POOL_GLTF_PBR_ALPHA_MASK); resetFrameStats(); @@ -1545,6 +1546,9 @@ LLDrawPool *LLPipeline::findPool(const U32 type, LLViewerTexture *tex0) case LLDrawPool::POOL_GLTF_PBR: poolp = mPBROpaquePool; break; + case LLDrawPool::POOL_GLTF_PBR_ALPHA_MASK: + poolp = mPBRAlphaMaskPool; + break; default: llassert(0); @@ -2432,6 +2436,26 @@ void LLPipeline::doOcclusion(LLCamera& camera) LL_PROFILE_GPU_ZONE("doOcclusion"); llassert(!gCubeSnapshot); + if (sReflectionProbesEnabled && sUseOcclusion > 1 && !LLPipeline::sShadowRender && !gCubeSnapshot) + { + gGL.setColorMask(false, false); + LLGLDepthTest depth(GL_TRUE, GL_FALSE); + LLGLDisable cull(GL_CULL_FACE); + + gOcclusionCubeProgram.bind(); + + if (mCubeVB.isNull()) + { //cube VB will be used for issuing occlusion queries + mCubeVB = ll_create_cube_vb(LLVertexBuffer::MAP_VERTEX); + } + mCubeVB->setBuffer(); + + mReflectionMapManager.doOcclusion(); + gOcclusionCubeProgram.unbind(); + + gGL.setColorMask(true, true); + } + if (LLPipeline::sUseOcclusion > 1 && !LLSpatialPartition::sTeleportRequested && (sCull->hasOcclusionGroups() || LLVOCachePartition::sNeedsOcclusionCheck)) { @@ -5192,6 +5216,19 @@ void LLPipeline::addToQuickLookup( LLDrawPool* new_poolp ) } break; + case LLDrawPool::POOL_GLTF_PBR_ALPHA_MASK: + if (mPBRAlphaMaskPool) + { + llassert(0); + LL_WARNS() << "LLPipeline::addPool(): Ignoring duplicate PBR Alpha Mask Pool" << LL_ENDL; + } + else + { + mPBRAlphaMaskPool = new_poolp; + } + break; + + default: llassert(0); LL_WARNS() << "Invalid Pool Type in LLPipeline::addPool()" << LL_ENDL; @@ -5308,6 +5345,11 @@ void LLPipeline::removeFromQuickLookup( LLDrawPool* poolp ) mPBROpaquePool = NULL; break; + case LLDrawPool::POOL_GLTF_PBR_ALPHA_MASK: + llassert(poolp == mPBRAlphaMaskPool); + mPBRAlphaMaskPool = NULL; + break; + default: llassert(0); LL_WARNS() << "Invalid Pool Type in LLPipeline::removeFromQuickLookup() type=" << poolp->getType() << LL_ENDL; diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 85878dd21d..29dd42e4ec 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -895,6 +895,8 @@ protected: LLDrawPool* mMaterialsPool = nullptr; LLDrawPool* mWLSkyPool = nullptr; LLDrawPool* mPBROpaquePool = nullptr; + LLDrawPool* mPBRAlphaMaskPool = nullptr; + // Note: no need to keep an quick-lookup to avatar pools, since there's only one per avatar public: -- cgit v1.3 From 8f83724f7eb6f05150951fabac2a89f4b83abe39 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 21 Feb 2023 20:56:20 -0600 Subject: DRTVWR-559 WIP -- Kill debug text on probes (whoops) --- indra/newview/llreflectionmap.cpp | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 9fcc6ae902..fb934da02e 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -271,10 +271,6 @@ void LLReflectionMap::doOcclusion(const LLVector4a& eye) if (o.getLength3().getF32() < dist) { // eye is inside radius, don't attempt to occlude mOccluded = false; - if (mViewerObject) - { - mViewerObject->setDebugText("Camera Non-Occluded"); - } return; } @@ -298,10 +294,6 @@ void LLReflectionMap::doOcclusion(const LLVector4a& eye) else { mOcclusionPendingFrames++; - if (mViewerObject) - { - mViewerObject->setDebugText(llformat("Query Pending - %d", mOcclusionPendingFrames)); - } } } @@ -312,17 +304,11 @@ void LLReflectionMap::doOcclusion(const LLVector4a& eye) LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; shader->uniform3fv(LLShaderMgr::BOX_CENTER, 1, mOrigin.getF32ptr()); - F32 r = mRadius + 0.25f; // pad by 1/4m for near clip plane etc shader->uniform3f(LLShaderMgr::BOX_SIZE, mRadius, mRadius, mRadius); gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(LLViewerCamera::getInstance(), mOrigin)); glEndQuery(GL_ANY_SAMPLES_PASSED); - - if (mViewerObject) - { - mViewerObject->setDebugText(llformat("Query Issued - %.2f, %.2f, %.2f", o.getLength3().getF32(), dist, mRadius)); - } } #endif } -- cgit v1.3 From 65d69ce80dca112ea0bfd06f2749d4d6fcb366b4 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Feb 2023 11:01:18 -0600 Subject: DRTVWR-559 Fix for stall in probe occlusion culling and fix for culled neighbors getting sampled (badly). --- indra/newview/llreflectionmap.cpp | 18 +++++++++++++++--- indra/newview/llreflectionmap.h | 2 ++ indra/newview/llreflectionmapmanager.cpp | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index fb934da02e..37ad74e54d 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -41,6 +41,14 @@ LLReflectionMap::LLReflectionMap() { } +LLReflectionMap::~LLReflectionMap() +{ + if (mOcclusionQuery) + { + glDeleteQueries(1, &mOcclusionQuery); + } +} + void LLReflectionMap::update(U32 resolution, U32 face) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; @@ -276,18 +284,21 @@ void LLReflectionMap::doOcclusion(const LLVector4a& eye) if (mOcclusionQuery == 0) { // no query was previously issued, allocate one and issue + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("rmdo - glGenQueries"); glGenQueries(1, &mOcclusionQuery); do_query = true; } else { // query was previously issued, check it and only issue a new query // if previous query is available - GLuint result = (GLuint) 0xFFFFFFFF; - glGetQueryObjectuiv(mOcclusionQuery, GL_QUERY_RESULT_NO_WAIT, &result); + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("rmdo - glGetQueryObject"); + GLuint result = 0; + glGetQueryObjectuiv(mOcclusionQuery, GL_QUERY_RESULT_AVAILABLE, &result); - if (result != (GLuint) 0xFFFFFFFF) + if (result > 0) { do_query = true; + glGetQueryObjectuiv(mOcclusionQuery, GL_QUERY_RESULT, &result); mOccluded = result == 0; mOcclusionPendingFrames = 0; } @@ -299,6 +310,7 @@ void LLReflectionMap::doOcclusion(const LLVector4a& eye) if (do_query) { + LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("rmdo - push query"); glBeginQuery(GL_ANY_SAMPLES_PASSED, mOcclusionQuery); LLGLSLShader* shader = LLGLSLShader::sCurBoundShaderPtr; diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index 0405d06eb5..6eff607ea5 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -39,6 +39,8 @@ public: // allocate an environment map of the given resolution LLReflectionMap(); + ~LLReflectionMap(); + // update this environment map // resolution - size of cube map to generate void update(U32 resolution, U32 face); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index bfc8b595c2..608585acf5 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -862,7 +862,7 @@ void LLReflectionMapManager::updateUniforms() } GLint idx = neighbor->mProbeIndex; - if (idx == -1) + if (idx == -1 || neighbor->mOccluded) { continue; } -- cgit v1.3 From bb79718c8f0050569c80a1bfe4dd428321706d1a Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 6 Apr 2023 13:21:25 -0500 Subject: SL-19538 Followup -- scrub all possible sources of NaNs, make dynamic exposure controls not persist, limit exposure range, and do a debug gl pass. --- indra/llrender/llgl.cpp | 24 ++++++++++++++++++---- indra/newview/app_settings/settings.xml | 10 ++++----- .../shaders/class1/deferred/blurLightF.glsl | 2 +- .../shaders/class1/deferred/bumpF.glsl | 7 ++----- .../shaders/class1/deferred/deferredUtil.glsl | 2 +- .../shaders/class1/deferred/diffuseAlphaMaskF.glsl | 7 ++----- .../class1/deferred/diffuseAlphaMaskIndexedF.glsl | 7 ++----- .../class1/deferred/diffuseAlphaMaskNoColorF.glsl | 7 ++----- .../shaders/class1/deferred/diffuseF.glsl | 7 ++----- .../shaders/class1/deferred/diffuseIndexedF.glsl | 7 ++----- .../shaders/class1/deferred/emissiveF.glsl | 2 +- .../shaders/class1/deferred/exposureF.glsl | 2 +- .../shaders/class1/deferred/fullbrightF.glsl | 3 +-- .../shaders/class1/deferred/highlightF.glsl | 7 ++----- .../shaders/class1/deferred/impostorF.glsl | 7 ++----- .../shaders/class1/deferred/materialF.glsl | 3 ++- .../shaders/class1/deferred/pbropaqueF.glsl | 8 ++++---- .../class1/deferred/postDeferredGammaCorrect.glsl | 7 ++----- .../shaders/class1/deferred/terrainF.glsl | 7 ++----- .../shaders/class1/deferred/treeF.glsl | 7 ++----- .../app_settings/shaders/class1/effects/glowF.glsl | 2 +- .../shaders/class1/interface/alphamaskF.glsl | 2 +- .../shaders/class1/interface/clipF.glsl | 2 +- .../shaders/class1/interface/debugF.glsl | 2 +- .../shaders/class1/interface/gaussianF.glsl | 2 +- .../shaders/class1/interface/highlightF.glsl | 2 +- .../shaders/class1/interface/radianceGenF.glsl | 2 +- .../shaders/class1/lighting/lightAlphaMaskF.glsl | 2 +- .../class1/lighting/lightAlphaMaskNonIndexedF.glsl | 2 +- .../shaders/class1/lighting/lightF.glsl | 2 +- .../shaders/class1/lighting/lightNonIndexedF.glsl | 2 +- .../class1/lighting/lightWaterAlphaMaskF.glsl | 2 +- .../lighting/lightWaterAlphaMaskNonIndexedF.glsl | 2 +- .../shaders/class1/lighting/lightWaterF.glsl | 2 +- .../class1/lighting/lightWaterNonIndexedF.glsl | 2 +- .../app_settings/shaders/class1/objects/bumpF.glsl | 2 +- .../shaders/class1/objects/impostorF.glsl | 2 +- .../shaders/class1/objects/previewF.glsl | 2 +- .../shaders/class1/objects/previewPhysicsF.glsl | 2 +- .../shaders/class2/deferred/alphaF.glsl | 2 +- .../shaders/class2/interface/irradianceGenF.glsl | 2 +- .../shaders/class2/interface/reflectionprobeF.glsl | 2 +- .../shaders/class3/deferred/fullbrightShinyF.glsl | 2 +- .../shaders/class3/deferred/materialF.glsl | 5 +++-- .../class3/deferred/screenSpaceReflPostF.glsl | 5 +++-- .../shaders/class3/deferred/softenLightF.glsl | 2 +- .../shaders/class3/environment/underWaterF.glsl | 2 +- .../shaders/class3/environment/waterF.glsl | 2 +- indra/newview/llreflectionmap.cpp | 5 +++++ indra/newview/pipeline.cpp | 2 +- .../en/floater_preferences_graphics_advanced.xml | 2 +- 51 files changed, 97 insertions(+), 107 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/llrender/llgl.cpp b/indra/llrender/llgl.cpp index c08c576531..303edddfaf 100644 --- a/indra/llrender/llgl.cpp +++ b/indra/llrender/llgl.cpp @@ -86,12 +86,27 @@ void APIENTRY gl_debug_callback(GLenum source, const GLchar* message, GLvoid* userParam) { - if (severity != GL_DEBUG_SEVERITY_HIGH //&& - //severity != GL_DEBUG_SEVERITY_MEDIUM && - //severity != GL_DEBUG_SEVERITY_LOW + /*if (severity != GL_DEBUG_SEVERITY_HIGH && + severity != GL_DEBUG_SEVERITY_MEDIUM && + severity != GL_DEBUG_SEVERITY_LOW ) { //suppress out-of-spec messages sent by nvidia driver (mostly vertexbuffer hints) return; + }*/ + + // list of messages to suppress + const char* suppress[] = + { + "Buffer detailed info:", + "Program undefined behavior warning: The current GL state uses a sampler (0) that has depth comparisons enabled" + }; + + for (const char* msg : suppress) + { + if (strncmp(msg, message, strlen(msg)) == 0) + { + return; + } } if (severity == GL_DEBUG_SEVERITY_HIGH) @@ -133,7 +148,8 @@ void APIENTRY gl_debug_callback(GLenum source, glGetBufferParameteriv(GL_UNIFORM_BUFFER, GL_BUFFER_SIZE, &ubo_size); glGetBufferParameteriv(GL_UNIFORM_BUFFER, GL_BUFFER_IMMUTABLE_STORAGE, &ubo_immutable); } - //if (severity == GL_DEBUG_SEVERITY_HIGH) + + if (severity == GL_DEBUG_SEVERITY_HIGH) { LL_ERRS() << "Halting on GL Error" << LL_ENDL; } diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 44a86dd22a..7d15214ccb 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10452,7 +10452,7 @@ Comment Amount to over-brighten sun for HDR effect during the day Persist - 1 + 0 Type F32 Value @@ -10463,7 +10463,7 @@ Comment Maximum effective probe ambiance for local lights Persist - 1 + 0 Type F32 Value @@ -10474,7 +10474,7 @@ Comment Minimum dynamic exposure amount Persist - 1 + 0 Type F32 Value @@ -10485,7 +10485,7 @@ Comment Maximum dynamic exposure amount Persist - 1 + 0 Type F32 Value @@ -10496,7 +10496,7 @@ Comment Luminance coefficient for dynamic exposure Persist - 1 + 0 Type F32 Value diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl index 93a85cad40..cc79b450ac 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl @@ -115,7 +115,7 @@ void main() col /= defined_weight.xyxx; //col.y *= col.y; - frag_color = col; + frag_color = max(col, vec4(0)); #ifdef IS_AMD_CARD // If it's AMD make sure the GLSL compiler sees the arrays referenced once by static index. Otherwise it seems to optimise the storage awawy which leads to unfun crashes and artifacts. diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl index 749ec3a6ac..c18bca066d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl @@ -25,11 +25,7 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; uniform float minimum_alpha; uniform sampler2D diffuseMap; @@ -65,4 +61,5 @@ void main() //frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested vec3 nvn = normalize(tnorm); frag_data[2] = vec4(encode_normal(nvn), vertex_color.a, GBUFFER_FLAG_HAS_ATMOS); + frag_data[3] = vec4(0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index 4bf16b50bf..aa61e10c7f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -531,7 +531,7 @@ vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, specContrib *= NdotL; specContrib = max(specContrib, vec3(0)); - return color; + return clamp(color, vec3(0), vec3(10)); } vec3 pbrPunctual(vec3 diffuseColor, vec3 specularColor, diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl index 3bf148502c..afc05b8bb5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskF.glsl @@ -25,11 +25,7 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; uniform float minimum_alpha; @@ -54,5 +50,6 @@ void main() frag_data[1] = vec4(0,0,0,0); // spec vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, GBUFFER_FLAG_HAS_ATMOS); + frag_data[3] = vec4(0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl index e15239b59d..078197f9a8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskIndexedF.glsl @@ -25,11 +25,7 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; VARYING vec3 vary_normal; @@ -53,4 +49,5 @@ void main() frag_data[1] = vec4(0,0,0,0); vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, GBUFFER_FLAG_HAS_ATMOS); + frag_data[3] = vec4(0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl index b0ff233414..307dda6b73 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseAlphaMaskNoColorF.glsl @@ -25,11 +25,7 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; uniform float minimum_alpha; @@ -53,5 +49,6 @@ void main() frag_data[1] = vec4(0,0,0,0); // spec vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, GBUFFER_FLAG_HAS_ATMOS); + frag_data[3] = vec4(0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl index b2d2e2fa71..24e290c614 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl @@ -25,11 +25,7 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; uniform sampler2D diffuseMap; @@ -47,5 +43,6 @@ void main() //frag_data[1] = vec4(vec3(vertex_color.a), vertex_color.a+(1.0-vertex_color.a)*vertex_color.a); // spec - from former class3 - maybe better, but not so well tested vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), vertex_color.a, GBUFFER_FLAG_HAS_ATMOS); + frag_data[3] = vec4(0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl index b4bc114dd5..be870b2424 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl @@ -25,11 +25,7 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; VARYING vec3 vary_normal; VARYING vec4 vertex_color; @@ -49,4 +45,5 @@ void main() frag_data[1] = vec4(spec, vertex_color.a); // spec vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), vertex_color.a, GBUFFER_FLAG_HAS_ATMOS); + frag_data[3] = vec4(0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl index fb97cd95b4..17e24a2bf2 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl @@ -41,6 +41,6 @@ void main() vec4 color = diffuseLookup(vary_texcoord0.xy)*vertex_color; color.rgb = fullbrightAtmosTransport(color.rgb); - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl index 3eda2b9050..7ed8e4c8ce 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl @@ -55,6 +55,6 @@ void main() s = mix(prev, s, min(dt*2.0*abs(prev-s), 0.04)); - frag_color = vec4(s, s, s, dt); + frag_color = max(vec4(s, s, s, dt), vec4(0.0)); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index 03df9fd4a1..b5eae3a1d5 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -92,7 +92,6 @@ void main() #endif - frag_color.rgb = color.rgb; - frag_color.a = color.a; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/highlightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/highlightF.glsl index 75f914cb02..74df43b7c3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/highlightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/highlightF.glsl @@ -23,11 +23,7 @@ * $/LicenseInfo$ */ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; uniform vec4 color; uniform sampler2D diffuseMap; @@ -39,4 +35,5 @@ void main() frag_data[0] = color*texture2D(diffuseMap, vary_texcoord0.xy); frag_data[1] = vec4(0.0); frag_data[2] = vec4(0.0, 1.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS); + frag_data[3] = vec4(0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl index 51afda2791..5e67442b3a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl @@ -25,11 +25,7 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; uniform float minimum_alpha; @@ -58,4 +54,5 @@ void main() frag_data[0] = vec4(col.rgb, 0.0); frag_data[1] = spec; frag_data[2] = vec4(encode_normal(norm.xyz),0,GBUFFER_FLAG_HAS_ATMOS); + frag_data[3] = vec4(0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 4b98e6708f..4dee23372f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -32,7 +32,7 @@ #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) out vec4 frag_color; #else -out vec4 frag_data[3]; +out vec4 frag_data[4]; #endif void main() @@ -44,6 +44,7 @@ void main() frag_data[0] = vec4(0.5, 0, 1, 0); // gbuffer is sRGB for legacy materials frag_data[1] = vec4(0); // XYZ = Specular color. W = Specular exponent. frag_data[2] = vec4(0); // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog) + frag_data[3] = vec4(0); #endif } diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl index 6659e67a7a..8e5a6c90e0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl @@ -101,10 +101,10 @@ void main() //emissive = vNt * 0.5 + 0.5; //emissive = tnorm*0.5+0.5; // See: C++: addDeferredAttachments(), GLSL: softenLightF - frag_data[0] = vec4(col, 0.0); // Diffuse - frag_data[1] = vec4(spec.rgb,vertex_color.a); // PBR linear packed Occlusion, Roughness, Metal. - frag_data[2] = vec4(encode_normal(tnorm), vertex_color.a, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags - frag_data[3] = vec4(emissive,0); // PBR sRGB Emissive + frag_data[0] = max(vec4(col, 0.0), vec4(0)); // Diffuse + frag_data[1] = max(vec4(spec.rgb,vertex_color.a), vec4(0)); // PBR linear packed Occlusion, Roughness, Metal. + frag_data[2] = max(vec4(encode_normal(tnorm), vertex_color.a, GBUFFER_FLAG_HAS_PBR), vec4(0)); // normal, environment intensity, flags + frag_data[3] = max(vec4(emissive,0), vec4(0)); // PBR sRGB Emissive } #else diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index bdbc0056f8..3cfad5498b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -190,10 +190,7 @@ void main() vec3 seed = (diff.rgb+vec3(1.0))*vec3(tc.xy, tc.x+tc.y); vec3 nz = vec3(noise(seed.rg), noise(seed.gb), noise(seed.rb)); diff.rgb += nz*0.003; - //diff.rgb = nz; - - //float exp_sample = texture(exposureMap, vec2(0.5,0.5)).r; - //diff.g = exp_sample; - frag_color = diff; + + frag_color = max(diff, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl index d6c14c48c9..3464212c84 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl @@ -25,11 +25,7 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; uniform sampler2D detail_0; uniform sampler2D detail_1; @@ -64,5 +60,6 @@ void main() frag_data[1] = vec4(0.0,0.0,0.0,-1.0); vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, GBUFFER_FLAG_HAS_ATMOS); + frag_data[3] = vec4(0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl index dc0e5b0ce3..d857e47b90 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl @@ -25,11 +25,7 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; uniform sampler2D diffuseMap; @@ -53,4 +49,5 @@ void main() frag_data[1] = vec4(0,0,0,0); vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, GBUFFER_FLAG_HAS_ATMOS); + frag_data[3] = vec4(0); } diff --git a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl index c1f6af9f57..301e8aba26 100644 --- a/indra/newview/app_settings/shaders/class1/effects/glowF.glsl +++ b/indra/newview/app_settings/shaders/class1/effects/glowF.glsl @@ -56,5 +56,5 @@ void main() col += kern[6] * texture2D(diffuseMap, vary_texcoord2.zw); col += kern[7] * texture2D(diffuseMap, vary_texcoord3.zw); - frag_color = vec4(col.rgb * glowStrength, col.a); + frag_color = max(vec4(col.rgb * glowStrength, col.a), vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl b/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl index f520f301d9..69c1983b4d 100644 --- a/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/alphamaskF.glsl @@ -44,5 +44,5 @@ void main() discard; } - frag_color = col; + frag_color = max(col, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/interface/clipF.glsl b/indra/newview/app_settings/shaders/class1/interface/clipF.glsl index ac2bc8703b..9454bbf21e 100644 --- a/indra/newview/app_settings/shaders/class1/interface/clipF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/clipF.glsl @@ -42,5 +42,5 @@ void main() discard; } - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/interface/debugF.glsl b/indra/newview/app_settings/shaders/class1/interface/debugF.glsl index 67c6baddbb..cb8d6a8c03 100644 --- a/indra/newview/app_settings/shaders/class1/interface/debugF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/debugF.glsl @@ -33,5 +33,5 @@ uniform vec4 color; void main() { - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl b/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl index 188fac5460..eca591d387 100644 --- a/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/gaussianF.glsl @@ -49,5 +49,5 @@ void main() col += texture(diffuseRect, tc).rgb * w[i]; } - frag_color = vec4(col, 0.0); + frag_color = max(vec4(col, 0.0), vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl index 6cc9bbbea2..58c9e5ad0a 100644 --- a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl @@ -36,5 +36,5 @@ VARYING vec2 vary_texcoord0; void main() { - frag_color = color*texture2D(diffuseMap, vary_texcoord0.xy); + frag_color = max(color*texture2D(diffuseMap, vary_texcoord0.xy), vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index a1839d4a67..cd5d97c785 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -162,6 +162,6 @@ vec4 prefilterEnvMap(vec3 R) void main() { vec3 N = normalize(vary_dir); - frag_color = prefilterEnvMap(N); + frag_color = max(prefilterEnvMap(N), vec4(0)); } // ============================================================================================================= diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl index b2c83a0f44..eaf0f71b41 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskF.glsl @@ -51,6 +51,6 @@ void default_lighting() color.rgb = atmosLighting(color.rgb); color.rgb = scaleSoftClip(color.rgb); - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl index d87403c78f..fc76c0cc00 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightAlphaMaskNonIndexedF.glsl @@ -54,6 +54,6 @@ void default_lighting() color.rgb = scaleSoftClip(color.rgb); - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl index 9fd189358b..6b86d717da 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl @@ -43,6 +43,6 @@ void default_lighting() color.rgb = scaleSoftClip(color.rgb); - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl index f9c7ad2ab3..59c1bc1446 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightNonIndexedF.glsl @@ -45,6 +45,6 @@ void default_lighting() color.rgb = scaleSoftClip(color.rgb); - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl index 9c89c09573..7da8e9054a 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskF.glsl @@ -50,6 +50,6 @@ void default_lighting_water() color.rgb = atmosLighting(color.rgb); - frag_color = applyWaterFog(color); + frag_color = max(applyWaterFog(color), vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl index 9de7a03180..f767c17f86 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterAlphaMaskNonIndexedF.glsl @@ -54,6 +54,6 @@ void default_lighting_water() color = applyWaterFog(color); - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl index 57ed993a66..2530bdcc74 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterF.glsl @@ -41,6 +41,6 @@ void default_lighting_water() color.rgb = atmosLighting(color.rgb); - frag_color = applyWaterFog(color); + frag_color = max(applyWaterFog(color), vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl index af5da1411b..7f112d7435 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightWaterNonIndexedF.glsl @@ -43,6 +43,6 @@ void default_lighting_water() color.rgb = atmosLighting(color.rgb); - frag_color = applyWaterFog(color); + frag_color = max(applyWaterFog(color), vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl b/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl index d55f0db530..1deb374cd0 100644 --- a/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/bumpF.glsl @@ -40,5 +40,5 @@ void main() float tex0 = texture2D(texture0, vary_texcoord0.xy).a; float tex1 = texture2D(texture1, vary_texcoord1.xy).a; - frag_color = vec4(tex0+(1.0-tex1)-0.5); + frag_color = max(vec4(tex0+(1.0-tex1)-0.5), vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl b/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl index add437d144..467a9949e4 100644 --- a/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/impostorF.glsl @@ -44,5 +44,5 @@ void main() discard; } - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/objects/previewF.glsl b/indra/newview/app_settings/shaders/class1/objects/previewF.glsl index 284da3d0ac..687d6b7482 100644 --- a/indra/newview/app_settings/shaders/class1/objects/previewF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/previewF.glsl @@ -37,5 +37,5 @@ VARYING vec2 vary_texcoord0; void main() { vec4 color = texture2D(diffuseMap,vary_texcoord0.xy) * vertex_color; - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class1/objects/previewPhysicsF.glsl b/indra/newview/app_settings/shaders/class1/objects/previewPhysicsF.glsl index 3a5e6fdf7c..b56fc97a85 100644 --- a/indra/newview/app_settings/shaders/class1/objects/previewPhysicsF.glsl +++ b/indra/newview/app_settings/shaders/class1/objects/previewPhysicsF.glsl @@ -38,5 +38,5 @@ VARYING vec2 vary_texcoord0; void main() { - frag_color = texture2D(diffuseMap,vary_texcoord0.xy) * color; + frag_color = max(texture2D(diffuseMap,vary_texcoord0.xy) * color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 70be9a9029..53552870ae 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -306,6 +306,6 @@ void main() color.rgb = linear_to_srgb(color.rgb); #endif - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class2/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class2/interface/irradianceGenF.glsl index d21af946e0..0753e73dc8 100644 --- a/indra/newview/app_settings/shaders/class2/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class2/interface/irradianceGenF.glsl @@ -209,6 +209,6 @@ void main() color = filterColor(vary_dir); - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class2/interface/reflectionprobeF.glsl b/indra/newview/app_settings/shaders/class2/interface/reflectionprobeF.glsl index 986b233e0b..c858531998 100644 --- a/indra/newview/app_settings/shaders/class2/interface/reflectionprobeF.glsl +++ b/indra/newview/app_settings/shaders/class2/interface/reflectionprobeF.glsl @@ -38,5 +38,5 @@ void main() float depth = getDepth(tc.xy); vec4 pos = getPositionWithDepth(tc, depth); - frag_color = sampleReflectionProbesDebug(pos.xyz); + frag_color = max(sampleReflectionProbesDebug(pos.xyz), vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl index f6bed16c84..6b7dc7ac1d 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl @@ -92,6 +92,6 @@ void main() color.a = 1.0; - frag_color = color; + frag_color = max(color, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 02ab4494f6..1aef971d3a 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -183,7 +183,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe #else #ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; +out vec4 frag_data[4]; #else #define frag_data gl_FragData #endif @@ -412,13 +412,14 @@ void main() color = temp.rgb; #endif - frag_color = vec4(color, al); + frag_color = max(vec4(color, al), vec4(0)); #else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer // deferred path // See: C++: addDeferredAttachment(), shader: softenLightF.glsl frag_data[0] = vec4(diffcol.rgb, emissive); // gbuffer is sRGB for legacy materials frag_data[1] = vec4(spec.rgb, glossiness); // XYZ = Specular color. W = Specular exponent. frag_data[2] = vec4(encode_normal(norm), env, GBUFFER_FLAG_HAS_ATMOS);; // XY = Normal. Z = Env. intensity. W = 1 skip atmos (mask off fog) + frag_data[3] = vec4(0); #endif } diff --git a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl index 742f528cb1..f1865a77e2 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/screenSpaceReflPostF.glsl @@ -73,7 +73,7 @@ void main() vec4 diffuse = texture2D(diffuseRect, tc); vec3 specCol = spec.rgb; - frag_color = texture(diffuseMap, tc); + vec4 fcol = texture(diffuseMap, tc); if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) { @@ -94,5 +94,6 @@ void main() collectedColor.rgb *= specCol.rgb; - frag_color += collectedColor * w; + fcol += collectedColor * w; + frag_color = max(fcol, vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 99beb0d890..e1206cc844 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -270,6 +270,6 @@ void main() color = fogged.rgb; #endif - frag_color.rgb = color.rgb; //output linear since local lights will be added to this shader's results + frag_color.rgb = max(color.rgb, vec3(0)); //output linear since local lights will be added to this shader's results frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl index 83454631d4..21c30012ab 100644 --- a/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/underWaterF.glsl @@ -77,5 +77,5 @@ void main() vec4 fb = vec4(waterFogColorLinear, 0.0); #endif - frag_color = applyWaterFogViewLinearNoClip(vary_position, fb, vec3(1)); + frag_color = max(applyWaterFogViewLinearNoClip(vary_position, fb, vec3(1)), vec4(0)); } diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl index ec0439fa97..3d4f4fc17b 100644 --- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl @@ -286,6 +286,6 @@ void main() float spec = min(max(max(punctual.r, punctual.g), punctual.b), 0.05); - frag_color = vec4(color, spec); //*sunAngle2); + frag_color = max(vec4(color, spec), vec4(0)); } diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 37ad74e54d..89ac0df286 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -265,6 +265,11 @@ bool LLReflectionMap::isActive() void LLReflectionMap::doOcclusion(const LLVector4a& eye) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; + if (LLGLSLShader::sProfileEnabled) + { + return; + } + #if 1 // super sloppy, but we're doing an occlusion cull against a bounding cube of // a bounding sphere, pad radius so we assume if the eye is within diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4ab6483c88..e4ffa5b6b0 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -3928,7 +3928,7 @@ void LLPipeline::renderGeomDeferred(LLCamera& camera, bool do_occlusion) } } - bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion; + bool occlude = LLPipeline::sUseOcclusion > 1 && do_occlusion && !LLGLSLShader::sProfileEnabled; setupHWLights(); diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index 534c4c3686..17875e9c19 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -760,7 +760,7 @@ layout="topleft" left="420" min_val="0.5" - max_val="4.0" + max_val="1.5" name="RenderExposure" show_text="true" top_delta="20" -- cgit v1.3 From de73cf7599e934441fe760f53163b0504c03adc7 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 7 Apr 2023 11:06:09 -0500 Subject: SL-19538 Remove clouds from irradiance maps and don't conflate max probe samples with max probe neighbors, and don't move manual probes after they are complete (removes flickering around Sponza). --- .../app_settings/shaders/class3/deferred/reflectionProbeF.glsl | 2 +- indra/newview/lldrawpoolwlsky.cpp | 6 +++++- indra/newview/llreflectionmap.cpp | 2 +- indra/newview/llreflectionmapmanager.cpp | 9 +++++++++ 4 files changed, 16 insertions(+), 3 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index e73e396b8e..e1b18935e8 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -134,7 +134,7 @@ void preProbeSample(vec3 pos) int neighborIdx = refIndex[i].y; if (neighborIdx != -1) { - int neighborCount = min(refIndex[i].z, REF_SAMPLE_COUNT-1); + int neighborCount = refIndex[i].z; int count = 0; while (count < neighborCount) diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index b49fe35851..820073b3e0 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -442,7 +442,11 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) { renderStarsDeferred(origin); } - renderSkyCloudsDeferred(origin, camHeightLocal, cloud_shader); + + if (!gCubeSnapshot || gPipeline.mReflectionMapManager.isRadiancePass()) // don't draw clouds in irradiance maps to avoid popping + { + renderSkyCloudsDeferred(origin, camHeightLocal, cloud_shader); + } } gGL.setColorMask(true, true); } diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 89ac0df286..261aa51d62 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -70,7 +70,7 @@ void LLReflectionMap::autoAdjustOrigin() { LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; - if (mGroup) + if (mGroup && !mComplete) { const LLVector4a* bounds = mGroup->getBounds(); auto* node = mGroup->getOctreeNode(); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 8252b4be36..dc84b0b10e 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -861,6 +861,9 @@ void LLReflectionMapManager::updateUniforms() { //LL_PROFILE_ZONE_NAMED_CATEGORY_DISPLAY("rmmsu - refNeighbors"); //pack neghbor list + const U32 max_neighbors = 64; + U32 neighbor_count = 0; + for (auto& neighbor : refmap->mNeighbors) { if (ni >= 4096) @@ -876,6 +879,12 @@ void LLReflectionMapManager::updateUniforms() // this neighbor may be sampled rpd.refNeighbor[ni++] = idx; + + neighbor_count++; + if (neighbor_count >= max_neighbors) + { + break; + } } } -- cgit v1.3 From 413ce656c8e910bf3758afc3fa354e07be2d4561 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 7 Apr 2023 14:10:53 -0500 Subject: SL-19538 Clear probes on sky setting slam. Better probe update prioritization. Incidental decruft. --- indra/newview/llenvironment.cpp | 2 + indra/newview/llreflectionmap.cpp | 7 +-- indra/newview/llreflectionmapmanager.cpp | 60 +++++++++++++++++----- indra/newview/llreflectionmapmanager.h | 7 ++- indra/newview/llviewermenu.cpp | 10 +--- indra/newview/skins/default/xui/en/menu_viewer.xml | 7 --- 6 files changed, 59 insertions(+), 34 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e4bfcdffa3..6557c2b351 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1265,6 +1265,8 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm } } + gPipeline.mReflectionMapManager.reset(); + if (!mSignalEnvChanged.empty()) mSignalEnvChanged(env, env_version); } diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 261aa51d62..624fbd1758 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -169,7 +169,6 @@ void LLReflectionMap::autoAdjustOrigin() bool LLReflectionMap::intersects(LLReflectionMap* other) { - // TODO: incorporate getBox LLVector4a delta; delta.setSub(other->mOrigin, mOrigin); @@ -239,11 +238,13 @@ bool LLReflectionMap::getBox(LLMatrix4& box) scale.set_scale(glh::vec3f(s.mV)); if (vobjp->mDrawable != nullptr) { + // object to agent space (no scale) glh::matrix4f rm((F32*)vobjp->mDrawable->getWorldMatrix().mMatrix); - glh::matrix4f rt((F32*)vobjp->getRelativeXform().mMatrix); + // construct object to camera space (with scale) + mv = mv * rm * scale; - mv = mv * rm * scale; // *rt; + // inverse is camera space to object unit cube mv = mv.inverse(); box = LLMatrix4(mv.m); diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index dc84b0b10e..fd80936496 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -75,6 +75,23 @@ struct CompareProbeDistance } }; +// return true if a is higher priority for an update than b +static bool check_priority(LLReflectionMap* a, LLReflectionMap* b) +{ + if (!a->mComplete && !b->mComplete) + { //neither probe is complete, use distance + return a->mDistance < b->mDistance; + } + else if (a->mComplete && b->mComplete) + { //both probes are complete, use combination of distance and last update time + return (a->mDistance - (gFrameTimeSeconds - a->mLastUpdateTime)) < + (b->mDistance - (gFrameTimeSeconds - b->mLastUpdateTime)); + } + + // one of these probes is not complete, if b is complete, a is higher priority + return b->mComplete; +} + // helper class to seed octree with probes void LLReflectionMapManager::update() { @@ -181,6 +198,12 @@ void LLReflectionMapManager::update() LLVector4a d; + if (probe != mDefaultProbe) + { + d.setSub(camera_pos, probe->mOrigin); + probe->mDistance = d.getLength3().getF32() - probe->mRadius; + } + if (probe->mComplete) { probe->mFadeIn = llmin((F32) (probe->mFadeIn + gFrameIntervalSeconds), 1.f); @@ -201,7 +224,7 @@ void LLReflectionMapManager::update() if (!did_update && i < mReflectionProbeCount && (oldestProbe == nullptr || - probe->mLastUpdateTime < oldestProbe->mLastUpdateTime)) + check_priority(probe, oldestProbe))) { oldestProbe = probe; } @@ -214,12 +237,6 @@ void LLReflectionMapManager::update() { closestDynamic = probe; } - - if (probe != mDefaultProbe) - { - d.setSub(camera_pos, probe->mOrigin); - probe->mDistance = d.getLength3().getF32() - probe->mRadius; - } } if (realtime && closestDynamic != nullptr) @@ -702,12 +719,9 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) } } -void LLReflectionMapManager::rebuild() +void LLReflectionMapManager::reset() { - for (auto& probe : mProbes) - { - probe->mLastUpdateTime = 0.f; - } + mReset = true; } void LLReflectionMapManager::shift(const LLVector4a& offset) @@ -950,12 +964,30 @@ void renderReflectionProbe(LLReflectionMap* probe) gGL.begin(gGL.LINES); for (auto& neighbor : probe->mNeighbors) { + if (probe->mViewerObject && neighbor->mViewerObject) + { + continue; + } + gGL.vertex3fv(po); gGL.vertex3fv(neighbor->mOrigin.getF32ptr()); } gGL.end(); gGL.flush(); + gGL.diffuseColor4f(1, 1, 0, 1); + gGL.begin(gGL.LINES); + for (auto& neighbor : probe->mNeighbors) + { + if (probe->mViewerObject && neighbor->mViewerObject) + { + gGL.vertex3fv(po); + gGL.vertex3fv(neighbor->mOrigin.getF32ptr()); + } + } + gGL.end(); + gGL.flush(); + #if 0 LLSpatialGroup* group = probe->mGroup; if (group) @@ -1022,8 +1054,9 @@ void LLReflectionMapManager::initReflectionMaps() U32 count = llclamp((S32) probe_count, 1, LL_MAX_REFLECTION_PROBE_COUNT); - if (mTexture.isNull() || mReflectionProbeCount != count) + if (mTexture.isNull() || mReflectionProbeCount != count || mReset) { + mReset = false; mReflectionProbeCount = count; mProbeResolution = nhpo2(llclamp(gSavedSettings.getU32("RenderReflectionProbeResolution"), (U32)64, (U32)512)); mMaxProbeLOD = log2f(mProbeResolution) - 1.f; // number of mips - 1 @@ -1045,6 +1078,7 @@ void LLReflectionMapManager::initReflectionMaps() for (auto& probe : mProbes) { + probe->mLastUpdateTime = 0.f; probe->mComplete = false; probe->mProbeIndex = -1; probe->mCubeArray = nullptr; diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index 9a46af58b3..066b1e380f 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -80,8 +80,8 @@ public: // Guaranteed to not return null LLReflectionMap* registerViewerObject(LLViewerObject* vobj); - // force an update of all probes - void rebuild(); + // reset all state on the next update + void reset(); // called on region crossing to "shift" probes into new coordinate frame void shift(const LLVector4a& offset); @@ -190,5 +190,8 @@ private: // amount to scale local lights during an irradiance map update (set during updateProbeFace and used by LLPipeline) F32 mLightScale = 1.f; + + // if true, reset all probe render state on the next update (for teleports and sky changes) + bool mReset = false; }; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 3a8206ad26..89538b3bd5 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -8451,12 +8451,6 @@ void handle_cache_clear_immediately() LLNotificationsUtil::add("ConfirmClearCache", LLSD(), LLSD(), callback_clear_cache_immediately); } -void handle_rebuild_reflection_probes() -{ - gPipeline.mReflectionMapManager.rebuild(); -} - - void handle_web_content_test(const LLSD& param) { std::string url = param.asString(); @@ -9550,9 +9544,7 @@ void initialize_menus() //Develop (clear cache immediately) commit.add("Develop.ClearCache", boost::bind(&handle_cache_clear_immediately) ); - //Develop (override environment map) - commit.add("Develop.RebuildReflectionProbes", boost::bind(&handle_rebuild_reflection_probes)); - + // Admin >Object view_listener_t::addMenu(new LLAdminForceTakeCopy(), "Admin.ForceTakeCopy"); view_listener_t::addMenu(new LLAdminHandleObjectOwnerSelf(), "Admin.HandleObjectOwnerSelf"); diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index b8515cb096..d77415877c 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -3238,13 +3238,6 @@ function="World.EnvPreset" function="Advanced.HandleAttachedLightParticles" parameter="RenderAttachedParticles" /> - - - Date: Tue, 18 Apr 2023 19:11:38 -0500 Subject: DRTVWR-559 Add control for automatic reflection probes to advanced preferences and featuretable. Remove Reflections checkbox. Don't persist reflection probe volume display between sessions. Incidental decruft. --- indra/newview/app_settings/settings.xml | 19 +++++-- .../shaders/class3/deferred/reflectionProbeF.glsl | 4 ++ .../shaders/class3/deferred/softenLightF.glsl | 15 ------ indra/newview/featuretable.txt | 10 +++- indra/newview/featuretable_mac.txt | 10 +++- indra/newview/llreflectionmap.cpp | 24 +++++++++ indra/newview/llreflectionmap.h | 3 ++ indra/newview/llreflectionmapmanager.cpp | 28 ++++++---- indra/newview/llreflectionmapmanager.h | 1 + indra/newview/llviewercontrol.cpp | 2 + indra/newview/llviewerregion.cpp | 51 +++++++++--------- indra/newview/llviewershadermgr.cpp | 2 + .../en/floater_preferences_graphics_advanced.xml | 62 +++++++++++++++------- 13 files changed, 156 insertions(+), 75 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index bc06a1f829..a057933009 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10197,7 +10197,7 @@ Comment Render influence volumes of Reflection Probes Persist - 1 + 0 Type Boolean Value @@ -10392,16 +10392,27 @@ Value 0 - RenderAutomaticReflectionProbes + RenderDefaultProbeUpdatePeriod Comment - Automatic reflection probes control. 0 - disable, 1 - Terrain/water only, 2- Terrain/water + objects. Requires restart. + When RenderReflectionProbeLevel is 0, amount of time in seconds to wait between updates to reflection map. + Persist + 1 + Type + F32 + Value + 20.0 + + RenderReflectionProbeLevel + + Comment + Reflection probes control. 0 - disable (one probe to rule them all), 1 - manual probes only, 2 - manual + terrain/water, 3 - Manual + Terrain/water + objects. Persist 1 Type S32 Value - 2 + 3 RenderReflectionRes diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 55a43f76d0..36b5262104 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -122,6 +122,7 @@ bool shouldSampleProbe(int i, vec3 pos) // populate "probeIndex" with N probe indices that influence pos where N is REF_SAMPLE_COUNT void preProbeSample(vec3 pos) { +#if REFMAP_LEVEL > 0 // TODO: make some sort of structure that reduces the number of distance checks for (int i = 1; i < refmapCount; ++i) { @@ -213,6 +214,9 @@ void preProbeSample(vec3 pos) { // probe at index 0 is a special probe for smoothing out automatic probes probeIndex[probeInfluences++] = 0; } +#else + probeIndex[probeInfluences++] = 0; +#endif } // from https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-sphere-intersection diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index ab83708c7b..a8d61afeca 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -246,20 +246,6 @@ void main() vec3 refnormpersp = reflect(pos.xyz, norm.xyz); -#if 0 // wrong implementation - if (spec.a > 0.0) // specular reflection - { - float sa = dot(normalize(refnormpersp), light_dir.xyz); - vec3 dumbshiny = sunlit * scol * (texture2D(lightFunc, vec2(sa, spec.a)).r); - - // add the two types of shiny together - vec3 spec_contrib = dumbshiny * spec.rgb; - color.rgb += spec_contrib; - - // add radiance map - applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz); - } -#else //right implementation (ported from pointLightF.glsl) if (spec.a > 0.0) { vec3 lv = light_dir.xyz; @@ -284,7 +270,6 @@ void main() // add radiance map applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz); } -#endif color.rgb = mix(color.rgb, baseColor.rgb, baseColor.a); diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 99007d52c2..78c2578cec 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 54 +version 55 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -62,6 +62,7 @@ Disregard96DefaultDrawDistance 1 1 RenderCompressTextures 1 1 RenderShaderLightingMaxLevel 1 3 RenderReflectionProbeCount 1 256 +RenderReflectionProbeLevel 1 3 RenderDeferred 1 1 RenderDeferredSSAO 1 1 RenderUseAdvancedAtmospherics 1 0 @@ -104,6 +105,7 @@ WLSkyDetail 1 96 RenderFSAASamples 1 0 RenderScreenSpaceReflections 1 0 RenderReflectionProbeCount 1 8 +RenderReflectionProbeLevel 1 0 // // Medium Low Graphics Settings @@ -133,6 +135,7 @@ WLSkyDetail 1 96 RenderFSAASamples 1 0 RenderScreenSpaceReflections 1 0 RenderReflectionProbeCount 1 16 +RenderReflectionProbeLevel 1 1 // // Medium Graphics Settings (standard) @@ -162,6 +165,7 @@ RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 RenderReflectionProbeCount 1 32 +RenderReflectionProbeLevel 1 2 // // Medium High Graphics Settings (deferred enabled) @@ -191,6 +195,7 @@ RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 RenderReflectionProbeCount 1 64 +RenderReflectionProbeLevel 1 2 // // High Graphics Settings (deferred + SSAO) @@ -220,6 +225,7 @@ RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 RenderReflectionProbeCount 1 128 +RenderReflectionProbeLevel 1 3 // // High Ultra Graphics Settings (deferred + SSAO + shadows) @@ -249,6 +255,7 @@ RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 RenderReflectionProbeCount 1 256 +RenderReflectionProbeLevel 1 3 // // Ultra graphics (REALLY PURTY!) @@ -278,6 +285,7 @@ RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 1 RenderReflectionProbeCount 1 256 +RenderReflectionProbeLevel 1 3 // // Class Unknown Hardware (unknown) diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 24023901d9..1d407b52d8 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 49 +version 50 // The version number above should be incremented IF AND ONLY IF some // change has been made that is sufficiently important to justify // resetting the graphics preferences of all users to the recommended @@ -73,6 +73,7 @@ RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 2 RenderScreenSpaceReflections 1 1 RenderReflectionProbeCount 1 256 +RenderReflectionProbeLevel 1 3 // // Low Graphics Settings @@ -102,6 +103,7 @@ RenderReflectionsEnabled 1 0 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 RenderReflectionProbeCount 1 8 +RenderReflectionProbeLevel 1 0 // // Medium Low Graphics Settings @@ -131,6 +133,7 @@ RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 RenderReflectionProbeCount 1 16 +RenderReflectionProbeLevel 1 1 // // Medium Graphics Settings (standard) @@ -160,6 +163,7 @@ RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 RenderReflectionProbeCount 1 32 +RenderReflectionProbeLevel 1 2 // // Medium High Graphics Settings (deferred enabled) @@ -189,6 +193,7 @@ RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 RenderReflectionProbeCount 1 64 +RenderReflectionProbeLevel 1 2 // // High Graphics Settings (deferred + SSAO) @@ -218,6 +223,7 @@ RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 RenderReflectionProbeCount 1 128 +RenderReflectionProbeLevel 1 3 // // High Ultra Graphics Settings (deferred + SSAO + shadows) @@ -247,6 +253,7 @@ RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 RenderReflectionProbeCount 1 256 +RenderReflectionProbeLevel 1 3 // // Ultra graphics (REALLY PURTY!) @@ -276,6 +283,7 @@ RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 1 RenderReflectionProbeCount 1 256 +RenderReflectionProbeLevel 1 3 // // Class Unknown Hardware (unknown) diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 624fbd1758..72dab0cba8 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -263,6 +263,30 @@ bool LLReflectionMap::isActive() return mCubeIndex != -1; } +bool LLReflectionMap::isRelevant() +{ + static LLCachedControl RenderReflectionProbeLevel(gSavedSettings, "RenderReflectionProbeLevel", 3); + + if (mViewerObject && RenderReflectionProbeLevel > 0) + { // not an automatic probe + return true; + } + + if (RenderReflectionProbeLevel == 3) + { // all automatics are relevant + return true; + } + + if (RenderReflectionProbeLevel == 2) + { // terrain and water only, ignore probes that have a group + return !mGroup; + } + + // no automatic probes, yes manual probes + return mViewerObject != nullptr; +} + + void LLReflectionMap::doOcclusion(const LLVector4a& eye) { LL_PROFILE_ZONE_SCOPED_CATEGORY_PIPELINE; diff --git a/indra/newview/llreflectionmap.h b/indra/newview/llreflectionmap.h index d639f6a54c..803f7bdc97 100644 --- a/indra/newview/llreflectionmap.h +++ b/indra/newview/llreflectionmap.h @@ -72,6 +72,9 @@ public: // perform occlusion query/readback void doOcclusion(const LLVector4a& eye); + // return false if this probe isn't currently relevant (for example, disabled due to graphics preferences) + bool isRelevant(); + // point at which environment map was last generated from (in agent space) LLVector4a mOrigin; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index ea2db63560..88edbc9224 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -173,6 +173,8 @@ void LLReflectionMapManager::update() bool did_update = false; static LLCachedControl sDetail(gSavedSettings, "RenderReflectionProbeDetail", -1); + static LLCachedControl sLevel(gSavedSettings, "RenderReflectionProbeLevel", 3); + bool realtime = sDetail >= (S32)LLReflectionMapManager::DetailLevel::REALTIME; LLReflectionMap* closestDynamic = nullptr; @@ -198,6 +200,11 @@ void LLReflectionMapManager::update() continue; } + if (probe != mDefaultProbe && !probe->isRelevant()) + { + continue; + } + probe->mProbeIndex = i; LLVector4a d; @@ -270,6 +277,13 @@ void LLReflectionMapManager::update() mRadiancePass = radiance_pass; } + static LLCachedControl sUpdatePeriod(gSavedSettings, "RenderDefaultProbeUpdatePeriod", 20.f); + if (sLevel == 0 && + gFrameTimeSeconds - mDefaultProbe->mLastUpdateTime < sUpdatePeriod) + { // when probes are disabled don't update the default probe more often than once every 20 seconds + oldestProbe = nullptr; + } + // switch to updating the next oldest probe if (!did_update && oldestProbe != nullptr) { @@ -360,17 +374,13 @@ void LLReflectionMapManager::getReflectionMaps(std::vector& ma LLReflectionMap* LLReflectionMapManager::registerSpatialGroup(LLSpatialGroup* group) { - static LLCachedControl automatic_probes(gSavedSettings, "RenderAutomaticReflectionProbes", 2); - if (automatic_probes > 1) + if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) { - if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME) + OctreeNode* node = group->getOctreeNode(); + F32 size = node->getSize().getF32ptr()[0]; + if (size >= 15.f && size <= 17.f) { - OctreeNode* node = group->getOctreeNode(); - F32 size = node->getSize().getF32ptr()[0]; - if (size >= 15.f && size <= 17.f) - { - return addProbe(group); - } + return addProbe(group); } } diff --git a/indra/newview/llreflectionmapmanager.h b/indra/newview/llreflectionmapmanager.h index 066b1e380f..234bde51a8 100644 --- a/indra/newview/llreflectionmapmanager.h +++ b/indra/newview/llreflectionmapmanager.h @@ -77,6 +77,7 @@ public: // presently hacked into LLViewerObject::setTE // Used by LLViewerObjects that are Reflection Probes + // vobj must not be null // Guaranteed to not return null LLReflectionMap* registerViewerObject(LLViewerObject* vobj); diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 8973d1c099..bbdae95b7f 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -420,6 +420,7 @@ static bool handleReflectionProbeDetailChanged(const LLSD& newvalue) gPipeline.releaseGLBuffers(); gPipeline.createGLBuffers(); LLViewerShaderMgr::instance()->setShaders(); + gPipeline.mReflectionMapManager.reset(); } return true; } @@ -652,6 +653,7 @@ void settings_setup_listeners() setting_setup_signal_listener(gSavedSettings, "RenderDeferredNoise", handleReleaseGLBufferChanged); setting_setup_signal_listener(gSavedSettings, "RenderDebugPipeline", handleRenderDebugPipelineChanged); setting_setup_signal_listener(gSavedSettings, "RenderResolutionDivisor", handleRenderResolutionDivisorChanged); + setting_setup_signal_listener(gSavedSettings, "RenderReflectionProbeLevel", handleReflectionProbeDetailChanged); setting_setup_signal_listener(gSavedSettings, "RenderReflectionProbeDetail", handleReflectionProbeDetailChanged); setting_setup_signal_listener(gSavedSettings, "RenderReflectionsEnabled", handleReflectionProbeDetailChanged); setting_setup_signal_listener(gSavedSettings, "RenderScreenSpaceReflections", handleReflectionProbeDetailChanged); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index d3ee6daa6f..402d03bc6e 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1255,43 +1255,40 @@ U32 LLViewerRegion::getNumOfVisibleGroups() const void LLViewerRegion::updateReflectionProbes() { - static LLCachedControl automatic_probes(gSavedSettings, "RenderAutomaticReflectionProbes", 2); - if (automatic_probes > 0) - { - const F32 probe_spacing = 32.f; - const F32 probe_radius = sqrtf((probe_spacing * 0.5f) * (probe_spacing * 0.5f) * 3.f); - const F32 hover_height = 2.f; + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + const F32 probe_spacing = 32.f; + const F32 probe_radius = sqrtf((probe_spacing * 0.5f) * (probe_spacing * 0.5f) * 3.f); + const F32 hover_height = 2.f; - F32 start = probe_spacing * 0.5f; + F32 start = probe_spacing * 0.5f; - U32 grid_width = REGION_WIDTH_METERS / probe_spacing; + U32 grid_width = REGION_WIDTH_METERS / probe_spacing; - mReflectionMaps.resize(grid_width * grid_width); + mReflectionMaps.resize(grid_width * grid_width); - F32 water_height = getWaterHeight(); - LLVector3 origin = getOriginAgent(); + F32 water_height = getWaterHeight(); + LLVector3 origin = getOriginAgent(); - for (U32 i = 0; i < grid_width; ++i) + for (U32 i = 0; i < grid_width; ++i) + { + F32 x = i * probe_spacing + start; + for (U32 j = 0; j < grid_width; ++j) { - F32 x = i * probe_spacing + start; - for (U32 j = 0; j < grid_width; ++j) - { - F32 y = j * probe_spacing + start; + F32 y = j * probe_spacing + start; - U32 idx = i * grid_width + j; + U32 idx = i * grid_width + j; - if (mReflectionMaps[idx].isNull()) - { - mReflectionMaps[idx] = gPipeline.mReflectionMapManager.addProbe(); - } + if (mReflectionMaps[idx].isNull()) + { + mReflectionMaps[idx] = gPipeline.mReflectionMapManager.addProbe(); + } - LLVector3 probe_origin = LLVector3(x, y, llmax(water_height, mImpl->mLandp->resolveHeightRegion(x, y))); - probe_origin.mV[2] += hover_height; - probe_origin += origin; + LLVector3 probe_origin = LLVector3(x, y, llmax(water_height, mImpl->mLandp->resolveHeightRegion(x, y))); + probe_origin.mV[2] += hover_height; + probe_origin += origin; - mReflectionMaps[idx]->mOrigin.load3(probe_origin.mV); - mReflectionMaps[idx]->mRadius = probe_radius; - } + mReflectionMaps[idx]->mOrigin.load3(probe_origin.mV); + mReflectionMaps[idx]->mRadius = probe_radius; } } } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 1fd536ceac..f51f35ba9a 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -658,6 +658,7 @@ std::string LLViewerShaderMgr::loadBasicShaders() bool has_reflection_probes = gSavedSettings.getBOOL("RenderReflectionsEnabled") && gGLManager.mGLVersion > 3.99f; S32 probe_count = llclamp(gSavedSettings.getS32("RenderReflectionProbeCount"), 1, LL_MAX_REFLECTION_PROBE_COUNT); + S32 probe_level = llclamp(gSavedSettings.getS32("RenderReflectionProbeLevel"), 0, 3); if (ambient_kill) { @@ -694,6 +695,7 @@ std::string LLViewerShaderMgr::loadBasicShaders() if (has_reflection_probes) { attribs["REFMAP_COUNT"] = std::to_string(probe_count); + attribs["REFMAP_LEVEL"] = std::to_string(probe_level); attribs["REF_SAMPLE_COUNT"] = "32"; } diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index 16b965843d..d867123c4b 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -648,27 +648,13 @@ value="2"/> - - - - @@ -682,7 +668,7 @@ follows="left|top" height="16" layout="topleft" - left="440" + left="420" name="ReflectionDetailText" text_readonly_color="LabelDisabledColor" top_delta="16" @@ -694,7 +680,7 @@ control_name="RenderReflectionProbeDetail" height="18" layout="topleft" - left_delta="110" + left_delta="130" top_delta="0" name="ReflectionDetail" width="150"> @@ -712,7 +698,47 @@ value="2"/> - + Reflection Coverage: + + + + + + + + + + Date: Mon, 26 Jun 2023 15:37:18 -0500 Subject: SL-19909 Fix for reflection probes on vehicles blocking mouse clicks. Incidental instrumentation and decruft. --- indra/newview/llappviewer.cpp | 2 -- indra/newview/llreflectionmap.cpp | 2 +- indra/newview/llviewerobject.cpp | 2 ++ indra/newview/llviewerobjectlist.cpp | 4 ++++ indra/newview/llviewerregion.cpp | 7 +++++++ indra/newview/llvovolume.cpp | 9 ++++++++- indra/newview/llworld.cpp | 3 ++- 7 files changed, 24 insertions(+), 5 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index abef25e34f..cf84094aa4 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4675,7 +4675,6 @@ public: static LLTrace::BlockTimerStatHandle FTM_AUDIO_UPDATE("Update Audio"); static LLTrace::BlockTimerStatHandle FTM_CLEANUP("Cleanup"); static LLTrace::BlockTimerStatHandle FTM_CLEANUP_DRAWABLES("Drawables"); -static LLTrace::BlockTimerStatHandle FTM_CLEANUP_OBJECTS("Objects"); static LLTrace::BlockTimerStatHandle FTM_IDLE_CB("Idle Callbacks"); static LLTrace::BlockTimerStatHandle FTM_LOD_UPDATE("Update LOD"); static LLTrace::BlockTimerStatHandle FTM_OBJECTLIST_UPDATE("Update Objectlist"); @@ -4972,7 +4971,6 @@ void LLAppViewer::idle() { LL_RECORD_BLOCK_TIME(FTM_CLEANUP); { - LL_RECORD_BLOCK_TIME(FTM_CLEANUP_OBJECTS); gObjectList.cleanDeadObjects(); } { diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 72dab0cba8..efaf068bd2 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -117,7 +117,7 @@ void LLReflectionMap::autoAdjustOrigin() { int face = -1; LLVector4a intersection; - LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], true, false, true, &face, &intersection); + LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], false, false, true, &face, &intersection); if (drawable != nullptr) { hit = true; diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index e67750af7c..628a787b9d 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -418,6 +418,7 @@ void LLViewerObject::markDead() { if (!mDead) { + LL_PROFILE_ZONE_SCOPED; //LL_INFOS() << "Marking self " << mLocalID << " as dead." << LL_ENDL; // Root object of this hierarchy unlinks itself. @@ -1153,6 +1154,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys, const EObjectUpdateType update_type, LLDataPacker *dp) { + LL_PROFILE_ZONE_SCOPED; LL_DEBUGS_ONCE("SceneLoadTiming") << "Received viewer object data" << LL_ENDL; LL_DEBUGS("ObjectUpdate") << " mesgsys " << mesgsys << " dp " << dp << " id " << getID() << " update_type " << (S32) update_type << LL_ENDL; diff --git a/indra/newview/llviewerobjectlist.cpp b/indra/newview/llviewerobjectlist.cpp index e576784db8..ce4f9b7e64 100644 --- a/indra/newview/llviewerobjectlist.cpp +++ b/indra/newview/llviewerobjectlist.cpp @@ -1353,6 +1353,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp) BOOL LLViewerObjectList::killObject(LLViewerObject *objectp) { + LL_PROFILE_ZONE_SCOPED; // Don't ever kill gAgentAvatarp, just force it to the agent's region // unless region is NULL which is assumed to mean you are logging out. if ((objectp == gAgentAvatarp) && gAgent.getRegion()) @@ -1379,6 +1380,7 @@ BOOL LLViewerObjectList::killObject(LLViewerObject *objectp) void LLViewerObjectList::killObjects(LLViewerRegion *regionp) { + LL_PROFILE_ZONE_SCOPED; LLViewerObject *objectp; @@ -1438,6 +1440,8 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer) return; } + LL_PROFILE_ZONE_SCOPED; + S32 num_removed = 0; LLViewerObject *objectp; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index d60fae4bd6..6b92b16ef4 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -716,6 +716,7 @@ static LLTrace::BlockTimerStatHandle FTM_SAVE_REGION_CACHE("Save Region Cache"); LLViewerRegion::~LLViewerRegion() { + LL_PROFILE_ZONE_SCOPED; mDead = TRUE; mImpl->mActiveSet.clear(); mImpl->mVisibleEntries.clear(); @@ -1590,6 +1591,7 @@ void LLViewerRegion::lightIdleUpdate() void LLViewerRegion::idleUpdate(F32 max_update_time) { + LL_PROFILE_ZONE_SCOPED; LLTimer update_timer; F32 max_time; @@ -1693,6 +1695,10 @@ BOOL LLViewerRegion::isViewerCameraStatic() void LLViewerRegion::killInvisibleObjects(F32 max_time) { +#if 1 // TODO: kill this. This is ill-conceived, objects that aren't in the camera frustum should not be deleted from memory. + // because of this, every time you turn around the simulator sends a swarm of full object update messages from cache + // probe misses and objects have to be reloaded from scratch. From some reason, disabling this causes holes to + // appear in the scene when flying back and forth between regions if(!sVOCacheCullingEnabled) { return; @@ -1769,6 +1775,7 @@ void LLViewerRegion::killInvisibleObjects(F32 max_time) } return; +#endif } void LLViewerRegion::killObject(LLVOCacheEntry* entry, std::vector& delete_list) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 8160785d75..de1d3fc012 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -244,6 +244,7 @@ LLVOVolume::LLVOVolume(const LLUUID &id, const LLPCode pcode, LLViewerRegion *re LLVOVolume::~LLVOVolume() { + LL_PROFILE_ZONE_SCOPED; delete mTextureAnimp; mTextureAnimp = NULL; delete mVolumeImpl; @@ -267,6 +268,7 @@ void LLVOVolume::markDead() { if (!mDead) { + LL_PROFILE_ZONE_SCOPED; if (getVolume()) { LLSculptIDSize::instance().rem(getVolume()->getParams().getSculptID()); @@ -4676,7 +4678,12 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end_face = face+1; } pick_transparent |= isHiglightedOrBeacon(); - bool special_cursor = specialHoverCursor(); + + // we *probably* shouldn't care about special cursor at all, but we *definitely* + // don't care about special cursor for reflection probes -- makes alt-zoom + // go through reflection probes on vehicles + bool special_cursor = mReflectionProbe.isNull() && specialHoverCursor(); + for (S32 i = start_face; i < end_face; ++i) { if (!special_cursor && !pick_transparent && getTE(i) && getTE(i)->getColor().mV[3] == 0.f) diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp index 0e0dbdc071..709a457862 100644 --- a/indra/newview/llworld.cpp +++ b/indra/newview/llworld.cpp @@ -111,7 +111,7 @@ LLWorld::LLWorld() : gGL.getTexUnit(0)->bind(mDefaultWaterTexturep); mDefaultWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP); - LLViewerRegion::sVOCacheCullingEnabled = gSavedSettings.getBOOL("RequestFullRegionCache") && gSavedSettings.getBOOL("ObjectCacheEnabled"); + LLViewerRegion::sVOCacheCullingEnabled = gSavedSettings.getBOOL("RequestFullRegionCache") && gSavedSettings.getBOOL("ObjectCacheEnabled"); } @@ -681,6 +681,7 @@ static LLTrace::SampleStatHandle<> sNumActiveCachedObjects("numactivecachedobjec void LLWorld::updateRegions(F32 max_update_time) { + LL_PROFILE_ZONE_SCOPED; LLTimer update_timer; mNumOfActiveCachedObjects = 0; -- cgit v1.3 From b67172aa12be4a37c83042437844747ff0e02e34 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 21 Jul 2023 15:46:12 -0500 Subject: SL-20010 Make reflection probes ignore touch actions. --- indra/newview/llreflectionmap.cpp | 2 +- indra/newview/llspatialpartition.cpp | 15 +++++--- indra/newview/llspatialpartition.h | 2 ++ indra/newview/lltoolpie.cpp | 2 +- indra/newview/llviewerwindow.cpp | 68 +++++++++++++++++++----------------- indra/newview/llviewerwindow.h | 5 ++- indra/newview/pipeline.cpp | 11 +++--- indra/newview/pipeline.h | 1 + 8 files changed, 61 insertions(+), 45 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index efaf068bd2..a039c8072a 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -117,7 +117,7 @@ void LLReflectionMap::autoAdjustOrigin() { int face = -1; LLVector4a intersection; - LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], false, false, true, &face, &intersection); + LLDrawable* drawable = mGroup->lineSegmentIntersect(bounds[0], corners[i], false, false, true, true, &face, &intersection); if (drawable != nullptr) { hit = true; diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index f52f1a925d..32c891dbb6 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -3507,8 +3507,9 @@ public: BOOL mPickTransparent; BOOL mPickRigged; BOOL mPickUnselectable; + BOOL mPickReflectionProbe; - LLOctreeIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, + LLOctreeIntersect(const LLVector4a& start, const LLVector4a& end, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, BOOL pick_reflection_probe, S32* face_hit, LLVector4a* intersection, LLVector2* tex_coord, LLVector4a* normal, LLVector4a* tangent) : mStart(start), mEnd(end), @@ -3520,7 +3521,8 @@ public: mHit(NULL), mPickTransparent(pick_transparent), mPickRigged(pick_rigged), - mPickUnselectable(pick_unselectable) + mPickUnselectable(pick_unselectable), + mPickReflectionProbe(pick_reflection_probe) { } @@ -3596,7 +3598,8 @@ public: { LLViewerObject* vobj = drawable->getVObj(); - if (vobj) + if (vobj && + (!vobj->isReflectionProbe() || mPickReflectionProbe)) { LLVector4a intersection; bool skip_check = false; @@ -3642,6 +3645,7 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, co BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, + BOOL pick_reflection_probe, S32* face_hit, // return the face hit LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -3650,7 +3654,7 @@ LLDrawable* LLSpatialPartition::lineSegmentIntersect(const LLVector4a& start, co ) { - LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, tex_coord, normal, tangent); + LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, pick_unselectable, pick_reflection_probe, face_hit, intersection, tex_coord, normal, tangent); LLDrawable* drawable = intersect.check(mOctree); return drawable; @@ -3660,6 +3664,7 @@ LLDrawable* LLSpatialGroup::lineSegmentIntersect(const LLVector4a& start, const BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, + BOOL pick_reflection_probe, S32* face_hit, // return the face hit LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -3668,7 +3673,7 @@ LLDrawable* LLSpatialGroup::lineSegmentIntersect(const LLVector4a& start, const ) { - LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, tex_coord, normal, tangent); + LLOctreeIntersect intersect(start, end, pick_transparent, pick_rigged, pick_unselectable, pick_reflection_probe, face_hit, intersection, tex_coord, normal, tangent); LLDrawable* drawable = intersect.check(getOctreeNode()); return drawable; diff --git a/indra/newview/llspatialpartition.h b/indra/newview/llspatialpartition.h index 88584f535a..fe23670bea 100644 --- a/indra/newview/llspatialpartition.h +++ b/indra/newview/llspatialpartition.h @@ -315,6 +315,7 @@ public: BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, + BOOL pick_reflection_probe, S32* face_hit, // return the face hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point @@ -389,6 +390,7 @@ public: BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, + BOOL pick_reflection_probe, S32* face_hit, // return the face hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 2c5b8ffae4..84cc3f03c2 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -114,7 +114,7 @@ BOOL LLToolPie::handleMouseDown(S32 x, S32 y, MASK mask) mMouseDownY = y; LLTimer pick_timer; BOOL pick_rigged = false; //gSavedSettings.getBOOL("AnimatedObjectsAllowLeftClick"); - LLPickInfo transparent_pick = gViewerWindow->pickImmediate(x, y, TRUE /*includes transparent*/, pick_rigged); + LLPickInfo transparent_pick = gViewerWindow->pickImmediate(x, y, TRUE /*includes transparent*/, pick_rigged, FALSE, TRUE, FALSE); LLPickInfo visible_pick = gViewerWindow->pickImmediate(x, y, FALSE, pick_rigged); LLViewerObject *transp_object = transparent_pick.getObject(); LLViewerObject *visible_object = visible_pick.getObject(); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index c6ed6ffb7d..71fe893091 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -3344,7 +3344,7 @@ void LLViewerWindow::updateUI() if (gPipeline.hasRenderDebugMask(LLPipeline::RENDER_DEBUG_RAYCAST)) { gDebugRaycastFaceHit = -1; - gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, + gDebugRaycastObject = cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, FALSE, &gDebugRaycastFaceHit, &gDebugRaycastIntersection, &gDebugRaycastTexCoord, @@ -4229,7 +4229,7 @@ void LLViewerWindow::pickAsync( S32 x, pick_transparent = TRUE; } - LLPickInfo pick_info(LLCoordGL(x, y_from_bot), mask, pick_transparent, pick_rigged, FALSE, TRUE, pick_unselectable, callback); + LLPickInfo pick_info(LLCoordGL(x, y_from_bot), mask, pick_transparent, pick_rigged, FALSE, TRUE, pick_unselectable, TRUE, callback); schedulePick(pick_info); } @@ -4285,7 +4285,7 @@ void LLViewerWindow::returnEmptyPicks() } // Performs the GL object/land pick. -LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_particle, BOOL pick_unselectable) +LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transparent, BOOL pick_rigged, BOOL pick_particle, BOOL pick_unselectable, BOOL pick_reflection_probe) { BOOL in_build_mode = LLFloaterReg::instanceVisible("build"); if ((in_build_mode && gSavedSettings.getBOOL("SelectInvisibleObjects")) || LLDrawPoolAlpha::sShowDebugAlpha) @@ -4297,7 +4297,7 @@ LLPickInfo LLViewerWindow::pickImmediate(S32 x, S32 y_from_bot, BOOL pick_transp // shortcut queueing in mPicks and just update mLastPick in place MASK key_mask = gKeyboard->currentMask(TRUE); - mLastPick = LLPickInfo(LLCoordGL(x, y_from_bot), key_mask, pick_transparent, pick_rigged, pick_particle, TRUE, FALSE, NULL); + mLastPick = LLPickInfo(LLCoordGL(x, y_from_bot), key_mask, pick_transparent, pick_rigged, pick_particle, pick_reflection_probe, TRUE, FALSE, NULL); mLastPick.fetchResults(); return mLastPick; @@ -4335,6 +4335,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de BOOL pick_transparent, BOOL pick_rigged, BOOL pick_unselectable, + BOOL pick_reflection_probe, S32* face_hit, LLVector4a *intersection, LLVector2 *uv, @@ -4413,7 +4414,8 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de } else // is a world object { - if (this_object->lineSegmentIntersect(mw_start, mw_end, this_face, pick_transparent, pick_rigged, pick_unselectable, + if ((pick_reflection_probe || !this_object->isReflectionProbe()) + && this_object->lineSegmentIntersect(mw_start, mw_end, this_face, pick_transparent, pick_rigged, pick_unselectable, face_hit, intersection, uv, normal, tangent)) { found = this_object; @@ -4427,7 +4429,7 @@ LLViewerObject* LLViewerWindow::cursorIntersect(S32 mouse_x, S32 mouse_y, F32 de if (!found) // if not found in HUD, look in world: { - found = gPipeline.lineSegmentIntersectInWorld(mw_start, mw_end, pick_transparent, pick_rigged, pick_unselectable, + found = gPipeline.lineSegmentIntersectInWorld(mw_start, mw_end, pick_transparent, pick_rigged, pick_unselectable, pick_reflection_probe, face_hit, intersection, uv, normal, tangent); if (found && !pick_transparent) { @@ -6085,30 +6087,32 @@ LLPickInfo::LLPickInfo() { } -LLPickInfo::LLPickInfo(const LLCoordGL& mouse_pos, - MASK keyboard_mask, - BOOL pick_transparent, - BOOL pick_rigged, - BOOL pick_particle, - BOOL pick_uv_coords, - BOOL pick_unselectable, - void (*pick_callback)(const LLPickInfo& pick_info)) - : mMousePt(mouse_pos), - mKeyMask(keyboard_mask), - mPickCallback(pick_callback), - mPickType(PICK_INVALID), - mWantSurfaceInfo(pick_uv_coords), - mObjectFace(-1), - mUVCoords(-1.f, -1.f), - mSTCoords(-1.f, -1.f), - mXYCoords(-1, -1), - mNormal(), - mTangent(), - mBinormal(), - mHUDIcon(NULL), - mPickTransparent(pick_transparent), - mPickRigged(pick_rigged), - mPickParticle(pick_particle), +LLPickInfo::LLPickInfo(const LLCoordGL& mouse_pos, + MASK keyboard_mask, + BOOL pick_transparent, + BOOL pick_rigged, + BOOL pick_particle, + BOOL pick_reflection_probe, + BOOL pick_uv_coords, + BOOL pick_unselectable, + void (*pick_callback)(const LLPickInfo& pick_info)) + : mMousePt(mouse_pos), + mKeyMask(keyboard_mask), + mPickCallback(pick_callback), + mPickType(PICK_INVALID), + mWantSurfaceInfo(pick_uv_coords), + mObjectFace(-1), + mUVCoords(-1.f, -1.f), + mSTCoords(-1.f, -1.f), + mXYCoords(-1, -1), + mNormal(), + mTangent(), + mBinormal(), + mHUDIcon(NULL), + mPickTransparent(pick_transparent), + mPickRigged(pick_rigged), + mPickParticle(pick_particle), + mPickReflectionProbe(pick_reflection_probe), mPickUnselectable(pick_unselectable) { } @@ -6139,7 +6143,7 @@ void LLPickInfo::fetchResults() } LLViewerObject* hit_object = gViewerWindow->cursorIntersect(mMousePt.mX, mMousePt.mY, 512.f, - NULL, -1, mPickTransparent, mPickRigged, mPickUnselectable, &face_hit, + NULL, -1, mPickTransparent, mPickRigged, mPickUnselectable, mPickReflectionProbe, &face_hit, &intersection, &uv, &normal, &tangent, &start, &end); mPickPt = mMousePt; @@ -6284,7 +6288,7 @@ void LLPickInfo::getSurfaceInfo() if (objectp) { if (gViewerWindow->cursorIntersect(ll_round((F32)mMousePt.mX), ll_round((F32)mMousePt.mY), 1024.f, - objectp, -1, mPickTransparent, mPickRigged, mPickUnselectable, + objectp, -1, mPickTransparent, mPickRigged, mPickUnselectable, mPickReflectionProbe, &mObjectFace, &intersection, &mSTCoords, diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index bbce9a25f6..943cdf2fc4 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -94,6 +94,7 @@ public: BOOL pick_transparent, BOOL pick_rigged, BOOL pick_particle, + BOOL pick_reflection_probe, BOOL pick_surface_info, BOOL pick_unselectable, void (*pick_callback)(const LLPickInfo& pick_info)); @@ -130,6 +131,7 @@ public: BOOL mPickRigged; BOOL mPickParticle; BOOL mPickUnselectable; + BOOL mPickReflectionProbe = FALSE; void getSurfaceInfo(); private: @@ -407,7 +409,7 @@ public: BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, BOOL pick_unselectable = FALSE); - LLPickInfo pickImmediate(S32 x, S32 y, BOOL pick_transparent, BOOL pick_rigged = FALSE, BOOL pick_particle = FALSE, BOOL pick_unselectable = TRUE); + LLPickInfo pickImmediate(S32 x, S32 y, BOOL pick_transparent, BOOL pick_rigged = FALSE, BOOL pick_particle = FALSE, BOOL pick_unselectable = TRUE, BOOL pick_reflection_probe = TRUE); LLHUDIcon* cursorIntersectIcon(S32 mouse_x, S32 mouse_y, F32 depth, LLVector4a* intersection); @@ -417,6 +419,7 @@ public: BOOL pick_transparent = FALSE, BOOL pick_rigged = FALSE, BOOL pick_unselectable = TRUE, + BOOL pick_reflection_probe = TRUE, S32* face_hit = NULL, LLVector4a *intersection = NULL, LLVector2 *uv = NULL, diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 1402591015..1b4c8f65a6 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6223,7 +6223,7 @@ LLVOPartGroup* LLPipeline::lineSegmentIntersectParticle(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_PARTICLE); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, TRUE, FALSE, TRUE, face_hit, &position, NULL, NULL, NULL); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, TRUE, FALSE, TRUE, FALSE, face_hit, &position, NULL, NULL, NULL); if (hit) { drawable = hit; @@ -6252,6 +6252,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, bool pick_transparent, bool pick_rigged, bool pick_unselectable, + bool pick_reflection_probe, S32* face_hit, LLVector4a* intersection, // return the intersection point LLVector2* tex_coord, // return the texture coordinates of the intersection point @@ -6285,7 +6286,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(j); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, &position, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, pick_reflection_probe, face_hit, &position, tex_coord, normal, tangent); if (hit) { drawable = hit; @@ -6342,7 +6343,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInWorld(const LLVector4a& start, LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_AVATAR); if (part && hasRenderType(part->mDrawableType)) { - LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, face_hit, &position, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, local_end, pick_transparent, pick_rigged, pick_unselectable, pick_reflection_probe, face_hit, &position, tex_coord, normal, tangent); if (hit) { LLVector4a delta; @@ -6430,7 +6431,7 @@ LLViewerObject* LLPipeline::lineSegmentIntersectInHUD(const LLVector4a& start, c LLSpatialPartition* part = region->getSpatialPartition(LLViewerRegion::PARTITION_HUD); if (part) { - LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, FALSE, TRUE, face_hit, intersection, tex_coord, normal, tangent); + LLDrawable* hit = part->lineSegmentIntersect(start, end, pick_transparent, FALSE, TRUE, FALSE, face_hit, intersection, tex_coord, normal, tangent); if (hit) { drawable = hit; @@ -7165,7 +7166,7 @@ void LLPipeline::renderDoF(LLRenderTarget* src, LLRenderTarget* dst) LLVector4a result; result.clear(); - gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, NULL, &result); + gViewerWindow->cursorIntersect(-1, -1, 512.f, NULL, -1, FALSE, FALSE, TRUE, TRUE, NULL, &result); focus_point.set(result.getF32ptr()); } diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 427240aad7..fe92c69cbb 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -205,6 +205,7 @@ public: bool pick_transparent, bool pick_rigged, bool pick_unselectable, + bool pick_reflection_probe, S32* face_hit, // return the face hit LLVector4a* intersection = NULL, // return the intersection point LLVector2* tex_coord = NULL, // return the texture coordinates of the intersection point -- cgit v1.3 From 2ce27627a18787113c1b9a1fd99b5a516d693a8c Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 30 Aug 2023 11:20:11 -0500 Subject: SL-19842 Followup -- fix sunlight going black and make automatic object probes more wishy-washy (removes dark splotches where probes get stuck in walls) --- indra/newview/llreflectionmap.cpp | 9 +++++++++ indra/newview/pipeline.cpp | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index a039c8072a..2a2f4dbd5a 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -157,6 +157,7 @@ void LLReflectionMap::autoAdjustOrigin() } mRadius = llmax(sqrtf(r2.getF32()), 8.f); + } } else if (mViewerObject) @@ -204,6 +205,14 @@ F32 LLReflectionMap::getNearClip() { ret = ((LLVOVolume*)mViewerObject)->getReflectionProbeNearClip(); } + else if (mGroup) + { + ret = mRadius * 0.5f; // default to half radius for automatic object probes + } + else + { + ret = 1.f; // default to 1m for automatic terrain probes + } return llmax(ret, MINIMUM_NEAR_CLIP); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 0b5908a440..78d4e65d42 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7730,8 +7730,18 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); } - //shader.uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, mSunDiffuse.mV); - //shader.uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); + // auto adjust legacy sun color if needed + static LLCachedControl should_auto_adjust(gSavedSettings, "RenderSkyAutoAdjustLegacy", true); + static LLCachedControl auto_adjust_sun_color_scale(gSavedSettings, "RenderSkyAutoAdjustSunColorScale", 1.f); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + LLColor3 sun_diffuse(mSunDiffuse.mV); + if (should_auto_adjust && psky->canAutoAdjust()) + { + sun_diffuse *= auto_adjust_sun_color_scale; + } + + shader.uniform3fv(LLShaderMgr::SUNLIGHT_COLOR, 1, sun_diffuse.mV); + shader.uniform3fv(LLShaderMgr::MOONLIGHT_COLOR, 1, mMoonDiffuse.mV); shader.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mReflectionMapManager.mMaxProbeLOD); } -- cgit v1.3 From 75a0719ff59118c0a5c6713e952cab4d0640a7d5 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Wed, 30 Aug 2023 12:57:48 -0500 Subject: SL-19842 Followup -- less aggressive ambient kill. --- indra/newview/app_settings/settings.xml | 2 +- indra/newview/llreflectionmap.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/newview/llreflectionmap.cpp') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index ee4c76943e..b4e149f0e0 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10654,7 +10654,7 @@ Type F32 Value - 0.5 + 0.7 RenderSkyAutoAdjustHDRScale diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp index 2a2f4dbd5a..ec54fa1165 100644 --- a/indra/newview/llreflectionmap.cpp +++ b/indra/newview/llreflectionmap.cpp @@ -157,6 +157,9 @@ void LLReflectionMap::autoAdjustOrigin() } mRadius = llmax(sqrtf(r2.getF32()), 8.f); + + // make sure near clip doesn't poke through ground + fp[2] = llmax(fp[2], height+mRadius*0.5f); } } -- cgit v1.3