From 9fc1365620894d7dd35d0426757b1aabaa87f3a6 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Wed, 3 Feb 2021 13:50:49 -0800 Subject: [PATCH] fix copying to unlit Signed-off-by: Ian Chen --- ogre2/src/Ogre2Material.cc | 21 ++++++++++++++------- ogre2/src/Ogre2ThermalCamera.cc | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/ogre2/src/Ogre2Material.cc b/ogre2/src/Ogre2Material.cc index d2e17d8c7..679fff2a8 100644 --- a/ogre2/src/Ogre2Material.cc +++ b/ogre2/src/Ogre2Material.cc @@ -585,16 +585,23 @@ Ogre::HlmsUnlitDatablock *Ogre2Material::UnlitDatablock() void Ogre2Material::FillUnlitDatablock(Ogre::HlmsUnlitDatablock *_datablock) const { - auto tex = this->ogreDatablock->getTexture(Ogre::PBSM_DIFFUSE); - if (tex) - _datablock->setTexture(0, 0, tex); + if (!this->textureName.empty()) + { + std::string baseName = common::basename(this->textureName); + Ogre::HlmsTextureManager *hlmsTextureManager = + this->ogreHlmsPbs->getHlmsManager()->getTextureManager(); + Ogre::HlmsTextureManager::TextureLocation texLocation = + hlmsTextureManager->createOrRetrieveTexture(baseName, + this->ogreDatablock->suggestMapTypeBasedOnTextureType( + Ogre::PBSM_DIFFUSE)); + _datablock->setTexture(0, texLocation.xIdx, texLocation.texture); + } + auto samplerblock = this->ogreDatablock->getSamplerblock(Ogre::PBSM_DIFFUSE); if (samplerblock) _datablock->setSamplerblock(0, *samplerblock); - _datablock->setMacroblock( - this->ogreDatablock->getMacroblock()); - _datablock->setBlendblock( - this->ogreDatablock->getBlendblock()); + _datablock->setMacroblock(this->ogreDatablock->getMacroblock()); + _datablock->setBlendblock(this->ogreDatablock->getBlendblock()); _datablock->setUseColour(true); Ogre::Vector3 c = this->ogreDatablock->getDiffuse(); diff --git a/ogre2/src/Ogre2ThermalCamera.cc b/ogre2/src/Ogre2ThermalCamera.cc index 504afa0e4..1d5f36302 100644 --- a/ogre2/src/Ogre2ThermalCamera.cc +++ b/ogre2/src/Ogre2ThermalCamera.cc @@ -348,7 +348,7 @@ void Ogre2ThermalCameraMaterialSwitcher::preRenderTargetUpdate( Ogre::AxisAlignedBox box = Ogre::AxisAlignedBox(aabb.getMinimum(), aabb.getMaximum()); - // we will be converting rgb values to tempearture values in shaders + // we will be converting rgb values to temperature values in shaders // but we want to make sure the object rgb values are not affected by // lighting, so disable lighting // Also check if objects are within camera view