From 4319ba5edcfeb066d712cdb5a851f155a87ed71b Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Mon, 13 Mar 2023 16:46:39 -0700 Subject: [PATCH 01/38] SL-19331: Improve performance of setSubImage (ex: media updates) --- indra/llrender/llimagegl.cpp | 59 ++++++++++++++++++++++++------------ indra/llrender/llimagegl.h | 1 + 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index 7c1cf2ba33..c42688e95b 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -732,21 +732,8 @@ void LLImageGL::setImage(const LLImageRaw* imageraw) BOOL LLImageGL::setImage(const U8* data_in, BOOL data_hasmips /* = FALSE */, S32 usename /* = 0 */) { LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - bool is_compressed = false; - switch (mFormatPrimary) - { - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: - case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: - is_compressed = true; - break; - default: - break; - } + const bool is_compressed = isCompressed(); if (mUseMipMaps) { @@ -1232,11 +1219,23 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 if (!res) LL_ERRS() << "LLImageGL::setSubImage(): bindTexture failed" << LL_ENDL; stop_glerror(); - // *TODO: glTexSubImage2D may not work on a subset of the texture if - // the texture is compressed. Make sure the image isn't compressed - // when using this function, then it's safe to replace this call with - // subImageLines, when it is performant to do so (see setManualImage) - glTexSubImage2D(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, datap); +#if LL_DARWIN + const bool use_sub_image = false; +#else + const bool use_sub_image = !isCompressed(); +#endif + if (!use_sub_image) + { + // *TODO: Why does this work here, in setSubImage, but not in + // setManualImage? Maybe because it only gets called with the + // dimensions of the full image? Or because the image is never + // compressed? + glTexSubImage2D(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, datap); + } + else + { + subImageLines(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, datap); + } gGL.getTexUnit(0)->disable(); stop_glerror(); @@ -1456,6 +1455,7 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt const bool use_sub_image = false; #else // glTexSubImage2D doesn't work with compressed textures on select tested Nvidia GPUs on Windows 10 -Cosmic,2023-03-08 + // *TODO: Small chance that glCompressedTexImage2D/glCompressedTexSubImage2D may work better here const bool use_sub_image = !compress; #endif if (!use_sub_image) @@ -2296,6 +2296,27 @@ void LLImageGL::freePickMask() mPickMaskWidth = mPickMaskHeight = 0; } +bool LLImageGL::isCompressed() +{ + llassert(mFormatPrimary != 0); + // *NOTE: Not all compressed formats are included here. + bool is_compressed = false; + switch (mFormatPrimary) + { + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + is_compressed = true; + break; + default: + break; + } + return is_compressed; +} + //---------------------------------------------------------------------------- void LLImageGL::updatePickMask(S32 width, S32 height, const U8* data_in) { diff --git a/indra/llrender/llimagegl.h b/indra/llrender/llimagegl.h index 08d8f60979..42f6efef77 100644 --- a/indra/llrender/llimagegl.h +++ b/indra/llrender/llimagegl.h @@ -214,6 +214,7 @@ public: private: U32 createPickMask(S32 pWidth, S32 pHeight); void freePickMask(); + bool isCompressed(); LLPointer mSaveData; // used for destroyGL/restoreGL LL::WorkQueue::weak_t mMainQueue; From 698fbfe1cf482ee01127950a445f41fad3d3fcef Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 21 Mar 2023 08:58:57 -0500 Subject: [PATCH 02/38] SL-19322 Disable automatic alpha masking because it is bugged. --- indra/newview/app_settings/settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index a369b22ef1..8996b1dd4f 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9887,7 +9887,7 @@ Type Boolean Value - 1 + 0 RenderFlexTimeFactor From 084ef5173fb79644ce2fd3e640c241a05529db70 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 21 Mar 2023 09:29:44 -0500 Subject: [PATCH 03/38] SL-19434 Temporary fix for minimap breakage. --- indra/llrender/llimagegl.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index c42688e95b..f4b580c490 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1219,12 +1219,12 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 if (!res) LL_ERRS() << "LLImageGL::setSubImage(): bindTexture failed" << LL_ENDL; stop_glerror(); -#if LL_DARWIN - const bool use_sub_image = false; -#else - const bool use_sub_image = !isCompressed(); -#endif - if (!use_sub_image) +//#if LL_DARWIN +// const bool use_sub_image = false; +//#else +// const bool use_sub_image = !isCompressed(); +//#endif + //if (!use_sub_image) { // *TODO: Why does this work here, in setSubImage, but not in // setManualImage? Maybe because it only gets called with the @@ -1232,10 +1232,10 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 // compressed? glTexSubImage2D(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, datap); } - else - { - subImageLines(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, datap); - } + //else + //{ + // subImageLines(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, datap); + //} gGL.getTexUnit(0)->disable(); stop_glerror(); From b30cde2a05c5217018d8be7608f14bda8b66127a Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 21 Mar 2023 21:31:18 +0200 Subject: [PATCH 04/38] SL-19392 Disable "Double Sided" by default when importing double sided materials --- indra/newview/llmaterialeditor.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 4cdc503af8..609d8ea5d7 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -2045,6 +2045,15 @@ void LLMaterialEditor::loadMaterial(const tinygltf::Model &model_in, const std:: setFromGltfMetaData(filename, model_in, index); + if (getDoubleSided()) + { + // SL-19392 Double sided materials double the number of pixels that must be rasterized, + // and a great many tools that export GLTF simply leave double sided enabled whether + // or not it is necessary. + LL_DEBUGS("MaterialEditor") << "Defaulting Double Sided to disabled on import" << LL_ENDL; + setDoubleSided(false); + } + markChangesUnsaved(U32_MAX); if (open_floater) From 6e6bac6b4025e01ee636b8490edbe09db2497722 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Tue, 21 Mar 2023 13:40:00 -0700 Subject: [PATCH 05/38] Phase 2 of fix for SL-18458 material overrides not being cached properly --- indra/newview/llfetchedgltfmaterial.h | 2 ++ indra/newview/llgltfmateriallist.cpp | 17 ++++++++++++++--- indra/newview/llviewerobject.cpp | 6 ++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/indra/newview/llfetchedgltfmaterial.h b/indra/newview/llfetchedgltfmaterial.h index 96f7fbea8e..0b51770493 100644 --- a/indra/newview/llfetchedgltfmaterial.h +++ b/indra/newview/llfetchedgltfmaterial.h @@ -46,6 +46,8 @@ public: // media_tex - optional media texture that may override the base color texture void bind(LLViewerTexture* media_tex = nullptr); + bool isFetching() const { return mFetching; } + // Textures used for fetching/rendering LLPointer mBaseColorTexture; LLPointer mNormalTexture; diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index 4051521ad4..d0c1c73f0e 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -157,8 +157,8 @@ public: // receive override data from simulator via LargeGenericMessage // message should have: // object_id - UUID of LLViewerObject - // side - S32 index of texture entry - // gltf_json - String of GLTF json for override data + // sides - array of S32 indices of texture entries + // gltf_json - array of corresponding Strings of GLTF json for override data LLSD message; @@ -380,11 +380,22 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj) { // object doesn't have its base GLTF material yet, don't apply override (yet) return; } - obj->setTEGLTFMaterialOverride(i, overrides[i]); + + S32 status = obj->setTEGLTFMaterialOverride(i, overrides[i]); + if (status == TEM_CHANGE_NONE) + { + // can't apply this yet, since failure to change the material override + // probably means the base material is still being fetched. leave in + // the queue for later + return; + } + if (obj->getTE(i)->isSelected()) { handle_gltf_override_message.doSelectionCallbacks(id, i); } + // success! + overrides[i] = nullptr; } } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index fd3c8de3e9..cb1694821d 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -5375,6 +5375,12 @@ S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_ma return retval; } + if(src_mat->isFetching()) + { + // if still fetching, we need to wait until it is done and try again + return retval; + } + tep->setGLTFMaterialOverride(override_mat); // if override mat exists, we must also have a source mat From 7d97008ebaa08212fd4e3dcb9a01861b4adff728 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Tue, 21 Mar 2023 14:27:37 -0700 Subject: [PATCH 06/38] Revert "SL-19434 Temporary fix for minimap breakage." This reverts commit 084ef5173fb79644ce2fd3e640c241a05529db70. --- indra/llrender/llimagegl.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index f4b580c490..c42688e95b 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1219,12 +1219,12 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 if (!res) LL_ERRS() << "LLImageGL::setSubImage(): bindTexture failed" << LL_ENDL; stop_glerror(); -//#if LL_DARWIN -// const bool use_sub_image = false; -//#else -// const bool use_sub_image = !isCompressed(); -//#endif - //if (!use_sub_image) +#if LL_DARWIN + const bool use_sub_image = false; +#else + const bool use_sub_image = !isCompressed(); +#endif + if (!use_sub_image) { // *TODO: Why does this work here, in setSubImage, but not in // setManualImage? Maybe because it only gets called with the @@ -1232,10 +1232,10 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 // compressed? glTexSubImage2D(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, datap); } - //else - //{ - // subImageLines(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, datap); - //} + else + { + subImageLines(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, datap); + } gGL.getTexUnit(0)->disable(); stop_glerror(); From a218eed9a6bffd61e7fea38d145a6751faf780aa Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Mon, 20 Mar 2023 17:00:30 -0700 Subject: [PATCH 07/38] SL-19434: Fix texture issues with minimap, but keep performance from SL-19331 --- indra/llrender/llimagegl.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/indra/llrender/llimagegl.cpp b/indra/llrender/llimagegl.cpp index c42688e95b..5b0690bc79 100644 --- a/indra/llrender/llimagegl.cpp +++ b/indra/llrender/llimagegl.cpp @@ -1100,15 +1100,9 @@ void LLImageGL::postAddToAtlas() stop_glerror(); } -// Equivalent to calling glSetSubImage2D(target, miplevel, x_offset, y_offset, width, height, pixformat, pixtype, src) -// However, instead there are multiple calls to glSetSubImage2D on smaller slices of the image -void subImageLines(U32 target, S32 miplevel, S32 x_offset, S32 y_offset, S32 width, S32 height, U32 pixformat, U32 pixtype, const U8* src) +U32 type_width_from_pixtype(U32 pixtype) { - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - - U32 components = LLImageGL::dataFormatComponents(pixformat); U32 type_width = 0; - switch (pixtype) { case GL_UNSIGNED_BYTE: @@ -1128,12 +1122,22 @@ void subImageLines(U32 target, S32 miplevel, S32 x_offset, S32 y_offset, S32 wid default: LL_ERRS() << "Unknown type: " << pixtype << LL_ENDL; } + return type_width; +} - const U32 line_width = width * components * type_width; +// Equivalent to calling glSetSubImage2D(target, miplevel, x_offset, y_offset, width, height, pixformat, pixtype, src), assuming the total width of the image is data_width +// However, instead there are multiple calls to glSetSubImage2D on smaller slices of the image +void subImageLines(U32 target, S32 miplevel, S32 x_offset, S32 y_offset, S32 width, S32 height, U32 pixformat, U32 pixtype, const U8* src, S32 data_width) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + + U32 components = LLImageGL::dataFormatComponents(pixformat); + U32 type_width = type_width_from_pixtype(pixtype); + + const U32 line_width = data_width * components * type_width; const U32 y_offset_end = y_offset + height; - for (U32 y = y_offset; y < y_offset_end; ++y) + for (U32 y_pos = y_offset; y_pos < y_offset_end; ++y_pos) { - const S32 y_pos = y + y_offset; glTexSubImage2D(target, miplevel, x_offset, y_pos, width, 1, pixformat, pixtype, src); src += line_width; } @@ -1213,7 +1217,7 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 stop_glerror(); } - datap += (y_pos * data_width + x_pos) * getComponents(); + const U8* sub_datap = datap + (y_pos * data_width + x_pos) * getComponents(); // Update the GL texture BOOL res = gGL.getTexUnit(0)->bindManual(mBindTarget, tex_name); if (!res) LL_ERRS() << "LLImageGL::setSubImage(): bindTexture failed" << LL_ENDL; @@ -1230,11 +1234,11 @@ BOOL LLImageGL::setSubImage(const U8* datap, S32 data_width, S32 data_height, S3 // setManualImage? Maybe because it only gets called with the // dimensions of the full image? Or because the image is never // compressed? - glTexSubImage2D(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, datap); + glTexSubImage2D(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, sub_datap); } else { - subImageLines(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, datap); + subImageLines(mTarget, 0, x_pos, y_pos, width, height, mFormatPrimary, mFormatType, sub_datap, data_width); } gGL.getTexUnit(0)->disable(); stop_glerror(); @@ -1475,7 +1479,7 @@ void LLImageGL::setManualImage(U32 target, S32 miplevel, S32 intformat, S32 widt if (src) { LL_PROFILE_ZONE_NAMED("glTexImage2D copy"); - subImageLines(target, miplevel, 0, 0, width, height, pixformat, pixtype, src); + subImageLines(target, miplevel, 0, 0, width, height, pixformat, pixtype, src, width); } } alloc_tex_image(width, height, pixformat); From 8c7c4c424d07e39191e827f441af406724829b50 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Mar 2023 10:38:24 -0500 Subject: [PATCH 08/38] DRTVWR-559 Quality pass -- Fix sky banding, fix off-by-one-mip in reflection probes (thanks Rye), remove noiseMap from light shaders (removes speckles), make irradiance maps RGB16F instead of RGBA16. Use actual luminance for sky instead of max color component during irradiance map pass. --- indra/newview/app_settings/settings.xml | 2 +- .../shaders/class1/deferred/cloudsF.glsl | 29 ++++++++---------- .../shaders/class1/deferred/moonF.glsl | 30 +++++++------------ .../shaders/class1/deferred/skyF.glsl | 28 +++++++---------- .../shaders/class1/deferred/starsF.glsl | 15 ++++------ .../shaders/class1/deferred/sunDiscF.glsl | 21 +++++-------- .../class1/interface/radianceGenF.glsl | 2 +- .../class3/deferred/multiPointLightF.glsl | 5 ---- .../class3/deferred/multiSpotLightF.glsl | 6 ++-- .../class3/deferred/reflectionProbeF.glsl | 2 +- .../shaders/class3/deferred/softenLightF.glsl | 2 +- .../shaders/class3/deferred/spotLightF.glsl | 6 ++-- indra/newview/llenvironment.cpp | 6 +++- indra/newview/llreflectionmapmanager.cpp | 2 +- 14 files changed, 61 insertions(+), 95 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 8996b1dd4f..6d7e93b364 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10402,7 +10402,7 @@ Type F32 Value - 32 + 16 RenderTonemapper diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index fe796a054d..e0e97bb938 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -24,19 +24,15 @@ */ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; ///////////////////////////////////////////////////////////////////////// // The fragment shader for the sky ///////////////////////////////////////////////////////////////////////// -VARYING vec3 vary_CloudColorSun; -VARYING vec3 vary_CloudColorAmbient; -VARYING float vary_CloudDensity; +in vec3 vary_CloudColorSun; +in vec3 vary_CloudColorAmbient; +in float vary_CloudDensity; uniform sampler2D cloud_noise_texture; uniform sampler2D cloud_noise_texture_next; @@ -46,16 +42,16 @@ uniform vec3 cloud_pos_density2; uniform float cloud_scale; uniform float cloud_variance; -VARYING vec2 vary_texcoord0; -VARYING vec2 vary_texcoord1; -VARYING vec2 vary_texcoord2; -VARYING vec2 vary_texcoord3; -VARYING float altitude_blend_factor; +in vec2 vary_texcoord0; +in vec2 vary_texcoord1; +in vec2 vary_texcoord2; +in vec2 vary_texcoord3; +in float altitude_blend_factor; vec4 cloudNoise(vec2 uv) { - vec4 a = texture2D(cloud_noise_texture, uv); - vec4 b = texture2D(cloud_noise_texture_next, uv); + vec4 a = texture(cloud_noise_texture, uv); + vec4 b = texture(cloud_noise_texture_next, uv); vec4 cloud_noise_sample = mix(a, b, blend_factor); return cloud_noise_sample; } @@ -118,8 +114,9 @@ void main() color.rgb *= 2.0; /// Gamma correct for WL (soft clip effect). - frag_data[0] = vec4(color.rgb, alpha1); + frag_data[0] = vec4(0); frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0,0,0,GBUFFER_FLAG_SKIP_ATMOS); + frag_data[3] = vec4(color.rgb, alpha1); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index 41dd485fae..fabc61eb5e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -27,11 +27,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 vec4 color; uniform vec3 moonlight_color; @@ -39,12 +35,7 @@ uniform vec3 moon_dir; uniform float moon_brightness; uniform sampler2D diffuseMap; -VARYING vec2 vary_texcoord0; - -vec3 srgb_to_linear(vec3 c); - -/// Soft clips the light with a gamma correction -vec3 scaleSoftClip(vec3 light); +in vec2 vary_texcoord0; void main() { @@ -53,24 +44,25 @@ void main() if( moon_dir.z > 0 ) fade = clamp( moon_dir.z*moon_dir.z*4.0, 0.0, 1.0 ); - vec4 c = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 c = texture(diffuseMap, vary_texcoord0.xy); // SL-14113 Don't write to depth; prevent moon's quad from hiding stars which should be visible // Moon texture has transparent pixels <0x55,0x55,0x55,0x00> if (c.a <= 2./255.) // 0.00784 + { discard; + } -// c.rgb = srgb_to_linear(c.rgb); - c.rgb *= moonlight_color.rgb; - c.rgb *= moon_brightness; - c.rgb *= fade; - c.a *= fade; + c.rgb *= moonlight_color.rgb; + c.rgb *= moon_brightness; - c.rgb = scaleSoftClip(c.rgb); + c.rgb *= fade; + c.a *= fade; - frag_data[0] = vec4(c.rgb, c.a); + frag_data[0] = vec4(0); frag_data[1] = vec4(0.0); frag_data[2] = vec4(0.0, 0.0, 0.0, GBUFFER_FLAG_HAS_ATMOS); + frag_data[3] = vec4(c.rgb, c.a); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl index 930338cefb..cc4c3b5dce 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl @@ -22,12 +22,10 @@ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ - -/*[EXTRA_CODE_HERE]*/ // Inputs -VARYING vec3 vary_HazeColor; -VARYING float vary_LightNormPosDot; +in vec3 vary_HazeColor; +in float vary_LightNormPosDot; uniform sampler2D rainbow_map; uniform sampler2D halo_map; @@ -36,11 +34,9 @@ uniform float moisture_level; uniform float droplet_radius; uniform float ice_level; -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; + +vec3 srgb_to_linear(vec3 c); ///////////////////////////////////////////////////////////////////////// // The fragment shader for the sky @@ -63,19 +59,16 @@ vec3 rainbow(float d) d = clamp(d, 0.0, 0.25) + interior_coord; float rad = (droplet_radius - 5.0f) / 1024.0f; - return pow(texture2D(rainbow_map, vec2(rad+0.5, d)).rgb, vec3(1.8)) * moisture_level; + return pow(texture(rainbow_map, vec2(rad+0.5, d)).rgb, vec3(1.8)) * moisture_level; } vec3 halo22(float d) { d = clamp(d, 0.1, 1.0); float v = sqrt(clamp(1 - (d * d), 0, 1)); - return texture2D(halo_map, vec2(0, v)).rgb * ice_level; + return texture(halo_map, vec2(0, v)).rgb * ice_level; } -/// Soft clips the light with a gamma correction -vec3 scaleSoftClip(vec3 light); - void main() { // Potential Fill-rate optimization. Add cloud calculation @@ -91,11 +84,10 @@ void main() color.rgb += rainbow(optic_d); color.rgb += halo_22; color.rgb *= 2.; - color.rgb = scaleSoftClip(color.rgb); - // Gamma correct for WL (soft clip effect). - frag_data[0] = vec4(color.rgb, 1.0); - frag_data[1] = vec4(0.0,0.0,0.0,0.0); + frag_data[0] = vec4(0); + frag_data[1] = vec4(0); frag_data[2] = vec4(0.0,0.0,0.0,GBUFFER_FLAG_SKIP_ATMOS); //1.0 in norm.w masks off fog + frag_data[3] = vec4(color.rgb, 1.0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl index cdafdba15c..4f1756c367 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl @@ -25,15 +25,11 @@ /*[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 vec4 vertex_color; -VARYING vec2 vary_texcoord0; -VARYING vec2 screenpos; +in vec4 vertex_color; +in vec2 vary_texcoord0; +in vec2 screenpos; uniform sampler2D diffuseMap; uniform float blend_factor; @@ -62,8 +58,9 @@ void main() col.a = (col.a * factor) * 32.0f; col.a *= twinkle(); - frag_data[0] = col; + frag_data[0] = vec4(0); frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS); + frag_data[3] = col; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl index e35ea83f0a..a85e6ebc66 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl @@ -27,36 +27,29 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[3]; -#else -#define frag_data gl_FragData -#endif +out vec4 frag_data[4]; vec3 srgb_to_linear(vec3 c); -vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); uniform sampler2D diffuseMap; uniform sampler2D altDiffuseMap; uniform float blend_factor; // interp factor between sunDisc A/B -VARYING vec2 vary_texcoord0; -VARYING float sun_fade; +in vec2 vary_texcoord0; +in float sun_fade; void main() { - vec4 sunDiscA = texture2D(diffuseMap, vary_texcoord0.xy); - vec4 sunDiscB = texture2D(altDiffuseMap, vary_texcoord0.xy); + vec4 sunDiscA = texture(diffuseMap, vary_texcoord0.xy); + vec4 sunDiscB = texture(altDiffuseMap, vary_texcoord0.xy); vec4 c = mix(sunDiscA, sunDiscB, blend_factor); - //c.rgb = fullbrightAtmosTransport(c.rgb); - c.rgb = fullbrightScaleSoftClip(c.rgb); // SL-9806 stars poke through //c.a *= sun_fade; - frag_data[0] = c; + frag_data[0] = vec4(0); frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, GBUFFER_FLAG_SKIP_ATMOS); + frag_data[3] = c; } diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl index b6f080739e..a1839d4a67 100644 --- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl @@ -151,7 +151,7 @@ vec4 prefilterEnvMap(vec3 R) // Solid angle of 1 pixel across all cube faces float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim); // Biased (+1.0) mip level for better result - float mipLevel = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f); + float mipLevel = roughness == 0.0 ? 0.0 : clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, max_probe_lod); color += textureLod(reflectionProbes, vec4(L, sourceIdx), mipLevel) * dotNL; totalWeight += dotNL; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index 7d8f9c218d..0fb30559d4 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -37,7 +37,6 @@ uniform sampler2D depthMap; uniform sampler2D diffuseRect; uniform sampler2D specularRect; uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl -uniform sampler2D noiseMap; uniform sampler2D lightFunc; uniform vec3 env_mat[3]; @@ -132,9 +131,6 @@ void main() } else { - - float noise = texture2D(noiseMap, tc).b; - diffuse = srgb_to_linear(diffuse); spec.rgb = srgb_to_linear(spec.rgb); @@ -154,7 +150,6 @@ void main() float fa = light_col[i].a; float dist_atten = calcLegacyDistanceAttenuation(dist, fa); - dist_atten *= noise; float lit = nl * dist_atten; diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl index 5ed8a75e0e..30b7895157 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -41,7 +41,6 @@ uniform sampler2D normalMap; uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl uniform samplerCube environmentMap; uniform sampler2D lightMap; -uniform sampler2D noiseMap; uniform sampler2D projectionMap; // rgba uniform sampler2D lightFunc; @@ -187,7 +186,6 @@ void main() diffuse = srgb_to_linear(diffuse); spec.rgb = srgb_to_linear(spec.rgb); - float noise = texture2D(noiseMap, tc).b; if (proj_tc.z > 0.0 && proj_tc.x < 1.0 && proj_tc.y < 1.0 && @@ -199,7 +197,7 @@ void main() if (nl > 0.0) { - lit = nl * dist_atten * noise; + lit = nl * dist_atten; dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy ); @@ -209,7 +207,7 @@ void main() amb_da += (nl*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance; } - amb_rgb = getProjectedLightAmbiance( amb_da, dist_atten, lit, nl, noise, proj_tc.xy ); + amb_rgb = getProjectedLightAmbiance( amb_da, dist_atten, lit, nl, 1.0, proj_tc.xy ); final_color += diffuse.rgb * amb_rgb; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index a6a2543915..bd06a680f5 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -656,7 +656,7 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, vec2 tc, vec3 pos, vec3 norm, float glossiness) { // TODO - don't hard code lods - float reflection_lods = max_probe_lod-1; + float reflection_lods = max_probe_lod; preProbeSample(pos); vec3 refnormpersp = reflect(pos.xyz, norm.xyz); diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index dfd1d47b3e..0e3ebd1534 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -211,7 +211,7 @@ void main() else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS)) { //should only be true of WL sky, just port over base color value - color = srgb_to_linear(baseColor.rgb); + color = srgb_to_linear(texture2D(emissiveRect, tc).rgb); } else { diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index 3d8b95b882..33ea2129cf 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -51,7 +51,6 @@ uniform sampler2D normalMap; uniform sampler2D emissiveRect; // PBR linear packed Occlusion, Roughness, Metal. See: pbropaqueF.glsl uniform samplerCube environmentMap; uniform sampler2D lightMap; -uniform sampler2D noiseMap; uniform sampler2D projectionMap; // rgba uniform sampler2D lightFunc; @@ -193,7 +192,6 @@ void main() diffuse = srgb_to_linear(diffuse); spec.rgb = srgb_to_linear(spec.rgb); - float noise = texture2D(noiseMap, tc).b; if (proj_tc.z > 0.0 && proj_tc.x < 1.0 && proj_tc.y < 1.0 && @@ -205,7 +203,7 @@ void main() if (nl > 0.0) { - lit = nl * dist_atten * noise; + lit = nl * dist_atten; dlit = getProjectedLightDiffuseColor( l_dist, proj_tc.xy ); @@ -214,7 +212,7 @@ void main() amb_da += (nl*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance; } - vec3 amb_rgb = getProjectedLightAmbiance( amb_da, dist_atten, lit, nl, noise, proj_tc.xy ); + vec3 amb_rgb = getProjectedLightAmbiance( amb_da, dist_atten, lit, nl, 1.0, proj_tc.xy ); final_color += diffuse.rgb*amb_rgb; #if DEBUG_LEG_LIGHT_TYPE final_color = vec3(0,0.5,0); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index d88f0f9847..c59fad82a4 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1758,7 +1758,11 @@ void LLEnvironment::updateGLVariablesForSettings(LLShaderUniforms* uniforms, con { // maximize and remove tinting if this is an irradiance map render pass and the parameter feeds into the sky background color auto max_vec = [](LLVector4 col) { - col.mV[0] = col.mV[1] = col.mV[2] = llmax(llmax(col.mV[0], col.mV[1]), col.mV[2]); + LLColor3 color(col); + F32 h, s, l; + color.calcHSL(&h, &s, &l); + + col.mV[0] = col.mV[1] = col.mV[2] = l; return col; }; diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index c664dbbe9e..58ce571505 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -1018,7 +1018,7 @@ void LLReflectionMapManager::initReflectionMaps() mTexture->allocate(mProbeResolution, 3, mReflectionProbeCount + 2); mIrradianceMaps = new LLCubeMapArray(); - mIrradianceMaps->allocate(LL_IRRADIANCE_MAP_RESOLUTION, 4, mReflectionProbeCount, FALSE); + mIrradianceMaps->allocate(LL_IRRADIANCE_MAP_RESOLUTION, 3, mReflectionProbeCount, FALSE); } if (mVertexBuffer.isNull()) From c97b6034eec9ce27a9d8f22db9a77b60e7e28779 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Mar 2023 13:49:33 -0500 Subject: [PATCH 09/38] SL-19297 Hacky fix for MY EYES! --- indra/newview/llvovolume.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index d1f4fa1c7a..e1335acc17 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -6655,12 +6655,19 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace LLRenderPass::PASS_NORMSPEC_EMISSIVE, }; - U32 mask = mat->getShaderMask(); + U32 alpha_mode = mat->getDiffuseAlphaMode(); + if (!distance_sort && alpha_mode == LLMaterial::DIFFUSE_ALPHA_MODE_BLEND) + { // HACK - this should never happen, but sometimes we get a material that thinks it has alpha blending when it ought not + alpha_mode = LLMaterial::DIFFUSE_ALPHA_MODE_NONE; + } + U32 mask = mat->getShaderMask(alpha_mode); llassert(mask < sizeof(pass)/sizeof(U32)); mask = llmin(mask, (U32)(sizeof(pass)/sizeof(U32)-1)); + // if this is going into alpha pool, distance sort MUST be true + llassert(pass[mask] == LLRenderPass::PASS_ALPHA ? distance_sort : true); registerFace(group, facep, pass[mask]); } } From 8d4430ffecca35948ae4e84d79f80713101da11a Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 22 Mar 2023 12:57:38 -0700 Subject: [PATCH 10/38] SL-19394: Change default midday to an asset ID with probe ambiance --- indra/newview/llenvironment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index d88f0f9847..8e8d396c95 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -812,7 +812,7 @@ const F64Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F64Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("01e41537-ff51-2f1f-8ef7-17e4df760bfb"); -const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("6c83e853-e7f8-cad7-8ee6-5f31c453721c"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("81d4c85e-6868-dfd0-1a8a-e1838262be4b"); const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("084e26cd-a900-28e8-08d0-64a9de5c15e2"); const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("8a01b97a-cb20-c1ea-ac63-f7ea84ad0090"); From e23b3972a00370aff25d582ce33dc0db6d795213 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 22 Mar 2023 18:25:47 -0500 Subject: [PATCH 11/38] DRTVWR-559 Fix for bad hashing of materials breaking render batches and who knows what else. --- indra/llprimitive/llgltfmaterial.cpp | 10 ++++++++++ indra/llprimitive/llgltfmaterial.h | 9 +-------- indra/llprimitive/llmaterial.cpp | 2 +- indra/newview/llvovolume.cpp | 3 ++- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp index 62b693919c..f3aa5b0648 100644 --- a/indra/llprimitive/llgltfmaterial.cpp +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -692,3 +692,13 @@ void LLGLTFMaterial::applyOverride(const LLGLTFMaterial& override_mat) } } } + +LLUUID LLGLTFMaterial::getHash() const +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; + // HACK - hash the bytes of this object but don't include the ref count + LLUUID hash; + HBXXH128::digest(hash, (unsigned char*)this + sizeof(LLRefCount), sizeof(*this) - sizeof(LLRefCount)); + return hash; +} + diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index b453b91e67..a53b68a50f 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -115,14 +115,7 @@ public: bool mOverrideAlphaMode = false; // get a UUID based on a hash of this LLGLTFMaterial - LLUUID getHash() const - { - LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; - // HACK - hash the bytes of this object but don't include the ref count - LLUUID hash; - HBXXH128::digest(hash, (unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32)); - return hash; - } + LLUUID getHash() const; //setters for various members (will clamp to acceptable ranges) // for_override - set to true if this value is being set as part of an override (important for handling override to default value) diff --git a/indra/llprimitive/llmaterial.cpp b/indra/llprimitive/llmaterial.cpp index a694a666c6..37525e4a3d 100644 --- a/indra/llprimitive/llmaterial.cpp +++ b/indra/llprimitive/llmaterial.cpp @@ -481,7 +481,7 @@ LLUUID LLMaterial::getHash() const LL_PROFILE_ZONE_SCOPED_CATEGORY_TEXTURE; // HACK - hash the bytes of this LLMaterial, but trim off the S32 in LLRefCount LLUUID id; - HBXXH128::digest(id, (unsigned char*)this + sizeof(S32), sizeof(this) - sizeof(S32)); + HBXXH128::digest(id, (unsigned char*)this + sizeof(LLRefCount), sizeof(*this) - sizeof(LLRefCount)); return id; } diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index e1335acc17..237f9e34a0 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5416,7 +5416,8 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, if (gltf_mat) { - // nothing to do, render pools will reference the GLTF material + // just remember the material ID, render pools will reference the GLTF material + draw_info->mMaterialID = mat_id; } else if (mat) { From ad590887cc1bd950c189f71b4edd52c012d02e7a Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 22 Mar 2023 15:26:21 -0700 Subject: [PATCH 12/38] SL-19399: Allow editing all PBR texture transforms at once with Complete material radio --- indra/newview/llpanelface.cpp | 101 ++++++++++++++++++++++------------ 1 file changed, 67 insertions(+), 34 deletions(-) diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index cb7bc7b5df..5cffef5f6d 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1827,9 +1827,7 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material, if (show_pbr) { const U32 pbr_type = findChild("radio_pbr_type")->getSelectedIndex(); - const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); - const bool show_texture_info = texture_info != LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; - const bool new_state = show_texture_info && has_pbr_capabilities && has_pbr_material; + const bool new_state = has_pbr_capabilities && has_pbr_material; LLUICtrl* gltfCtrlTextureScaleU = getChild("gltfTextureScaleU"); LLUICtrl* gltfCtrlTextureScaleV = getChild("gltfTextureScaleV"); @@ -1858,11 +1856,6 @@ void LLPanelFace::updateVisibilityGLTF() const U32 pbr_type = radio_pbr_type->getSelectedIndex(); const bool show_pbr_render_material_id = show_pbr && (pbr_type == PBRTYPE_RENDER_MATERIAL_ID); - const bool show_pbr_base_color = show_pbr && (pbr_type == PBRTYPE_BASE_COLOR); - const bool show_pbr_normal = show_pbr && (pbr_type == PBRTYPE_NORMAL); - const bool show_pbr_metallic_roughness = show_pbr && (pbr_type == PBRTYPE_METALLIC_ROUGHNESS); - const bool show_pbr_emissive = show_pbr && (pbr_type == PBRTYPE_EMISSIVE); - const bool show_pbr_transform = show_pbr_base_color || show_pbr_normal || show_pbr_metallic_roughness || show_pbr_emissive; getChildView("pbr_control")->setVisible(show_pbr_render_material_id); @@ -1870,11 +1863,11 @@ void LLPanelFace::updateVisibilityGLTF() getChildView("edit_selected_pbr")->setVisible(show_pbr_render_material_id); getChildView("save_selected_pbr")->setVisible(show_pbr_render_material_id); - getChildView("gltfTextureScaleU")->setVisible(show_pbr_transform); - getChildView("gltfTextureScaleV")->setVisible(show_pbr_transform); - getChildView("gltfTextureRotation")->setVisible(show_pbr_transform); - getChildView("gltfTextureOffsetU")->setVisible(show_pbr_transform); - getChildView("gltfTextureOffsetV")->setVisible(show_pbr_transform); + getChildView("gltfTextureScaleU")->setVisible(show_pbr); + getChildView("gltfTextureScaleV")->setVisible(show_pbr); + getChildView("gltfTextureRotation")->setVisible(show_pbr); + getChildView("gltfTextureOffsetU")->setVisible(show_pbr); + getChildView("gltfTextureOffsetV")->setVisible(show_pbr); } void LLPanelFace::updateCopyTexButton() @@ -4654,7 +4647,8 @@ void LLPanelFace::updateGLTFTextureTransform(float value, U32 pbr_type, std::fun { U32 texture_info_start; U32 texture_info_end; - if (gSavedSettings.getBOOL("SyncMaterialSettings")) + const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); + if (gSavedSettings.getBOOL("SyncMaterialSettings") || texture_info == LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT) { texture_info_start = 0; texture_info_end = LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; @@ -4685,11 +4679,20 @@ void LLPanelFace::setMaterialOverridesFromSelection() { const U32 pbr_type = findChild("radio_pbr_type")->getSelectedIndex(); const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); + U32 texture_info_start; + U32 texture_info_end; if (texture_info == LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_COUNT) { - return; + texture_info_start = 0; + texture_info_end = LLGLTFMaterial::TextureInfo::GLTF_TEXTURE_INFO_COUNT; + } + else + { + texture_info_start = texture_info; + texture_info_end = texture_info + 1; } + bool read_transform = true; LLGLTFMaterial::TextureTransform transform; bool scale_u_same = true; bool scale_v_same = true; @@ -4697,26 +4700,56 @@ void LLPanelFace::setMaterialOverridesFromSelection() bool offset_u_same = true; bool offset_v_same = true; - readSelectedGLTFMaterial([&](const LLGLTFMaterial* mat) + for (U32 i = texture_info_start; i < texture_info_end; ++i) { - return mat ? mat->mTextureTransform[texture_info].mScale[VX] : 0.f; - }, transform.mScale[VX], scale_u_same, true, 1e-3f); - readSelectedGLTFMaterial([&](const LLGLTFMaterial* mat) - { - return mat ? mat->mTextureTransform[texture_info].mScale[VY] : 0.f; - }, transform.mScale[VY], scale_v_same, true, 1e-3f); - readSelectedGLTFMaterial([&](const LLGLTFMaterial* mat) - { - return mat ? mat->mTextureTransform[texture_info].mRotation : 0.f; - }, transform.mRotation, rotation_same, true, 1e-3f); - readSelectedGLTFMaterial([&](const LLGLTFMaterial* mat) - { - return mat ? mat->mTextureTransform[texture_info].mOffset[VX] : 0.f; - }, transform.mOffset[VX], offset_u_same, true, 1e-3f); - readSelectedGLTFMaterial([&](const LLGLTFMaterial* mat) - { - return mat ? mat->mTextureTransform[texture_info].mOffset[VY] : 0.f; - }, transform.mOffset[VY], offset_v_same, true, 1e-3f); + LLGLTFMaterial::TextureTransform this_transform; + bool this_scale_u_same = true; + bool this_scale_v_same = true; + bool this_rotation_same = true; + bool this_offset_u_same = true; + bool this_offset_v_same = true; + + readSelectedGLTFMaterial([&](const LLGLTFMaterial* mat) + { + return mat ? mat->mTextureTransform[i].mScale[VX] : 0.f; + }, this_transform.mScale[VX], this_scale_u_same, true, 1e-3f); + readSelectedGLTFMaterial([&](const LLGLTFMaterial* mat) + { + return mat ? mat->mTextureTransform[i].mScale[VY] : 0.f; + }, this_transform.mScale[VY], this_scale_v_same, true, 1e-3f); + readSelectedGLTFMaterial([&](const LLGLTFMaterial* mat) + { + return mat ? mat->mTextureTransform[i].mRotation : 0.f; + }, this_transform.mRotation, this_rotation_same, true, 1e-3f); + readSelectedGLTFMaterial([&](const LLGLTFMaterial* mat) + { + return mat ? mat->mTextureTransform[i].mOffset[VX] : 0.f; + }, this_transform.mOffset[VX], this_offset_u_same, true, 1e-3f); + readSelectedGLTFMaterial([&](const LLGLTFMaterial* mat) + { + return mat ? mat->mTextureTransform[i].mOffset[VY] : 0.f; + }, this_transform.mOffset[VY], this_offset_v_same, true, 1e-3f); + + scale_u_same = scale_u_same && this_scale_u_same; + scale_v_same = scale_v_same && this_scale_v_same; + rotation_same = rotation_same && this_rotation_same; + offset_u_same = offset_u_same && this_offset_u_same; + offset_v_same = offset_v_same && this_offset_v_same; + + if (read_transform) + { + read_transform = false; + transform = this_transform; + } + else + { + scale_u_same = scale_u_same && (this_transform.mScale[VX] == transform.mScale[VX]); + scale_v_same = scale_v_same && (this_transform.mScale[VY] == transform.mScale[VY]); + rotation_same = rotation_same && (this_transform.mRotation == transform.mRotation); + offset_u_same = offset_u_same && (this_transform.mOffset[VX] == transform.mOffset[VX]); + offset_v_same = offset_v_same && (this_transform.mOffset[VY] == transform.mOffset[VY]); + } + } LLUICtrl* gltfCtrlTextureScaleU = getChild("gltfTextureScaleU"); LLUICtrl* gltfCtrlTextureScaleV = getChild("gltfTextureScaleV"); From 1ba1159a3627520d2dfc6ab099808d6e01be5fc3 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 22 Mar 2023 15:53:08 -0700 Subject: [PATCH 13/38] SL-19399: Reorganize controls for PBR material editing in the build floater in more sensible way. Ignore "Lock repeat" in PBR mode as it's redundant --- indra/newview/llpanelface.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 5cffef5f6d..25b191aad1 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1282,7 +1282,7 @@ void LLPanelFace::updateUI(bool force_set_values /*false*/) LLCheckBoxCtrl* cb_planar_align = getChild("checkbox planar align"); align_planar = (cb_planar_align && cb_planar_align->get()); - bool enabled = (editable && isIdenticalPlanarTexgen() && (!pbr_selected || texture_info_selected)); + bool enabled = (editable && isIdenticalPlanarTexgen() && !texture_info_selected); childSetValue("checkbox planar align", align_planar && enabled); childSetVisible("checkbox planar align", enabled); childSetEnabled("checkbox planar align", enabled); @@ -2724,14 +2724,14 @@ void LLPanelFace::updateVisibility() const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled(); const U32 pbr_type = findChild("radio_pbr_type")->getSelectedIndex(); const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); - const bool show_texture_info = show_pbr && texture_info != LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; + const bool show_pbr_asset = show_pbr && texture_info == LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; radio_mat_type->setVisible(show_material); // Shared material controls - getChildView("checkbox_sync_settings")->setVisible(show_material || show_media || show_texture_info); - getChildView("tex gen")->setVisible(show_material || show_media || show_texture_info); - getChildView("combobox texgen")->setVisible(show_material || show_media || show_texture_info); + getChildView("checkbox_sync_settings")->setVisible(show_material || show_media); + getChildView("tex gen")->setVisible(show_material || show_media || show_pbr_asset); + getChildView("combobox texgen")->setVisible(show_material || show_media || show_pbr_asset); getChildView("button align textures")->setVisible(show_material || show_media); // Media controls @@ -4648,7 +4648,7 @@ void LLPanelFace::updateGLTFTextureTransform(float value, U32 pbr_type, std::fun U32 texture_info_start; U32 texture_info_end; const LLGLTFMaterial::TextureInfo texture_info = texture_info_from_pbrtype(pbr_type); - if (gSavedSettings.getBOOL("SyncMaterialSettings") || texture_info == LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT) + if (texture_info == LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT) { texture_info_start = 0; texture_info_end = LLGLTFMaterial::GLTF_TEXTURE_INFO_COUNT; From 00997b997efb5bb9a44c0a807241f0aa01199e60 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 22 Mar 2023 17:11:19 -0700 Subject: [PATCH 14/38] SL-19399: Thanks to Ai Austin for PBR material editing improvement idea --- doc/contributions.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/contributions.txt b/doc/contributions.txt index 5b5ca64d37..99c2242275 100755 --- a/doc/contributions.txt +++ b/doc/contributions.txt @@ -19,6 +19,7 @@ Agathos Frascati CT-317 CT-352 Ai Austin + SL-19399 Aiko Ying Aimee Trescothick SNOW-227 From d423263d54fc72cf857f3e147ac3860ca16c652f Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Thu, 23 Mar 2023 01:18:07 +0200 Subject: [PATCH 15/38] SL-19169 Local material updates aren't applied with non-default transforms --- indra/llprimitive/llgltfmaterial.h | 7 +++++ indra/llprimitive/lltextureentry.cpp | 27 ++++++++++++++++ indra/newview/llfetchedgltfmaterial.cpp | 12 +++++++ indra/newview/llfetchedgltfmaterial.h | 2 ++ indra/newview/lllocalgltfmaterials.cpp | 31 +++++++++++++++++++ indra/newview/lllocalgltfmaterials.h | 5 +++ indra/newview/llviewerobject.cpp | 9 +++--- .../xui/en/floater_material_editor.xml | 1 - 8 files changed, 88 insertions(+), 6 deletions(-) diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index a53b68a50f..bdabd657e1 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -41,6 +41,8 @@ namespace tinygltf class Model; } +class LLTextureEntry; + class LLGLTFMaterial : public LLRefCount { public: @@ -193,6 +195,11 @@ public: // True if setBaseMaterial() was just called bool isClearedForBaseMaterial(); + // For local materials, they have to keep track of where + // they are assigned to for full updates + virtual void addTextureEntry(LLTextureEntry* te) {}; + virtual void removeTextureEntry(LLTextureEntry* te) {}; + private: template void setFromTexture(const tinygltf::Model& model, const T& texture_info, TextureInfo texture_info_id); diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index 49f67918f8..a665db378b 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -112,7 +112,15 @@ LLTextureEntry &LLTextureEntry::operator=(const LLTextureEntry &rhs) mMaterialID = rhs.mMaterialID; + if (mGLTFMaterial) + { + mGLTFMaterial->removeTextureEntry(this); + } mGLTFMaterial = rhs.mGLTFMaterial; + if (mGLTFMaterial) + { + mGLTFMaterial->addTextureEntry(this); + } if (rhs.mGLTFMaterialOverrides.notNull()) { @@ -155,6 +163,12 @@ LLTextureEntry::~LLTextureEntry() delete mMediaEntry; mMediaEntry = NULL; } + + if (mGLTFMaterial) + { + mGLTFMaterial->removeTextureEntry(this); + mGLTFMaterial = NULL; + } } bool LLTextureEntry::operator!=(const LLTextureEntry &rhs) const @@ -524,7 +538,20 @@ void LLTextureEntry::setGLTFMaterial(LLGLTFMaterial* material, bool local_origin // NOTE: if you're hitting this assert, try to make sure calling code is using LLViewerObject::setRenderMaterialID llassert(!local_origin || getGLTFMaterialOverride() == nullptr || getGLTFMaterialOverride()->isClearedForBaseMaterial()); + if (mGLTFMaterial) + { + // Local materials have to keep track + // due to update mechanics + mGLTFMaterial->removeTextureEntry(this); + } + mGLTFMaterial = material; + + if (mGLTFMaterial) + { + mGLTFMaterial->addTextureEntry(this); + } + if (mGLTFMaterial == nullptr) { setGLTFRenderMaterial(nullptr); diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp index 80074cc655..2e71b4fa87 100644 --- a/indra/newview/llfetchedgltfmaterial.cpp +++ b/indra/newview/llfetchedgltfmaterial.cpp @@ -46,6 +46,18 @@ LLFetchedGLTFMaterial::~LLFetchedGLTFMaterial() } +LLFetchedGLTFMaterial& LLFetchedGLTFMaterial::operator=(const LLFetchedGLTFMaterial& rhs) +{ + LLGLTFMaterial::operator =(rhs); + + mBaseColorTexture = rhs.mBaseColorTexture; + mNormalTexture = rhs.mNormalTexture; + mMetallicRoughnessTexture = rhs.mMetallicRoughnessTexture; + mEmissiveTexture = rhs.mEmissiveTexture; + + return *this; +} + void LLFetchedGLTFMaterial::bind(LLViewerTexture* media_tex) { // glTF 2.0 Specification 3.9.4. Alpha Coverage diff --git a/indra/newview/llfetchedgltfmaterial.h b/indra/newview/llfetchedgltfmaterial.h index 0b51770493..1668657281 100644 --- a/indra/newview/llfetchedgltfmaterial.h +++ b/indra/newview/llfetchedgltfmaterial.h @@ -39,6 +39,8 @@ public: LLFetchedGLTFMaterial(); virtual ~LLFetchedGLTFMaterial(); + LLFetchedGLTFMaterial& operator=(const LLFetchedGLTFMaterial& rhs); + // If this material is loaded, fire the given function void onMaterialComplete(std::function material_complete); diff --git a/indra/newview/lllocalgltfmaterials.cpp b/indra/newview/lllocalgltfmaterials.cpp index 996b168262..d464ea0571 100644 --- a/indra/newview/lllocalgltfmaterials.cpp +++ b/indra/newview/lllocalgltfmaterials.cpp @@ -45,6 +45,7 @@ #include "llmaterialmgr.h" #include "llnotificationsutil.h" #include "llscrolllistctrl.h" +#include "lltextureentry.h" #include "lltinygltfhelper.h" #include "llviewertexture.h" @@ -118,6 +119,15 @@ S32 LLLocalGLTFMaterial::getIndexInFile() const return mMaterialIndex; } +void LLLocalGLTFMaterial::addTextureEntry(LLTextureEntry* te) +{ + mTextureEntires.insert(te); +} +void LLLocalGLTFMaterial::removeTextureEntry(LLTextureEntry* te) +{ + mTextureEntires.erase(te); +} + /* update functions */ bool LLLocalGLTFMaterial::updateSelf() { @@ -154,6 +164,27 @@ bool LLLocalGLTFMaterial::updateSelf() gGLTFMaterialList.addMaterial(mWorldID, this); mUpdateRetries = LL_LOCAL_UPDATE_RETRIES; + + for (LLTextureEntry* entry : mTextureEntires) + { + // Normally a change in applied material id is supposed to + // drop overrides thus reset material, but local materials + // currently reuse their existing asset id, and purpose is + // to preview how material will work in-world, overrides + // included, so do an override to render update instead. + LLGLTFMaterial* override_mat = entry->getGLTFMaterialOverride(); + if (override_mat) + { + // do not create a new material, reuse existing pointer + LLFetchedGLTFMaterial* render_mat = (LLFetchedGLTFMaterial*)entry->getGLTFRenderMaterial(); + if (render_mat) + { + *render_mat = *this; + render_mat->applyOverride(*override_mat); + } + } + } + updated = true; } diff --git a/indra/newview/lllocalgltfmaterials.h b/indra/newview/lllocalgltfmaterials.h index 6919b9b4b2..1442b83a40 100644 --- a/indra/newview/lllocalgltfmaterials.h +++ b/indra/newview/lllocalgltfmaterials.h @@ -34,6 +34,7 @@ class LLScrollListCtrl; class LLGLTFMaterial; class LLViewerObject; +class LLTextureEntry; class LLLocalGLTFMaterial : public LLFetchedGLTFMaterial { @@ -48,6 +49,9 @@ public: /* accessors */ LLUUID getWorldID() const; S32 getIndexInFile() const; + void addTextureEntry(LLTextureEntry* te) override; + void removeTextureEntry(LLTextureEntry* te) override; + public: bool updateSelf(); @@ -77,6 +81,7 @@ private: /* members */ ELinkStatus mLinkStatus; S32 mUpdateRetries; S32 mMaterialIndex; // Single file can have more than one + std::set mTextureEntires; }; class LLLocalGLTFMaterialTimer : public LLEventTimer diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index cb1694821d..a3a825c199 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -5368,8 +5368,10 @@ S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_ma LLFetchedGLTFMaterial* src_mat = (LLFetchedGLTFMaterial*) tep->getGLTFMaterial(); + // if override mat exists, we must also have a source mat if (!src_mat) - { // we can get into this state if an override has arrived before the viewer has + { + // we can get into this state if an override has arrived before the viewer has // received or handled an update, return TEM_CHANGE_NONE to signal to LLGLTFMaterialList that it // should queue the update for later return retval; @@ -5383,10 +5385,7 @@ S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_ma tep->setGLTFMaterialOverride(override_mat); - // if override mat exists, we must also have a source mat - llassert(override_mat ? bool(src_mat) : true); - - if (override_mat && src_mat) + if (override_mat) { LLFetchedGLTFMaterial* render_mat = new LLFetchedGLTFMaterial(*src_mat); render_mat->applyOverride(*override_mat); diff --git a/indra/newview/skins/default/xui/en/floater_material_editor.xml b/indra/newview/skins/default/xui/en/floater_material_editor.xml index 1c58ea6977..a6a401f43e 100644 --- a/indra/newview/skins/default/xui/en/floater_material_editor.xml +++ b/indra/newview/skins/default/xui/en/floater_material_editor.xml @@ -29,7 +29,6 @@ color="DkGray2" opaque="true" tab_stop="true" - border="false" reserve_scroll_corner="false"> Date: Thu, 23 Mar 2023 11:39:45 -0500 Subject: [PATCH 16/38] SL-18458 Fix for one failure mode of overrides getting applied before base material is set. --- indra/newview/llvovolume.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 237f9e34a0..7be9394364 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5670,6 +5670,12 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } + // HACK -- brute force this check every time a drawable gets rebuilt + for (S32 i = 0; i < drawablep->getNumFaces(); ++i) + { + vobj->updateTEMaterialTextures(i); + } + // apply any pending material overrides gGLTFMaterialList.applyQueuedOverrides(vobj); @@ -5754,9 +5760,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { continue; } - - // HACK -- brute force this check every time a drawable gets rebuilt - vobj->updateTEMaterialTextures(i); #if 0 #if LL_RELEASE_WITH_DEBUG_INFO const LLUUID pbr_id( "49c88210-7238-2a6b-70ac-92d4f35963cf" ); From 5721bdbc4d1138bb251cac9a504221ce04c23407 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 22 Mar 2023 17:56:55 -0700 Subject: [PATCH 17/38] SL-19399: Cleanup --- indra/newview/llpanelface.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/indra/newview/llpanelface.cpp b/indra/newview/llpanelface.cpp index 25b191aad1..dd3fdf91d9 100644 --- a/indra/newview/llpanelface.cpp +++ b/indra/newview/llpanelface.cpp @@ -1826,7 +1826,6 @@ void LLPanelFace::updateUIGLTF(LLViewerObject* objectp, bool& has_pbr_material, const bool show_pbr = mComboMatMedia->getCurrentIndex() == MATMEDIA_PBR && mComboMatMedia->getEnabled(); if (show_pbr) { - const U32 pbr_type = findChild("radio_pbr_type")->getSelectedIndex(); const bool new_state = has_pbr_capabilities && has_pbr_material; LLUICtrl* gltfCtrlTextureScaleU = getChild("gltfTextureScaleU"); From 81bccc05e296b80163bf28aea537e9ded2a0927e Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 23 Mar 2023 13:33:21 -0500 Subject: [PATCH 18/38] SL-18458 Fix for overrides not applying if material is not loaded on rebuild. --- indra/newview/llgltfmateriallist.cpp | 11 +++++++++-- indra/newview/llviewerobject.cpp | 13 +++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index d0c1c73f0e..678ec7e46b 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -376,8 +376,14 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj) { if (overrides[i].notNull()) { - if (!obj->getTE(i) || !obj->getTE(i)->getGLTFMaterial()) - { // object doesn't have its base GLTF material yet, don't apply override (yet) + if (!obj->getTE(i)) + { // object is incomplete + return; + } + + if (!obj->getTE(i)->getGLTFMaterial()) + { + // doesn't have its base GLTF material yet, don't apply override(yet) return; } @@ -387,6 +393,7 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj) // can't apply this yet, since failure to change the material override // probably means the base material is still being fetched. leave in // the queue for later + //obj->setDebugText("early out 3"); return; } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index a3a825c199..cc7e716bb5 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4961,6 +4961,18 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) if (mat == nullptr && mat_id.notNull()) { mat = (LLFetchedGLTFMaterial*) gGLTFMaterialList.getMaterial(mat_id); + if (mat->isFetching()) + { // material is not loaded yet, rebuild draw info when the object finishes loading + LLUUID id = getID(); + mat->onMaterialComplete([=] + { + LLViewerObject* obj = gObjectList.findObject(id); + if (obj) + { + obj->markForUpdate(FALSE); + } + }); + } getTE(te)->setGLTFMaterial(mat); } else if (mat_id.isNull() && mat != nullptr) @@ -5391,6 +5403,7 @@ S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_ma render_mat->applyOverride(*override_mat); tep->setGLTFRenderMaterial(render_mat); retval = TEM_CHANGE_TEXTURE; + } else if (tep->setGLTFRenderMaterial(nullptr)) { From 82125e8fba67de32f43d4a1c2290f2eec6a1d5e2 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 23 Mar 2023 14:16:52 -0500 Subject: [PATCH 19/38] SL-18458 Fix for overrides not applying when zooming out and back in again. --- indra/newview/llviewerregion.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index afe48f01b5..4663129d35 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1862,6 +1862,9 @@ LLViewerObject* LLViewerRegion::addNewObject(LLVOCacheEntry* entry) //should not hit here any more, but does not hurt either, just put it back to active list addActiveCacheEntry(entry); } + + loadCacheMiscExtras(entry->getLocalID(), entry, entry->getCRC()); + return obj; } @@ -2759,7 +2762,7 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U32 flags, U8 &cache_miss entry->setValid(); decodeBoundingInfo(entry); - loadCacheMiscExtras(local_id, entry, crc); + //loadCacheMiscExtras(local_id, entry, crc); return true; } From 2f97c6e142c82c0a280c3d073f906af2b15d8ca4 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Thu, 23 Mar 2023 14:09:28 -0700 Subject: [PATCH 20/38] SL-19394: Update default midday per feedback --- indra/newview/llenvironment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 8e8d396c95..464a833e1e 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -812,7 +812,7 @@ const F64Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F64Seconds LLEnvironment::TRANSITION_ALTITUDE(5.0f); const LLUUID LLEnvironment::KNOWN_SKY_SUNRISE("01e41537-ff51-2f1f-8ef7-17e4df760bfb"); -const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("81d4c85e-6868-dfd0-1a8a-e1838262be4b"); +const LLUUID LLEnvironment::KNOWN_SKY_MIDDAY("e4391f43-74d6-d889-19fb-99a4a3ad6c5c"); const LLUUID LLEnvironment::KNOWN_SKY_SUNSET("084e26cd-a900-28e8-08d0-64a9de5c15e2"); const LLUUID LLEnvironment::KNOWN_SKY_MIDNIGHT("8a01b97a-cb20-c1ea-ac63-f7ea84ad0090"); From 9b96bf168e15d49bfb6857b3370b9c843b150390 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 23 Mar 2023 16:31:49 -0500 Subject: [PATCH 21/38] SL-19478 Fix for assert when applying specular map. --- indra/newview/llvovolume.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 7be9394364..77849c668a 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -5473,6 +5473,7 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, llassert(type != LLRenderPass::PASS_BUMP || (info->mVertexBuffer->getTypeMask() & LLVertexBuffer::MAP_TANGENT) != 0); llassert(type != LLRenderPass::PASS_NORMSPEC || info->mNormalMap.notNull()); + llassert(type != LLRenderPass::PASS_SPECMAP || (info->mVertexBuffer->getTypeMask() & LLVertexBuffer::MAP_TEXCOORD2) != 0); } void LLVolumeGeometryManager::getGeometry(LLSpatialGroup* group) @@ -6666,6 +6667,15 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace } U32 mask = mat->getShaderMask(alpha_mode); + U32 vb_mask = facep->getVertexBuffer()->getTypeMask(); + + // HACK - this should also never happen, but sometimes we get here and the material thinks it has a specmap now + // even though it didn't appear to have a specmap when the face was added to the list of faces + if ((mask & 0x4) && !(vb_mask & LLVertexBuffer::MAP_TEXCOORD2)) + { + mask &= ~0x4; + } + llassert(mask < sizeof(pass)/sizeof(U32)); mask = llmin(mask, (U32)(sizeof(pass)/sizeof(U32)-1)); From cf3a0c77f1855aa1a33ff39f86e846e7fb9031d1 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Thu, 23 Mar 2023 16:51:30 -0700 Subject: [PATCH 22/38] Fix for SL-18458 overrides not applying when cache load happened before LLViewerObject::updateTEMaterialTextures call --- indra/newview/llgltfmateriallist.cpp | 2 ++ indra/newview/llviewerobject.cpp | 39 ++++++++++++++++++++++------ indra/newview/llviewerobject.h | 1 + indra/newview/llviewerregion.cpp | 13 +++++----- indra/newview/llviewerregion.h | 4 +-- 5 files changed, 42 insertions(+), 17 deletions(-) diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index 678ec7e46b..9c78e48cab 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -366,6 +366,8 @@ void LLGLTFMaterialList::queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFM void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj) { LL_PROFILE_ZONE_SCOPED; + + llassert(obj); const LLUUID& id = obj->getID(); auto iter = mQueuedOverrides.find(id); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index cc7e716bb5..1c53bddb62 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4963,12 +4963,16 @@ void LLViewerObject::updateTEMaterialTextures(U8 te) mat = (LLFetchedGLTFMaterial*) gGLTFMaterialList.getMaterial(mat_id); if (mat->isFetching()) { // material is not loaded yet, rebuild draw info when the object finishes loading - LLUUID id = getID(); - mat->onMaterialComplete([=] + mat->onMaterialComplete([id=getID()] { LLViewerObject* obj = gObjectList.findObject(id); if (obj) { + LLViewerRegion* region = obj->getRegion(); + if(region) + { + region->loadCacheMiscExtras(obj->getLocalID()); + } obj->markForUpdate(FALSE); } }); @@ -5698,6 +5702,23 @@ void LLViewerObject::setDebugText(const std::string &utf8text) updateText(); } +void LLViewerObject::appendDebugText(const std::string &utf8text) +{ + if (utf8text.empty() && !mText) + { + return; + } + + if (!mText) + { + initHudText(); + } + mText->addLine(utf8text, LLColor4::white); + mText->setZCompare(FALSE); + mText->setDoFade(FALSE); + updateText(); +} + void LLViewerObject::initHudText() { mText = (LLHUDText *)LLHUDObject::addHUDObject(LLHUDObject::LL_HUD_TEXT); @@ -7260,12 +7281,14 @@ void LLViewerObject::setRenderMaterialID(S32 te_in, const LLUUID& id, bool updat } else { - LLPointer this_ptr = this; - new_material->onMaterialComplete([this_ptr]() mutable { - if (this_ptr->isDead()) { return; } - - this_ptr->rebuildMaterial(); - }); + new_material->onMaterialComplete([obj_id = getID()]() + { + LLViewerObject* obj = gObjectList.findObject(obj_id); + if (obj) + { + obj->rebuildMaterial(); + } + }); } // predictively update LLRenderMaterialParams (don't wait for server) diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h index 560c51139b..e647fdd045 100644 --- a/indra/newview/llviewerobject.h +++ b/indra/newview/llviewerobject.h @@ -442,6 +442,7 @@ public: void sendMaterialUpdate() const; void setDebugText(const std::string &utf8text); + void appendDebugText(const std::string &utf8text); void initHudText(); void restoreHudText(); void setIcon(LLViewerTexture* icon_image); diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 4663129d35..dd4ff50259 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -823,7 +823,7 @@ void LLViewerRegion::saveObjectCache() // Map of LLVOCacheEntry takes time to release, store map for cleanup on idle sRegionCacheCleanup.insert(mImpl->mCacheMap.begin(), mImpl->mCacheMap.end()); mImpl->mCacheMap.clear(); - // TODO - probably need to do the same for overrides cache + // TODO - probably need to do the same for overrides cache } void LLViewerRegion::sendMessage() @@ -1151,6 +1151,8 @@ void LLViewerRegion::killCacheEntry(LLVOCacheEntry* entry, bool for_rendering) entry->setState(LLVOCacheEntry::INACTIVE); entry->removeOctreeEntry(); entry->setValid(FALSE); + + // TODO kill extras/material overrides cache too } //physically delete the cache entry @@ -1863,7 +1865,7 @@ LLViewerObject* LLViewerRegion::addNewObject(LLVOCacheEntry* entry) addActiveCacheEntry(entry); } - loadCacheMiscExtras(entry->getLocalID(), entry, entry->getCRC()); + loadCacheMiscExtras(entry->getLocalID()); return obj; } @@ -2879,6 +2881,7 @@ void LLViewerRegion::dumpCache() { LL_INFOS() << "Changes " << i << " " << change_bin[i] << LL_ENDL; } + // TODO - add overrides cache too } void LLViewerRegion::unpackRegionHandshake() @@ -3547,15 +3550,11 @@ std::string LLViewerRegion::getSimHostName() return std::string("..."); } -void LLViewerRegion::loadCacheMiscExtras(U32 local_id, LLVOCacheEntry * entry, U32 crc) +void LLViewerRegion::loadCacheMiscExtras(U32 local_id) { auto iter = mImpl->mGLTFOverridesJson.find(local_id); if (iter != mImpl->mGLTFOverridesJson.end()) { LLGLTFMaterialList::loadCacheOverrides(iter->second); } - else - { - LL_DEBUGS("GLTF") << "cache miss for handle: " << mHandle << " local_id:" << local_id << LL_ENDL; - } } diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index ec507fb982..b132a3a5f3 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -423,9 +423,9 @@ private: void decodeBoundingInfo(LLVOCacheEntry* entry); bool isNonCacheableObjectCreated(U32 local_id); - void loadCacheMiscExtras(U32 local_id, LLVOCacheEntry * entry, U32 crc); - public: + void loadCacheMiscExtras(U32 local_id); + struct CompareDistance { bool operator()(const LLViewerRegion* const& lhs, const LLViewerRegion* const& rhs) From df9d2b6e9613d15d39e3e870fc09686e41b6c37f Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 24 Mar 2023 10:31:32 -0500 Subject: [PATCH 23/38] SL-19321 Optimization pass -- reduce occlusion culling frame stalls, reduce shadow draw distance in probes. --- indra/newview/app_settings/settings.xml | 11 +++++++++++ indra/newview/llvieweroctree.cpp | 4 +++- indra/newview/pipeline.cpp | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 6d7e93b364..5ade88e32b 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -14261,6 +14261,17 @@ Value 1 + RenderOcclusionTimeout + + Comment + Maximum number of frames to wait on an occlusion query before forcibly reading it back + Persist + 1 + Type + S32 + Value + 8 + UseObjectCacheOcclusion Comment diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index d1d23cfb8e..a2d8d30fb2 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1131,7 +1131,9 @@ void LLOcclusionCullingGroup::checkOcclusion() mOcclusionCheckCount[LLViewerCamera::sCurCameraID]++; } - if (available || mOcclusionCheckCount[LLViewerCamera::sCurCameraID] > 4) + static LLCachedControl occlusion_timeout(gSavedSettings, "RenderOcclusionTimeout", 4); + + if (available || mOcclusionCheckCount[LLViewerCamera::sCurCameraID] > occlusion_timeout) { mOcclusionCheckCount[LLViewerCamera::sCurCameraID] = 0; GLuint query_result; // Will be # samples drawn, or a boolean depending on mHasOcclusionQuery2 (both are type GLuint) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 18b0192346..f059c87c91 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9419,7 +9419,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } else { - for (S32 j = 0; j < 4; j++) + for (S32 j = 0; j < (gCubeSnapshot ? 3 : 4); j++) { if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { From 5882215a6d53f5a20779be78805392f4e38c3669 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 24 Mar 2023 14:33:41 -0500 Subject: [PATCH 24/38] SL-19321 Optimization pass -- Remove another shadow split from probe render, incidental decruft. --- indra/llmath/llcamera.cpp | 222 ------------------------ indra/llmath/llcamera.h | 9 - indra/newview/app_settings/settings.xml | 46 ----- indra/newview/pipeline.cpp | 39 ++--- indra/newview/pipeline.h | 3 - 5 files changed, 10 insertions(+), 309 deletions(-) diff --git a/indra/llmath/llcamera.cpp b/indra/llmath/llcamera.cpp index 9034182072..18d704dd0f 100644 --- a/indra/llmath/llcamera.cpp +++ b/indra/llmath/llcamera.cpp @@ -311,104 +311,6 @@ int LLCamera::sphereInFrustumQuick(const LLVector3 &sphere_center, const F32 rad return 0; } -// HACK: This version is still around because the version below doesn't work -// unless the agent planes are initialized. -// Return 1 if sphere is in frustum, 2 if fully in frustum, otherwise 0. -// NOTE: 'center' is in absolute frame. -int LLCamera::sphereInFrustumOld(const LLVector3 &sphere_center, const F32 radius) const -{ - // Returns 1 if sphere is in frustum, 0 if not. - // modified so that default view frust is along X with Z vertical - F32 x, y, z, rightDist, leftDist, topDist, bottomDist; - - // Subtract the view position - //LLVector3 relative_center; - //relative_center = sphere_center - getOrigin(); - LLVector3 rel_center(sphere_center); - rel_center -= mOrigin; - - bool all_in = TRUE; - - // Transform relative_center.x to camera frame - x = mXAxis * rel_center; - if (x < MIN_NEAR_PLANE - radius) - { - return 0; - } - else if (x < MIN_NEAR_PLANE + radius) - { - all_in = FALSE; - } - - if (x > mFarPlane + radius) - { - return 0; - } - else if (x > mFarPlane - radius) - { - all_in = FALSE; - } - - // Transform relative_center.y to camera frame - y = mYAxis * rel_center; - - // distance to plane is the dot product of (x, y, 0) * plane_normal - rightDist = x * mLocalPlanes[PLANE_RIGHT][VX] + y * mLocalPlanes[PLANE_RIGHT][VY]; - if (rightDist < -radius) - { - return 0; - } - else if (rightDist < radius) - { - all_in = FALSE; - } - - leftDist = x * mLocalPlanes[PLANE_LEFT][VX] + y * mLocalPlanes[PLANE_LEFT][VY]; - if (leftDist < -radius) - { - return 0; - } - else if (leftDist < radius) - { - all_in = FALSE; - } - - // Transform relative_center.y to camera frame - z = mZAxis * rel_center; - - topDist = x * mLocalPlanes[PLANE_TOP][VX] + z * mLocalPlanes[PLANE_TOP][VZ]; - if (topDist < -radius) - { - return 0; - } - else if (topDist < radius) - { - all_in = FALSE; - } - - bottomDist = x * mLocalPlanes[PLANE_BOTTOM][VX] + z * mLocalPlanes[PLANE_BOTTOM][VZ]; - if (bottomDist < -radius) - { - return 0; - } - else if (bottomDist < radius) - { - all_in = FALSE; - } - - if (all_in) - { - return 2; - } - - return 1; -} - - -// HACK: This (presumably faster) version only currently works if you set up the -// frustum planes using GL. At some point we should get those planes through another -// mechanism, and then we can get rid of the "old" version above. - // Return 1 if sphere is in frustum, 2 if fully in frustum, otherwise 0. // NOTE: 'center' is in absolute frame. int LLCamera::sphereInFrustum(const LLVector3 &sphere_center, const F32 radius) const @@ -463,65 +365,6 @@ F32 LLCamera::heightInPixels(const LLVector3 ¢er, F32 radius ) const } } -// If pos is visible, return the distance from pos to the camera. -// Use fudge distance to scale rad against top/bot/left/right planes -// Otherwise, return -distance -F32 LLCamera::visibleDistance(const LLVector3 &pos, F32 rad, F32 fudgedist, U32 planemask) const -{ - if (mFixedDistance > 0) - { - return mFixedDistance; - } - LLVector3 dvec = pos - mOrigin; - // Check visibility - F32 dist = dvec.magVec(); - if (dist > rad) - { - F32 dp,tdist; - dp = dvec * mXAxis; - if (dp < -rad) - return -dist; - - rad *= fudgedist; - LLVector3 tvec(pos); - for (int p=0; p rad) - return -dist; - } - } - return dist; -} - -// Like visibleDistance, except uses mHorizPlanes[], which are left and right -// planes perpindicular to (0,0,1) in world space -F32 LLCamera::visibleHorizDistance(const LLVector3 &pos, F32 rad, F32 fudgedist, U32 planemask) const -{ - if (mFixedDistance > 0) - { - return mFixedDistance; - } - LLVector3 dvec = pos - mOrigin; - // Check visibility - F32 dist = dvec.magVec(); - if (dist > rad) - { - rad *= fudgedist; - LLVector3 tvec(pos); - for (int p=0; p rad) - return -dist; - } - } - return dist; -} // ---------------- friends and operators ---------------- @@ -536,18 +379,6 @@ std::ostream& operator<<(std::ostream &s, const LLCamera &C) s << " Aspect = " << C.getAspect() << "\n"; s << " NearPlane = " << C.mNearPlane << "\n"; s << " FarPlane = " << C.mFarPlane << "\n"; - s << " TopPlane = " << C.mLocalPlanes[LLCamera::PLANE_TOP][VX] << " " - << C.mLocalPlanes[LLCamera::PLANE_TOP][VY] << " " - << C.mLocalPlanes[LLCamera::PLANE_TOP][VZ] << "\n"; - s << " BottomPlane = " << C.mLocalPlanes[LLCamera::PLANE_BOTTOM][VX] << " " - << C.mLocalPlanes[LLCamera::PLANE_BOTTOM][VY] << " " - << C.mLocalPlanes[LLCamera::PLANE_BOTTOM][VZ] << "\n"; - s << " LeftPlane = " << C.mLocalPlanes[LLCamera::PLANE_LEFT][VX] << " " - << C.mLocalPlanes[LLCamera::PLANE_LEFT][VY] << " " - << C.mLocalPlanes[LLCamera::PLANE_LEFT][VZ] << "\n"; - s << " RightPlane = " << C.mLocalPlanes[LLCamera::PLANE_RIGHT][VX] << " " - << C.mLocalPlanes[LLCamera::PLANE_RIGHT][VY] << " " - << C.mLocalPlanes[LLCamera::PLANE_RIGHT][VZ] << "\n"; s << "}"; return s; } @@ -675,26 +506,6 @@ void LLCamera::calcRegionFrustumPlanes(const LLVector3& shift, F32 far_clip_dist void LLCamera::calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom) { - LLVector3 a, b, c; - - // For each plane we need to define 3 points (LLVector3's) in camera view space. - // The order in which we pass the points to planeFromPoints() matters, because the - // plane normal has a degeneracy of 2; we want it pointing _into_ the frustum. - - a.setVec(0.0f, 0.0f, 0.0f); - b.setVec(mFarPlane, right, top); - c.setVec(mFarPlane, right, bottom); - mLocalPlanes[PLANE_RIGHT].setVec(a, b, c); - - c.setVec(mFarPlane, left, top); - mLocalPlanes[PLANE_TOP].setVec(a, c, b); - - b.setVec(mFarPlane, left, bottom); - mLocalPlanes[PLANE_LEFT].setVec(a, b, c); - - c.setVec(mFarPlane, right, bottom); - mLocalPlanes[PLANE_BOTTOM].setVec( a, c, b); - //calculate center and radius squared of frustum in world absolute coordinates static LLVector3 const X_AXIS(1.f, 0.f, 0.f); mFrustCenter = X_AXIS*mFarPlane*0.5f; @@ -718,39 +529,6 @@ void LLCamera::calculateFrustumPlanesFromWindow(F32 x1, F32 y1, F32 x2, F32 y2) calculateFrustumPlanes(left, right, top, bottom); } -void LLCamera::calculateWorldFrustumPlanes() -{ - F32 d; - LLVector3 center = mOrigin - mXAxis*mNearPlane; - mWorldPlanePos = center; - LLVector3 pnorm; - for (int p = 0; p < PLANE_NUM; p++) - { - mLocalPlanes[p].getVector3(pnorm); - LLVector3 norm = rotateToAbsolute(pnorm); - norm.normVec(); - d = -(center * norm); - mWorldPlanes[p] = LLPlane(norm, d); - } - // horizontal planes, perpindicular to (0,0,1); - LLVector3 zaxis(0, 0, 1.0f); - F32 yaw = getYaw(); - { - LLVector3 tnorm; - mLocalPlanes[PLANE_LEFT].getVector3(tnorm); - tnorm.rotVec(yaw, zaxis); - d = -(mOrigin * tnorm); - mHorizPlanes[HORIZ_PLANE_LEFT] = LLPlane(tnorm, d); - } - { - LLVector3 tnorm; - mLocalPlanes[PLANE_RIGHT].getVector3(tnorm); - tnorm.rotVec(yaw, zaxis); - d = -(mOrigin * tnorm); - mHorizPlanes[HORIZ_PLANE_RIGHT] = LLPlane(tnorm, d); - } -} - // NOTE: this is the OpenGL matrix that will transform the default OpenGL view // (-Z=at, Y=up) to the default view of the LLCamera class (X=at, Z=up): // diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h index d0afa0e88f..27eaa614c9 100644 --- a/indra/llmath/llcamera.h +++ b/indra/llmath/llcamera.h @@ -131,14 +131,10 @@ private: S32 mViewHeightInPixels; // for ViewHeightInPixels() only F32 mNearPlane; F32 mFarPlane; - LL_ALIGN_16(LLPlane mLocalPlanes[PLANE_NUM]); F32 mFixedDistance; // Always return this distance, unless < 0 LLVector3 mFrustCenter; // center of frustum and radius squared for ultra-quick exclusion test F32 mFrustRadiusSquared; - LL_ALIGN_16(LLPlane mWorldPlanes[PLANE_NUM]); - LL_ALIGN_16(LLPlane mHorizPlanes[HORIZ_PLANE_NUM]); - U32 mPlaneCount; //defaults to 6, if setUserClipPlane is called, uses user supplied clip plane in LLVector3 mWorldPlanePos; // Position of World Planes (may be offset from camera) @@ -184,7 +180,6 @@ public: return atan2f(mXAxis[VZ], xylen); } - const LLPlane& getWorldPlane(S32 index) const { return mWorldPlanes[index]; } const LLVector3& getWorldPlanePos() const { return mWorldPlanePos; } // Copy mView, mAspect, mNearPlane, and mFarPlane to buffer. @@ -200,7 +195,6 @@ public: // Returns 1 if partly in, 2 if fully in. // NOTE: 'center' is in absolute frame. - S32 sphereInFrustumOld(const LLVector3 ¢er, const F32 radius) const; S32 sphereInFrustum(const LLVector3 ¢er, const F32 radius) const; S32 pointInFrustum(const LLVector3 &point) const { return sphereInFrustum(point, 0.0f); } S32 sphereInFrustumFull(const LLVector3 ¢er, const F32 radius) const { return sphereInFrustum(center, radius); } @@ -217,8 +211,6 @@ public: F32 heightInPixels(const LLVector3 ¢er, F32 radius ) const; // return the distance from pos to camera if visible (-distance if not visible) - F32 visibleDistance(const LLVector3 &pos, F32 rad, F32 fudgescale = 1.0f, U32 planemask = PLANE_ALL_MASK) const; - F32 visibleHorizDistance(const LLVector3 &pos, F32 rad, F32 fudgescale = 1.0f, U32 planemask = HORIZ_PLANE_ALL_MASK) const; void setFixedDistance(F32 distance) { mFixedDistance = distance; } friend std::ostream& operator<<(std::ostream &s, const LLCamera &C); @@ -227,7 +219,6 @@ protected: void calculateFrustumPlanes(); void calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom); void calculateFrustumPlanesFromWindow(F32 x1, F32 y1, F32 x2, F32 y2); - void calculateWorldFrustumPlanes(); } LL_ALIGN_POSTFIX(16); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 5ade88e32b..e0662b8115 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9002,37 +9002,6 @@ Value 1 - - RenderShadowNearDist - - Comment - Near clip plane of shadow camera (affects precision of depth shadows). - Persist - 1 - Type - Vector3 - Value - - 256 - 256 - 256 - - - RenderShadowClipPlanes - - Comment - Near clip plane split distances for shadow map frusta. - Persist - 1 - Type - Vector3 - Value - - 1.0 - 12.0 - 32.0 - - RenderShadowSplitExponent Comment @@ -9048,21 +9017,6 @@ 2.0 - RenderShadowOrthoClipPlanes - - Comment - Near clip plane split distances for orthographic shadow map frusta. - Persist - 1 - Type - Vector3 - Value - - 4.0 - 8.0 - 24.0 - - RenderShadowProjOffset Comment diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index f059c87c91..a53b3aac8e 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -202,9 +202,6 @@ LLVector3 LLPipeline::RenderShadowGaussian; F32 LLPipeline::RenderShadowBlurDistFactor; bool LLPipeline::RenderDeferredAtmospheric; F32 LLPipeline::RenderHighlightFadeTime; -LLVector3 LLPipeline::RenderShadowClipPlanes; -LLVector3 LLPipeline::RenderShadowOrthoClipPlanes; -LLVector3 LLPipeline::RenderShadowNearDist; F32 LLPipeline::RenderFarClip; LLVector3 LLPipeline::RenderShadowSplitExponent; F32 LLPipeline::RenderShadowErrorCutoff; @@ -558,9 +555,6 @@ void LLPipeline::init() connectRefreshCachedSettingsSafe("RenderShadowBlurDistFactor"); connectRefreshCachedSettingsSafe("RenderDeferredAtmospheric"); connectRefreshCachedSettingsSafe("RenderHighlightFadeTime"); - connectRefreshCachedSettingsSafe("RenderShadowClipPlanes"); - connectRefreshCachedSettingsSafe("RenderShadowOrthoClipPlanes"); - connectRefreshCachedSettingsSafe("RenderShadowNearDist"); connectRefreshCachedSettingsSafe("RenderFarClip"); connectRefreshCachedSettingsSafe("RenderShadowSplitExponent"); connectRefreshCachedSettingsSafe("RenderShadowErrorCutoff"); @@ -1043,9 +1037,6 @@ void LLPipeline::refreshCachedSettings() RenderShadowBlurDistFactor = gSavedSettings.getF32("RenderShadowBlurDistFactor"); RenderDeferredAtmospheric = gSavedSettings.getBOOL("RenderDeferredAtmospheric"); RenderHighlightFadeTime = gSavedSettings.getF32("RenderHighlightFadeTime"); - RenderShadowClipPlanes = gSavedSettings.getVector3("RenderShadowClipPlanes"); - RenderShadowOrthoClipPlanes = gSavedSettings.getVector3("RenderShadowOrthoClipPlanes"); - RenderShadowNearDist = gSavedSettings.getVector3("RenderShadowNearDist"); RenderFarClip = gSavedSettings.getF32("RenderFarClip"); RenderShadowSplitExponent = gSavedSettings.getVector3("RenderShadowSplitExponent"); RenderShadowErrorCutoff = gSavedSettings.getF32("RenderShadowErrorCutoff"); @@ -9277,27 +9268,12 @@ void LLPipeline::generateSunShadow(LLCamera& camera) glh::matrix4f view[6]; glh::matrix4f proj[6]; - //clip contains parallel split distances for 3 splits - LLVector3 clip = RenderShadowClipPlanes; - LLVector3 caster_dir(environment.getIsSunUp() ? mSunDir : mMoonDir); - //F32 slope_threshold = gSavedSettings.getF32("RenderShadowSlopeThreshold"); - - //far clip on last split is minimum of camera view distance and 128 - mSunClipPlanes = LLVector4(clip, clip.mV[2] * clip.mV[2]/clip.mV[1]); - - clip = RenderShadowOrthoClipPlanes; - mSunOrthoClipPlanes = LLVector4(clip, clip.mV[2]*clip.mV[2]/clip.mV[1]); - - //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] }; - //put together a universal "near clip" plane for shadow frusta LLPlane shadow_near_clip; { - LLVector3 p = gAgent.getPositionAgent(); + LLVector3 p = camera.getOrigin(); // gAgent.getPositionAgent(); p += caster_dir * RenderFarClip*2.f; shadow_near_clip.setVec(p, caster_dir); } @@ -9318,9 +9294,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) up = camera.getUpAxis(); } - /*LLVector3 left = up%at; - up = at%left;*/ - up.normVec(); at.normVec(); @@ -9403,6 +9376,14 @@ void LLPipeline::generateSunShadow(LLCamera& camera) mSunClipPlanes.mV[0] *= 1.25f; //bump back first split for transition padding } + if (gCubeSnapshot) + { // stretch clip planes for reflection probe renders to reduce number of shadow passes + mSunClipPlanes.mV[1] = mSunClipPlanes.mV[2]; + mSunClipPlanes.mV[2] = mSunClipPlanes.mV[3]; + mSunClipPlanes.mV[3] *= 1.5f; + } + + // convenience array of 4 near clip plane distances F32 dist[] = { near_clip, mSunClipPlanes.mV[0], mSunClipPlanes.mV[1], mSunClipPlanes.mV[2], mSunClipPlanes.mV[3] }; @@ -9419,7 +9400,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) } else { - for (S32 j = 0; j < (gCubeSnapshot ? 3 : 4); j++) + for (S32 j = 0; j < (gCubeSnapshot ? 2 : 4); j++) { if (!hasRenderDebugMask(RENDER_DEBUG_SHADOW_FRUSTA) && !gCubeSnapshot) { diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 0faa0c3f20..4cefb719fd 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -999,9 +999,6 @@ public: static F32 RenderShadowBlurDistFactor; static bool RenderDeferredAtmospheric; static F32 RenderHighlightFadeTime; - static LLVector3 RenderShadowClipPlanes; - static LLVector3 RenderShadowOrthoClipPlanes; - static LLVector3 RenderShadowNearDist; static F32 RenderFarClip; static LLVector3 RenderShadowSplitExponent; static F32 RenderShadowErrorCutoff; From 893f72557058017246d7e8b9674886c257f9aeb3 Mon Sep 17 00:00:00 2001 From: Brad Linden Date: Fri, 24 Mar 2023 15:30:22 -0700 Subject: [PATCH 25/38] Attempt to fix build breakage for DRTVWR-559 --- indra/llcorehttp/tests/test_llcorehttp_peer.py | 1 - 1 file changed, 1 deletion(-) diff --git a/indra/llcorehttp/tests/test_llcorehttp_peer.py b/indra/llcorehttp/tests/test_llcorehttp_peer.py index 778de90962..185e8e25c6 100755 --- a/indra/llcorehttp/tests/test_llcorehttp_peer.py +++ b/indra/llcorehttp/tests/test_llcorehttp_peer.py @@ -38,7 +38,6 @@ from io import StringIO from http.server import HTTPServer, BaseHTTPRequestHandler -from llbase.fastest_elementtree import parse as xml_parse from llbase import llsd # we're in llcorehttp/tests ; testrunner.py is found in llmessage/tests From 960715efc1cda86f924acc50f2a322e9403abd14 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 27 Mar 2023 13:07:31 -0500 Subject: [PATCH 26/38] SL-19477 Remove angular attenuation from sphere probe weight to fix harsh indirect lighting. Minor incidental decruft. --- .../shaders/class2/deferred/alphaF.glsl | 2 -- .../class3/deferred/reflectionProbeF.glsl | 18 ++++++------------ 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index ef35bf3fd7..e7322c14fb 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -79,7 +79,6 @@ vec3 srgb_to_linear(vec3 c); vec3 linear_to_srgb(vec3 c); vec2 encode_normal (vec3 n); -vec3 scaleSoftClipFragLinear(vec3 l); vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten); void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); @@ -279,7 +278,6 @@ void main() color.rgb = linear_to_srgb(color.rgb); color.rgb = atmosFragLightingLinear(color.rgb, additive, atten); - color.rgb = scaleSoftClipFragLinear(color.rgb); color.rgb = srgb_to_linear(color.rgb); vec4 light = vec4(0,0,0,0); diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index bd06a680f5..1f4833ea21 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -95,6 +95,7 @@ bool shouldSampleProbe(int i, vec3 pos) return false; } + // never allow automatic probes to encroach on box probes sample_automatic = false; } else @@ -429,25 +430,19 @@ void boxIntersectDebug(vec3 origin, vec3 pos, int i, inout vec4 col) // dir - normal to be weighted // origin - center of sphere probe // r - radius of probe influence volume -// min_da - minimum angular attenuation coefficient // 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 sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, 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 atten = 1.0 - max(d2 - r1, 0.0) / max((r - r1), 0.001); float w = 1.0 / d2; dw = w * atten * max(r, 1.0)*4; - atten *= max(dot(normalize(-delta), dir), min_da); - w *= atten; return w; @@ -484,7 +479,7 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 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 rr); - w = sphereWeight(pos, dir, refSphere[i].xyz, r, 0.25, i, dw); + w = sphereWeight(pos, dir, refSphere[i].xyz, r, i, dw); } v -= c; @@ -524,7 +519,7 @@ vec3 tapIrradianceMap(vec3 pos, vec3 dir, out float w, out float dw, vec3 c, int 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, i, dw); + w = sphereWeight(pos, dir, refSphere[i].xyz, r, i, dw); } v -= c; @@ -562,7 +557,6 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod) float dw = 0; vec3 refcol; - { refcol = tapRefMap(pos, dir, w, dw, lod, refSphere[i].xyz, i); @@ -735,7 +729,7 @@ void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 refnormpersp = reflect(pos.xyz, norm.xyz); ambenv = sampleProbeAmbient(pos, norm); - + if (glossiness > 0.0) { float lod = (1.0-glossiness)*reflection_lods; From c20058b7a7207cb80426796d9d77864c696a5eec Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 27 Mar 2023 13:31:45 -0500 Subject: [PATCH 27/38] SL-18563 Pull featuretable settings for avatar impostors and volume lod from auto-fps viewer --- indra/newview/featuretable.txt | 16 +++++++++++----- indra/newview/featuretable_mac.txt | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 020c7bbc74..14d8d3fae5 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 51 +version 52 // 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 @@ -109,6 +109,7 @@ RenderScreenSpaceReflections 1 0 list LowMid RenderAnisotropic 1 0 RenderAvatarLODFactor 1 0.5 +RenderAvatarMaxNonImpostors 1 5 RenderAvatarMaxComplexity 1 100000 RenderAvatarPhysicsLODFactor 1 0.75 RenderFarClip 1 96 @@ -136,6 +137,7 @@ RenderScreenSpaceReflections 1 0 list Mid RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 7 RenderAvatarMaxComplexity 1 200000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -147,7 +149,7 @@ RenderTransparentWater 1 0 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.25 RenderDeferredSSAO 1 0 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 @@ -163,6 +165,7 @@ RenderScreenSpaceReflections 1 0 list MidHigh RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 9 RenderAvatarMaxComplexity 1 250000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -174,7 +177,7 @@ RenderTransparentWater 1 1 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.375 RenderDeferredSSAO 1 0 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 @@ -190,6 +193,7 @@ RenderScreenSpaceReflections 1 0 list High RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 11 RenderAvatarMaxComplexity 1 300000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -201,7 +205,7 @@ RenderTransparentWater 1 1 RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.5 RenderDeferredSSAO 1 1 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 @@ -217,6 +221,7 @@ RenderScreenSpaceReflections 1 0 list HighUltra RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 16 RenderAvatarMaxComplexity 1 350000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -228,7 +233,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.75 RenderDeferredSSAO 1 1 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 @@ -244,6 +249,7 @@ RenderScreenSpaceReflections 1 0 list Ultra RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 16 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 256 RenderFlexTimeFactor 1 1.0 diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index dbb33b3997..b7a0ac6e28 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 46 +version 47 // 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 @@ -107,6 +107,7 @@ RenderScreenSpaceReflections 1 0 list LowMid RenderAnisotropic 1 0 RenderAvatarLODFactor 1 0.5 +RenderAvatarMaxNonImpostors 1 5 RenderAvatarMaxComplexity 1 100000 RenderAvatarPhysicsLODFactor 1 0.75 RenderFarClip 1 96 @@ -134,6 +135,7 @@ RenderScreenSpaceReflections 1 0 list Mid RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 7 RenderAvatarMaxComplexity 1 200000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -145,7 +147,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.25 RenderDeferredSSAO 1 0 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 @@ -161,6 +163,7 @@ RenderScreenSpaceReflections 1 0 list MidHigh RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 9 RenderAvatarMaxComplexity 1 250000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -172,7 +175,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.375 RenderDeferredSSAO 1 0 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 @@ -188,6 +191,7 @@ RenderScreenSpaceReflections 1 0 list High RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 11 RenderAvatarMaxComplexity 1 300000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -199,7 +203,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.5 RenderDeferredSSAO 1 1 RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 @@ -215,6 +219,7 @@ RenderScreenSpaceReflections 1 0 list HighUltra RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 16 RenderAvatarMaxComplexity 1 350000 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 128 @@ -226,7 +231,7 @@ RenderTerrainDetail 1 1 RenderTerrainLODFactor 1 2.0 RenderTransparentWater 1 1 RenderTreeLODFactor 1 0.5 -RenderVolumeLODFactor 1 1.125 +RenderVolumeLODFactor 1 1.75 RenderDeferredSSAO 1 1 RenderShadowDetail 1 2 RenderUseAdvancedAtmospherics 1 0 @@ -242,6 +247,7 @@ RenderScreenSpaceReflections 1 0 list Ultra RenderAnisotropic 1 1 RenderAvatarLODFactor 1 1.0 +RenderAvatarMaxNonImpostors 1 16 RenderAvatarPhysicsLODFactor 1 1.0 RenderFarClip 1 256 RenderFlexTimeFactor 1 1.0 From 6c554c9c92a0150fdf5a177bf33269eac8341d02 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Mon, 27 Mar 2023 15:06:25 -0700 Subject: [PATCH 28/38] Fix up the graphics setting detection SL-18563 --- .../shaders/class3/deferred/reflectionProbeF.glsl | 3 --- indra/newview/llfeaturemanager.cpp | 8 ++++---- indra/newview/llviewershadermgr.cpp | 11 ++++++++++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index a6a2543915..9b5cb39883 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -29,9 +29,6 @@ float tapScreenSpaceReflection(int totalSamples, vec2 tc, vec3 viewPos, vec3 n, inout vec4 collectedColor, sampler2D source); #endif -#define REFMAP_COUNT 256 -#define REF_SAMPLE_COUNT 64 //maximum number of samples to consider - uniform samplerCubeArray reflectionProbes; uniform samplerCubeArray irradianceProbes; uniform sampler2D sceneMap; diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp index 81a7aa47c8..0974ae0742 100644 --- a/indra/newview/llfeaturemanager.cpp +++ b/indra/newview/llfeaturemanager.cpp @@ -434,19 +434,19 @@ bool LLFeatureManager::loadGPUClass() mGPUClass = GPU_CLASS_0; #endif } - else if (gbps <= 8.f) + else if (gbps <= 32.0f) { mGPUClass = GPU_CLASS_1; } - else if (gbps <= 16.f) + else if (gbps <= 64.0f) { mGPUClass = GPU_CLASS_2; } - else if (gbps <= 40.f) + else if (gbps <= 128.0f) { mGPUClass = GPU_CLASS_3; } - else if (gbps <= 80.f) + else if (gbps <= 256.0f) { mGPUClass = GPU_CLASS_4; } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 31c71aac2a..7790013f01 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -667,6 +667,10 @@ std::string LLViewerShaderMgr::loadBasicShaders() BOOL local_light_kill = gSavedSettings.getBOOL("LocalLightDisable"); BOOL ssr = gSavedSettings.getBOOL("RenderScreenSpaceReflections"); + bool has_reflection_probes = gSavedSettings.getBOOL("RenderReflectionsEnabled") && gGLManager.mGLVersion > 3.99f; + + S32 probe_count = gSavedSettings.getS32("RenderReflectionProbeCount"); + if (ambient_kill) { attribs["AMBIENT_KILL"] = "1"; @@ -699,6 +703,12 @@ std::string LLViewerShaderMgr::loadBasicShaders() attribs["SSR"] = "1"; } + if (has_reflection_probes) + { + attribs["REFMAP_COUNT"] = std::to_string(probe_count); + attribs["REF_SAMPLE_COUNT"] = "32"; + } + // We no longer have to bind the shaders to global glhandles, they are automatically added to a map now. for (U32 i = 0; i < shaders.size(); i++) { @@ -721,7 +731,6 @@ std::string LLViewerShaderMgr::loadBasicShaders() ch = llmax(LLGLSLShader::sIndexedTextureChannels, 1); } - bool has_reflection_probes = gSavedSettings.getBOOL("RenderReflectionsEnabled") && gGLManager.mGLVersion > 3.99f; std::vector index_channels; index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsVarsF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); From 366bae14963151905cae7a08c4c77d422223b9e1 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 27 Mar 2023 18:22:53 -0500 Subject: [PATCH 29/38] DRTVWR-559 Fix for off-white metal not looking chromed when it should (fake hacky HDR sky reflections). --- .../app_settings/shaders/class1/deferred/skyV.glsl | 8 ++++++-- indra/newview/lldrawpoolwlsky.cpp | 2 ++ indra/newview/pipeline.cpp | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 1424b57d6f..f028b303f7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -32,8 +32,8 @@ ATTRIBUTE vec3 position; /////////////////////////////////////////////////////////////////////////////// // Output parameters -VARYING vec3 vary_HazeColor; -VARYING float vary_LightNormPosDot; +out vec3 vary_HazeColor; +out float vary_LightNormPosDot; // Inputs uniform vec3 camPosLocal; @@ -56,6 +56,8 @@ uniform float max_y; uniform vec3 glow; uniform float sun_moon_glow_factor; +uniform int cube_snapshot; + // NOTE: Keep these in sync! // indra\newview\app_settings\shaders\class1\deferred\skyV.glsl // indra\newview\app_settings\shaders\class1\deferred\cloudsV.glsl @@ -90,6 +92,8 @@ void main() // Initialize temp variables vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + float scale = cube_snapshot*0.75+1; + sunlight *= scale; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index acbc349567..b49fe35851 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -139,6 +139,8 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->bind(); + sky_shader->uniform1i(LLShaderMgr::CUBE_SNAPSHOT, gCubeSnapshot ? 1 : 0); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); LLViewerTexture* rainbow_tex = gSky.mVOSkyp->getRainbowTex(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index a53b3aac8e..7a5443825d 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -338,7 +338,7 @@ bool addDeferredAttachments(LLRenderTarget& target, bool for_impostor = false) bool valid = true && target.addColorAttachment(GL_RGBA) // frag-data[1] specular OR PBR ORM && target.addColorAttachment(GL_RGBA16F) // frag_data[2] normal+z+fogmask, See: class1\deferred\materialF.glsl & softenlight - && target.addColorAttachment(GL_RGB16); // frag_data[3] PBR emissive + && target.addColorAttachment(GL_RGB16F); // frag_data[3] PBR emissive return valid; } From b81761c1d0c6f29e618b11d71ba9abb314214451 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Mon, 27 Mar 2023 18:29:35 -0500 Subject: [PATCH 30/38] DRTVWR-559 Bump down ambiance scale to compensate for HDRishness. --- indra/newview/app_settings/settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index e0662b8115..d6af39f97e 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10356,7 +10356,7 @@ Type F32 Value - 16 + 8 RenderTonemapper From 08cd239c5f8f4b67b22372e7e608d9ec8e21a26c Mon Sep 17 00:00:00 2001 From: "Jonathan \"Geenz\" Goodman" Date: Tue, 28 Mar 2023 09:46:07 -0700 Subject: [PATCH 31/38] Update the feature table. SL-18563 --- indra/newview/featuretable.txt | 9 ++++++++- indra/newview/featuretable_mac.txt | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index 14d8d3fae5..3d634c7484 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -1,4 +1,4 @@ -version 52 +version 53 // 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 @@ -102,6 +102,7 @@ RenderShadowDetail 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 8 // // Medium Low Graphics Settings @@ -130,6 +131,7 @@ RenderShadowDetail 1 0 WLSkyDetail 1 96 RenderFSAASamples 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 16 // // Medium Graphics Settings (standard) @@ -158,6 +160,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 32 // // Medium High Graphics Settings (deferred enabled) @@ -186,6 +189,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 64 // // High Graphics Settings (deferred + SSAO) @@ -214,6 +218,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 128 // // High Ultra Graphics Settings (deferred + SSAO + shadows) @@ -242,6 +247,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 256 // // Ultra graphics (REALLY PURTY!) @@ -270,6 +276,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 1 +RenderReflectionProbeCount 1 256 // // Class Unknown Hardware (unknown) diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index b7a0ac6e28..eed790ddac 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -1,4 +1,4 @@ -version 47 +version 48 // 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 @@ -71,7 +71,7 @@ RenderGLMultiThreaded 1 0 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 2 RenderScreenSpaceReflections 1 1 -RenderReflectionProbeCount 1 8 +RenderReflectionProbeCount 1 256 // // Low Graphics Settings @@ -100,6 +100,7 @@ RenderFSAASamples 1 0 RenderReflectionsEnabled 1 0 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 8 // // Medium Low Graphics Settings @@ -128,6 +129,7 @@ RenderFSAASamples 1 0 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 16 // // Medium Graphics Settings (standard) @@ -156,6 +158,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 32 // // Medium High Graphics Settings (deferred enabled) @@ -184,6 +187,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 0 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 64 // // High Graphics Settings (deferred + SSAO) @@ -212,6 +216,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 128 // // High Ultra Graphics Settings (deferred + SSAO + shadows) @@ -240,6 +245,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 0 +RenderReflectionProbeCount 1 256 // // Ultra graphics (REALLY PURTY!) @@ -268,6 +274,7 @@ RenderFSAASamples 1 2 RenderReflectionsEnabled 1 1 RenderReflectionProbeDetail 1 1 RenderScreenSpaceReflections 1 1 +RenderReflectionProbeCount 1 256 // // Class Unknown Hardware (unknown) From 10f66c05190585e9de2e85831712323c297d81c4 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 28 Mar 2023 14:30:59 -0500 Subject: [PATCH 32/38] DRTVWR-559 Dynamically adjust exposure. --- indra/llrender/llshadermgr.cpp | 1 + indra/llrender/llshadermgr.h | 1 + .../shaders/class1/deferred/exposureF.glsl | 66 +++++++++++++++++++ .../deferred/postDeferredGammaCorrect.glsl | 9 ++- .../class1/deferred/postDeferredNoTCV.glsl | 2 +- .../shaders/class1/deferred/skyV.glsl | 6 +- .../class2/windlight/atmosphericsFuncs.glsl | 6 +- indra/newview/llviewershadermgr.cpp | 16 +++++ indra/newview/llviewershadermgr.h | 1 + indra/newview/pipeline.cpp | 58 ++++++++++++++-- indra/newview/pipeline.h | 8 ++- 11 files changed, 158 insertions(+), 16 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 08a2e6779e..016cbe6e75 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1238,6 +1238,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("diffuseRect"); mReservedUniforms.push_back("specularRect"); mReservedUniforms.push_back("emissiveRect"); + mReservedUniforms.push_back("exposureMap"); mReservedUniforms.push_back("brdfLut"); mReservedUniforms.push_back("noiseMap"); mReservedUniforms.push_back("lightFunc"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 93ea49d16a..ec3455952b 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -192,6 +192,7 @@ public: DEFERRED_DIFFUSE, // "diffuseRect" DEFERRED_SPECULAR, // "specularRect" DEFERRED_EMISSIVE, // "emissiveRect" + EXPOSURE_MAP, // "exposureMap" DEFERRED_BRDF_LUT, // "brdfLut" DEFERRED_NOISE, // "noiseMap" DEFERRED_LIGHTFUNC, // "lightFunc" diff --git a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl new file mode 100644 index 0000000000..6994a20b79 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl @@ -0,0 +1,66 @@ +/** + * @file exposureF.glsl + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2023, 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]*/ + +out vec4 frag_color; + +uniform sampler2D diffuseRect; +uniform float dt; + +void main() +{ + int samples = 16; + float step = 1.0/(samples-4); + + float start = step; + float end = 1.0-step; + + float w = 0.0; + + vec3 col; + + for (float x = start; x <= end; x += step) + { + for (float y = start; y <= end; y += step) + { + vec2 tc = vec2(x,y); + w += 1.0; + col += texture(diffuseRect, tc).rgb; + } + } + + col /= w; + + // calculate luminance the same way LLColor4::calcHSL does + float mx = max(max(col.r, col.g), col.b); + float mn = min(min(col.r, col.g), col.b); + float lum = (mx + mn) * 0.5; + + frag_color = vec4(lum, lum, lum, dt); +} + diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 87324bca7f..87725affe7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -35,6 +35,7 @@ out vec4 frag_color; uniform sampler2D diffuseRect; uniform sampler2D emissiveRect; +uniform sampler2D exposureMap; uniform vec2 screen_res; VARYING vec2 vary_fragcoord; @@ -107,7 +108,10 @@ uniform float gamma; vec3 toneMap(vec3 color) { - color *= exposure; + float exp_sample = texture(exposureMap, vec2(0.5,0.5)).r; + + float exp_scale = clamp(0.1/exp_sample, 0.4, 8.0); + color *= exposure * exp_scale; #ifdef TONEMAP_ACES_NARKOWICZ color = toneMapACES_Narkowicz(color); @@ -190,6 +194,9 @@ void main() 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; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl index 4d24b4de9a..8b4cac3e64 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoTCV.glsl @@ -33,6 +33,6 @@ void main() { //transform vertex vec4 pos = vec4(position.xyz, 1.0); - gl_Position = pos; + gl_Position = pos; vary_fragcoord = (pos.xy*0.5+0.5); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index f028b303f7..0090155e5c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -91,10 +91,8 @@ void main() vary_LightNormPosDot = rel_pos_lightnorm_dot; // Initialize temp variables - vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; - float scale = cube_snapshot*0.75+1; - sunlight *= scale; - + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color*2.0 : moonlight_color; + // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes vec3 light_atten = (blue_density + vec3(haze_density * 0.25)) * (density_multiplier * max_y); diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index 55e1411be2..f9a1f5e4d6 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -62,7 +62,9 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou vec3 rel_pos_norm = normalize(rel_pos); float rel_pos_len = length(rel_pos); - vec3 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + float scale = sun_up_factor + 1.0; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color: moonlight_color; + sunlight *= scale; // sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -140,7 +142,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou // fudge sunlit and amblit to get consistent lighting compared to legacy // midday before PBR was a thing - sunlit = sunlight.rgb * 0.7; + sunlit = sunlight.rgb / scale; amblit = tmpAmbient.rgb * 0.25; additive *= vec3(1.0 - combined_haze); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 7790013f01..93f4d22ff8 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -187,6 +187,7 @@ LLGLSLShader gDeferredPostProgram; LLGLSLShader gDeferredCoFProgram; LLGLSLShader gDeferredDoFCombineProgram; LLGLSLShader gDeferredPostGammaCorrectProgram; +LLGLSLShader gExposureProgram; LLGLSLShader gFXAAProgram; LLGLSLShader gDeferredPostNoDoFProgram; LLGLSLShader gDeferredWLSkyProgram; @@ -1000,6 +1001,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredPostProgram.unload(); gDeferredCoFProgram.unload(); gDeferredDoFCombineProgram.unload(); + gExposureProgram.unload(); gDeferredPostGammaCorrectProgram.unload(); gFXAAProgram.unload(); gDeferredWLSkyProgram.unload(); @@ -2518,6 +2520,20 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredAvatarAlphaProgram.mFeatures.hasLighting = true; } + if (success) + { + gExposureProgram.mName = "Exposure"; + gExposureProgram.mFeatures.hasSrgb = true; + gExposureProgram.mFeatures.isDeferred = true; + gExposureProgram.mShaderFiles.clear(); + gExposureProgram.clearPermutations(); + gExposureProgram.mShaderFiles.push_back(make_pair("deferred/postDeferredNoTCV.glsl", GL_VERTEX_SHADER)); + gExposureProgram.mShaderFiles.push_back(make_pair("deferred/exposureF.glsl", GL_FRAGMENT_SHADER)); + gExposureProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gExposureProgram.createShader(NULL, NULL); + llassert(success); + } + if (success) { gDeferredPostGammaCorrectProgram.mName = "Deferred Gamma Correction Post Process"; diff --git a/indra/newview/llviewershadermgr.h b/indra/newview/llviewershadermgr.h index 867413b6c9..6fb2bc3fec 100644 --- a/indra/newview/llviewershadermgr.h +++ b/indra/newview/llviewershadermgr.h @@ -235,6 +235,7 @@ extern LLGLSLShader gDeferredDoFCombineProgram; extern LLGLSLShader gFXAAProgram; extern LLGLSLShader gDeferredPostNoDoFProgram; extern LLGLSLShader gDeferredPostGammaCorrectProgram; +extern LLGLSLShader gExposureProgram; extern LLGLSLShader gDeferredAvatarShadowProgram; extern LLGLSLShader gDeferredAvatarAlphaShadowProgram; extern LLGLSLShader gDeferredAvatarAlphaMaskShadowProgram; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7a5443825d..7b72d7f987 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -849,6 +849,13 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) mSceneMap.allocate(resX, resY, GL_RGB, true); } + mPostMap.allocate(resX, resY, GL_RGBA); + + mExposureMap.allocate(1, 1, GL_R16F); + mExposureMap.bindTarget(); + mExposureMap.clear(); + mExposureMap.flush(); + //HACK make screenbuffer allocations start failing after 30 seconds if (gSavedSettings.getBOOL("SimulateFBOFailure")) { @@ -1079,6 +1086,10 @@ void LLPipeline::releaseGLBuffers() mSceneMap.release(); + mExposureMap.release(); + + mPostMap.release(); + for (U32 i = 0; i < 3; i++) { mGlow[i].release(); @@ -7393,7 +7404,36 @@ void LLPipeline::renderFinalize() dst.flush(); } - screenTarget()->bindTarget(); + // exposure sample + { + LL_PROFILE_GPU_ZONE("exposure sample"); + mExposureMap.bindTarget(); + + LLGLDepthTest depth(GL_FALSE, GL_FALSE); + LLGLEnable blend(GL_BLEND); + gGL.setSceneBlendType(LLRender::BT_ALPHA); + + gExposureProgram.bind(); + + S32 channel = 0; + channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); + if (channel > -1) + { + screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); + } + + static LLStaticHashedString dt("dt"); + gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + gGL.getTexUnit(channel)->unbind(screenTarget()->getUsage()); + gExposureProgram.unbind(); + mExposureMap.flush(); + } + + mPostMap.bindTarget(); // gamma correct lighting { @@ -7420,6 +7460,12 @@ void LLPipeline::renderFinalize() mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } + channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::EXPOSURE_MAP, mExposureMap.getUsage()); + if (channel > -1) + { + mExposureMap.bindTexture(0, channel); + } + gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screenTarget()->getWidth(), screenTarget()->getHeight()); static LLCachedControl exposure(gSavedSettings, "RenderExposure", 1.f); @@ -7437,7 +7483,7 @@ void LLPipeline::renderFinalize() gDeferredPostGammaCorrectProgram.unbind(); } - screenTarget()->flush(); + mPostMap.flush(); LLVertexBuffer::unbind(); } @@ -7466,10 +7512,10 @@ void LLPipeline::renderFinalize() shader->bind(); shader->uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, width, height); - channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); + channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mPostMap.getUsage()); if (channel > -1) { - screenTarget()->bindTexture(0, channel); + mPostMap.bindTexture(0, channel); } { @@ -7480,7 +7526,7 @@ void LLPipeline::renderFinalize() gGL.flush(); - shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); + shader->disableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mPostMap.getUsage()); shader->unbind(); mRT->fxaaBuffer.flush(); @@ -7535,7 +7581,7 @@ void LLPipeline::renderFinalize() S32 screen_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DIFFUSE); S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); - gGL.getTexUnit(screen_channel)->bind(screenTarget()); + gGL.getTexUnit(screen_channel)->bind(&mPostMap); gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 4cefb719fd..19d511c2c4 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -300,8 +300,6 @@ public: void bindReflectionProbes(LLGLSLShader& shader); void unbindReflectionProbes(LLGLSLShader& shader); - - void renderDeferredLighting(); void postDeferredGammaCorrect(LLRenderTarget* screen_target); @@ -679,6 +677,12 @@ public: // for use by SSR LLRenderTarget mSceneMap; + // exposure map for getting average color in scene + LLRenderTarget mExposureMap; + + // tonemapped and gamma corrected render ready for post + LLRenderTarget mPostMap; + LLCullResult mSky; LLCullResult mReflectedObjects; LLCullResult mRefractedObjects; From 81c440a4a962a314d85cee854365e6593b72e87c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 28 Mar 2023 15:51:29 -0500 Subject: [PATCH 33/38] DRTVWR-559 Dynamic exposure followup -- balance moon brightness and add glow to exposure sample. --- .../app_settings/shaders/class1/deferred/cloudsV.glsl | 2 +- .../app_settings/shaders/class1/deferred/exposureF.glsl | 3 ++- .../shaders/class1/deferred/postDeferredGammaCorrect.glsl | 2 +- .../newview/app_settings/shaders/class1/deferred/skyV.glsl | 2 +- .../shaders/class2/windlight/atmosphericsFuncs.glsl | 5 ++--- indra/newview/pipeline.cpp | 6 ++++++ 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl index 5ca210863e..3a7552d23e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl @@ -114,7 +114,7 @@ void main() float rel_pos_len = length(rel_pos); // Initialize temp variables - vec3 sunlight = sunlight_color; + vec3 sunlight = sunlight_color*2.0; vec3 light_atten; // Sunlight attenuation effect (hue and brightness) due to atmosphere diff --git a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl index 6994a20b79..d0269735fd 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl @@ -30,6 +30,7 @@ out vec4 frag_color; uniform sampler2D diffuseRect; +uniform sampler2D emissiveRect; uniform float dt; void main() @@ -50,7 +51,7 @@ void main() { vec2 tc = vec2(x,y); w += 1.0; - col += texture(diffuseRect, tc).rgb; + col += texture(diffuseRect, tc).rgb + texture(emissiveRect, tc).rgb; } } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 87725affe7..834cf9dc43 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -110,7 +110,7 @@ vec3 toneMap(vec3 color) { float exp_sample = texture(exposureMap, vec2(0.5,0.5)).r; - float exp_scale = clamp(0.1/exp_sample, 0.4, 8.0); + float exp_scale = clamp(0.1/exp_sample, 0.5, 8.0); color *= exposure * exp_scale; #ifdef TONEMAP_ACES_NARKOWICZ diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 0090155e5c..08fbc4bce8 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -91,7 +91,7 @@ void main() vary_LightNormPosDot = rel_pos_lightnorm_dot; // Initialize temp variables - vec3 sunlight = (sun_up_factor == 1) ? sunlight_color*2.0 : moonlight_color; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color*2.0 : moonlight_color*0.5; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index f9a1f5e4d6..7129718ff8 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -62,9 +62,8 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou vec3 rel_pos_norm = normalize(rel_pos); float rel_pos_len = length(rel_pos); - float scale = sun_up_factor + 1.0; - vec3 sunlight = (sun_up_factor == 1) ? sunlight_color: moonlight_color; - sunlight *= scale; + float scale = 2.0; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color * scale: moonlight_color/scale; // sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7b72d7f987..da8c46de83 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7422,6 +7422,12 @@ void LLPipeline::renderFinalize() screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); } + channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, screenTarget()->getUsage()); + if (channel > -1) + { + mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + } + static LLStaticHashedString dt("dt"); gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); From bf9d090045d7baf72f2ba7eadab0adc9d5c8f553 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Mon, 27 Mar 2023 15:20:38 -0700 Subject: [PATCH 34/38] SL-19331: No need to create texture in doMediaTexUpdate - should already be handled by preMediaTexUpdate --- indra/newview/llviewermedia.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 8570c0cd5d..b02bfff099 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -2961,12 +2961,15 @@ void LLViewerMediaImpl::doMediaTexUpdate(LLViewerMediaTexture* media_tex, U8* da LL_PROFILE_ZONE_SCOPED_CATEGORY_MEDIA; mLock.lock(); // don't allow media source tear-down during update + const LLGLuint tex_name = media_tex->getGLTexture() ? media_tex->getGLTexture()->getTexName() : (LLGLuint)0; + if (!tex_name) + { + llassert(false); + return; + } + // wrap "data" in an LLImageRaw but do NOT make a copy LLPointer raw = new LLImageRaw(data, media_tex->getWidth(), media_tex->getHeight(), media_tex->getComponents(), true); - - // Allocate GL texture based on LLImageRaw but do NOT copy to GL - LLGLuint tex_name = 0; - media_tex->createGLTexture(0, raw, 0, TRUE, LLGLTexture::OTHER, true, &tex_name); // copy just the subimage covered by the image raw to GL media_tex->setSubImage(data, data_width, data_height, x_pos, y_pos, width, height, tex_name); From a2a777ebe4a72412690ebe68d9510f91b51a978a Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 29 Mar 2023 10:28:21 -0700 Subject: [PATCH 35/38] SL-19331: When initializing a media prim, set the mipmap state correctly from the beginning --- indra/newview/llviewermedia.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index b02bfff099..0bd58b8d4d 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1564,7 +1564,8 @@ LLViewerMediaImpl::LLViewerMediaImpl( const LLUUID& texture_id, // connect this media_impl to the media texture, creating it if it doesn't exist.0 // This is necessary because we need to be able to use getMaxVirtualSize() even if the media plugin is not loaded. - LLViewerMediaTexture* media_tex = LLViewerTextureManager::getMediaTexture(mTextureId); + const BOOL use_mipmaps = FALSE; + LLViewerMediaTexture* media_tex = LLViewerTextureManager::getMediaTexture(mTextureId, use_mipmaps); if(media_tex) { media_tex->setMediaImpl(); @@ -3005,10 +3006,10 @@ LLViewerMediaTexture* LLViewerMediaImpl::updateMediaImage() } llassert(!mTextureId.isNull()); - LLViewerMediaTexture* media_tex = LLViewerTextureManager::getMediaTexture( mTextureId ); + const BOOL use_mipmaps = FALSE; + LLViewerMediaTexture* media_tex = LLViewerTextureManager::getMediaTexture( mTextureId, use_mipmaps ); if ( mNeedsNewTexture - || media_tex->getUseMipMaps() || (media_tex->getWidth() != mMediaSource->getTextureWidth()) || (media_tex->getHeight() != mMediaSource->getTextureHeight()) || (mTextureUsedWidth != mMediaSource->getWidth()) @@ -3024,8 +3025,6 @@ LLViewerMediaTexture* LLViewerMediaImpl::updateMediaImage() // MEDIAOPT: check to see if size actually changed before doing work media_tex->destroyGLTexture(); - // MEDIAOPT: apparently just calling setUseMipMaps(FALSE) doesn't work? - media_tex->reinit(FALSE); // probably not needed // MEDIAOPT: seems insane that we actually have to make an imageraw then // immediately discard it From b130831106d058f0be5414a9a3bcaa99636c7bc0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 29 Mar 2023 13:24:07 -0500 Subject: [PATCH 36/38] DRTVWR-559 Dynamic exposure followup -- stochastic sampling, weight based on luminance and distance to center of screen, rebalance night, don't rely on blending not clamping R16F. --- .../shaders/class1/deferred/exposureF.glsl | 45 +++++++--- .../deferred/postDeferredGammaCorrect.glsl | 3 +- .../shaders/class1/deferred/skyV.glsl | 2 +- .../class2/windlight/atmosphericsFuncs.glsl | 2 +- indra/newview/pipeline.cpp | 83 ++++++++++--------- indra/newview/pipeline.h | 1 + 6 files changed, 82 insertions(+), 54 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl index d0269735fd..689929fe38 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl @@ -31,12 +31,22 @@ out vec4 frag_color; uniform sampler2D diffuseRect; uniform sampler2D emissiveRect; +uniform sampler2D exposureMap; + uniform float dt; +uniform vec2 noiseVec; + +// calculate luminance the same way LLColor4::calcHSL does +float lum(vec3 col) +{ + float mx = max(max(col.r, col.g), col.b); + float mn = min(min(col.r, col.g), col.b); + return (mx + mn) * 0.5; +} void main() { - int samples = 16; - float step = 1.0/(samples-4); + float step = 1.0/32.0; float start = step; float end = 1.0-step; @@ -45,23 +55,38 @@ void main() vec3 col; + vec2 nz = noiseVec * step * 0.5; + for (float x = start; x <= end; x += step) { for (float y = start; y <= end; y += step) { - vec2 tc = vec2(x,y); - w += 1.0; - col += texture(diffuseRect, tc).rgb + texture(emissiveRect, tc).rgb; + vec2 tc = vec2(x,y) + nz; + vec3 c = texture(diffuseRect, tc).rgb + texture(emissiveRect, tc).rgb; + float L = max(lum(c), 0.25); + + float d = length(vec2(0.5)-tc); + d = 1.0-d; + d *= d; + d *= d; + d *= d; + L *= d; + + w += L; + + col += c * L; } } col /= w; - // calculate luminance the same way LLColor4::calcHSL does - float mx = max(max(col.r, col.g), col.b); - float mn = min(min(col.r, col.g), col.b); - float lum = (mx + mn) * 0.5; + float L = lum(col); - frag_color = vec4(lum, lum, lum, dt); + float s = clamp(0.1/L, 0.5, 4.0); + + float prev = texture(exposureMap, vec2(0.5,0.5)).r; + s = mix(prev, s, min(dt*2.0, 0.04)); + + frag_color = vec4(s, s, s, dt); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 834cf9dc43..4ac1ff9368 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -108,9 +108,8 @@ uniform float gamma; vec3 toneMap(vec3 color) { - float exp_sample = texture(exposureMap, vec2(0.5,0.5)).r; + float exp_scale = texture(exposureMap, vec2(0.5,0.5)).r; - float exp_scale = clamp(0.1/exp_sample, 0.5, 8.0); color *= exposure * exp_scale; #ifdef TONEMAP_ACES_NARKOWICZ diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 08fbc4bce8..fc6291d438 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -91,7 +91,7 @@ void main() vary_LightNormPosDot = rel_pos_lightnorm_dot; // Initialize temp variables - vec3 sunlight = (sun_up_factor == 1) ? sunlight_color*2.0 : moonlight_color*0.5; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color*2.0 : moonlight_color*0.75; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index 7129718ff8..0d3dbf85e2 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -63,7 +63,7 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou vec3 rel_pos_norm = normalize(rel_pos); float rel_pos_len = length(rel_pos); float scale = 2.0; - vec3 sunlight = (sun_up_factor == 1) ? sunlight_color * scale: moonlight_color/scale; + vec3 sunlight = (sun_up_factor == 1) ? sunlight_color * scale: moonlight_color*0.75; // sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index da8c46de83..eaec698f84 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -116,27 +116,7 @@ #include "llenvironment.h" #include "llsettingsvo.h" -#ifdef _DEBUG -// Debug indices is disabled for now for debug performance - djs 4/24/02 -//#define DEBUG_INDICES -#else -//#define DEBUG_INDICES -#endif - -// Expensive and currently broken -// -#define MATERIALS_IN_REFLECTIONS 0 - -// NOTE: Keep in sync with indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml -// NOTE: Unused consts are commented out since some compilers (on macOS) may complain about unused variables. -// const S32 WATER_REFLECT_NONE_WATER_OPAQUE = -2; - //const S32 WATER_REFLECT_NONE_WATER_TRANSPARENT = -1; - //const S32 WATER_REFLECT_MINIMAL = 0; -// const S32 WATER_REFLECT_TERRAIN = 1; - //const S32 WATER_REFLECT_STATIC_OBJECTS = 2; - //const S32 WATER_REFLECT_AVATARS = 3; - //const S32 WATER_REFLECT_EVERYTHING = 4; - +extern BOOL gSnapshot; bool gShiftFrame = false; //cached settings @@ -851,11 +831,6 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) mPostMap.allocate(resX, resY, GL_RGBA); - mExposureMap.allocate(1, 1, GL_R16F); - mExposureMap.bindTarget(); - mExposureMap.clear(); - mExposureMap.flush(); - //HACK make screenbuffer allocations start failing after 30 seconds if (gSavedSettings.getBOOL("SimulateFBOFailure")) { @@ -1086,8 +1061,6 @@ void LLPipeline::releaseGLBuffers() mSceneMap.release(); - mExposureMap.release(); - mPostMap.release(); for (U32 i = 0; i < 3; i++) @@ -1110,6 +1083,10 @@ void LLPipeline::releaseLUTBuffers() } mPbrBrdfLut.release(); + + mExposureMap.release(); + mLastExposure.release(); + } void LLPipeline::releaseShadowBuffers() @@ -1286,6 +1263,13 @@ void LLPipeline::createLUTBuffers() gDeferredGenBrdfLutProgram.unbind(); mPbrBrdfLut.flush(); + + mExposureMap.allocate(1, 1, GL_R16F); + mExposureMap.bindTarget(); + mExposureMap.clear(); + mExposureMap.flush(); + + mLastExposure.allocate(1, 1, GL_R16F); } @@ -7407,30 +7391,50 @@ void LLPipeline::renderFinalize() // exposure sample { LL_PROFILE_GPU_ZONE("exposure sample"); + + { + // copy last frame's exposure into mLastExposure + mLastExposure.bindTarget(); + gCopyProgram.bind(); + gGL.getTexUnit(0)->bind(&mExposureMap); + + mScreenTriangleVB->setBuffer(); + mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); + + mLastExposure.flush(); + } + + mExposureMap.bindTarget(); LLGLDepthTest depth(GL_FALSE, GL_FALSE); - LLGLEnable blend(GL_BLEND); - gGL.setSceneBlendType(LLRender::BT_ALPHA); - + gExposureProgram.bind(); S32 channel = 0; - channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screenTarget()->getUsage()); + channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE); if (channel > -1) { screenTarget()->bindTexture(0, channel, LLTexUnit::TFO_POINT); } - channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE, screenTarget()->getUsage()); + channel = gExposureProgram.enableTexture(LLShaderMgr::DEFERRED_EMISSIVE); if (channel > -1) { - mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); + mGlow[1].bindTexture(0, channel); + } + + channel = gExposureProgram.enableTexture(LLShaderMgr::EXPOSURE_MAP); + if (channel > -1) + { + mLastExposure.bindTexture(0, channel); } static LLStaticHashedString dt("dt"); + static LLStaticHashedString noiseVec("noiseVec"); gExposureProgram.uniform1f(dt, gFrameIntervalSeconds); - + gExposureProgram.uniform2f(noiseVec, ll_frand() * 2.0 - 1.0, ll_frand() * 2.0 - 1.0); + mScreenTriangleVB->setBuffer(); mScreenTriangleVB->drawArrays(LLRender::TRIANGLES, 0, 3); @@ -7562,9 +7566,8 @@ void LLPipeline::renderFinalize() 2.f / width * scale_x, 2.f / height * scale_y); { - // at this point we should pointed at the backbuffer - llassert(LLRenderTarget::sCurFBO == 0); - + // at this point we should pointed at the backbuffer (or a snapshot render target) + llassert(gSnapshot || LLRenderTarget::sCurFBO == 0); LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); S32 depth_channel = shader->getTextureChannel(LLShaderMgr::DEFERRED_DEPTH); gGL.getTexUnit(depth_channel)->bind(&mRT->deferredScreen, true); @@ -7577,8 +7580,8 @@ void LLPipeline::renderFinalize() } else { - // at this point we should pointed at the backbuffer - llassert(LLRenderTarget::sCurFBO == 0); + // at this point we should pointed at the backbuffer (or a snapshot render target) + llassert(gSnapshot || LLRenderTarget::sCurFBO == 0); LLGLDepthTest depth_test(GL_TRUE, GL_TRUE, GL_ALWAYS); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 19d511c2c4..eb30c85993 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -679,6 +679,7 @@ public: // exposure map for getting average color in scene LLRenderTarget mExposureMap; + LLRenderTarget mLastExposure; // tonemapped and gamma corrected render ready for post LLRenderTarget mPostMap; From 8018e7935a8c25a92d700aeceb3d8f75d3ea5f16 Mon Sep 17 00:00:00 2001 From: Cosmic Linden Date: Wed, 29 Mar 2023 14:10:02 -0700 Subject: [PATCH 37/38] SL-19331: Clarify that mipmapping on media prims being disabled is known behavior that should be corrected at some point --- indra/newview/llviewermedia.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 0bd58b8d4d..d7426b7092 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -79,6 +79,8 @@ #include // for SkinFolder listener #include +// *TODO: Consider enabling mipmaps (they have been disabled for a long time). Likely has a significant performance impact for tiled/high texture repeat media. Mip generation in a shader may also be an option if necessary. +constexpr BOOL USE_MIPMAPS = FALSE; void init_threaded_picker_load_dialog(LLPluginClassMedia* plugin, LLFilePicker::ELoadFilter filter, bool get_multiple) { @@ -1564,8 +1566,8 @@ LLViewerMediaImpl::LLViewerMediaImpl( const LLUUID& texture_id, // connect this media_impl to the media texture, creating it if it doesn't exist.0 // This is necessary because we need to be able to use getMaxVirtualSize() even if the media plugin is not loaded. - const BOOL use_mipmaps = FALSE; - LLViewerMediaTexture* media_tex = LLViewerTextureManager::getMediaTexture(mTextureId, use_mipmaps); + // *TODO: Consider enabling mipmaps (they have been disabled for a long time). Likely has a significant performance impact for tiled/high texture repeat media. Mip generation in a shader may also be an option if necessary. + LLViewerMediaTexture* media_tex = LLViewerTextureManager::getMediaTexture(mTextureId, USE_MIPMAPS); if(media_tex) { media_tex->setMediaImpl(); @@ -3006,8 +3008,8 @@ LLViewerMediaTexture* LLViewerMediaImpl::updateMediaImage() } llassert(!mTextureId.isNull()); - const BOOL use_mipmaps = FALSE; - LLViewerMediaTexture* media_tex = LLViewerTextureManager::getMediaTexture( mTextureId, use_mipmaps ); + // *TODO: Consider enabling mipmaps (they have been disabled for a long time). Likely has a significant performance impact for tiled/high texture repeat media. Mip generation in a shader may also be an option if necessary. + LLViewerMediaTexture* media_tex = LLViewerTextureManager::getMediaTexture( mTextureId, USE_MIPMAPS ); if ( mNeedsNewTexture || (media_tex->getWidth() != mMediaSource->getTextureWidth()) From f5fb3ae27140d7455956ba7264dc0a545fb2ec3c Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Wed, 29 Mar 2023 16:53:19 -0500 Subject: [PATCH 38/38] DRTVWR-559 Drop the upper bound on exposure. --- .../newview/app_settings/shaders/class1/deferred/exposureF.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl index 689929fe38..ff37f9e4b3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/exposureF.glsl @@ -82,7 +82,7 @@ void main() float L = lum(col); - float s = clamp(0.1/L, 0.5, 4.0); + float s = clamp(0.1/L, 0.5, 2.0); float prev = texture(exposureMap, vec2(0.5,0.5)).r; s = mix(prev, s, min(dt*2.0, 0.04));