diff --git a/indra/llprimitive/llprimitive.cpp b/indra/llprimitive/llprimitive.cpp index 42d3678af4ffc72f42075ce780a81de073c1c9fc..85845133665c818c1bf3ae1e7a9aa8e039fcbaae 100644 --- a/indra/llprimitive/llprimitive.cpp +++ b/indra/llprimitive/llprimitive.cpp @@ -87,7 +87,7 @@ const F32 LIGHT_MAX_CUTOFF = 180.f; // reflection probes const F32 REFLECTION_PROBE_MIN_AMBIANCE = 0.f; -const F32 REFLECTION_PROBE_MAX_AMBIANCE = 1.f; +const F32 REFLECTION_PROBE_MAX_AMBIANCE = 100.f; const F32 REFLECTION_PROBE_DEFAULT_AMBIANCE = 0.f; const F32 REFLECTION_PROBE_MIN_CLIP_DISTANCE = 0.f; const F32 REFLECTION_PROBE_MAX_CLIP_DISTANCE = 1024.f; diff --git a/indra/llprimitive/lltextureentry.cpp b/indra/llprimitive/lltextureentry.cpp index a665db378b358dc040a30da9d8311d19a8f1ef34..17b1f4cf5cbdba443e9d5fb582145db5f4027f65 100644 --- a/indra/llprimitive/lltextureentry.cpp +++ b/indra/llprimitive/lltextureentry.cpp @@ -559,10 +559,17 @@ void LLTextureEntry::setGLTFMaterial(LLGLTFMaterial* material, bool local_origin } } -void LLTextureEntry::setGLTFMaterialOverride(LLGLTFMaterial* mat) +S32 LLTextureEntry::setGLTFMaterialOverride(LLGLTFMaterial* mat) { llassert(mat == nullptr || getGLTFMaterial() != nullptr); // if override is not null, base material must not be null - mGLTFMaterialOverrides = mat; + if (mat == mGLTFMaterialOverrides) + { + return TEM_CHANGE_NONE; + } + + mGLTFMaterialOverrides = mat; + + return TEM_CHANGE_TEXTURE; } S32 LLTextureEntry::setBaseMaterial() diff --git a/indra/llprimitive/lltextureentry.h b/indra/llprimitive/lltextureentry.h index 857c706586c100ed99ded94b52be748cb5035f34..bca5960eb17d90e53a167c382b7e90c4a54d7c62 100644 --- a/indra/llprimitive/lltextureentry.h +++ b/indra/llprimitive/lltextureentry.h @@ -202,7 +202,7 @@ class LLTextureEntry final // GLTF override LLGLTFMaterial* getGLTFMaterialOverride() const { return mGLTFMaterialOverrides; } - void setGLTFMaterialOverride(LLGLTFMaterial* mat); + S32 setGLTFMaterialOverride(LLGLTFMaterial* mat); // Clear most overrides so the render material better matches the material // ID (preserve transforms). If the overrides become passthrough, set the // overrides to nullptr. diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 5b53ad0e22e868fa43f0b40ee9e314a1566b19dc..c79bc31a7da7b8a347801093d5201a8cff9233cc 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -263,7 +263,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) } } - if (features->hasAtmospherics || features->isDeferred) + if (features->hasAtmospherics || features->isDeferred || features->hasTransport) { if (!shader->attachFragmentObject("windlight/atmosphericsFuncs.glsl")) { return FALSE; diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 38f7a36b356cc6bcd097899809f63abcf82cd67a..78d9c1e3d56ca4be4b224e3b865e220bfc15d32b 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -2441,7 +2441,7 @@ if (LL_TESTS) # llremoteparcelrequest.cpp llviewerhelputil.cpp llversioninfo.cpp - llvocache.cpp +# llvocache.cpp llworldmap.cpp llworldmipmap.cpp ) @@ -2455,12 +2455,12 @@ if (LL_TESTS) #llviewertexturelist.cpp ) - set_source_files_properties( - llvocache.cpp - PROPERTIES - LL_TEST_ADDITIONAL_SOURCE_FILES ../llmessage/lldatapacker.cpp - LL_TEST_ADDITIONAL_PROJECTS "llprimitive" - ) +# set_source_files_properties( +# llvocache.cpp +# PROPERTIES +# LL_TEST_ADDITIONAL_SOURCE_FILES ../llmessage/lldatapacker.cpp +# LL_TEST_ADDITIONAL_PROJECTS "llprimitive" +# ) set(test_libs llcommon diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index d018adce7b60301461c5a97775c78cb372680723..8fe14d119406b410da352c1c54e864b8bc5db1ec 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10824,17 +10824,6 @@ <key>Value</key> <integer>128</integer> </map> - <key>RenderReflectionProbeAmbianceScale</key> - <map> - <key>Comment</key> - <string>Scaler to apply to reflection probes to over-brighten sky contributions to indirect light</string> - <key>Persist</key> - <integer>1</integer> - <key>Type</key> - <string>F32</string> - <key>Value</key> - <real>8</real> - </map> <key>RenderTonemapper</key> <map> <key>Comment</key> diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index d1aedae16048073067aca976b9e385aa3e4de87f..5f659135365d6a8b02ce9b6f1dce2c22846c28c9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -42,7 +42,6 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cl); vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); #ifdef HAS_ALPHA_MASK uniform float minimum_alpha; @@ -86,8 +85,9 @@ void main() #endif #ifndef IS_HUD - color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = srgb_to_linear(color.rgb); + color.rgb = fullbrightAtmosTransport(color.rgb); + #endif frag_color.rgb = color.rgb; diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 0090155e5cd61d7585e25ac52e54e8449e471903..62d134188c7d24e8b3d1dc53552342887a4a1845 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 : moonlight_color; // 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/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl index 7ce5f4a332dfa67327f4f2b58095fb4a8d4559e9..3e50174cdd179015ad7d2a2e6e1dba71975241c3 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl @@ -274,9 +274,7 @@ void main() color.rgb *= diffuse_linear.rgb; - color.rgb = linear_to_srgb(color.rgb); color.rgb = atmosFragLightingLinear(color.rgb, additive, atten); - color.rgb = srgb_to_linear(color.rgb); vec4 light = vec4(0,0,0,0); diff --git a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl index fb76db99a043320c7dc5bc9e21720689fc6b1cd8..b76443f0f09876c490eb0a92a8bad9c19bb87253 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/pbralphaF.glsl @@ -83,7 +83,6 @@ vec3 linear_to_srgb(vec3 c); void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); vec3 atmosFragLightingLinear(vec3 color, vec3 additive, vec3 atten); -vec3 scaleSoftClipFragLinear(vec3 color); void calcHalfVectors(vec3 lv, vec3 n, vec3 v, out vec3 h, out vec3 l, out float nh, out float nl, out float nv, out float vh, out float lightDist); float calcLegacyDistanceAttenuation(float distance, float falloff); @@ -236,11 +235,8 @@ void main() color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten, spec); glare += max(max(spec.r, spec.g), spec.b); - 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); - + vec3 light = vec3(0); // Punctual lights diff --git a/indra/newview/app_settings/shaders/class2/interface/irradianceGenF.glsl b/indra/newview/app_settings/shaders/class2/interface/irradianceGenF.glsl index baf68e11f423df021bc3c1efa83b8616f48f58c3..d21af946e05c0972824319da20d35bd5c0c02324 100644 --- a/indra/newview/app_settings/shaders/class2/interface/irradianceGenF.glsl +++ b/indra/newview/app_settings/shaders/class2/interface/irradianceGenF.glsl @@ -32,7 +32,6 @@ uniform samplerCubeArray reflectionProbes; uniform int sourceIdx; uniform float max_probe_lod; -uniform float ambiance_scale; in vec3 vary_dir; @@ -200,8 +199,6 @@ vec4 filterColor(vec3 N) color /= float(u_sampleCount); - color.rgb *= ambiance_scale; - return color; } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index 1d024982090f94892b909348d09be92fdfdd6f2d..22e93496d2f801576445c52d24f508dd2a04f3c8 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -30,10 +30,14 @@ vec3 scaleSoftClipFrag(vec3 light); vec3 srgb_to_linear(vec3 col); vec3 linear_to_srgb(vec3 col); +uniform int sun_up_factor; + vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) { light *= atten.r; - light += additive * 2.0; + additive = srgb_to_linear(additive*2.0); + additive *= sun_up_factor + 1.0; + light += additive; return light; } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl index 47b69f6639805e5679145ae843318966b7d6ab1b..a34ade7d77ccc25154c26f2bea9863b33443c5d6 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsFuncs.glsl @@ -63,9 +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 = sun_up_factor + 1; 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 @@ -143,7 +141,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 / scale; + sunlit = sunlight.rgb; amblit = tmpAmbient.rgb * 0.25; additive *= vec3(1.0 - combined_haze); diff --git a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl index 6aa719d2001239e848d902e759b47e40f8496e6d..8221ba9516a0e2c028f1f89cfa9ff4c6a6f075d7 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/transportF.glsl @@ -30,14 +30,13 @@ vec3 getAdditiveColor(); vec3 getAtmosAttenuation(); -vec3 srgb_to_linear(vec3 col); -vec3 linear_to_srgb(vec3 col); +vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); + +// the below implementations are deprecated but remain here as adapters for shaders that haven't been refactored yet vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { - light *= atten.r; - light += additive * 2.0; - return light; + return atmosFragLighting(light, additive, atten); } vec3 atmosTransport(vec3 light) @@ -45,30 +44,17 @@ vec3 atmosTransport(vec3 light) return atmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); } -vec3 fullbrightAtmosTransportFragLinear(vec3 light, vec3 additive, vec3 atten) -{ - // same as non-linear version, probably fine - //float brightness = dot(light.rgb * 0.5, vec3(0.3333)) + 0.1; - //return mix(atmosTransportFrag(light.rgb, additive, atten), light.rgb + additive, brightness * brightness); - return atmosTransportFrag(light, additive, atten); -} - vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten) { - //float brightness = dot(light.rgb * 0.5, vec3(0.3333)) + 0.1; - //return mix(atmosTransportFrag(light.rgb, additive, atten), light.rgb + additive, brightness * brightness); return atmosTransportFrag(light, additive, atten); } vec3 fullbrightAtmosTransport(vec3 light) { - //return fullbrightAtmosTransportFrag(light, getAdditiveColor(), getAtmosAttenuation()); return atmosTransport(light); } vec3 fullbrightShinyAtmosTransport(vec3 light) { - //float brightness = dot(light.rgb, vec3(0.33333)); - //return mix(atmosTransport(light.rgb), (light.rgb + getAdditiveColor().rgb) * (2.0 - brightness), brightness * brightness); return atmosTransport(light); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl index b90de7609bff6201f52eedf6f8c586b983d50854..f6bed16c8435da03359f5db096226a0371439a44 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl @@ -43,9 +43,7 @@ VARYING vec3 vary_position; uniform samplerCube environmentMap; -vec3 fullbrightShinyAtmosTransport(vec3 light); vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten); -vec3 fullbrightScaleSoftClip(vec3 light); void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten, bool use_ao); @@ -88,9 +86,8 @@ void main() sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, vec2(0), pos.xyz, norm.xyz, spec.a, env_intensity); applyLegacyEnv(color.rgb, legacyenv, spec, pos, norm, env_intensity); - color.rgb = fullbrightAtmosTransportFrag(color.rgb, additive, atten); - color.rgb = fullbrightScaleSoftClip(color.rgb); color.rgb = srgb_to_linear(color.rgb); + color.rgb = fullbrightAtmosTransportFrag(color.rgb, additive, atten); #endif color.a = 1.0; diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl index 6e41df34a4fd833c570763167d96c3c749558cec..02ab4494f6ea19bbf592c75220431c99b9a589df 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl @@ -44,7 +44,6 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); vec3 atmosFragLightingLinear(vec3 l, vec3 additive, vec3 atten); vec3 scaleSoftClipFragLinear(vec3 l); void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); -vec3 fullbrightAtmosTransportFragLinear(vec3 light, vec3 additive, vec3 atten); vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cs); @@ -386,10 +385,7 @@ void main() glare += cur_glare; } - 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); vec3 npos = normalize(-pos.xyz); vec3 light = vec3(0, 0, 0); diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index 03cf6ddc25401ab7315038e78c1bbb810915fd15..e19d780e7fc89ae2d5fb9f04a198850fb1693529 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -70,7 +70,6 @@ vec4 getPositionWithDepth(vec2 pos_screen, float depth); void calcAtmosphericVarsLinear(vec3 inPositionEye, vec3 norm, vec3 light_dir, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); vec3 atmosFragLightingLinear(vec3 l, vec3 additive, vec3 atten); vec3 scaleSoftClipFragLinear(vec3 l); -vec3 fullbrightAtmosTransportFragLinear(vec3 light, vec3 additive, vec3 atten); // reflection probe interface void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, @@ -211,6 +210,7 @@ void main() { //should only be true of WL sky, just port over base color value color = srgb_to_linear(texture2D(emissiveRect, tc).rgb); + color *= sun_up_factor + 1.0; } else { @@ -261,9 +261,7 @@ void main() if (do_atmospherics) { - color = linear_to_srgb(color); color = atmosFragLightingLinear(color, additive, atten); - color = srgb_to_linear(color); } } diff --git a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl index 9da86759c9e82b6542d02df9650176ffb8cb4bb6..ec0439fa97c66c7ea6ab4ae1a73a6b1b16c5de8a 100644 --- a/indra/newview/app_settings/shaders/class3/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/environment/waterF.glsl @@ -282,11 +282,7 @@ void main() color = mix(color, fb.rgb, f); - color.rgb = linear_to_srgb(color.rgb); color = atmosFragLightingLinear(color, additive, atten); - color = scaleSoftClipFragLinear(color); - color.rgb = srgb_to_linear(color.rgb); - float spec = min(max(max(punctual.r, punctual.g), punctual.b), 0.05); diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index b0e74b5029818dd37c379c4586c999553d6efac5..6acebf6d08dce0bb3d561fbc9a085c69f0a7c665 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -4243,7 +4243,7 @@ U32 LLAppViewer::getObjectCacheVersion() { // Viewer object cache version, change if object update // format changes. JC - const U32 INDRA_OBJECT_CACHE_VERSION = 15; + const U32 INDRA_OBJECT_CACHE_VERSION = 16; return INDRA_OBJECT_CACHE_VERSION; } diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp index 2e71b4fa87b8a730d6088932c334e835a16f4a77..4efe1ad189c76d332a95872ccfc68250bf9a06f3 100644 --- a/indra/newview/llfetchedgltfmaterial.cpp +++ b/indra/newview/llfetchedgltfmaterial.cpp @@ -89,7 +89,7 @@ void LLFetchedGLTFMaterial::bind(LLViewerTexture* media_tex) if (!LLPipeline::sShadowRender) { - if (mNormalTexture.notNull()) + if (mNormalTexture.notNull() && mNormalTexture->getDiscardLevel() <= 4) { shader->bindTexture(LLShaderMgr::BUMP_MAP, mNormalTexture); } diff --git a/indra/newview/llgltfmateriallist.cpp b/indra/newview/llgltfmateriallist.cpp index 060820b6392a3d9a0141775bad39a7812c5aea8e..a01bda13500a83ec8563ce1fc890a1ff1b53e8f8 100644 --- a/indra/newview/llgltfmateriallist.cpp +++ b/indra/newview/llgltfmateriallist.cpp @@ -191,14 +191,7 @@ class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler { LL_DEBUGS("GLTF") << "material overrides cache" << LL_ENDL; - // default to main region if message doesn't specify - LLViewerRegion * region = gAgent.getRegion();; - - if (object_override.mHasRegionHandle) - { - // TODO start requiring this once server sends this for all messages - region = LLWorld::instance().getRegionFromHandle(object_override.mRegionHandle); - } + LLViewerRegion * region = LLWorld::instance().getRegionFromHandle(object_override.mRegionHandle); if (region) { @@ -247,8 +240,8 @@ class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler { results.reserve(object_override.mSides.size()); // parse json - std::map<S32, std::string>::const_iterator iter = object_override.mSides.begin(); - std::map<S32, std::string>::const_iterator end = object_override.mSides.end(); + std::unordered_map<S32, std::string>::const_iterator iter = object_override.mSides.begin(); + std::unordered_map<S32, std::string>::const_iterator end = object_override.mSides.end(); while (iter != end) { LLPointer<LLGLTFMaterial> override_data = new LLGLTFMaterial(); @@ -277,7 +270,6 @@ class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler }, [object_override, this](std::vector<ReturnData> results) // Callback to main thread { - LLViewerObject * obj = gObjectList.findObject(object_override.mObjectId); if (results.size() > 0 ) @@ -291,23 +283,16 @@ class LLGLTFMaterialOverrideDispatchHandler : public LLDispatchHandler // flag this side to not be nulled out later side_set.insert(results[i].mSide); - if (!obj || !obj->setTEGLTFMaterialOverride(results[i].mSide, results[i].mMaterial)) + if (obj) { - // object not ready to receive override data, queue for later - gGLTFMaterialList.queueOverrideUpdate(object_override.mObjectId, results[i].mSide, results[i].mMaterial); - } - else if (obj && obj->getTE(results[i].mSide) && obj->getTE(results[i].mSide)->isSelected()) - { - doSelectionCallbacks(object_override.mObjectId, results[i].mSide); + obj->setTEGLTFMaterialOverride(results[i].mSide, results[i].mMaterial); } } - else + + // unblock material editor + if (obj && obj->getTE(results[i].mSide) && obj->getTE(results[i].mSide)->isSelected()) { - // unblock material editor - if (obj && obj->getTE(results[i].mSide) && obj->getTE(results[i].mSide)->isSelected()) - { - doSelectionCallbacks(object_override.mObjectId, results[i].mSide); - } + doSelectionCallbacks(object_override.mObjectId, results[i].mSide); } } @@ -352,6 +337,7 @@ namespace void LLGLTFMaterialList::queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFMaterial* override_data) { +#if 0 override_list_t& overrides = mQueuedOverrides[id]; if (overrides.size() < side + 1) @@ -360,6 +346,7 @@ void LLGLTFMaterialList::queueOverrideUpdate(const LLUUID& id, S32 side, LLGLTFM } overrides[side] = override_data; +#endif } void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj) @@ -367,6 +354,8 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj) LL_PROFILE_ZONE_SCOPED; llassert(obj); + +#if 0 const LLUUID& id = obj->getID(); auto iter = mQueuedOverrides.find(id); @@ -409,6 +398,14 @@ void LLGLTFMaterialList::applyQueuedOverrides(LLViewerObject* obj) mQueuedOverrides.erase(iter); } +#else + // the override cache is the authoritarian source of the most recent override data + LLViewerRegion* regionp = obj->getRegion(); + if (regionp) + { + regionp->applyCacheMiscExtras(obj); + } +#endif } void LLGLTFMaterialList::queueModify(const LLViewerObject* obj, S32 side, const LLGLTFMaterial* mat) diff --git a/indra/newview/llreflectionmapmanager.cpp b/indra/newview/llreflectionmapmanager.cpp index 2f6c4e275daa53481e53fc9d2b1b491b2dcb2b1c..850b293e7c2de94d608d54506170f23a1d16bbfd 100644 --- a/indra/newview/llreflectionmapmanager.cpp +++ b/indra/newview/llreflectionmapmanager.cpp @@ -651,10 +651,6 @@ void LLReflectionMapManager::updateProbeFace(LLReflectionMap* probe, U32 face) S32 channel = gIrradianceGenProgram.enableTexture(LLShaderMgr::REFLECTION_PROBES, LLTexUnit::TT_CUBE_MAP_ARRAY); mTexture->bind(channel); - static LLCachedControl<F32> ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); - static LLStaticHashedString ambiance_scale_str("ambiance_scale"); - - gIrradianceGenProgram.uniform1f(ambiance_scale_str, ambiance_scale); gIrradianceGenProgram.uniform1i(sSourceIdx, sourceIdx); gIrradianceGenProgram.uniform1f(LLShaderMgr::REFLECTION_PROBE_MAX_LOD, mMaxProbeLOD); diff --git a/indra/newview/llspatialpartition.cpp b/indra/newview/llspatialpartition.cpp index ccb750946cd186364ad8f0af8ae1da8bccf646ac..10c3946cfd37aed8ca3d8323e52388db228f5b0c 100644 --- a/indra/newview/llspatialpartition.cpp +++ b/indra/newview/llspatialpartition.cpp @@ -1381,7 +1381,7 @@ S32 LLSpatialPartition::cull(LLCamera &camera, std::vector<LLDrawable *>* result selecter.traverse(mOctree); return 0; - } +} extern BOOL gCubeSnapshot; @@ -1546,6 +1546,7 @@ void pushVertsColorCoded(LLSpatialGroup* group) // - a linked rigged drawable face has the wrong draw order index bool check_rigged_group(LLDrawable* drawable) { +#if 0 if (drawable->isState(LLDrawable::RIGGED)) { LLSpatialGroup* group = drawable->getSpatialGroup(); @@ -1593,7 +1594,7 @@ bool check_rigged_group(LLDrawable* drawable) } } } - +#endif return true; } diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 646c9c20d9d87d2c1fa77306bca06bb44c866416..3ba4d33859af057aca90ebdfa323ba57a745d6a9 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -2967,15 +2967,16 @@ void LLViewerMediaImpl::doMediaTexUpdate(LLViewerMediaTexture* media_tex, U8* da LL_PROFILE_ZONE_SCOPED_CATEGORY_MEDIA; LLMutexLock lock(&mLock); // 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<LLImageRaw> raw = new LLImageRaw(data, media_tex->getWidth(), media_tex->getHeight(), media_tex->getComponents(), true); + + // *NOTE: Recreating the GL texture each media update may seem wasteful + // (note the texture creation in preMediaTexUpdate), however, it apparently + // prevents GL calls from blocking, due to poor bookkeeping of state of + // updated textures by the OpenGL implementation. + // 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); diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index 5bc52611ff7009515eae82abd2554ecc51c9a381..52cd43f0bb56ec5923a0291d8c97e051e8d6d5bc 100644 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -5468,19 +5468,22 @@ S32 LLViewerObject::setTEGLTFMaterialOverride(U8 te, LLGLTFMaterial* override_ma return retval; } - tep->setGLTFMaterialOverride(override_mat); + retval = tep->setGLTFMaterialOverride(override_mat); - if (override_mat) + if (retval) { - LLFetchedGLTFMaterial* render_mat = new LLFetchedGLTFMaterial(*src_mat); - render_mat->applyOverride(*override_mat); - tep->setGLTFRenderMaterial(render_mat); - retval = TEM_CHANGE_TEXTURE; + if (override_mat) + { + LLFetchedGLTFMaterial* render_mat = new LLFetchedGLTFMaterial(*src_mat); + render_mat->applyOverride(*override_mat); + tep->setGLTFRenderMaterial(render_mat); + retval = TEM_CHANGE_TEXTURE; - } - else if (tep->setGLTFRenderMaterial(nullptr)) - { - retval = TEM_CHANGE_TEXTURE; + } + else if (tep->setGLTFRenderMaterial(nullptr)) + { + retval = TEM_CHANGE_TEXTURE; + } } return retval; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 087b2d40ca698bd51afa52e63d8fd49843ee4b89..62c5fe30be7b35ebc14db1ffccf5a7454a174ec5 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -2885,20 +2885,8 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec void LLViewerRegion::cacheFullUpdateGLTFOverride(const LLGLTFOverrideCacheEntry &override_data) { - LLUUID object_id = override_data.mObjectId; - LLViewerObject * obj = gObjectList.findObject(object_id); - if (obj != nullptr) - { - llassert(obj->getRegion() == this); - - U32 local_id = obj->getLocalID(); - - mImpl->mGLTFOverridesJson[local_id] = override_data; - } - else - { - LL_WARNS("GLTF") << "got material override for unknown object_id, cannot cache it" << LL_ENDL; - } + U32 local_id = override_data.mLocalId; + mImpl->mGLTFOverridesJson[local_id] = override_data; } LLVOCacheEntry* LLViewerRegion::getCacheEntryForOctree(U32 local_id) @@ -3891,6 +3879,24 @@ void LLViewerRegion::loadCacheMiscExtras(U32 local_id) } } +void LLViewerRegion::applyCacheMiscExtras(LLViewerObject* obj) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY; + llassert(obj); + + U32 local_id = obj->getLocalID(); + auto iter = mImpl->mGLTFOverridesJson.find(local_id); + if (iter != mImpl->mGLTFOverridesJson.end()) + { + llassert(iter->second.mGLTFMaterial.size() == iter->second.mSides.size()); + + for (auto& side : iter->second.mGLTFMaterial) + { + obj->setTEGLTFMaterialOverride(side.first, side.second); + } + } +} + bool LLViewerRegion::getRegionAllowsExport() const { if (mSimulatorFeatures.has("OpenSimExtras") diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index fd8a528ae40db6ddbe8539ac40d13e5640e0b3e8..b7c457dc4e86c8f49b8d07d6c8cb7e01169dd093 100644 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -483,6 +483,8 @@ class LLViewerRegion final : public LLCapabilityProvider // implements this inte public: void loadCacheMiscExtras(U32 local_id); + void applyCacheMiscExtras(LLViewerObject* obj); + struct CompareDistance { bool operator()(const LLViewerRegion* const& lhs, const LLViewerRegion* const& rhs) diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 9f64d1b3752116d4bfc0bee7737ffdadbd252c0f..a2445bd6aa6926cedb58f3981379a660aa573d00 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1949,7 +1949,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredFullbrightProgram.mFeatures.calculatesAtmospherics = true; gDeferredFullbrightProgram.mFeatures.hasGamma = true; gDeferredFullbrightProgram.mFeatures.hasTransport = true; - gDeferredFullbrightProgram.mFeatures.hasSrgb = true; + gDeferredFullbrightProgram.mFeatures.hasSrgb = true; gDeferredFullbrightProgram.mFeatures.mIndexedTextureChannels = LLGLSLShader::sIndexedTextureChannels; gDeferredFullbrightProgram.mShaderFiles.clear(); gDeferredFullbrightProgram.mShaderFiles.push_back(make_pair("deferred/fullbrightV.glsl", GL_VERTEX_SHADER)); diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp index dfcaa23a8f44dafcb553d555e1059bd7eb51a1fd..7c799ad0d68b909697894adaacf8875d47278f14 100644 --- a/indra/newview/llvocache.cpp +++ b/indra/newview/llvocache.cpp @@ -57,9 +57,14 @@ BOOL check_write(LLAPRFile* apr_file, void* src, S32 n_bytes) bool LLGLTFOverrideCacheEntry::fromLLSD(const LLSD& data) { - if (!data.has("object_id")) + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; + + llassert(data.has("local_id")); + llassert(data.has("object_id")); + llassert(data.has("region_handle_x") && data.has("region_handle_y")); + + if (!data.has("local_id")) { - mObjectId.setNull(); return false; } @@ -69,13 +74,13 @@ bool LLGLTFOverrideCacheEntry::fromLLSD(const LLSD& data) U32 region_handle_y = data["region_handle_y"].asInteger(); U32 region_handle_x = data["region_handle_x"].asInteger(); mRegionHandle = to_region_handle(region_handle_x, region_handle_y); - mHasRegionHandle = true; } else { - mHasRegionHandle = false; + return false; } + mLocalId = data["local_id"].asInteger(); mObjectId = data["object_id"]; // message should be interpreted thusly: @@ -94,7 +99,26 @@ bool LLGLTFOverrideCacheEntry::fromLLSD(const LLSD& data) for (int i = 0; i < sides.size(); ++i) { S32 side_idx = sides[i].asInteger(); - mSides[side_idx] = gltf_json[i].asString(); + std::string gltf_json_str = gltf_json[i].asString(); + mSides[side_idx] = gltf_json_str; + LLGLTFMaterial* override_mat = new LLGLTFMaterial(); + std::string error, warn; + if (override_mat->fromJSON(gltf_json_str, warn, error)) + { + mGLTFMaterial[i] = override_mat; + } + else + { + LL_WARNS() << "Invalid GLTF string: \n" << gltf_json_str << LL_ENDL; + if (!error.empty()) + { + LL_WARNS() << "Error: " << error << LL_ENDL; + } + if (!warn.empty()) + { + LL_WARNS() << "Warning: " << warn << LL_ENDL; + } + } } } else @@ -107,16 +131,15 @@ bool LLGLTFOverrideCacheEntry::fromLLSD(const LLSD& data) LLSD LLGLTFOverrideCacheEntry::toLLSD() const { + LL_PROFILE_ZONE_SCOPED_CATEGORY_NETWORK; LLSD data; - if (mHasRegionHandle) - { - U32 region_handle_x, region_handle_y; - from_region_handle(mRegionHandle, ®ion_handle_x, ®ion_handle_y); - data["region_handle_y"] = LLSD::Integer(region_handle_y); - data["region_handle_x"] = LLSD::Integer(region_handle_x); - } + U32 region_handle_x, region_handle_y; + from_region_handle(mRegionHandle, ®ion_handle_x, ®ion_handle_y); + data["region_handle_y"] = LLSD::Integer(region_handle_y); + data["region_handle_x"] = LLSD::Integer(region_handle_x); data["object_id"] = mObjectId; + data["local_id"] = (LLSD::Integer) mLocalId; for (auto const & side : mSides) { diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h index 803829f7de6db9dc53d700bb37f5893d46ac0062..c0f4b3ae6a5d817e0ac07af7ea3c219a9fe72795 100644 --- a/indra/newview/llvocache.h +++ b/indra/newview/llvocache.h @@ -32,6 +32,7 @@ #include "lldir.h" #include "llvieweroctree.h" #include "llapr.h" +#include "llgltfmaterial.h" #include <unordered_map> @@ -46,9 +47,10 @@ class LLGLTFOverrideCacheEntry LLSD toLLSD() const; LLUUID mObjectId; - std::map<S32, std::string> mSides; //json per side - U64 mRegionHandle; - bool mHasRegionHandle; + U32 mLocalId = 0; + std::unordered_map<S32, std::string> mSides; //json per side + std::unordered_map<S32, LLPointer<LLGLTFMaterial> > mGLTFMaterial; //GLTF material per side + U64 mRegionHandle = 0; }; class LLVOCacheEntry final diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 749f74452b3936b6ce48e7fbab267c3302028c18..cd7d84694dfca4681715896c18bbe98c2ed45d88 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -5738,15 +5738,6 @@ void LLPipeline::setupHWLights() // Ambient LLColor4 ambient = psky->getTotalAmbient(); - static LLCachedControl<F32> ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); - - F32 light_scale = 1.f; - - if (gCubeSnapshot && !mReflectionMapManager.isRadiancePass()) - { //darken local lights based on brightening of sky lighting - light_scale = 1.f / ambiance_scale; - } - gGL.setAmbientLightColor(ambient); bool sun_up = environment.getIsSunUp(); @@ -5840,7 +5831,7 @@ void LLPipeline::setupHWLights() } //send linear light color to shader - LLColor4 light_color = light->getLightLinearColor()*light_scale; + LLColor4 light_color = light->getLightLinearColor(); light_color.mV[3] = 0.0f; F32 fade = iter->fade; @@ -7935,15 +7926,6 @@ void LLPipeline::renderDeferredLighting() llassert(!sRenderingHUDs); - static LLCachedControl<F32> ambiance_scale(gSavedSettings, "RenderReflectionProbeAmbianceScale", 8.f); - - F32 light_scale = 1.f; - - if (gCubeSnapshot && !mReflectionMapManager.isRadiancePass()) - { //darken local lights based on brightening of sky lighting - light_scale = 1.f / ambiance_scale; - } - LLRenderTarget *screen_target = &mRT->screen; LLRenderTarget* deferred_light_target = &mRT->deferredLight; @@ -8157,7 +8139,7 @@ void LLPipeline::renderDeferredLighting() F32 s = volume->getLightRadius() * 1.5f; // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor()*light_scale; + LLColor3 col = volume->getLightLinearColor(); if (col.magVecSquared() < 0.001f) { @@ -8252,7 +8234,7 @@ void LLPipeline::renderDeferredLighting() setupSpotLight(gDeferredSpotLightProgram, drawablep); // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor() * light_scale; + LLColor3 col = volume->getLightLinearColor(); gDeferredSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, c); gDeferredSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, s); @@ -8327,7 +8309,7 @@ void LLPipeline::renderDeferredLighting() setupSpotLight(gDeferredMultiSpotLightProgram, drawablep); // send light color to shader in linear space - LLColor3 col = volume->getLightLinearColor() * light_scale; + LLColor3 col = volume->getLightLinearColor(); gDeferredMultiSpotLightProgram.uniform3fv(LLShaderMgr::LIGHT_CENTER, 1, center.getF32ptr()); gDeferredMultiSpotLightProgram.uniform1f(LLShaderMgr::LIGHT_SIZE, light_size_final); diff --git a/indra/newview/skins/default/xui/en/floater_adjust_environment.xml b/indra/newview/skins/default/xui/en/floater_adjust_environment.xml index 39fe573c98ff426a57d5dbd201900f92131590da..f6bfb3574d5a8f596d5adaddc5591796d47231ac 100644 --- a/indra/newview/skins/default/xui/en/floater_adjust_environment.xml +++ b/indra/newview/skins/default/xui/en/floater_adjust_environment.xml @@ -266,7 +266,7 @@ layout="topleft" left_delta="5" min_val="0" - max_val="1" + max_val="10" name="probe_ambiance" top_pad="5" width="185" diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 7cdb46937f2b6bf7ea7ac6aa19833e675fee491e..e27c766b628dcdedc433a5217f099adfaeda6c32 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -2698,7 +2698,7 @@ even though the user gets a free copy. label="Ambiance" label_width="55" left="10" - max_val="1" + max_val="100" min_val="0" mouse_opaque="true" name="Probe Ambiance" diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml index 094be36b01f9b2ccb22c88c3cae32818fbde4e67..a80b1a91669c3eb9b9c3ef8ba7f4b9ea57d502ab 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_atmos.xml @@ -333,7 +333,7 @@ layout="topleft" left_delta="5" min_val="0" - max_val="1" + max_val="10" name="probe_ambiance" top_delta="20" width="219"