Merged improvements to osgVolume from svn/trunk using :
svn merge -r 10100:10137 http://www.openscenegraph.org/svn/osg/OpenSceneGraph/trunk/src/osgVolume
This commit is contained in:
@@ -98,9 +98,25 @@ osg::Node* createCube(const osg::Vec3& center, float size, unsigned int numSlice
|
||||
|
||||
void FixedFunctionTechnique::init()
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"FixedFunctionTechnique::init()"<<std::endl;
|
||||
osg::notify(osg::INFO)<<"FixedFunctionTechnique::init()"<<std::endl;
|
||||
|
||||
if (!_volumeTile) return;
|
||||
if (!_volumeTile)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"FixedFunctionTechnique::init(), error no volume tile assigned."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_volumeTile->getLayer()==0)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"FixedFunctionTechnique::init(), error no layer assigend to volume tile."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_volumeTile->getLayer()->getImage()==0)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"FixedFunctionTechnique::init(), error no image assigned to layer."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
float alphaFuncValue = 0.1;
|
||||
|
||||
|
||||
@@ -51,21 +51,38 @@ enum ShadingModel
|
||||
|
||||
void RayTracedTechnique::init()
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"RayTracedTechnique::init()"<<std::endl;
|
||||
|
||||
if (!_volumeTile) return;
|
||||
|
||||
osg::notify(osg::INFO)<<"RayTracedTechnique::init()"<<std::endl;
|
||||
|
||||
if (!_volumeTile)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"RayTracedTechnique::init(), error no volume tile assigned."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_volumeTile->getLayer()==0)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"RayTracedTechnique::init(), error no layer assigend to volume tile."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_volumeTile->getLayer()->getImage()==0)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"RayTracedTechnique::init(), error no image assigned to layer."<<std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
ShadingModel shadingModel = Isosurface;
|
||||
float alphaFuncValue = 0.1;
|
||||
|
||||
|
||||
_geode = new osg::Geode;
|
||||
|
||||
|
||||
osg::Image* image_3d = 0;
|
||||
osg::TransferFunction1D* tf = 0;
|
||||
osgVolume::Locator* masterLocator = _volumeTile->getLocator();
|
||||
|
||||
image_3d = _volumeTile->getLayer()->getImage();
|
||||
|
||||
|
||||
|
||||
CollectPropertiesVisitor cpv;
|
||||
if (_volumeTile->getLayer()->getProperty())
|
||||
{
|
||||
@@ -113,7 +130,7 @@ void RayTracedTechnique::init()
|
||||
}
|
||||
|
||||
|
||||
osg::notify(osg::NOTICE)<<"Matrix = "<<matrix<<std::endl;
|
||||
osg::notify(osg::INFO)<<"RayTracedTechnique::init() : matrix = "<<matrix<<std::endl;
|
||||
|
||||
osg::Texture::InternalFormatMode internalFormatMode = osg::Texture::USE_IMAGE_DATA_FORMAT;
|
||||
|
||||
@@ -173,8 +190,12 @@ void RayTracedTechnique::init()
|
||||
}
|
||||
|
||||
|
||||
bool enableBlending = false;
|
||||
|
||||
if (shadingModel==MaximumIntensityProjection)
|
||||
{
|
||||
enableBlending = true;
|
||||
|
||||
if (tf)
|
||||
{
|
||||
osg::Texture1D* texture1D = new osg::Texture1D;
|
||||
@@ -259,6 +280,8 @@ void RayTracedTechnique::init()
|
||||
}
|
||||
else if (shadingModel==Light)
|
||||
{
|
||||
enableBlending = true;
|
||||
|
||||
if (tf)
|
||||
{
|
||||
osg::Texture1D* texture1D = new osg::Texture1D;
|
||||
@@ -301,10 +324,12 @@ void RayTracedTechnique::init()
|
||||
}
|
||||
else
|
||||
{
|
||||
enableBlending = true;
|
||||
|
||||
if (tf)
|
||||
{
|
||||
osg::notify(osg::NOTICE)<<"Setting up TF path"<<std::endl;
|
||||
|
||||
osg::notify(osg::INFO)<<"Setting up TF path"<<std::endl;
|
||||
|
||||
osg::Texture1D* texture1D = new osg::Texture1D;
|
||||
texture1D->setImage(tf->getImage());
|
||||
texture1D->setResizeNonPowerOfTwoHint(false);
|
||||
@@ -329,7 +354,7 @@ void RayTracedTechnique::init()
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
|
||||
osg::Shader* fragmentShader = osgDB::readShaderFile(osg::Shader::FRAGMENT, "shaders/volume.frag");
|
||||
if (fragmentShader)
|
||||
@@ -362,6 +387,13 @@ void RayTracedTechnique::init()
|
||||
stateset->addUniform(new osg::Uniform("AlphaFuncValue",alphaFuncValue));
|
||||
|
||||
|
||||
if (enableBlending)
|
||||
{
|
||||
stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
|
||||
stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
||||
}
|
||||
|
||||
|
||||
stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
||||
|
||||
osg::TexGen* texgen = new osg::TexGen;
|
||||
|
||||
@@ -108,8 +108,9 @@ char volume_iso_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
" color.y = lightScale;\n"
|
||||
" color.z = lightScale;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" if (color.w>1.0) color.w = 1.0; \n"
|
||||
"\n"
|
||||
" color.a = 1.0;\n"
|
||||
"\n"
|
||||
" gl_FragColor = color;\n"
|
||||
" \n"
|
||||
" return;\n"
|
||||
@@ -124,4 +125,5 @@ char volume_iso_frag[] = "uniform sampler3D baseTexture;\n"
|
||||
"\n"
|
||||
" // we didn't find an intersection so just discard fragment\n"
|
||||
" discard;\n"
|
||||
"}\n";
|
||||
"}\n"
|
||||
"\n";
|
||||
|
||||
Reference in New Issue
Block a user