Commit e24a46eb by Sebastian Eichelbaum

[ADD] - the 3d noise resolution can now be modified automatically by using the screen size.

parent 02bd5e56
......@@ -151,10 +151,14 @@ void WMImageSpaceLIC::properties()
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.", false );
m_3dNoiseRes = m_advancedLicGroup->addProperty( "3D Noise Resolution", "The 3D noise is of 128^3 pixels size. This scaler allows "
"modification of this size.", 4.0 );
"modification of this size.", 3.0 );
m_3dNoiseRes->setMin( 1 );
m_3dNoiseRes->setMax( 10 );
m_3dNoiseAutoRes = m_advancedLicGroup->addProperty( "3D Noise Auto-Resolution", "If checked, the resolution of the 3D noise gets calculated "
"automatically according to the screen size. If disabled, the user can zoom into the LIC.",
true );
m_numIters = m_advancedLicGroup->addProperty( "Number of Iterations", "How much iterations along a streamline should be done per frame.",
30 );
m_numIters->setMin( 1 );
......@@ -286,6 +290,9 @@ void WMImageSpaceLIC::moduleMain()
WGEShaderDefineOptions::SPtr availableDataDefines = WGEShaderDefineOptions::SPtr( new WGEShaderDefineOptions( "SCALARDATA", "VECTORDATA" ) );
transformationShader->addPreprocessor( availableDataDefines );
transformationShader->addPreprocessor( define3dNoise );
transformationShader->addPreprocessor( WGEShaderPreprocessor::SPtr(
new WGEShaderPropertyDefineOptions< WPropBool >( m_3dNoiseAutoRes, "NOISE3DAUTORES_DISABLED", "NOISE3DAUTORES_ENABLED" )
) );
osg::ref_ptr< WGEOffscreenRenderPass > transformation = offscreen->addGeometryRenderPass(
m_output,
......
......@@ -192,6 +192,11 @@ private:
* The resolution scaling for the 3d noise
*/
WPropDouble m_3dNoiseRes;
/**
* Automatically adapt resolution of 3d texture according to zoom level
*/
WPropBool m_3dNoiseAutoRes;
};
#endif // WMIMAGESPACELIC_H
......
......@@ -70,13 +70,6 @@ uniform int u_texture0SizeY = 255;
*/
uniform int u_texture0SizeZ = 255;
#ifdef NOISE3D_ENABLED
/**
* The "virtual" resolution of the 3D noise texture in u_texture1Sampler
*/
uniform float u_noise3DResoultuion = 4.0;
#endif
/**
* Transforms each vector on each pixel to image space.
*/
......@@ -86,7 +79,7 @@ void main()
// if we have a 3D noise texture, use it.
#ifdef NOISE3D_ENABLED
float noise3D = texture3D( u_texture1Sampler, gl_TexCoord[0].xyz * u_noise3DResoultuion ).r;
float noise3D = texture3D( u_texture1Sampler, gl_TexCoord[0].xyz * v_noiseScaleFactor.xyz ).r;
#else
float noise3D = 1.0;
#endif
......
......@@ -37,3 +37,10 @@ varying vec3 v_lightSource;
*/
varying vec3 v_viewDir;
/**
* The factor which scales the 3d noise texture to a proper size according to screen size.
*/
#ifdef NOISE3D_ENABLED
varying vec3 v_noiseScaleFactor;
#endif
......@@ -30,10 +30,54 @@
#include "WMImageSpaceLIC-Transformation-varyings.glsl"
/**
* How much should the slice be moved along u_vertexShiftDirection?
*/
uniform int u_vertexShift;
/**
* The direction along which the slice gets moved
*/
uniform vec3 u_vertexShiftDirection;
/**
* Size of input texture in pixels
*/
uniform int u_texture0SizeX = 255;
/**
* Size of input texture in pixels
*/
uniform int u_texture0SizeY = 255;
/**
* Size of input texture in pixels
*/
uniform int u_texture0SizeZ = 255;
/**
* Size of input noise texture in pixels
*/
uniform int u_texture1SizeX = 255;
/**
* Size of input noise texture in pixels
*/
uniform int u_texture1SizeY = 255;
/**
* Size of input noise texture in pixels
*/
uniform int u_texture1SizeZ = 255;
#ifdef NOISE3D_ENABLED
/**
* The "virtual" resolution of the 3D noise texture in u_texture1Sampler
*/
uniform float u_noise3DResoultuion = 3.0;
#endif
/**
* Vertex Main. Simply transforms the geometry. The work is done per fragment.
*/
void main()
......@@ -52,6 +96,17 @@ void main()
// some light precalculations
v_normal = gl_Normal;
// if we use 3d noise textures and auto resolution feature:
#ifdef NOISE3D_ENABLED
vec4 vec1 = vec4( float( u_texture0SizeX ) / float( u_texture1SizeX ),
float( u_texture0SizeY ) / float( u_texture1SizeY ),
float( u_texture0SizeZ ) / float( u_texture1SizeZ ), 0.0 );
v_noiseScaleFactor = vec1.xyz;
#ifdef NOISE3DAUTORES_ENABLED
vec4 vecMV = gl_ModelViewMatrix * vec4( vec3( 1.0 ), 0.0 ); // if the resolution should be modified, use the scaling info from the MV matrix
v_noiseScaleFactor *= u_noise3DResoultuion * length( vecMV.xyz );
#endif
#endif
// also get the coordinates of the light
vec4 lpos = gl_LightSource[0].position; // this simply doesn't work well with OSG
lpos = vec4( 0.0, 0.0, 1000.0, 1.0 );
......
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