From 764d87eae6f32af85da7ca97d4006151af26c06b Mon Sep 17 00:00:00 2001 From: John Turner <7strbass@gmail.com> Date: Tue, 14 Nov 2023 09:18:59 -0500 Subject: [PATCH] --initial commit; Make fallback material noticeable --make material color magenta --add flag that this material is a fallback for an object lacking any other materials --remove default phong material function; specifying phong shader to use should be sufficient for depth sensor. --- src/esp/assets/ResourceManager.cpp | 20 +++++++++++++++++--- src/esp/assets/ResourceManager.h | 5 ++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/esp/assets/ResourceManager.cpp b/src/esp/assets/ResourceManager.cpp index f0ad6df3fd..adc3968354 100644 --- a/src/esp/assets/ResourceManager.cpp +++ b/src/esp/assets/ResourceManager.cpp @@ -2138,7 +2138,8 @@ Mn::Trade::MaterialData ResourceManager::setMaterialDefaultUserAttributes( ObjectInstanceShaderType shaderTypeToUse, bool hasVertObjID, bool hasTxtrObjID, - int txtrIdx) const { + int txtrIdx, + bool isFallback) const { // New material's attributes Cr::Containers::Array newAttributes; arrayAppend(newAttributes, Cr::InPlaceInit, "hasPerVertexObjectId", @@ -2150,6 +2151,8 @@ Mn::Trade::MaterialData ResourceManager::setMaterialDefaultUserAttributes( arrayAppend(newAttributes, Cr::InPlaceInit, "shaderTypeToUse", static_cast(shaderTypeToUse)); + arrayAppend(newAttributes, Cr::InPlaceInit, "isFallbackMaterial", isFallback); + Cr::Containers::Optional finalMaterial = Mn::MaterialTools::merge( material, Mn::Trade::MaterialData{{}, std::move(newAttributes), {}}); @@ -2250,9 +2253,20 @@ void ResourceManager::initDefaultMaterials() { // Build default material for fallback material Mn::Trade::MaterialData fallbackMaterial = buildDefaultMaterial(); - // Set expected user-defined attributes + // Make fallback magenta so visibly obvious + fallbackMaterial.mutableAttribute( + Mn::Trade::MaterialAttribute::AmbientColor) = + Mn::Color4{1.0f, 0.0f, 1.0f, 1.0f}; + fallbackMaterial.mutableAttribute( + Mn::Trade::MaterialAttribute::DiffuseColor) = + Mn::Color4{1.0f, 0.0f, 1.0f, 1.0f}; + fallbackMaterial.mutableAttribute( + Mn::Trade::MaterialAttribute::SpecularColor) = + Mn::Color4{1.0f, 0.0f, 1.0f, 1.0f}; + // Set expected user-defined attributes - specify Phong shader to use fallbackMaterial = setMaterialDefaultUserAttributes( - fallbackMaterial, ObjectInstanceShaderType::Flat); + fallbackMaterial, ObjectInstanceShaderType::Phong, false, false, -1, + true); // Add to shaderManager as fallback material shaderManager_.setFallback( std::move(fallbackMaterial)); diff --git a/src/esp/assets/ResourceManager.h b/src/esp/assets/ResourceManager.h index f79ed15f67..b1f284522e 100644 --- a/src/esp/assets/ResourceManager.h +++ b/src/esp/assets/ResourceManager.h @@ -751,6 +751,8 @@ class ResourceManager { * ids for semantics. * @param txtrIdx The absolute index in the @ref textures_ store for the semantic * annotation texture. + * @param isFallback This material is default fallback material for missing + * materials. * @return the updated material */ Mn::Trade::MaterialData setMaterialDefaultUserAttributes( @@ -758,7 +760,8 @@ class ResourceManager { ObjectInstanceShaderType shaderTypeToUse, bool hasVertObjID = false, bool hasTxtrObjID = false, - int txtrIdx = -1) const; + int txtrIdx = -1, + bool isFallback = false) const; /** * @brief Configure the importerManager_ GL Extensions appropriately based on