SL-19606: Fix missing GLTF texture transforms in PBR alpha mask/alpha blend shadows
parent
5c903d9c95
commit
005a5fa207
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue