Share texture type attributes

pull/3236/head
Alexei Kotov 2 months ago
parent 1349fdb4f2
commit 964dafd42c

@ -1027,7 +1027,7 @@ namespace NifOsg
} }
osg::ref_ptr<osg::Texture2D> attachTexture(const std::string& name, osg::ref_ptr<osg::Image> image, bool wrapS, osg::ref_ptr<osg::Texture2D> attachTexture(const std::string& name, osg::ref_ptr<osg::Image> image, bool wrapS,
bool wrapT, unsigned int uvSet, osg::StateSet* stateset, std::vector<unsigned int>& boundTextures) const bool wrapT, unsigned int uvSet, osg::StateSet* stateset, std::vector<unsigned int>& boundTextures)
{ {
osg::ref_ptr<osg::Texture2D> texture2d = new osg::Texture2D(image); osg::ref_ptr<osg::Texture2D> texture2d = new osg::Texture2D(image);
if (image) if (image)
@ -1038,22 +1038,23 @@ namespace NifOsg
if (stateset) if (stateset)
{ {
stateset->setTextureAttributeAndModes(texUnit, texture2d, osg::StateAttribute::ON); stateset->setTextureAttributeAndModes(texUnit, texture2d, osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes( osg::ref_ptr<SceneUtil::TextureType> textureType = new SceneUtil::TextureType(name);
texUnit, new SceneUtil::TextureType(name), osg::StateAttribute::ON); textureType = shareAttribute(textureType);
stateset->setTextureAttributeAndModes(texUnit, textureType, osg::StateAttribute::ON);
} }
boundTextures.emplace_back(uvSet); boundTextures.emplace_back(uvSet);
return texture2d; return texture2d;
} }
osg::ref_ptr<osg::Texture2D> attachExternalTexture(const std::string& name, const std::string& path, bool wrapS, osg::ref_ptr<osg::Texture2D> attachExternalTexture(const std::string& name, const std::string& path, bool wrapS,
bool wrapT, unsigned int uvSet, osg::StateSet* stateset, std::vector<unsigned int>& boundTextures) const bool wrapT, unsigned int uvSet, osg::StateSet* stateset, std::vector<unsigned int>& boundTextures)
{ {
return attachTexture(name, getTextureImage(path), wrapS, wrapT, uvSet, stateset, boundTextures); return attachTexture(name, getTextureImage(path), wrapS, wrapT, uvSet, stateset, boundTextures);
} }
osg::ref_ptr<osg::Texture2D> attachNiSourceTexture(const std::string& name, const Nif::NiSourceTexture* st, osg::ref_ptr<osg::Texture2D> attachNiSourceTexture(const std::string& name, const Nif::NiSourceTexture* st,
bool wrapS, bool wrapT, unsigned int uvSet, osg::StateSet* stateset, bool wrapS, bool wrapT, unsigned int uvSet, osg::StateSet* stateset,
std::vector<unsigned int>& boundTextures) const std::vector<unsigned int>& boundTextures)
{ {
return attachTexture(name, handleSourceTexture(st), wrapS, wrapT, uvSet, stateset, boundTextures); return attachTexture(name, handleSourceTexture(st), wrapS, wrapT, uvSet, stateset, boundTextures);
} }

Loading…
Cancel
Save