Skip to content

Commit 678d0fc

Browse files
committed
ovis: handle bg material change after shader genration
1 parent 758c1a9 commit 678d0fc

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

modules/ovis/src/ovis.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -443,14 +443,21 @@ class WindowSceneImpl : public WindowScene
443443

444444
_createTexture(name, image.getMat());
445445

446+
// ensure bgplane is visible
447+
bgplane->setVisible(true);
446448
bgplane->setDefaultUVs();
447449

448-
Pass* rpass = bgplane->getMaterial()->getBestTechnique()->getPasses()[0];
449-
rpass->getTextureUnitStates()[0]->setTextureName(name);
450-
rpass->getTextureUnitStates()[0]->setTextureAddressingMode(TAM_CLAMP);
450+
Pass* rpass = bgplane->getMaterial()->getTechnique(0)->getPasses()[0];
451+
auto tus = rpass->getTextureUnitStates()[0];
451452

452-
// ensure bgplane is visible
453-
bgplane->setVisible(true);
453+
if(tus->getTextureName() != name)
454+
{
455+
RTShader::ShaderGenerator::getSingleton().invalidateMaterial(
456+
RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, *bgplane->getMaterial());
457+
458+
tus->setTextureName(name);
459+
tus->setTextureAddressingMode(TAM_CLAMP);
460+
}
454461
}
455462

456463
void setCompositors(const std::vector<String>& names) CV_OVERRIDE

0 commit comments

Comments
 (0)