Commit e7c6b10b authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[FIX] fixed severe bug where vectors on surfaces got clipped although they are in the render plane

parent c612791d
...@@ -108,7 +108,7 @@ void main() ...@@ -108,7 +108,7 @@ void main()
discard; discard;
} }
// project the vectors to image space // project the vectors to image space as the input vector is in the tangent space
vecProjected = projectVector( vec ).xyz; vecProjected = projectVector( vec ).xyz;
#endif #endif
...@@ -152,19 +152,12 @@ void main() ...@@ -152,19 +152,12 @@ void main()
// if( isZero( cmap.r - 1.0, 0.15 ) ) // if( isZero( cmap.r - 1.0, 0.15 ) )
// gl_FragData[1] = vec4( 1.0, 0.0, 0.0, 1.0 ); // gl_FragData[1] = vec4( 1.0, 0.0, 0.0, 1.0 );
// } // }
gl_FragData[1] = colormapping();
// is the vector very orthogonal to the surface? // is the vector very orthogonal to the surface? We scale our advection according to this.
float dotS = abs( dot( v_normal, vec.xyz ) );
vec2 dotScaled = ( 1.0 - dotS ) * scaleMaxToOne( vecProjected ).xy;
float dotS = dot( v_normal, vec.xyz );
vec2 dotScaled = ( 1.0 + sign( dotS ) ) * scaleMaxToOne( vecProjected ).xy;
// MPI Paper Hack;
// dotScaled = 40.0*vecProjected.xy;
gl_FragData[0] = vec4( vec2( 0.5 ) + ( 0.5 * dotScaled ), light, noise3D ); gl_FragData[0] = vec4( vec2( 0.5 ) + ( 0.5 * dotScaled ), light, noise3D );
// MPI PAper Hack:
// {
// //gl_FragData[1] = colormapping();
// }
gl_FragData[1] = colormapping();
} }
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
*/ */
varying vec3 v_normal; varying vec3 v_normal;
/**
* The normal interpolated and projected to screenspace
*/
varying vec3 v_normalProjected;
/** /**
* The light source in local coordinates * The light source in local coordinates
*/ */
......
...@@ -33,12 +33,12 @@ ...@@ -33,12 +33,12 @@
/** /**
* How much should the slice be moved along u_vertexShiftDirection? * How much should the slice be moved along u_vertexShiftDirection?
*/ */
uniform int u_vertexShift; uniform int u_vertexShift = 0;
/** /**
* The direction along which the slice gets moved * The direction along which the slice gets moved
*/ */
uniform vec3 u_vertexShiftDirection; uniform vec3 u_vertexShiftDirection = vec3( 0.0, 0.0, 0.0 );
/** /**
* Size of input texture in pixels * Size of input texture in pixels
...@@ -96,6 +96,10 @@ void main() ...@@ -96,6 +96,10 @@ void main()
// some light precalculations // some light precalculations
v_normal = gl_Normal; v_normal = gl_Normal;
// NOTE: we normalize the vec here although we need to normalize it again in the fragment shader since the projected vector might be very
// small and we want to avoid numerical issues when interpolating.
v_normalProjected = normalize( projectVector( vec4( gl_Normal.xyz, 0.0 ) ) );
// if we use 3d noise textures and auto resolution feature: // if we use 3d noise textures and auto resolution feature:
#ifdef NOISE3D_ENABLED #ifdef NOISE3D_ENABLED
vec4 vec1 = vec4( float( u_texture0SizeX ) / float( u_texture1SizeX ), vec4 vec1 = vec4( float( u_texture0SizeX ) / float( u_texture1SizeX ),
......
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