diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 7105147e6d..9b31a1b93e 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -400,7 +400,10 @@ namespace NifOsg return; } - osg::ref_ptr texture2d (new osg::Texture2D(handleSourceTexture(textureEffect->texture.getPtr(), imageManager))); + osg::ref_ptr image (handleSourceTexture(textureEffect->texture.getPtr(), imageManager)); + osg::ref_ptr texture2d (new osg::Texture2D(image)); + if (image) + texture2d->setTextureSize(image->s(), image->t()); texture2d->setName("envMap"); unsigned int clamp = static_cast(textureEffect->clamp); int wrapT = (clamp) & 0x1; @@ -771,7 +774,10 @@ namespace NifOsg wrapT = inherit->getWrap(osg::Texture2D::WRAP_T); } - osg::ref_ptr texture (new osg::Texture2D(handleSourceTexture(st.getPtr(), imageManager))); + osg::ref_ptr image (handleSourceTexture(st.getPtr(), imageManager)); + osg::ref_ptr texture (new osg::Texture2D(image)); + if (image) + texture->setTextureSize(image->s(), image->t()); texture->setWrap(osg::Texture::WRAP_S, wrapS); texture->setWrap(osg::Texture::WRAP_T, wrapT); textures.push_back(texture); @@ -1338,6 +1344,8 @@ namespace NifOsg const Nif::NiSourceTexture *st = tex.texture.getPtr(); osg::ref_ptr image = handleSourceTexture(st, imageManager); texture2d = new osg::Texture2D(image); + if (image) + texture2d->setTextureSize(image->s(), image->t()); } else texture2d = new osg::Texture2D; diff --git a/components/shader/shadervisitor.cpp b/components/shader/shadervisitor.cpp index 63c6761188..e40cc255b9 100644 --- a/components/shader/shadervisitor.cpp +++ b/components/shader/shadervisitor.cpp @@ -163,6 +163,7 @@ namespace Shader if (image) { osg::ref_ptr normalMapTex (new osg::Texture2D(image)); + normalMapTex->setTextureSize(image->s(), image->t()); normalMapTex->setWrap(osg::Texture::WRAP_S, diffuseMap->getWrap(osg::Texture::WRAP_S)); normalMapTex->setWrap(osg::Texture::WRAP_T, diffuseMap->getWrap(osg::Texture::WRAP_T)); normalMapTex->setFilter(osg::Texture::MIN_FILTER, diffuseMap->getFilter(osg::Texture::MIN_FILTER)); @@ -186,7 +187,9 @@ namespace Shader boost::replace_last(specularMapFileName, ".", mSpecularMapPattern + "."); if (mImageManager.getVFS()->exists(specularMapFileName)) { - osg::ref_ptr specularMapTex (new osg::Texture2D(mImageManager.getImage(specularMapFileName))); + osg::ref_ptr image (mImageManager.getImage(specularMapFileName)); + osg::ref_ptr specularMapTex (new osg::Texture2D(image)); + specularMapTex->setTextureSize(image->s(), image->t()); specularMapTex->setWrap(osg::Texture::WRAP_S, diffuseMap->getWrap(osg::Texture::WRAP_S)); specularMapTex->setWrap(osg::Texture::WRAP_T, diffuseMap->getWrap(osg::Texture::WRAP_T)); specularMapTex->setFilter(osg::Texture::MIN_FILTER, diffuseMap->getFilter(osg::Texture::MIN_FILTER));