WFiberStipples-vertex.glsl 3.54 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------

#version 120

#include "WGETextureTools.glsl"
#include "WFiberStipples-varyings.glsl"
29
#include "WFiberStipples-uniforms.glsl"
30 31 32 33 34 35 36 37 38

/**
 * Vertex Main. Simply transforms the geometry and computes the projected diffusion direction.
 */
void main()
{
    gl_TexCoord[0] = gl_MultiTexCoord0; // for distinguishing the verties of the quad
    gl_TexCoord[1] = gl_MultiTexCoord1; // for coordinate system within fragment shader (enable unit quad coordinates)
    gl_TexCoord[2] = gl_MultiTexCoord2; // for selecting the noisy vertex slice
39
    gl_TexCoord[3] = gl_MultiTexCoord3; // for selecting quads within a single hierarchy level
40 41

    // compute texture coordinates from worldspace coordinates for texture access
42 43 44
    v_probTexturePos = ( gl_TextureMatrix[ 1 ] * u_WorldTransform * gl_Vertex ).xyz;
    v_vecTexturePos = ( gl_TextureMatrix[ 0 ] * u_WorldTransform * gl_Vertex ).xyz;
    v_colorTexturePos = ( gl_TextureMatrix[ 2 ] * u_WorldTransform * gl_Vertex ).xyz;
45 46

    // get connectivity score from probTract (please not, it is already scaled between 0.0...1.0 from WDataTexture3D::createTexture
47
    v_probability = texture3D( u_probTractSampler, v_probTexturePos ).r;
48

49 50
    // // span quad incase of regions with high probablility
    if( v_probability > u_threshold && ( u_minRange + v_probability ) * u_maxRange * u_numDensitySlices >= gl_TexCoord[2].x + gl_TexCoord[3].x )
51
    // // Debug: fewer hierarchy levels and you may turn on and off the smooth level transition with the last multiplication to gl_TexCoord[3].x. 0.0 == disable 1.0 == enable
52
    // if( v_probability > u_threshold && ( u_minRange + v_probability ) * u_maxRange * int( u_numDensitySlices / 10 )  > int( gl_TexCoord[2].x / 10 ) + 0.0* gl_TexCoord[3].x )
53
    // // Debug: pure rejection sampling
54
    // if( v_probability > u_threshold && ( u_minRange + v_probability ) * u_maxRange >= 1.0 * gl_TexCoord[3].x )
55
    // // Debug: bipartionate
56
    // if( v_probability < 0.5 && gl_TexCoord[2].x < 10  || v_probability > 0.5 )
57
    // // Debug: Draw seed points with repect to probability and their density-slice-number
58
    // if( v_probability > u_threshold &&  0 == gl_TexCoord[2].x )
59
    // // Debug: Draw all seed points. You need to disable else
60
    // if( true )
61 62
    {
         // transform position, the 4th component must be explicitly set, as otherwise they would have been scaled
63
       gl_Position = gl_ModelViewProjectionMatrix * ( vec4( u_glyphSize * gl_TexCoord[0].xyz + gl_Vertex.xyz, 1.0 ) );
64 65 66
    }
    else
    {
67
       gl_Position = ftransform(); // discard those vertices
68 69
    }
}