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

[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
......
......@@ -41,6 +41,7 @@
* \param coord the coordinate where to get the value
* \param size the size in voxels
* \param minV the minimum of the original value
* \param clipZeroEnabled if true, zero values get clipped
* \param scaleV the scaler used to downscale the original value to [0-1]
* \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.
......@@ -51,6 +52,7 @@
*/
void colormap( inout vec4 color, in sampler3D sampler, in vec3 coord, in vec3 size,
float minV, float scaleV,
bool clipZeroEnabled,
float thresholdVLower, float thresholdVUpper, bool thresholdEnabled,
bool windowEnabled, vec2 window,
float alpha, int cmap, bool active )
......@@ -89,7 +91,10 @@ void colormap( inout vec4 color, in sampler3D sampler, in vec3 coord, in vec3 si
vec4 value = texture3D( sampler, coord ).rgba;
// let someone else apply the colormap
vec4 src = colormap( value, minV, scaleV, thresholdVLower, thresholdVUpper, thresholdEnabled, window, windowEnabled, alpha, cmap, active );
vec4 src = colormap( value, minV, scaleV, clipZeroEnabled,
thresholdVLower, thresholdVUpper, thresholdEnabled,
window, windowEnabled,
alpha, cmap, active );
// compositing:
// associated colors needed
......@@ -119,56 +124,72 @@ vec4 colormapping( vec4 texcoord )
#ifdef Colormap7Enabled
colormap( finalColor, u_colormap7Sampler, ( gl_TextureMatrix[ Colormap7Unit ] * t ).xyz,
vec3( u_colormap7SizeX, u_colormap7SizeY, u_colormap7SizeZ ),
u_colormap7Min, u_colormap7Scale, u_colormap7ThresholdLower, u_colormap7ThresholdUpper, u_colormap7ThresholdEnabled,
u_colormap7Min, u_colormap7Scale,
u_colormap7ClipZeroEnabled,
u_colormap7ThresholdLower, u_colormap7ThresholdUpper, u_colormap7ThresholdEnabled,
u_colormap7WindowEnabled, u_colormap7Window,
u_colormap7Alpha, u_colormap7Colormap, u_colormap7Active );
#endif
#ifdef Colormap6Enabled
colormap( finalColor, u_colormap6Sampler, ( gl_TextureMatrix[ Colormap6Unit ] * t ).xyz,
vec3( u_colormap6SizeX, u_colormap6SizeY, u_colormap6SizeZ ),
u_colormap6Min, u_colormap6Scale, u_colormap6ThresholdLower, u_colormap6ThresholdUpper, u_colormap6ThresholdEnabled,
u_colormap6Min, u_colormap6Scale,
u_colormap6ClipZeroEnabled,
u_colormap6ThresholdLower, u_colormap6ThresholdUpper, u_colormap6ThresholdEnabled,
u_colormap6WindowEnabled, u_colormap6Window,
u_colormap6Alpha, u_colormap6Colormap, u_colormap6Active );
#endif
#ifdef Colormap5Enabled
colormap( finalColor, u_colormap5Sampler, ( gl_TextureMatrix[ Colormap5Unit ] * t ).xyz,
vec3( u_colormap5SizeX, u_colormap5SizeY, u_colormap5SizeZ ),
u_colormap5Min, u_colormap5Scale, u_colormap5ThresholdLower, u_colormap5ThresholdUpper, u_colormap5ThresholdEnabled,
u_colormap5Min, u_colormap5Scale,
u_colormap5ClipZeroEnabled,
u_colormap5ThresholdLower, u_colormap5ThresholdUpper, u_colormap5ThresholdEnabled,
u_colormap5WindowEnabled, u_colormap5Window,
u_colormap5Alpha, u_colormap5Colormap, u_colormap5Active );
#endif
#ifdef Colormap4Enabled
colormap( finalColor, u_colormap4Sampler, ( gl_TextureMatrix[ Colormap4Unit ] * t ).xyz,
vec3( u_colormap4SizeX, u_colormap4SizeY, u_colormap4SizeZ ),
u_colormap4Min, u_colormap4Scale, u_colormap4ThresholdLower, u_colormap4ThresholdUpper, u_colormap4ThresholdEnabled,
u_colormap4Min, u_colormap4Scale,
u_colormap4ClipZeroEnabled,
u_colormap4ThresholdLower, u_colormap4ThresholdUpper, u_colormap4ThresholdEnabled,
u_colormap4WindowEnabled, u_colormap4Window,
u_colormap4Alpha, u_colormap4Colormap, u_colormap4Active );
#endif
#ifdef Colormap3Enabled
colormap( finalColor, u_colormap3Sampler, ( gl_TextureMatrix[ Colormap3Unit ] * t ).xyz,
vec3( u_colormap3SizeX, u_colormap3SizeY, u_colormap3SizeZ ),
u_colormap3Min, u_colormap3Scale, u_colormap3ThresholdLower, u_colormap3ThresholdUpper, u_colormap3ThresholdEnabled,
u_colormap3Min, u_colormap3Scale,
u_colormap3ClipZeroEnabled,
u_colormap3ThresholdLower, u_colormap3ThresholdUpper, u_colormap3ThresholdEnabled,
u_colormap3WindowEnabled, u_colormap3Window,
u_colormap3Alpha, u_colormap3Colormap, u_colormap3Active );
#endif
#ifdef Colormap2Enabled
colormap( finalColor, u_colormap2Sampler, ( gl_TextureMatrix[ Colormap2Unit ] * t ).xyz,
vec3( u_colormap2SizeX, u_colormap2SizeY, u_colormap2SizeZ ),
u_colormap2Min, u_colormap2Scale, u_colormap2ThresholdLower, u_colormap2ThresholdUpper, u_colormap2ThresholdEnabled,
u_colormap2Min, u_colormap2Scale,
u_colormap2ClipZeroEnabled,
u_colormap2ThresholdLower, u_colormap2ThresholdUpper, u_colormap2ThresholdEnabled,
u_colormap2WindowEnabled, u_colormap2Window,
u_colormap2Alpha, u_colormap2Colormap, u_colormap2Active );
#endif
#ifdef Colormap1Enabled
colormap( finalColor, u_colormap1Sampler, ( gl_TextureMatrix[ Colormap1Unit ] * t ).xyz,
vec3( u_colormap1SizeX, u_colormap1SizeY, u_colormap1SizeZ ),
u_colormap1Min, u_colormap1Scale, u_colormap1ThresholdLower, u_colormap1ThresholdUpper, u_colormap1ThresholdEnabled,
u_colormap1Min, u_colormap1Scale,
u_colormap1ClipZeroEnabled,
u_colormap1ThresholdLower, u_colormap1ThresholdUpper, u_colormap1ThresholdEnabled,
u_colormap1WindowEnabled, u_colormap1Window,
u_colormap1Alpha, u_colormap1Colormap, u_colormap1Active );
#endif
#ifdef Colormap0Enabled
colormap( finalColor, u_colormap0Sampler, ( gl_TextureMatrix[ Colormap0Unit ] * t ).xyz,
vec3( u_colormap0SizeX, u_colormap0SizeY, u_colormap0SizeZ ),
u_colormap0Min, u_colormap0Scale, u_colormap0ThresholdLower, u_colormap0ThresholdUpper, u_colormap0ThresholdEnabled,
u_colormap0Min, u_colormap0Scale,
u_colormap0ClipZeroEnabled,
u_colormap0ThresholdLower, u_colormap0ThresholdUpper, u_colormap0ThresholdEnabled,
u_colormap0WindowEnabled, u_colormap0Window,
u_colormap0Alpha, u_colormap0Colormap, u_colormap0Active );
#endif
......@@ -192,7 +213,9 @@ vec4 colormapping()
#ifdef Colormap7Enabled
colormap( finalColor, u_colormap7Sampler, v_colormap7TexCoord.xyz,
vec3( u_colormap7SizeX, u_colormap7SizeY, u_colormap7SizeZ ),
u_colormap7Min, u_colormap7Scale, u_colormap7ThresholdLower, u_colormap7ThresholdUpper,
u_colormap7Min, u_colormap7Scale,
u_colormap7ClipZeroEnabled,
u_colormap7ThresholdLower, u_colormap7ThresholdUpper,
u_colormap7ThresholdEnabled,
u_colormap7WindowEnabled, u_colormap7Window,
u_colormap7Alpha, u_colormap7Colormap, u_colormap7Active );
......@@ -200,7 +223,9 @@ vec4 colormapping()
#ifdef Colormap6Enabled
colormap( finalColor, u_colormap6Sampler, v_colormap6TexCoord.xyz,
vec3( u_colormap6SizeX, u_colormap6SizeY, u_colormap6SizeZ ),
u_colormap6Min, u_colormap6Scale, u_colormap6ThresholdLower, u_colormap6ThresholdUpper,
u_colormap6Min, u_colormap6Scale,
u_colormap6ClipZeroEnabled,
u_colormap6ThresholdLower, u_colormap6ThresholdUpper,
u_colormap6ThresholdEnabled,
u_colormap6WindowEnabled, u_colormap6Window,
u_colormap6Alpha, u_colormap6Colormap, u_colormap6Active );
......@@ -208,7 +233,9 @@ vec4 colormapping()
#ifdef Colormap5Enabled
colormap( finalColor, u_colormap5Sampler, v_colormap5TexCoord.xyz,
vec3( u_colormap5SizeX, u_colormap5SizeY, u_colormap5SizeZ ),
u_colormap5Min, u_colormap5Scale, u_colormap5ThresholdLower, u_colormap5ThresholdUpper,
u_colormap5Min, u_colormap5Scale,
u_colormap5ClipZeroEnabled,
u_colormap5ThresholdLower, u_colormap5ThresholdUpper,
u_colormap5ThresholdEnabled,
u_colormap5WindowEnabled, u_colormap5Window,
u_colormap5Alpha, u_colormap5Colormap, u_colormap5Active );
......@@ -216,7 +243,9 @@ vec4 colormapping()
#ifdef Colormap4Enabled
colormap( finalColor, u_colormap4Sampler, v_colormap4TexCoord.xyz,
vec3( u_colormap4SizeX, u_colormap4SizeY, u_colormap4SizeZ ),
u_colormap4Min, u_colormap4Scale, u_colormap4ThresholdLower, u_colormap4ThresholdUpper,
u_colormap4Min, u_colormap4Scale,
u_colormap4ClipZeroEnabled,
u_colormap4ThresholdLower, u_colormap4ThresholdUpper,
u_colormap4ThresholdEnabled,
u_colormap4WindowEnabled, u_colormap4Window,
u_colormap4Alpha, u_colormap4Colormap, u_colormap4Active );
......@@ -224,7 +253,9 @@ vec4 colormapping()
#ifdef Colormap3Enabled
colormap( finalColor, u_colormap3Sampler, v_colormap3TexCoord.xyz,
vec3( u_colormap3SizeX, u_colormap3SizeY, u_colormap3SizeZ ),
u_colormap3Min, u_colormap3Scale, u_colormap3ThresholdLower, u_colormap3ThresholdUpper,
u_colormap3Min, u_colormap3Scale,
u_colormap3ClipZeroEnabled,
u_colormap3ThresholdLower, u_colormap3ThresholdUpper,
u_colormap3ThresholdEnabled,
u_colormap3WindowEnabled, u_colormap3Window,
u_colormap3Alpha, u_colormap3Colormap, u_colormap3Active );
......@@ -232,7 +263,9 @@ vec4 colormapping()
#ifdef Colormap2Enabled
colormap( finalColor, u_colormap2Sampler, v_colormap2TexCoord.xyz,
vec3( u_colormap2SizeX, u_colormap2SizeY, u_colormap2SizeZ ),
u_colormap2Min, u_colormap2Scale, u_colormap2ThresholdLower, u_colormap2ThresholdUpper,
u_colormap2Min, u_colormap2Scale,
u_colormap2ClipZeroEnabled,
u_colormap2ThresholdLower, u_colormap2ThresholdUpper,
u_colormap2ThresholdEnabled,
u_colormap2WindowEnabled, u_colormap2Window,
u_colormap2Alpha, u_colormap2Colormap, u_colormap2Active );
......@@ -240,7 +273,9 @@ vec4 colormapping()
#ifdef Colormap1Enabled
colormap( finalColor, u_colormap1Sampler, v_colormap1TexCoord.xyz,
vec3( u_colormap1SizeX, u_colormap1SizeY, u_colormap1SizeZ ),
u_colormap1Min, u_colormap1Scale, u_colormap1ThresholdLower, u_colormap1ThresholdUpper,
u_colormap1Min, u_colormap1Scale,
u_colormap1ClipZeroEnabled,
u_colormap1ThresholdLower, u_colormap1ThresholdUpper,
u_colormap1ThresholdEnabled,
u_colormap1WindowEnabled, u_colormap1Window,
u_colormap1Alpha, u_colormap1Colormap, u_colormap1Active );
......@@ -248,7 +283,9 @@ vec4 colormapping()
#ifdef Colormap0Enabled
colormap( finalColor, u_colormap0Sampler, v_colormap0TexCoord.xyz,
vec3( u_colormap0SizeX, u_colormap0SizeY, u_colormap0SizeZ ),
u_colormap0Min, u_colormap0Scale, u_colormap0ThresholdLower, u_colormap0ThresholdUpper,
u_colormap0Min, u_colormap0Scale,
u_colormap0ClipZeroEnabled,
u_colormap0ThresholdLower, u_colormap0ThresholdUpper,
u_colormap0ThresholdEnabled,
u_colormap0WindowEnabled, u_colormap0Window,
u_colormap0Alpha, u_colormap0Colormap, u_colormap0Active );
......
......@@ -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