Skip to content
Snippets Groups Projects
Commit 75e743be authored by David Parks's avatar David Parks
Browse files

SL-18442 Port of Caladbolg's fix for emissive overrides not taking. Remove unused function.

parent 94afae5b
No related branches found
No related tags found
2 merge requests!3Update to main branch,!2Rebase onto current main branch
......@@ -241,8 +241,14 @@ void LLGLTFMaterial::writeToModel(tinygltf::Model& model, S32 mat_index) const
material_out.alphaCutoff = mAlphaCutoff;
mBaseColor.write(material_out.pbrMetallicRoughness.baseColorFactor);
material_out.emissiveFactor.resize(3); // 0 size by default
mEmissiveColor.write(material_out.emissiveFactor);
if (mEmissiveColor != LLGLTFMaterial::getDefaultEmissiveColor())
{
material_out.emissiveFactor.resize(3);
mEmissiveColor.write(material_out.emissiveFactor);
}
material_out.pbrMetallicRoughness.metallicFactor = mMetallicFactor;
material_out.pbrMetallicRoughness.roughnessFactor = mRoughnessFactor;
......@@ -439,65 +445,6 @@ F32 LLGLTFMaterial::getDefaultTextureRotation()
return 0.f;
}
void LLGLTFMaterial::writeOverridesToModel(tinygltf::Model& model, S32 mat_index, LLGLTFMaterial const* base_material) const
{
if (model.materials.size() < mat_index + 1)
{
model.materials.resize(mat_index + 1);
}
tinygltf::Material& material_out = model.materials[mat_index];
// TODO - fix handling of resetting to null/default values
constexpr bool is_override = true;
// set base color texture
writeToTexture(model, material_out.pbrMetallicRoughness.baseColorTexture, GLTF_TEXTURE_INFO_BASE_COLOR, mBaseColorId, is_override, base_material->mBaseColorId);
// set normal texture
writeToTexture(model, material_out.normalTexture, GLTF_TEXTURE_INFO_NORMAL, mNormalId, is_override, base_material->mNormalId);
// set metallic-roughness texture
writeToTexture(model, material_out.pbrMetallicRoughness.metallicRoughnessTexture, GLTF_TEXTURE_INFO_METALLIC_ROUGHNESS, mMetallicRoughnessId, is_override, base_material->mMetallicRoughnessId);
// set emissive texture
writeToTexture(model, material_out.emissiveTexture, GLTF_TEXTURE_INFO_EMISSIVE, mEmissiveId, is_override, base_material->mEmissiveId);
if (mAlphaMode != base_material->mAlphaMode)
{
material_out.alphaMode = getAlphaMode();
}
if (mAlphaCutoff != base_material->mAlphaCutoff)
{
material_out.alphaCutoff = mAlphaCutoff;
}
if (mBaseColor != base_material->mBaseColor)
{
mBaseColor.write(material_out.pbrMetallicRoughness.baseColorFactor);
}
if (mEmissiveColor != base_material->mEmissiveColor)
{
material_out.emissiveFactor.resize(3); // 0 size by default
mEmissiveColor.write(material_out.emissiveFactor);
}
if (mMetallicFactor != base_material->mMetallicFactor)
{
material_out.pbrMetallicRoughness.metallicFactor = mMetallicFactor;
}
if (mRoughnessFactor != base_material->mRoughnessFactor)
{
material_out.pbrMetallicRoughness.roughnessFactor = mRoughnessFactor;
}
if (mDoubleSided != base_material->mDoubleSided)
{
material_out.doubleSided = mDoubleSided;
}
}
void LLGLTFMaterial::applyOverride(const LLGLTFMaterial& override_mat)
{
// TODO: potentially reimplement this with a more general purpose JSON merge
......
......@@ -185,9 +185,6 @@ class LLGLTFMaterial : public LLRefCount
// write to given tinygltf::Model
void writeToModel(tinygltf::Model& model, S32 mat_index) const;
// calculate the fields in this material that differ from a base material and write them out to a given tinygltf::Model
void writeOverridesToModel(tinygltf::Model& model, S32 mat_index, LLGLTFMaterial const* base_material) const;
void applyOverride(const LLGLTFMaterial& override_mat);
private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment