Introduced SampleRatioValueProperty for more intuitive control of how many samples to take when volume rendering
This commit is contained in:
@@ -1067,8 +1067,14 @@ int main( int argc, char **argv )
|
|||||||
sp->setActiveProperty(0);
|
sp->setActiveProperty(0);
|
||||||
|
|
||||||
osgVolume::AlphaFuncProperty* ap = new osgVolume::AlphaFuncProperty(alphaFunc);
|
osgVolume::AlphaFuncProperty* ap = new osgVolume::AlphaFuncProperty(alphaFunc);
|
||||||
osgVolume::SampleDensityProperty* sd = new osgVolume::SampleDensityProperty(0.005);
|
|
||||||
|
// SampleDensity is now deprecated
|
||||||
|
osgVolume::SampleDensityProperty* sd = new osgVolume::SampleDensityProperty(0.005f);
|
||||||
osgVolume::SampleDensityWhenMovingProperty* sdwm = sampleDensityWhenMoving!=0.0 ? new osgVolume::SampleDensityWhenMovingProperty(sampleDensityWhenMoving) : 0;
|
osgVolume::SampleDensityWhenMovingProperty* sdwm = sampleDensityWhenMoving!=0.0 ? new osgVolume::SampleDensityWhenMovingProperty(sampleDensityWhenMoving) : 0;
|
||||||
|
|
||||||
|
// use SampleRatio in place of SampleDensity
|
||||||
|
osgVolume::SampleRatioProperty* sr = new osgVolume::SampleRatioProperty(1.0f);
|
||||||
|
|
||||||
osgVolume::TransparencyProperty* tp = new osgVolume::TransparencyProperty(1.0);
|
osgVolume::TransparencyProperty* tp = new osgVolume::TransparencyProperty(1.0);
|
||||||
osgVolume::TransferFunctionProperty* tfp = transferFunction.valid() ? new osgVolume::TransferFunctionProperty(transferFunction.get()) : 0;
|
osgVolume::TransferFunctionProperty* tfp = transferFunction.valid() ? new osgVolume::TransferFunctionProperty(transferFunction.get()) : 0;
|
||||||
|
|
||||||
@@ -1076,8 +1082,10 @@ int main( int argc, char **argv )
|
|||||||
// Standard
|
// Standard
|
||||||
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
|
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
|
||||||
cp->addProperty(ap);
|
cp->addProperty(ap);
|
||||||
cp->addProperty(sd);
|
if (useMultipass) cp->addProperty(sr);
|
||||||
|
else cp->addProperty(sd);
|
||||||
cp->addProperty(tp);
|
cp->addProperty(tp);
|
||||||
|
|
||||||
if (sdwm) cp->addProperty(sdwm);
|
if (sdwm) cp->addProperty(sdwm);
|
||||||
if (tfp) cp->addProperty(tfp);
|
if (tfp) cp->addProperty(tfp);
|
||||||
|
|
||||||
@@ -1088,7 +1096,8 @@ int main( int argc, char **argv )
|
|||||||
// Light
|
// Light
|
||||||
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
|
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
|
||||||
cp->addProperty(ap);
|
cp->addProperty(ap);
|
||||||
cp->addProperty(sd);
|
if (useMultipass) cp->addProperty(sr);
|
||||||
|
else cp->addProperty(sd);
|
||||||
cp->addProperty(tp);
|
cp->addProperty(tp);
|
||||||
cp->addProperty(new osgVolume::LightingProperty);
|
cp->addProperty(new osgVolume::LightingProperty);
|
||||||
if (sdwm) cp->addProperty(sdwm);
|
if (sdwm) cp->addProperty(sdwm);
|
||||||
@@ -1100,7 +1109,8 @@ int main( int argc, char **argv )
|
|||||||
{
|
{
|
||||||
// Isosurface
|
// Isosurface
|
||||||
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
|
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
|
||||||
cp->addProperty(sd);
|
if (useMultipass) cp->addProperty(sr);
|
||||||
|
else cp->addProperty(sd);
|
||||||
cp->addProperty(tp);
|
cp->addProperty(tp);
|
||||||
cp->addProperty(new osgVolume::IsoSurfaceProperty(alphaFunc));
|
cp->addProperty(new osgVolume::IsoSurfaceProperty(alphaFunc));
|
||||||
if (sdwm) cp->addProperty(sdwm);
|
if (sdwm) cp->addProperty(sdwm);
|
||||||
@@ -1113,7 +1123,10 @@ int main( int argc, char **argv )
|
|||||||
// MaximumIntensityProjection
|
// MaximumIntensityProjection
|
||||||
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
|
osgVolume::CompositeProperty* cp = new osgVolume::CompositeProperty;
|
||||||
cp->addProperty(ap);
|
cp->addProperty(ap);
|
||||||
cp->addProperty(sd);
|
|
||||||
|
if (useMultipass) cp->addProperty(sr);
|
||||||
|
else cp->addProperty(sd);
|
||||||
|
|
||||||
cp->addProperty(tp);
|
cp->addProperty(tp);
|
||||||
cp->addProperty(new osgVolume::MaximumIntensityProjectionProperty);
|
cp->addProperty(new osgVolume::MaximumIntensityProjectionProperty);
|
||||||
if (sdwm) cp->addProperty(sdwm);
|
if (sdwm) cp->addProperty(sdwm);
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class IsoSurfaceProperty;
|
|||||||
class MaximumIntensityProjectionProperty;
|
class MaximumIntensityProjectionProperty;
|
||||||
class LightingProperty;
|
class LightingProperty;
|
||||||
class AlphaFuncProperty;
|
class AlphaFuncProperty;
|
||||||
|
class SampleRatioProperty;
|
||||||
class SampleDensityProperty;
|
class SampleDensityProperty;
|
||||||
class SampleDensityWhenMovingProperty;
|
class SampleDensityWhenMovingProperty;
|
||||||
class TransparencyProperty;
|
class TransparencyProperty;
|
||||||
@@ -55,6 +56,7 @@ class OSGVOLUME_EXPORT PropertyVisitor
|
|||||||
virtual void apply(AlphaFuncProperty&) {}
|
virtual void apply(AlphaFuncProperty&) {}
|
||||||
virtual void apply(MaximumIntensityProjectionProperty&) {}
|
virtual void apply(MaximumIntensityProjectionProperty&) {}
|
||||||
virtual void apply(LightingProperty&) {}
|
virtual void apply(LightingProperty&) {}
|
||||||
|
virtual void apply(SampleRatioProperty&) {}
|
||||||
virtual void apply(SampleDensityProperty&) {}
|
virtual void apply(SampleDensityProperty&) {}
|
||||||
virtual void apply(SampleDensityWhenMovingProperty&) {}
|
virtual void apply(SampleDensityWhenMovingProperty&) {}
|
||||||
virtual void apply(TransparencyProperty&) {}
|
virtual void apply(TransparencyProperty&) {}
|
||||||
@@ -327,6 +329,25 @@ class OSGVOLUME_EXPORT SampleDensityWhenMovingProperty : public ScalarProperty
|
|||||||
virtual ~SampleDensityWhenMovingProperty() {}
|
virtual ~SampleDensityWhenMovingProperty() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Sample density to use when the volume is static relative to the eye point or when moving if no SampleDensityWhenMovingProperty is assigned.*/
|
||||||
|
class OSGVOLUME_EXPORT SampleRatioProperty : public ScalarProperty
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
SampleRatioProperty(float value=1.0f);
|
||||||
|
|
||||||
|
SampleRatioProperty(const SampleRatioProperty& isp,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
|
||||||
|
|
||||||
|
META_Object(osgVolume, SampleRatioProperty);
|
||||||
|
|
||||||
|
virtual void accept(PropertyVisitor& pv) { pv.apply(*this); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
virtual ~SampleRatioProperty() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class OSGVOLUME_EXPORT TransparencyProperty : public ScalarProperty
|
class OSGVOLUME_EXPORT TransparencyProperty : public ScalarProperty
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -360,6 +381,7 @@ class OSGVOLUME_EXPORT CollectPropertiesVisitor : public osgVolume::PropertyVisi
|
|||||||
virtual void apply(LightingProperty& lp);
|
virtual void apply(LightingProperty& lp);
|
||||||
virtual void apply(SampleDensityProperty& sdp);
|
virtual void apply(SampleDensityProperty& sdp);
|
||||||
virtual void apply(SampleDensityWhenMovingProperty& sdp);
|
virtual void apply(SampleDensityWhenMovingProperty& sdp);
|
||||||
|
virtual void apply(SampleRatioProperty& sdp);
|
||||||
virtual void apply(TransparencyProperty& tp);
|
virtual void apply(TransparencyProperty& tp);
|
||||||
|
|
||||||
osg::ref_ptr<TransferFunctionProperty> _tfProperty;
|
osg::ref_ptr<TransferFunctionProperty> _tfProperty;
|
||||||
@@ -369,6 +391,7 @@ class OSGVOLUME_EXPORT CollectPropertiesVisitor : public osgVolume::PropertyVisi
|
|||||||
osg::ref_ptr<LightingProperty> _lightingProperty;
|
osg::ref_ptr<LightingProperty> _lightingProperty;
|
||||||
osg::ref_ptr<SampleDensityProperty> _sampleDensityProperty;
|
osg::ref_ptr<SampleDensityProperty> _sampleDensityProperty;
|
||||||
osg::ref_ptr<SampleDensityWhenMovingProperty> _sampleDensityWhenMovingProperty;
|
osg::ref_ptr<SampleDensityWhenMovingProperty> _sampleDensityWhenMovingProperty;
|
||||||
|
osg::ref_ptr<SampleRatioProperty> _sampleRatioProperty;
|
||||||
osg::ref_ptr<TransparencyProperty> _transparencyProperty;
|
osg::ref_ptr<TransparencyProperty> _transparencyProperty;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -185,10 +185,10 @@ void MultipassTechnique::init()
|
|||||||
alphaFuncValue = cpv._isoProperty->getValue();
|
alphaFuncValue = cpv._isoProperty->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cpv._sampleDensityProperty.valid())
|
if (cpv._sampleRatioProperty.valid())
|
||||||
stateset->addUniform(cpv._sampleDensityProperty->getUniform());
|
stateset->addUniform(cpv._sampleRatioProperty->getUniform());
|
||||||
else
|
else
|
||||||
stateset->addUniform(new osg::Uniform("SampleDensityValue",0.0005f));
|
stateset->addUniform(new osg::Uniform("SampleRatioValue",1.0f));
|
||||||
|
|
||||||
|
|
||||||
if (cpv._transparencyProperty.valid())
|
if (cpv._transparencyProperty.valid())
|
||||||
@@ -265,6 +265,8 @@ void MultipassTechnique::init()
|
|||||||
|
|
||||||
osg::ref_ptr<osg::Uniform> volumeCellSize = new osg::Uniform("volumeCellSize", osg::Vec3(1.0f/static_cast<float>(image_3d->s()),1.0f/static_cast<float>(image_3d->t()),1.0f/static_cast<float>(image_3d->r())));
|
osg::ref_ptr<osg::Uniform> volumeCellSize = new osg::Uniform("volumeCellSize", osg::Vec3(1.0f/static_cast<float>(image_3d->s()),1.0f/static_cast<float>(image_3d->t()),1.0f/static_cast<float>(image_3d->r())));
|
||||||
stateset->addUniform(volumeCellSize.get());
|
stateset->addUniform(volumeCellSize.get());
|
||||||
|
|
||||||
|
OSG_NOTICE<<"Texture Dimensions "<<image_3d->s()<<", "<<image_3d->t()<<", "<<image_3d->r()<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -193,6 +193,21 @@ SampleDensityWhenMovingProperty::SampleDensityWhenMovingProperty(const SampleDen
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SampleRatioProperty
|
||||||
|
//
|
||||||
|
SampleRatioProperty::SampleRatioProperty(float value):
|
||||||
|
ScalarProperty("SampleRatioValue",value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SampleRatioProperty::SampleRatioProperty(const SampleRatioProperty& srp,const osg::CopyOp& copyop):
|
||||||
|
ScalarProperty(srp, copyop)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@@ -262,6 +277,7 @@ void CollectPropertiesVisitor::apply(MaximumIntensityProjectionProperty& mip) {
|
|||||||
void CollectPropertiesVisitor::apply(LightingProperty& lp) { _lightingProperty = &lp; }
|
void CollectPropertiesVisitor::apply(LightingProperty& lp) { _lightingProperty = &lp; }
|
||||||
void CollectPropertiesVisitor::apply(SampleDensityProperty& sdp) { _sampleDensityProperty = &sdp; }
|
void CollectPropertiesVisitor::apply(SampleDensityProperty& sdp) { _sampleDensityProperty = &sdp; }
|
||||||
void CollectPropertiesVisitor::apply(SampleDensityWhenMovingProperty& sdp) { _sampleDensityWhenMovingProperty = &sdp; }
|
void CollectPropertiesVisitor::apply(SampleDensityWhenMovingProperty& sdp) { _sampleDensityWhenMovingProperty = &sdp; }
|
||||||
|
void CollectPropertiesVisitor::apply(SampleRatioProperty& srp) { _sampleRatioProperty = &srp; }
|
||||||
void CollectPropertiesVisitor::apply(TransparencyProperty& tp) { _transparencyProperty = &tp; }
|
void CollectPropertiesVisitor::apply(TransparencyProperty& tp) { _transparencyProperty = &tp; }
|
||||||
|
|
||||||
|
|
||||||
@@ -400,25 +416,25 @@ bool PropertyAdjustmentCallback::handle(const osgGA::GUIEventAdapter& ea,osgGA::
|
|||||||
|
|
||||||
if (_updateAlphaCutOff && cpv._isoProperty.valid())
|
if (_updateAlphaCutOff && cpv._isoProperty.valid())
|
||||||
{
|
{
|
||||||
OSG_INFO<<"Setting isoProperty to "<<v<<std::endl;
|
OSG_NOTICE<<"Setting isoProperty to "<<v<<std::endl;
|
||||||
cpv._isoProperty->setValue(v);
|
cpv._isoProperty->setValue(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_updateAlphaCutOff && cpv._afProperty.valid())
|
if (_updateAlphaCutOff && cpv._afProperty.valid())
|
||||||
{
|
{
|
||||||
OSG_INFO<<"Setting afProperty to "<<v2<<std::endl;
|
OSG_NOTICE<<"Setting afProperty to "<<v2<<std::endl;
|
||||||
cpv._afProperty->setValue(v2);
|
cpv._afProperty->setValue(v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_updateTransparency && cpv._transparencyProperty.valid())
|
if (_updateTransparency && cpv._transparencyProperty.valid())
|
||||||
{
|
{
|
||||||
OSG_INFO<<"Setting transparency to "<<v2<<std::endl;
|
OSG_NOTICE<<"Setting transparency to "<<v2<<std::endl;
|
||||||
cpv._transparencyProperty->setValue(1.0f-v2);
|
cpv._transparencyProperty->setValue(1.0f-v2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_updateSampleDensity && cpv._sampleDensityProperty.valid())
|
if (_updateSampleDensity && cpv._sampleDensityProperty.valid())
|
||||||
{
|
{
|
||||||
OSG_INFO<<"Setting sample density to "<<v4<<std::endl;
|
OSG_NOTICE<<"Setting sample density to "<<v4<<std::endl;
|
||||||
cpv._sampleDensityProperty->setValue(v4);
|
cpv._sampleDensityProperty->setValue(v4);
|
||||||
}
|
}
|
||||||
if (_updateSampleDensity && cpv._sampleDensityWhenMovingProperty.valid())
|
if (_updateSampleDensity && cpv._sampleDensityWhenMovingProperty.valid())
|
||||||
@@ -426,6 +442,13 @@ bool PropertyAdjustmentCallback::handle(const osgGA::GUIEventAdapter& ea,osgGA::
|
|||||||
OSG_INFO<<"Setting sample density when moving to "<<v4<<std::endl;
|
OSG_INFO<<"Setting sample density when moving to "<<v4<<std::endl;
|
||||||
cpv._sampleDensityWhenMovingProperty->setValue(v4);
|
cpv._sampleDensityWhenMovingProperty->setValue(v4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_updateSampleDensity && cpv._sampleRatioProperty.valid())
|
||||||
|
{
|
||||||
|
float sampleRatio = v2*4;
|
||||||
|
OSG_NOTICE<<"Setting sample ratio to "<<sampleRatio<<std::endl;
|
||||||
|
cpv._sampleRatioProperty->setValue(sampleRatio);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user