From 60bc6569909a94d252c9e8d82979b5a3ed1a2ea7 Mon Sep 17 00:00:00 2001 From: John Turner <7strbass@gmail.com> Date: Wed, 26 Apr 2023 15:13:04 -0400 Subject: [PATCH] --revert change to user-def ptr attributes; --- src/esp/assets/ResourceManager.cpp | 7 +++--- src/esp/gfx/GenericDrawable.cpp | 30 +++++++++++++------------- src/esp/gfx/PbrDrawable.cpp | 34 +++++++++++++++--------------- 3 files changed, 36 insertions(+), 35 deletions(-) diff --git a/src/esp/assets/ResourceManager.cpp b/src/esp/assets/ResourceManager.cpp index f978e73b72..291786042e 100644 --- a/src/esp/assets/ResourceManager.cpp +++ b/src/esp/assets/ResourceManager.cpp @@ -2360,7 +2360,7 @@ Mn::Trade::MaterialData ResourceManager::setDefaultMaterialUserAttributes( arrayAppend(newAttributes, Cr::InPlaceInit, "hasPerVertexObjectId", hasVertObjID); if (hasTxtrObjID) { - arrayAppend(newAttributes, Cr::InPlaceInit, "objectIdTexture", + arrayAppend(newAttributes, Cr::InPlaceInit, "objectIdTexturePtr", textures_.at(txtrIdx).get()); } arrayAppend(newAttributes, Cr::InPlaceInit, "shaderTypeToUse", @@ -2608,7 +2608,8 @@ void ResourceManager::loadMaterials(Importer& importer, // copy texture into new attributes tagged with lowercase material // name auto newAttrName = Cr::Utility::formatString( - "{}{}", Cr::Utility::String::lowercase(attrName.slice(0, 1)), + "{}{}Ptr", + Cr::Utility::String::lowercase(attrName.slice(0, 1)), attrName.slice(1, attrName.size())); // Temporary debug message Cr::Utility::formatInto(debugStr, debugStr.size(), @@ -2673,7 +2674,7 @@ Mn::Trade::MaterialData ResourceManager::buildCustomAttributeFlatMaterial( // material if (flatMat.hasTexture()) { arrayAppend(custAttributes, - {"ambientTexture", + {"ambientTexturePtr", textures_.at(textureBaseIndex + flatMat.texture()).get()}); } // Merge new attributes with those specified in original material diff --git a/src/esp/gfx/GenericDrawable.cpp b/src/esp/gfx/GenericDrawable.cpp index f1ff9380e3..d03e60e425 100644 --- a/src/esp/gfx/GenericDrawable.cpp +++ b/src/esp/gfx/GenericDrawable.cpp @@ -45,24 +45,24 @@ GenericDrawable::GenericDrawable( /* If texture transformation is specified, enable it only if the material is actually textured -- it's an error otherwise */ if (materialData_->commonTextureMatrix() != Mn::Matrix3{} && - (materialData_->hasAttribute("ambientTexture") || - materialData_->hasAttribute("baseColorTexture") || - materialData_->hasAttribute("diffuseTexture") || - materialData_->hasAttribute("specularTexture") || - materialData_->hasAttribute("objectIdTexture"))) { + (materialData_->hasAttribute("ambientTexturePtr") || + materialData_->hasAttribute("baseColorTexturePtr") || + materialData_->hasAttribute("diffuseTexturePtr") || + materialData_->hasAttribute("specularTexturePtr") || + materialData_->hasAttribute("objectIdTexturePtr"))) { flags_ |= Mn::Shaders::PhongGL::Flag::TextureTransformation; } - if (materialData_->hasAttribute("ambientTexture")) { + if (materialData_->hasAttribute("ambientTexturePtr")) { flags_ |= Mn::Shaders::PhongGL::Flag::AmbientTexture; } - if (materialData_->hasAttribute("diffuseTexture")) { + if (materialData_->hasAttribute("diffuseTexturePtr")) { flags_ |= Mn::Shaders::PhongGL::Flag::DiffuseTexture; } - if (materialData_->hasAttribute("specularTexture")) { + if (materialData_->hasAttribute("specularTexturePtr")) { flags_ |= Mn::Shaders::PhongGL::Flag::SpecularTexture; } - if (materialData_->hasAttribute("normalTexture")) { + if (materialData_->hasAttribute("normalTexturePtr")) { if (meshAttributeFlags & Drawable::Flag::HasTangent) { flags_ |= Mn::Shaders::PhongGL::Flag::NormalTexture; if (meshAttributeFlags & Drawable::Flag::HasSeparateBitangent) { @@ -76,7 +76,7 @@ GenericDrawable::GenericDrawable( if (materialData_->attribute("hasPerVertexObjectId")) { flags_ |= Mn::Shaders::PhongGL::Flag::InstancedObjectId; } - if (materialData_->hasAttribute("objectIdTexture")) { + if (materialData_->hasAttribute("objectIdTexturePtr")) { flags_ |= Mn::Shaders::PhongGL::Flag::ObjectIdTexture; } if (meshAttributeFlags & Drawable::Flag::HasVertexColor) { @@ -184,23 +184,23 @@ void GenericDrawable::draw(const Mn::Matrix4& transformationMatrix, if (flags_ & Mn::Shaders::PhongGL::Flag::AmbientTexture) { shader_->bindAmbientTexture( - *(materialData_->attribute("ambientTexture"))); + *(materialData_->attribute("ambientTexturePtr"))); } if (flags_ & Mn::Shaders::PhongGL::Flag::DiffuseTexture) { shader_->bindDiffuseTexture( - *(materialData_->attribute("diffuseTexture"))); + *(materialData_->attribute("diffuseTexturePtr"))); } if (flags_ & Mn::Shaders::PhongGL::Flag::SpecularTexture) { shader_->bindSpecularTexture( - *(materialData_->attribute("specularTexture"))); + *(materialData_->attribute("specularTexturePtr"))); } if (flags_ & Mn::Shaders::PhongGL::Flag::NormalTexture) { shader_->bindNormalTexture( - *(materialData_->attribute("normalTexture"))); + *(materialData_->attribute("normalTexturePtr"))); } if (flags_ >= Mn::Shaders::PhongGL::Flag::ObjectIdTexture) { shader_->bindObjectIdTexture( - *(materialData_->attribute("objectIdTexture"))); + *(materialData_->attribute("objectIdTexturePtr"))); } if (skinData_) { diff --git a/src/esp/gfx/PbrDrawable.cpp b/src/esp/gfx/PbrDrawable.cpp index c45564ac9f..780940d205 100644 --- a/src/esp/gfx/PbrDrawable.cpp +++ b/src/esp/gfx/PbrDrawable.cpp @@ -30,11 +30,11 @@ PbrDrawable::PbrDrawable(scene::SceneNode& node, materialData_{ shaderManager.get(materialDataKey)}, pbrIbl_(pbrIbl) { - if (materialData_->hasAttribute("metallicTexture") && - materialData_->hasAttribute("roughnessTexture")) { + if (materialData_->hasAttribute("metallicTexturePtr") && + materialData_->hasAttribute("roughnessTexturePtr")) { CORRADE_ASSERT( - materialData_->attribute("metallicTexture") == - materialData_->attribute("roughnessTexture"), + materialData_->attribute("metallicTexturePtr") == + materialData_->attribute("roughnessTexturePtr"), "PbrDrawable::PbrDrawable(): if both the metallic and roughness " "texture exist, they must be packed in the same texture based on glTF " "2.0 Spec.", ); @@ -46,16 +46,16 @@ PbrDrawable::PbrDrawable(scene::SceneNode& node, if (tmpMaterialData.commonTextureMatrix() != Mn::Matrix3{}) { flags_ |= PbrShader::Flag::TextureTransformation; } - if (materialData_->hasAttribute("baseColorTexture")) { + if (materialData_->hasAttribute("baseColorTexturePtr")) { flags_ |= PbrShader::Flag::BaseColorTexture; } - if (materialData_->hasAttribute("roughnessTexture")) { + if (materialData_->hasAttribute("roughnessTexturePtr")) { flags_ |= PbrShader::Flag::RoughnessTexture; } - if (materialData_->hasAttribute("metallicTexture")) { + if (materialData_->hasAttribute("metallicTexturePtr")) { flags_ |= PbrShader::Flag::MetallicTexture; } - if (materialData_->hasAttribute("normalTexture")) { + if (materialData_->hasAttribute("normalTexturePtr")) { flags_ |= PbrShader::Flag::NormalTexture; if (meshAttributeFlags & gfx::Drawable::Flag::HasTangent) { flags_ |= PbrShader::Flag::PrecomputedTangent; @@ -67,7 +67,7 @@ PbrDrawable::PbrDrawable(scene::SceneNode& node, "must be positive.", ); } } - if (materialData_->hasAttribute("emissiveTexture")) { + if (materialData_->hasAttribute("emissiveTexturePtr")) { flags_ |= PbrShader::Flag::EmissiveTexture; } if (materialData_->attribute("hasPerVertexObjectId")) { @@ -165,19 +165,19 @@ void PbrDrawable::draw(const Mn::Matrix4& transformationMatrix, // just in case user would like to do so during the run-time. if ((flags_ & PbrShader::Flag::BaseColorTexture) && - (materialData_->attribute("baseColorTexture") != + (materialData_->attribute("baseColorTexturePtr") != nullptr)) { shader_->bindBaseColorTexture( - *materialData_->attribute("baseColorTexture")); + *materialData_->attribute("baseColorTexturePtr")); } if (flags_ & (PbrShader::Flag::RoughnessTexture | PbrShader::Flag::MetallicTexture)) { Mn::GL::Texture2D* metallicRoughnessTexture = - materialData_->attribute("roughnessTexture"); + materialData_->attribute("roughnessTexturePtr"); if (!metallicRoughnessTexture) { metallicRoughnessTexture = - materialData_->attribute("metallicTexture"); + materialData_->attribute("metallicTexturePtr"); } CORRADE_ASSERT(metallicRoughnessTexture, "PbrDrawable::draw(): texture pointer cannot be nullptr if " @@ -186,17 +186,17 @@ void PbrDrawable::draw(const Mn::Matrix4& transformationMatrix, } if ((flags_ & PbrShader::Flag::NormalTexture) && - (materialData_->attribute("normalTexture") != + (materialData_->attribute("normalTexturePtr") != nullptr)) { shader_->bindNormalTexture( - *materialData_->attribute("normalTexture")); + *materialData_->attribute("normalTexturePtr")); } if ((flags_ & PbrShader::Flag::EmissiveTexture) && - (materialData_->attribute("emissiveTexture") != + (materialData_->attribute("emissiveTexturePtr") != nullptr)) { shader_->bindEmissiveTexture( - *materialData_->attribute("emissiveTexture")); + *materialData_->attribute("emissiveTexturePtr")); } if ((flags_ & PbrShader::Flag::TextureTransformation) &&