[osg-users] Changing minFilter/magFilter of texture in osgVolume::RayTracedTechnique

Sailesh Sidhwani ssidhwan at mathworks.com
Tue Apr 16 12:10:28 PDT 2019


I have RayTracedTechnique putting graphics on the screen, but things aren't rendering correctly. The culprit is the 'osg::Texture3D::LINEAR' choice that is used by default as the min/mag filter for the Texture3D object created by RayTracedTechnique. I'd like to change to NEAREST as I'm working with segmented/ labeled volume.   The problem I'm seeing is that when I use the setMinFilter and setMaxFilter methods on the associated ImageLayer, things aren't getting updated for some reason. I know that's what's going on because if I actually edit the code in RayTracedTechnique.cpp to use NEAREST for the min/max filter on the Texture3D, I get the texture I want on the screen.


Here is some code for context:

            osg::ref_ptr<osgVolume::Volume> volume = new osgVolume::Volume;

            osg::ref_ptr<osgVolume::VolumeTile> tile = new osgVolume::VolumeTile;
            volume->addChild(tile.get());

            osg::ref_ptr<osg::Image> image_3d = createTexture3D(data,xfer_table);

            osg::ref_ptr<osgVolume::ImageLayer> layer = new osgVolume::ImageLayer(image_3d.get());

            tile->setLayer(layer.get());

            layer->addProperty(new osgVolume::AlphaFuncProperty(0.02f));

            osg::ref_ptr<osgVolume:: RayTracedTechnique > technique = new osgVolume:: RayTracedTechnique ();
            technique->setNumSlices(200);
            tile->setVolumeTechnique(technique);

            layer->setMagFilter(osg::Texture3D:: NEAREST);
            layer->setMinFilter(osg::Texture3D:: NEAREST);


Here is how the output looks when I edit RayTracedTechnique.cpp to use NEAREST minFilter/magFilter. This is how I expect it to look

[cid:image001.png at 01D4F464.82427F50]



Default RayTracedTechnique.cpp (which uses LINEAR minFilter/magFilter): (Not expected)
[cid:image003.png at 01D4F466.84604450]


How can I force the Texture3D object created by RayTracedTechnique to use NEAREST for minFilter/magFiltering?


I'm using OSG 3.0. I know I need to upgrade, but I didn't see any way to do this even in OSG 3.6


Thanks,
-Sailesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20190416/d66f79cb/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 3808 bytes
Desc: image001.png
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20190416/d66f79cb/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 50062 bytes
Desc: image003.png
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20190416/d66f79cb/attachment-0003.png>


More information about the osg-users mailing list