From 499adba97fc2f7eb6f7d1982833ae63b86a4ec09 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 9 Dec 2013 10:39:01 +0000 Subject: [PATCH] Improvements to new MultipassTechnique --- src/osgVolume/MultipassTechnique.cpp | 12 ++++++++++-- src/osgVolume/VolumeScene.cpp | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/osgVolume/MultipassTechnique.cpp b/src/osgVolume/MultipassTechnique.cpp index d30cd2d97..3d2d066e8 100644 --- a/src/osgVolume/MultipassTechnique.cpp +++ b/src/osgVolume/MultipassTechnique.cpp @@ -227,8 +227,13 @@ void MultipassTechnique::init() osg::ref_ptr texture3D = new osg::Texture3D; { osg::Texture::InternalFormatMode internalFormatMode = osg::Texture::USE_IMAGE_DATA_FORMAT; +#if 1 osg::Texture::FilterMode minFilter = osg::Texture::LINEAR; osg::Texture::FilterMode magFilter = osg::Texture::LINEAR; +#else + osg::Texture::FilterMode minFilter = osg::Texture::NEAREST; + osg::Texture::FilterMode magFilter = osg::Texture::NEAREST; +#endif // set up the 3d texture itself, // note, well set the filtering up so that mip mapping is disabled, @@ -255,8 +260,11 @@ void MultipassTechnique::init() stateset->setTextureAttributeAndModes(volumeTextureUnit, texture3D, osg::StateAttribute::ON); - osg::Uniform* baseTextureSampler = new osg::Uniform("volumeTexture", int(volumeTextureUnit)); - stateset->addUniform(baseTextureSampler); + osg::ref_ptr baseTextureSampler = new osg::Uniform("volumeTexture", int(volumeTextureUnit)); + stateset->addUniform(baseTextureSampler.get()); + + osg::ref_ptr volumeCellSize = new osg::Uniform("volumeCellSize", osg::Vec3(1.0f/static_cast(image_3d->s()),1.0f/static_cast(image_3d->t()),1.0f/static_cast(image_3d->r()))); + stateset->addUniform(volumeCellSize.get()); } diff --git a/src/osgVolume/VolumeScene.cpp b/src/osgVolume/VolumeScene.cpp index c65f6b3f7..3a0ef337a 100644 --- a/src/osgVolume/VolumeScene.cpp +++ b/src/osgVolume/VolumeScene.cpp @@ -87,6 +87,9 @@ void VolumeScene::tileVisited(osg::NodeVisitor* nv, osgVolume::VolumeTile* tile) tileData->modelviewMatrix = cv->getModelViewMatrix(); viewData->_tiles.push_back(tileData.get()); } + + osg::BoundingBox bb(0.0f,0.0f,0.0f,1.0f,1.0f,1.0f); + cv->updateCalculatedNearFar(*(cv->getModelViewMatrix()),bb); } }