~ubuntu-branches/ubuntu/raring/openwalnut/raring

« back to all changes in this revision

Viewing changes to src/modules/fiberDisplaySimple/shaders/WMFiberDisplaySimple-vertex.glsl

  • Committer: Package Import Robot
  • Author(s): Sebastian Eichelbaum
  • Date: 2012-12-12 11:26:32 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20121212112632-xhiuwkxuz5h0idkh
Tags: 1.3.1+hg5849-1
* Minor changes compared to 1.3.0 but included several bug fixes.
* See http://www.openwalnut.org/versions/4

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
#include "WGEColormapping-vertex.glsl"
28
28
 
 
29
#include "WGETransformationTools.glsl"
 
30
 
29
31
#include "WMFiberDisplaySimple-varyings.glsl"
30
32
 
31
33
/////////////////////////////////////////////////////////////////////////////
68
70
    // define the plane
69
71
    vec3 n = normalize( u_planeVector );
70
72
    float d = dot( u_planePoint, n );
71
 
    dist = dot( gl_Vertex.xyz, n ) - d;
 
73
    v_dist = dot( gl_Vertex.xyz, n ) - d;
72
74
#endif  // CLIPPLANE_ENABLED
73
75
 
74
76
    // The same accounds for the vertex. Transfer it to world-space.
77
79
    // fill this varying with a dummy. Not always needed.
78
80
    v_normal = vec3( 1.0, 0.0, 0.0 );
79
81
 
 
82
    // To avoid that the quad strip gets thinner and thinner when zooming in (or the other way around: to avoid the quad strip always occupies
 
83
    // the same screen space), we need to calculate the zoom factor involved in OpenWalnut's current camera.
 
84
    v_worldScale = getModelViewScale();
 
85
 
80
86
    // Grab the tangent. We have uploaded it normalized in gl_Normal per vertex
81
87
    // We need to transfer it to the world-space ass all further operations are done there.
82
88
    vec3 tangent = normalize( ( gl_ModelViewMatrix * vec4( gl_Normal, 0.0 ) ).xyz );
 
89
    v_tangent = tangent;
83
90
 
84
91
    // The view direction in world-space. In OpenGL this is always defined by this vector
85
92
    vec3 view = vec3( 0.0, 0.0, -1.0 );
98
105
 
99
106
#ifdef TUBE_ENABLED
100
107
#ifdef ZOOMABLE_ENABLED
101
 
    // To avoid that the quad strip gets thinner and thinner when zooming in (or the other way around: to avoid the quad strip always occupies
102
 
    // the same screen space), we need to calculate the zoom factor involved in OpenWalnut's current camera.
103
 
    float worldScale = length( ( gl_ModelViewMatrix * vec4( 1.0, 1.0, 1.0, 0.0 ) ).xyz );
104
108
 
105
109
    // worldScale now contains the scaling which is done by ModelView transformation (including the camera).
106
110
    // With this, we can ensure that our offset, which is of unit-length, is scaled acccording to the camera zoom. The
107
111
    // additional uniform u_tubeSize allows the user to scale the tubes.
108
112
    // We clamp the value to ensure a minimum width of the quadstrip of 1px on screen:
109
 
    worldScale = clamp( u_tubeSize * worldScale, 1.0, 1000000.0 );
 
113
    float worldScale = clamp( u_tubeSize * v_worldScale, 1.0, 1000000.0 );
110
114
#else  // ZOOMABLE_ENABLED
111
115
    // In this mode, the tubes should not be zoomed. Just use the user defined size here.
112
116
    float worldScale = clamp( u_tubeSize, 1.0, 1000000.0 );
127
131
    // ignore the actual width of the tube.
128
132
    colormapping( gl_ModelViewMatrixInverse * v_vertex );
129
133
#endif
 
134
#ifdef CLUSTER_FILTER_ENABLED
 
135
    v_clusterColor = gl_SecondaryColor.rgb;
 
136
#endif
130
137
 
131
138
    // Simply project the vertex afterwards
132
139
    gl_Position = gl_ProjectionMatrix * v_vertex;