Hi Josiah,
Can you check the GL_MAX_3D_TEXTURE_SIZE with something like GPU Caps
Viewer?
Even my GTX680 only supports 2048. So basically you might be hitting the
limit.
cheers
Sebastian
Hi,
I am involved in a project where I have to build a 3D image from
processed ultrasound data. The 3D image is built up as a stack of 2D
images. I inherited the code to build the 3D volume in Qt 4.7.1 on a
linux machine. The code has been working fine until I developed a new
imaging algorithm and had to increase the size of the volume. Here is
the code snippet that sets up the viewer:
//image
osg::Image* image = new osg::Image;
image->allocateImage(_S, _T, _R, GL_RGBA, GL_FLOAT);
for(int s = 0; s < image->s(); s++)
{
for(int t = 0; t < image->t(); t++)
{
for(int r = 0; r < image->r(); r++)
{
float*_data = (float*)(image->data(s, t, r));
_data[0] = 0.0f;
_data[1] = 0.0f;
_data[2] = 1.0f;
_data[3] = 0.1f;
}
}
}
float image_s = (float)(image->s());
float image_t = (float)(image->t())/10.0f;
float image_r = (float)(image->r());
osg::ref_ptr<osg::RefMatrix> matrix = new osg::RefMatrix();
osgVolume::Locator* locator = new
osgVolume::Locator(*matrix.get());
locator->setTransformAsExtents(0.0f, 0.0f, image_s, image_t,
0.0f, image_r);
osgVolume::Layer* layer = new osgVolume::ImageLayer(image);
layer->setLocator(locator);
osgVolume::VolumeTile* tile = new osgVolume::VolumeTile;
tile->setLocator(locator);
tile->setLayer(layer);
tile->setEventCallback(new
osgVolume::PropertyAdjustmentCallback());
hss::ShaderModel shaderModel = hss::StanderdShaderModel;
hss::ShaderTechnique shaderTechnique =
hss::RayTracedShaderTechnique;
float alphaFunc=0.001;
switch (shaderTechnique)
{
case (hss::RayTracedShaderTechnique):
{
osgVolume::SwitchProperty* sp = new
osgVolume::SwitchProperty;
sp->setActiveProperty(0);
osgVolume::AlphaFuncProperty* ap = new
osgVolume::AlphaFuncProperty(alphaFunc);
osgVolume::SampleDensityProperty* sd = new
osgVolume::SampleDensityProperty(0.005);
osgVolume::TransparencyProperty* tp = new
osgVolume::TransparencyProperty(1.0);
osgVolume::TransferFunctionProperty* tfp = 0;
{
// Standard
osgVolume::CompositeProperty* cp = new
osgVolume::CompositeProperty;
cp->addProperty(ap);
cp->addProperty(sd);
cp->addProperty(tp);
if (tfp) cp->addProperty(tfp);
sp->addProperty(cp);
}
{
// Light
osgVolume::CompositeProperty* cp = new
osgVolume::CompositeProperty;
cp->addProperty(ap);
cp->addProperty(sd);
cp->addProperty(tp);
cp->addProperty(new osgVolume::LightingProperty);
if (tfp) cp->addProperty(tfp);
sp->addProperty(cp);
}
{
// IsoSurface
osgVolume::CompositeProperty* cp = new
osgVolume::CompositeProperty;
cp->addProperty(sd);
cp->addProperty(tp);
cp->addProperty(new
osgVolume::IsoSurfaceProperty(alphaFunc));
if (tfp) cp->addProperty(tfp);
sp->addProperty(cp);
}
{
// MaximumIntensityProjection
osgVolume::CompositeProperty* cp = new
osgVolume::CompositeProperty;
cp->addProperty(ap);
cp->addProperty(sd);
cp->addProperty(tp);
cp->addProperty(new
osgVolume::MaximumIntensityProjectionProperty);
if (tfp) cp->addProperty(tfp);
sp->addProperty(cp);
}
switch(shaderModel)
{
case(hss::StanderdShaderModel): sp->setActiveProperty(0); break;
case(hss::LightShaderModel): sp->setActiveProperty(1); break;
case(hss::IsosurfaceShaderModel): sp->setActiveProperty(2); break;
case(hss::MaximumIntensityProjectionShaderModel):
sp->setActiveProperty(3); break;
}
layer->addProperty(sp);
tile->setVolumeTechnique(new
osgVolume::RayTracedTechnique);
}
break;
default:
{
layer->addProperty(new
osgVolume::AlphaFuncProperty(alphaFunc));
tile->setVolumeTechnique(new
osgVolume::FixedFunctionTechnique);
}
}
//volume
osgVolume::Volume* volume = new osgVolume::Volume;
volume->addChild(tile);
osg::Group* rootBox = new osg::Group;
rootBox->addChild(volume);
The typical values for _S, _T, and _R used in the allocateImage()
function call are 127, 2048 and 63 respectively and they are represent
the exact size of the data matrix.
I observed that when _T is increased to 4096, the mapping from data to
the 3D image becomes distorted and the image seems to shift to the
2nd half of the volume. While debugging I noticed that when I only
initialize the pixels in the first half of the 3D image ( for(int t =
0; t < image->t()/2; t++) ), I get something that looks like Fig. 1
instead of Fig. 2. In Fig. 1, it seems to be initializing 32 slices
of the entire volume instead of the all 63 slices of only the first
half (like in Fig 2), as a result the location of the representation
of my targets in the 3D image does not correlate with that actual
location of the targets in the real world.
Could you help me understand why this is happening and the possible
solutions to this? I am quite new to OSG so I request that you be
patient with me if I ask dumb questions?
PS: I have an nvidia geforce GTX 480 graphics card on the system.
Thank you
Regards,
Josiah
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org