Commit 0cce86e0 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] made several improvements to the image space lic module, including a...

[CHANGE] made several improvements to the image space lic module, including a better control over vector projection.
parent 7fde8df8
......@@ -139,8 +139,15 @@ void WMImageSpaceLIC::properties()
m_lightIntensity->setMin( 0.0 );
m_lightIntensity->setMax( 10.0 );
m_useEdges = m_licGroup->addProperty( "Edges", "Check to enable blending in edges.", true );
m_useEdges = m_licGroup->addProperty( "Edges", "Check to enable blending in edges.", true );
m_useEdgesColor = m_licGroup->addProperty( "Edge Color", "Define the color of the edges.", defaultColor::WHITE );
m_useEdgesStep = m_licGroup->addProperty( "Edge Step", "Define the steepness of the blend function between color and edge color.", 1.0 );
m_useEdgesStep->setMin( 0.0 );
m_useEdgesStep->setMax( 10.0 );
m_useHighContrast = m_licGroup->addProperty( "High Contrast", "Use an extremely increased contrast.", false );
m_useDepthCueing = m_licGroup->addProperty( "Depth Cueing", "Use depth as additional cue? Mostly useful for isosurfaces.",
false );
m_cmapRatio = m_licGroup->addProperty( "Ratio Colormap to LIC", "Blending ratio between LIC and colormap.", 0.5 );
m_cmapRatio->setMin( 0.0 );
......@@ -149,13 +156,11 @@ void WMImageSpaceLIC::properties()
m_advancedLicGroup = m_properties->addPropertyGroup( "Advanced", "More advanced LIC properties." );
// show hud?
m_showHUD = m_advancedLicGroup->addProperty( "Show HUD", "Check to enable the debugging texture HUD.", false );
m_useDepthCueing = m_advancedLicGroup->addProperty( "Depth Cueing", "Use depth as additional cue? Mostly useful for isosurfaces.",
false );
m_3dNoise = m_advancedLicGroup->addProperty( "Use 3D noise", "Use 3D noise? This provides better coherence during transformation of "
"the geometry but might introduce resolution problems.", true );
m_3dNoiseRes = m_advancedLicGroup->addProperty( "3D Noise Resolution", "The 3D noise is of 128^3 pixels size. This scaler allows "
"modification of this size.", 1.5 );
m_3dNoiseRes->setMin( 1 );
m_3dNoiseRes->setMin( 0 );
m_3dNoiseRes->setMax( 10 );
m_3dNoiseAutoRes = m_advancedLicGroup->addProperty( "3D Noise Auto-Resolution", "If checked, the resolution of the 3D noise gets calculated "
......@@ -167,6 +172,14 @@ void WMImageSpaceLIC::properties()
m_numIters->setMin( 1 );
m_numIters->setMax( 1000 );
m_projectionAngleThreshold = m_advancedLicGroup->addProperty( "Projection Angle Threshold", "This defines the threshold of the angle between tangential "
"plane of the surface and the vector which is going to be projected. You can adjust how steep a vector can be before it is clipped and NOT "
"projected. Note: all vectors with an angle below this threshold are projected but linearly reduced in influence depending on the "
"angle.", 90.0 );
m_projectionAngleThreshold->setMin( 0.0 );
m_projectionAngleThreshold->setMax( 90.0 );
// call WModule's initialization
WModule::properties();
}
......@@ -345,6 +358,7 @@ void WMImageSpaceLIC::moduleMain()
osg::ref_ptr< osg::Texture2D > transformationDepth = transformation->attach( osg::Camera::DEPTH_BUFFER );
// and some uniforms
transformation->addUniform( new WGEPropertyUniform< WPropDouble >( "u_noise3DResoultuion", m_3dNoiseRes ) );
transformation->addUniform( new WGEPropertyUniform< WPropDouble >( "u_projectionAngleThreshold", m_projectionAngleThreshold ) );
// Edge Detection Pass, needs Depth as input
// * Edges in R
......@@ -365,12 +379,20 @@ void WMImageSpaceLIC::moduleMain()
osg::ref_ptr< osg::Uniform > numIters = new WGEPropertyUniform< WPropInt >( "u_numIter", m_numIters );
advection->addUniform( numIters );
// provide the Gbuffer input, with several mipmap levels
advectionOutA->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
edgeDetectionOut1->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
transformationColormapped->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
// Final clipping and blending phase, needs Advected Noise, Edges, Depth and Light
clipBlend->bind( advectionOutA, 0 );
clipBlend->bind( edgeDetectionOut1, 1 );
clipBlend->bind( transformationColormapped, 2 );
// final pass needs some uniforms controlled by properties
clipBlend->addUniform( new WGEPropertyUniform< WPropBool >( "u_useEdges", m_useEdges ) );
clipBlend->addUniform( new WGEPropertyUniform< WPropColor >( "u_useEdgesColor", m_useEdgesColor ) );
clipBlend->addUniform( new WGEPropertyUniform< WPropDouble >( "u_useEdgesStep", m_useEdgesStep ) );
clipBlend->addUniform( new WGEPropertyUniform< WPropBool >( "u_useLight", m_useLight ) );
clipBlend->addUniform( new WGEPropertyUniform< WPropDouble >( "u_lightIntensity", m_lightIntensity ) );
clipBlend->addUniform( new WGEPropertyUniform< WPropBool >( "u_useDepthCueing", m_useDepthCueing ) );
......
......@@ -166,6 +166,10 @@ private:
WPropBool m_useEdges; //!< indicates whether to show the edges
WPropColor m_useEdgesColor; //!< indicated whether the edges (if enabled) should be black or white or green or red or ....
WPropDouble m_useEdgesStep; //!< define the steepness of the step function used to blend in the edge color.
WPropBool m_useLight; //!< indicates whether to use Phong
WPropDouble m_lightIntensity; //!< light intensity
......@@ -178,6 +182,8 @@ private:
WPropDouble m_cmapRatio; //!< the ratio between colormap and LIC
WPropDouble m_projectionAngleThreshold; //!< the angle threshold between surface and vector before clipping the vector.
/**
* The group for more advanced LIC features
*/
......
......@@ -22,9 +22,10 @@
//
//---------------------------------------------------------------------------
#version 120
#version 130
#include "WGEUtils.glsl"
#include "WGEShadingTools.glsl"
/**
* The texture Unit for the advection texture
......@@ -56,6 +57,16 @@ uniform float u_lightIntensity;
*/
uniform bool u_useEdges;
/**
* Edge color to use
*/
uniform vec4 u_useEdgesColor;
/**
* Step function border for blending in the edges.
*/
uniform float u_useEdgesStep;
/**
* If true, the depth is blended in
*/
......@@ -87,26 +98,13 @@ void main()
float u_contrastingP = u_useHighContrast ? 8 : 2.5;
vec3 plainColor = u_cmapRatio * cmap + ( 1.0 - u_cmapRatio ) * vec3( u_contrastingS * pow( advected, u_contrastingP ) );
// MPI Paper Hack: {
// plainColor = u_cmapRatio * cmap;
// plainColor += 1.5*( 1.0 - u_cmapRatio ) * vec3( u_contrastingS * pow( advected, u_contrastingP ), 0.0, 0.0 );
// if( isZero( cmap.r, 0.1 ) )
// discard;
// }
vec4 col = vec4(
( vec3( edge ) + plainColor ) // plain color mapped advection texture with edges
mix( plainColor, u_useEdgesColor.xyz, smoothstep( 0, u_useEdgesStep, edge ) ) // plain color mapped advection texture with edges
* clamp( 1.0 - ( float( u_useDepthCueing ) * depth * depth ), 0.4, 1.0 ) // scaled by depth if enabled
* ( u_useLight ? light * 1.3 * u_lightIntensity: 1.0 ), // NOTE: the 1.3 is here to keep compatibility with the old version
1.0
);
// math: BioVis Paper Hack
// if( cmap.g < 0.1 )
// discard;
// else
// gl_FragColor = col;
gl_FragColor = col;
gl_FragDepth = depth;
}
......
......@@ -70,6 +70,11 @@ uniform int u_texture0SizeY = 255;
*/
uniform int u_texture0SizeZ = 255;
/**
* Projection angle cutoff
*/
uniform float u_projectionAngleThreshold;
/**
* Transforms each vector on each pixel to image space.
*/
......@@ -144,11 +149,33 @@ void main()
// }
gl_FragData[1] = colormapping();
// is the vector very orthogonal to the surface? We scale our advection according to this.
float dotS = abs( dot( v_normalObject, vec.xyz ) );
const float piHalf = 3.14159265 / 2.0;
const float pi = 3.14159265;
// is the vector very orthogonal to the surface? We scale our advection according to this. We use the angle between normal and vector but use
// 1 - dot to get the angle between vector and surface which is 90 degree shifted against the dot of the normal and the vector.
float geometryVecAngle = ( acos(
abs(
dot( normalize( v_normalObject ),
normalize(vec.xyz)
)
)
) / piHalf
);
// we measured the angle between normal and vector, but we want the angle between surface tangent and vector, which is a shift of half PI /
// halfPi = 1
geometryVecAngle = 1.0 - geometryVecAngle;
// the user defines an angle in degrees used as cutoff value. Angles above this one should be clipped
float cutoffAngle = u_projectionAngleThreshold / 90.0;
// scale down the vector -> the more it "comes out of the surface, the shorter the vector".
vec2 dotScaled = smoothstep( 0.0, 1.0 , 1.0 - dotS ) * scaleMaxToOne( vecProjected ).xy;
float dotScale = cutoffAngle - geometryVecAngle;
if( dotScale < 0 )
dotScale = 0;
gl_FragData[0] = vec4( vec2( 0.5 ) + ( 0.5 * dotScaled ), light, noise3D );
// scale our vector according to the above metric and output
vec2 dotScaledVector = dotScale * scaleMaxToOne( vecProjected ).xy;
gl_FragData[0] = vec4( vec2( 0.5 ) + ( 0.5 * dotScaledVector ), light, noise3D );
}
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