[osg-users] problem setting texture min/mag filter

antiro black antiro42 at gmail.com
Sun Feb 11 23:51:50 PST 2018


Hi,

I'm trying to use a texture to get some data to a shader. The texure is created by first creating an osg::Image, setting its pixel values manually and then assigning the image to a texture. I have verified that the image is created correctly by writing it to a file.

As for the actual texture generation I use the following code:


Code:

osg::ref_ptr<osg::Image> m_tileDataImg=nullptr;

// some code to create the osg::image
// ...
// ...

auto tileDataTexture=new osg::Texture2D();

tileDataTexture->setWrap(osg::Texture::WRAP_S,osg::Texture::REPEAT);
tileDataTexture->setWrap(osg::Texture::WRAP_T,osg::Texture::REPEAT);
tileDataTexture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::NEAREST);
tileDataTexture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::NEAREST);
tileDataTexture->setImage(m_tileDataImg);

drawableNode->getStateSet()->setTextureAttributeAndModes(0,tileDataTexture,osg::StateAttribute::ON);





In my shader I rendered the texture for debugging purposes and realized that the data was changed. After a closer inspection it turned out that the data had been interpolated, hence my suspicion that the "setFilter" code did not work correctly.

My question is whether there is some other thing I need to do to ensure that no interpolation happens when sampling the texture in my shader?

Any help would be greatly appreciated.
Thank you!

Cheers,
antiro

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=72956#72956







More information about the osg-users mailing list