Commit 3c3fa480 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[ADD] you can now manually define wether a texture should be clipped if the value is 0

parent b75e4b5a
......@@ -118,6 +118,13 @@ public:
*/
WPropDouble alpha() const;
/**
* Clip the values assumed to be zero.
*
* \return true to clip.
*/
WPropBool clipZero() const;
/**
* Returns the threshold property. The property can be changed. A change affects all colormaps using this texture.
*
......@@ -348,6 +355,11 @@ private:
*/
WPropDouble m_alpha;
/**
* If set to true, zero values are clipped by making them transparent
*/
WPropBool m_clipZero;
/**
* Threshold for clipping areas.
*/
......@@ -459,6 +471,8 @@ void WGETexture< TextureType >::setupProperties( double scale, double min )
m_alpha->setMin( 0.0 );
m_alpha->setMax( 1.0 );
m_clipZero = m_properties->addProperty( "Enable Zero Clip", "If enabled, zero values are clipped.", true );
m_thresholdEnabled = m_properties->addProperty( "Enable Threshold",
"If enabled, threshold based clipping is used. If not, threshold is ignored.", false );
......@@ -546,6 +560,12 @@ inline WPropDouble WGETexture< TextureType >::alpha() const
return m_alpha;
}
template < typename TextureType >
inline WPropBool WGETexture< TextureType >::clipZero() const
{
return m_clipZero;
}
template < typename TextureType >
inline WPropDouble WGETexture< TextureType >::thresholdLower() const
{
......@@ -616,6 +636,7 @@ void WGETexture< TextureType >::applyUniforms( std::string prefix, osg::StateSe
states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "Min", minimum() ) );
states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "Scale", scale() ) );
states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "Alpha", alpha() ) );
states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "ClipZeroEnabled", clipZero() ) );
states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "ThresholdEnabled", thresholdEnabled() ) );
states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "ThresholdLower", thresholdLower() ) );
states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "ThresholdUpper", thresholdUpper() ) );
......
......@@ -436,8 +436,9 @@ vec4 atlas( in float value )
*
* \return this color gets mixed using alpha value with the new colormap color
* \param value the value to map, <b>scaled</b>
* \param minV the minimum of the original value
* \param minV the minimum of the original value *
* \param scaleV the scaler used to downscale the original value to [0-1]
* \param clipZeroEnabled if true, zero values get clipped; based on descaled value.
* \param thresholdVLower a threshold in original space (you need to downscale it to [0-1] if you want to use it to scaled values.
* \param thresholdVUpper a threshold in original space (you need to downscale it to [0-1] if you want to use it to scaled values.
* \param thresholdEnabled a flag denoting whether threshold-based clipping should be done or not
......@@ -447,6 +448,7 @@ vec4 atlas( in float value )
* \param colormap the colormap index to use
*/
vec4 colormap( in vec4 value, float minV, float scaleV,
bool clipZeroEnabled,
float thresholdVLower, float thresholdVUpper, bool thresholdEnabled,
vec2 window, bool windowEnabled,
float alpha, int colormap, bool active )
......@@ -483,7 +485,7 @@ vec4 colormap( in vec4 value, float minV, float scaleV,
float isNotBorder = float( value.a >= 0.75 );
// make "zero" values transarent
float clip = clipZero( valueWindowedOriginal.r, minV );
float clip = max( float( !clipZeroEnabled ), clipZero( valueWindowedOriginal.r, minV ) );
// use threshold to clip away fragments.
// NOTE: thresholding is applied to the original interval in valueDescaled, NOT the window interval
......
......@@ -43,6 +43,9 @@ uniform float u_colormap0Scale = 1;
//!< The alpha value for this colormap. Is in [0,1].
uniform float u_colormap0Alpha;
//!< Flag denoting whether to clip the zero value.
uniform bool u_colormap0ClipZeroEnabled = false;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap0ThresholdLower;
......@@ -85,6 +88,9 @@ uniform float u_colormap1Scale = 1;
//!< The alpha value for this colormap. Is in [0,1].
uniform float u_colormap1Alpha;
//!< Flag denoting whether to clip the zero value.
uniform bool u_colormap1ClipZeroEnabled = false;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap1ThresholdLower;
......@@ -127,6 +133,9 @@ uniform float u_colormap2Scale = 1;
//!< The alpha value for this colormap. Is in [0,1].
uniform float u_colormap2Alpha;
//!< Flag denoting whether to clip the zero value.
uniform bool u_colormap2ClipZeroEnabled = false;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap2ThresholdLower;
......@@ -169,6 +178,9 @@ uniform float u_colormap3Scale = 1;
//!< The alpha value for this colormap. Is in [0,1].
uniform float u_colormap3Alpha;
//!< Flag denoting whether to clip the zero value.
uniform bool u_colormap3ClipZeroEnabled = false;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap3ThresholdLower;
......@@ -211,6 +223,9 @@ uniform float u_colormap4Scale = 1;
//!< The alpha value for this colormap. Is in [0,1].
uniform float u_colormap4Alpha;
//!< Flag denoting whether to clip the zero value.
uniform bool u_colormap4ClipZeroEnabled = false;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap4ThresholdLower;
......@@ -253,6 +268,9 @@ uniform float u_colormap5Scale = 1;
//!< The alpha value for this colormap. Is in [0,1].
uniform float u_colormap5Alpha;
//!< Flag denoting whether to clip the zero value.
uniform bool u_colormap5ClipZeroEnabled = false;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap5ThresholdLower;
......@@ -295,6 +313,9 @@ uniform float u_colormap6Scale = 1;
//!< The alpha value for this colormap. Is in [0,1].
uniform float u_colormap6Alpha;
//!< Flag denoting whether to clip the zero value.
uniform bool u_colormap6ClipZeroEnabled = false;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap6ThresholdLower;
......@@ -337,6 +358,9 @@ uniform float u_colormap7Scale = 1;
//!< The alpha value for this colormap. Is in [0,1].
uniform float u_colormap7Alpha;
//!< Flag denoting whether to clip the zero value.
uniform bool u_colormap7ClipZeroEnabled = false;
//!< The threshold value for this colormap. Is in [Min,Scale+Min]
uniform float u_colormap7ThresholdLower;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment