summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosmic Linden <cosmic@lindenlab.com>2023-04-21 13:26:24 -0700
committercosmic-linden <111533034+cosmic-linden@users.noreply.github.com>2023-04-21 15:10:05 -0700
commit005a5fa207d158995217cb9ecf5c214c8b2354cc (patch)
tree08ae2464306b77a4743d6898cf81a1c7e95fa696
parent5c903d9c953e422a95ccd88b345d803b60ce65ff (diff)
SL-19606: Fix missing GLTF texture transforms in PBR alpha mask/alpha blend shadows
-rw-r--r--indra/llprimitive/llgltfmaterial.cpp2
-rw-r--r--indra/llprimitive/llgltfmaterial.h2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowAlphaMaskV.glsl25
-rw-r--r--indra/newview/lldrawpool.cpp30
-rw-r--r--indra/newview/lldrawpool.h12
-rw-r--r--indra/newview/lldrawpoolbump.cpp4
-rw-r--r--indra/newview/lldrawpoolbump.h2
-rw-r--r--indra/newview/llfetchedgltfmaterial.cpp8
-rw-r--r--indra/newview/pipeline.cpp12
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;