Commit 8e15beaf by Sebastian Eichelbaum

[FIX] the normal used for projecting the input vectors needs to be in object space.

parent 63080c52
......@@ -145,7 +145,8 @@ 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_normal, vec.xyz ) );
float dotS = abs( dot( v_normalObject, vec.xyz ) );
// scale down the vector -> the more it "comes out of the surface, the shorter the vector".
vec2 dotScaled = ( 1.0 - dotS ) * scaleMaxToOne( vecProjected ).xy;
gl_FragData[0] = vec4( vec2( 0.5 ) + ( 0.5 * dotScaled ), light, noise3D );
......
......@@ -28,6 +28,11 @@
varying vec3 v_normal;
/**
* Normal in object space
*/
varying vec3 v_normalObject;
/**
* The normal interpolated and projected to screenspace
*/
varying vec3 v_normalProjected;
......
......@@ -95,10 +95,11 @@ void main()
// some light precalculations
v_normal = gl_NormalMatrix * gl_Normal;
v_normalObject = 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 ) ) );
v_normalProjected = normalize( projectVector( vec4( v_normal, 0.0 ) ) );
// if we use 3d noise textures and auto resolution feature:
#ifdef NOISE3D_ENABLED
......
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