From 5c903d9c953e422a95ccd88b345d803b60ce65ff Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 21 Apr 2023 11:19:14 -0500 Subject: [PATCH 1/3] DRTVWR-559 Don't use automatic probes on water (fixes lots of visual artifacts) --- .../class3/deferred/reflectionProbeF.glsl | 19 ++++++++++++++++--- .../floater_preferences_graphics_advanced.xml | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl index 36b5262104..9b42f0df5c 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl @@ -651,12 +651,11 @@ vec3 sampleProbeAmbient(vec3 pos, vec3 dir) return col[1]+col[0]; } -void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, +void doProbeSample(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; - preProbeSample(pos); vec3 refnormpersp = reflect(pos.xyz, norm.xyz); @@ -676,10 +675,24 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, #endif } +void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, + vec2 tc, vec3 pos, vec3 norm, float glossiness) +{ + preProbeSample(pos); + doProbeSample(ambenv, glossenv, tc, pos, norm, glossiness); +} + void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv, vec2 tc, vec3 pos, vec3 norm, float glossiness) { - sampleReflectionProbes(ambenv, glossenv, tc, pos, norm, glossiness); + // don't sample automatic probes for water + sample_automatic = false; + preProbeSample(pos); + sample_automatic = true; + // always include void probe on water + probeIndex[probeInfluences++] = 0; + + doProbeSample(ambenv, glossenv, tc, pos, norm, glossiness); // fudge factor to get PBR water at a similar luminance ot legacy water glossenv *= 0.4; diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index d867123c4b..22e889a99c 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -729,7 +729,7 @@ name="1" value="1"/> Date: Fri, 21 Apr 2023 13:26:24 -0700 Subject: [PATCH 2/3] SL-19606: Fix missing GLTF texture transforms in PBR alpha mask/alpha blend shadows --- indra/llprimitive/llgltfmaterial.cpp | 2 +- indra/llprimitive/llgltfmaterial.h | 2 +- .../class1/deferred/shadowAlphaMaskF.glsl | 8 ++--- .../class1/deferred/shadowAlphaMaskV.glsl | 25 ++++++++-------- indra/newview/lldrawpool.cpp | 30 +++++++++++++------ indra/newview/lldrawpool.h | 12 ++++---- indra/newview/lldrawpoolbump.cpp | 4 ++- indra/newview/lldrawpoolbump.h | 2 +- indra/newview/llfetchedgltfmaterial.cpp | 8 ++--- indra/newview/pipeline.cpp | 12 ++++---- 10 files changed, 61 insertions(+), 44 deletions(-) diff --git a/indra/llprimitive/llgltfmaterial.cpp b/indra/llprimitive/llgltfmaterial.cpp index f3aa5b0648..c16803d39d 100644 --- a/indra/llprimitive/llgltfmaterial.cpp +++ b/indra/llprimitive/llgltfmaterial.cpp @@ -43,7 +43,7 @@ const char* const GLTF_FILE_EXTENSION_TRANSFORM_ROTATION = "rotation"; // special UUID that indicates a null UUID in override data static const LLUUID GLTF_OVERRIDE_NULL_UUID = LLUUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); -void LLGLTFMaterial::TextureTransform::getPacked(F32 (&packed)[8]) +void LLGLTFMaterial::TextureTransform::getPacked(F32 (&packed)[8]) const { packed[0] = mScale.mV[VX]; packed[1] = mScale.mV[VY]; diff --git a/indra/llprimitive/llgltfmaterial.h b/indra/llprimitive/llgltfmaterial.h index bdabd657e1..0bd65fadef 100644 --- a/indra/llprimitive/llgltfmaterial.h +++ b/indra/llprimitive/llgltfmaterial.h @@ -61,7 +61,7 @@ public: LLVector2 mScale = { 1.f, 1.f }; F32 mRotation = 0.f; - void getPacked(F32 (&packed)[8]); + void getPacked(F32 (&packed)[8]) const; bool operator==(const TextureTransform& other) const; }; diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl index 68e9addc1b..eb2ba68415 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl @@ -33,10 +33,10 @@ out vec4 frag_color; uniform sampler2D diffuseMap; -VARYING vec4 post_pos; -VARYING float target_pos_x; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; +in vec4 post_pos; +in float target_pos_x; +in vec4 vertex_color; +in vec2 vary_texcoord0; uniform float minimum_alpha; void main() diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl index 2249a7f239..72a07fa3d0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl @@ -27,26 +27,27 @@ uniform mat4 texture_matrix0; #if defined(HAS_SKIN) uniform mat4 modelview_matrix; uniform mat4 projection_matrix; +mat4 getObjectSkinnedTransform(); #else uniform mat4 modelview_projection_matrix; #endif + +uniform vec4[2] texture_base_color_transform; +vec2 texture_transform(vec2 vertex_texcoord, vec4[2] khr_gltf_transform, mat4 sl_animation_transform); + uniform float shadow_target_width; -ATTRIBUTE vec3 position; -ATTRIBUTE vec4 diffuse_color; -ATTRIBUTE vec2 texcoord0; +in vec3 position; +in vec4 diffuse_color; +in vec2 texcoord0; -VARYING vec4 post_pos; -VARYING float target_pos_x; -VARYING vec4 vertex_color; -VARYING vec2 vary_texcoord0; +out vec4 post_pos; +out float target_pos_x; +out vec4 vertex_color; +out vec2 vary_texcoord0; void passTextureIndex(); -#if defined(HAS_SKIN) -mat4 getObjectSkinnedTransform(); -#endif - void main() { //transform vertex @@ -69,6 +70,6 @@ void main() passTextureIndex(); - vary_texcoord0 = (texture_matrix0 * vec4(texcoord0,0,1)).xy; + vary_texcoord0 = texture_transform(texcoord0, texture_base_color_transform, texture_matrix0); vertex_color = diffuse_color; } diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp index 2eb277fc4e..3de0e8a7c4 100644 --- a/indra/newview/lldrawpool.cpp +++ b/indra/newview/lldrawpool.cpp @@ -504,7 +504,7 @@ void LLRenderPass::pushRiggedGLTFBatch(LLDrawInfo& params, LLVOAvatar*& lastAvat pushGLTFBatch(params); } -void LLRenderPass::pushBatches(U32 type, bool texture, bool batch_textures) +void LLRenderPass::pushBatches(U32 type, bool texture, bool batch_textures, bool reset_gltf) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; auto* begin = gPipeline.beginRenderMap(type); @@ -514,11 +514,12 @@ void LLRenderPass::pushBatches(U32 type, bool texture, bool batch_textures) LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); - pushBatch(*pparams, texture, batch_textures); + pushBatch(*pparams, texture, batch_textures, reset_gltf); + reset_gltf = false; } } -void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures) +void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures, bool reset_gltf) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLVOAvatar* lastAvatar = nullptr; @@ -537,11 +538,12 @@ void LLRenderPass::pushRiggedBatches(U32 type, bool texture, bool batch_textures lastMeshId = pparams->mSkinInfo->mHash; } - pushBatch(*pparams, texture, batch_textures); + pushBatch(*pparams, texture, batch_textures, reset_gltf); + reset_gltf = false; } } -void LLRenderPass::pushMaskBatches(U32 type, bool texture, bool batch_textures) +void LLRenderPass::pushMaskBatches(U32 type, bool texture, bool batch_textures, bool reset_gltf) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; auto* begin = gPipeline.beginRenderMap(type); @@ -551,11 +553,12 @@ void LLRenderPass::pushMaskBatches(U32 type, bool texture, bool batch_textures) LLDrawInfo* pparams = *i; LLCullResult::increment_iterator(i, end); LLGLSLShader::sCurBoundShaderPtr->setMinimumAlpha(pparams->mAlphaMaskCutoff); - pushBatch(*pparams, texture, batch_textures); + pushBatch(*pparams, texture, batch_textures, reset_gltf); + reset_gltf = false; } } -void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_textures) +void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_textures, bool reset_gltf) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; LLVOAvatar* lastAvatar = nullptr; @@ -584,7 +587,8 @@ void LLRenderPass::pushRiggedMaskBatches(U32 type, bool texture, bool batch_text lastMeshId = pparams->mSkinInfo->mHash; } - pushBatch(*pparams, texture, batch_textures); + pushBatch(*pparams, texture, batch_textures, reset_gltf); + reset_gltf = false; } } @@ -603,7 +607,14 @@ void LLRenderPass::applyModelMatrix(const LLDrawInfo& params) } } -void LLRenderPass::pushBatch(LLDrawInfo& params, bool texture, bool batch_textures) +void LLRenderPass::resetGLTFTextureTransform() +{ + F32 ignore_gltf_transform[8]; + LLGLTFMaterial::sDefault.mTextureTransform[LLGLTFMaterial::GLTF_TEXTURE_INFO_BASE_COLOR].getPacked(ignore_gltf_transform); + LLGLSLShader::sCurBoundShaderPtr->uniform4fv(LLShaderMgr::TEXTURE_BASE_COLOR_TRANSFORM, 2, (F32*)ignore_gltf_transform); +} + +void LLRenderPass::pushBatch(LLDrawInfo& params, bool texture, bool batch_textures, bool reset_gltf) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; if (!params.mCount) @@ -612,6 +623,7 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, bool texture, bool batch_textur } applyModelMatrix(params); + if (reset_gltf) { resetGLTFTextureTransform(); } bool tex_setup = false; diff --git a/indra/newview/lldrawpool.h b/indra/newview/lldrawpool.h index 09c95a1705..8704f2e340 100644 --- a/indra/newview/lldrawpool.h +++ b/indra/newview/lldrawpool.h @@ -349,15 +349,17 @@ public: void resetDrawOrders() { } static void applyModelMatrix(const LLDrawInfo& params); - virtual void pushBatches(U32 type, bool texture = true, bool batch_textures = false); - virtual void pushRiggedBatches(U32 type, bool texture = true, bool batch_textures = false); + static void resetGLTFTextureTransform(); + virtual void pushBatches(U32 type, bool texture = true, bool batch_textures = false, bool reset_gltf = false); + virtual void pushRiggedBatches(U32 type, bool texture = true, bool batch_textures = false, bool reset_gltf = false); void pushGLTFBatches(U32 type); void pushGLTFBatch(LLDrawInfo& params); void pushRiggedGLTFBatches(U32 type); void pushRiggedGLTFBatch(LLDrawInfo& params, LLVOAvatar*& lastAvatar, U64& lastMeshId); - virtual void pushMaskBatches(U32 type, bool texture = true, bool batch_textures = false); - virtual void pushRiggedMaskBatches(U32 type, bool texture = true, bool batch_textures = false); - virtual void pushBatch(LLDrawInfo& params, bool texture, bool batch_textures = false); + virtual void pushMaskBatches(U32 type, bool texture = true, bool batch_textures = false, bool reset_gltf = false); + virtual void pushRiggedMaskBatches(U32 type, bool texture = true, bool batch_textures = false, bool reset_gltf = false); + // reset_gltf: batch is interleaved with GLTF batches that share the same shader + virtual void pushBatch(LLDrawInfo& params, bool texture, bool batch_textures = false, bool reset_gltf = false); static bool uploadMatrixPalette(LLDrawInfo& params); static bool uploadMatrixPalette(LLVOAvatar* avatar, LLMeshSkinInfo* skinInfo); virtual void renderGroup(LLSpatialGroup* group, U32 type, bool texture = true); diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp index 45c74776e1..35265b6df0 100644 --- a/indra/newview/lldrawpoolbump.cpp +++ b/indra/newview/lldrawpoolbump.cpp @@ -1218,13 +1218,15 @@ void LLDrawPoolBump::pushBumpBatches(U32 type) } } -void LLDrawPoolBump::pushBatch(LLDrawInfo& params, bool texture, bool batch_textures) +void LLDrawPoolBump::pushBatch(LLDrawInfo& params, bool texture, bool batch_textures, bool reset_gltf) { LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWPOOL; applyModelMatrix(params); bool tex_setup = false; + if (reset_gltf) { LLRenderPass::resetGLTFTextureTransform(); } + if (batch_textures && params.mTextureList.size() > 1) { for (U32 i = 0; i < params.mTextureList.size(); ++i) diff --git a/indra/newview/lldrawpoolbump.h b/indra/newview/lldrawpoolbump.h index 840af0c99d..41c4879ded 100644 --- a/indra/newview/lldrawpoolbump.h +++ b/indra/newview/lldrawpoolbump.h @@ -53,7 +53,7 @@ public: LLDrawPoolBump(); /*virtual*/ void prerender() override; - void pushBatch(LLDrawInfo& params, bool texture, bool batch_textures = false) override; + void pushBatch(LLDrawInfo& params, bool texture, bool batch_textures = false, bool reset_gltf = false) override; void pushBumpBatches(U32 type); void renderGroup(LLSpatialGroup* group, U32 type, bool texture) override; diff --git a/indra/newview/llfetchedgltfmaterial.cpp b/indra/newview/llfetchedgltfmaterial.cpp index 1f7d672062..1fb3577dd7 100644 --- a/indra/newview/llfetchedgltfmaterial.cpp +++ b/indra/newview/llfetchedgltfmaterial.cpp @@ -90,6 +90,10 @@ void LLFetchedGLTFMaterial::bind(LLViewerTexture* media_tex) gGL.getTexUnit(0)->bindFast(LLViewerFetchedTexture::sWhiteImagep); } + F32 base_color_packed[8]; + mTextureTransform[GLTF_TEXTURE_INFO_BASE_COLOR].getPacked(base_color_packed); + shader->uniform4fv(LLShaderMgr::TEXTURE_BASE_COLOR_TRANSFORM, 2, (F32*)base_color_packed); + if (!LLPipeline::sShadowRender) { if (mNormalTexture.notNull() && mNormalTexture->getDiscardLevel() <= 4) @@ -125,10 +129,6 @@ void LLFetchedGLTFMaterial::bind(LLViewerTexture* media_tex) shader->uniform1f(LLShaderMgr::METALLIC_FACTOR, mMetallicFactor); shader->uniform3fv(LLShaderMgr::EMISSIVE_COLOR, 1, mEmissiveColor.mV); - F32 base_color_packed[8]; - mTextureTransform[GLTF_TEXTURE_INFO_BASE_COLOR].getPacked(base_color_packed); - shader->uniform4fv(LLShaderMgr::TEXTURE_BASE_COLOR_TRANSFORM, 2, (F32*)base_color_packed); - F32 normal_packed[8]; mTextureTransform[GLTF_TEXTURE_INFO_NORMAL].getPacked(normal_packed); shader->uniform4fv(LLShaderMgr::TEXTURE_NORMAL_TRANSFORM, 2, (F32*)normal_packed); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 60d19bf1d6..ee011bf37c 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6794,7 +6794,7 @@ void LLPipeline::renderAlphaObjects(bool rigged) lastMeshId = pparams->mSkinInfo->mHash; } - mSimplePool->pushBatch(*pparams, true, true); + mSimplePool->pushBatch(*pparams, true, true, true); } } else @@ -6805,7 +6805,7 @@ void LLPipeline::renderAlphaObjects(bool rigged) } else { - mSimplePool->pushBatch(*pparams, true, true); + mSimplePool->pushBatch(*pparams, true, true, true); } } } @@ -6822,11 +6822,11 @@ void LLPipeline::renderMaskedObjects(U32 type, bool texture, bool batch_texture, gGLLastMatrix = NULL; if (rigged) { - mAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture); + mAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture, true); } else { - mAlphaMaskPool->pushMaskBatches(type, texture, batch_texture); + mAlphaMaskPool->pushMaskBatches(type, texture, batch_texture, true); } gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; @@ -6840,11 +6840,11 @@ void LLPipeline::renderFullbrightMaskedObjects(U32 type, bool texture, bool batc gGLLastMatrix = NULL; if (rigged) { - mFullbrightAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture); + mFullbrightAlphaMaskPool->pushRiggedMaskBatches(type+1, texture, batch_texture, true); } else { - mFullbrightAlphaMaskPool->pushMaskBatches(type, texture, batch_texture); + mFullbrightAlphaMaskPool->pushMaskBatches(type, texture, batch_texture, true); } gGL.loadMatrix(gGLModelView); gGLLastMatrix = NULL; From 78bb75989e36b9598852e7dcce05dce37ab0ebe1 Mon Sep 17 00:00:00 2001 From: RunitaiLinden Date: Fri, 21 Apr 2023 17:19:39 -0500 Subject: [PATCH 3/3] DRTVWR-559 Nudge legacy sky ambient to be more like release. Incidental decruft --- .../class1/deferred/postDeferredGammaCorrect.glsl | 1 - indra/newview/llsettingsvo.cpp | 14 ++++++++++---- indra/newview/pipeline.cpp | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index de766d6bc7..82d7bb9835 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -38,7 +38,6 @@ uniform sampler2D exposureMap; uniform vec2 screen_res; VARYING vec2 vary_fragcoord; -uniform float display_gamma; vec3 linear_to_srgb(vec3 cl); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index f2f269fa63..1427dbefa1 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -716,6 +716,16 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force) LLColor3 ambient(getTotalAmbient()); + F32 g = getGamma(); + if (ambient != LLColor3::black && getReflectionProbeAmbiance() == 0.f) + { //desaturate ambient for legacy compatibility + F32 h, s, l; + ambient.calcHSL(&h, &s, &l); + s *= 0.5f; + l *= 1.f / (g + llmax(g-1.f, 0.f)); + ambient.setHSL(h, s, l); + } + if (irradiance_pass) { // during an irradiance map update, disable ambient lighting (direct lighting only) and desaturate sky color (avoid tinting the world blue) shader->uniform3fv(LLShaderMgr::AMBIENT_LINEAR, LLVector3::zero.mV); @@ -755,11 +765,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget, bool force) shader->uniform1f(LLShaderMgr::HAZE_DENSITY_LINEAR, sRGBtoLinear(getHazeDensity())); - F32 g = getGamma(); - F32 display_gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); - shader->uniform1f(LLShaderMgr::GAMMA, g); - shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, display_gamma); } LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 60d19bf1d6..9fe9f4e487 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7039,7 +7039,7 @@ void LLPipeline::gammaCorrect(LLRenderTarget* src, LLRenderTarget* dst) { static LLCachedControl exposure(gSavedSettings, "RenderExposure", 1.f); - F32 e = llclamp(exposure(), 0.5f, 4.f); + F32 e = llclamp(exposure(), 0.5f, 4.f); static LLStaticHashedString s_exposure("exposure");