~ubuntu-branches/ubuntu/precise/openwalnut/precise

« back to all changes in this revision

Viewing changes to src/modules/imageSpaceLIC/shaders/WMImageSpaceLIC-Transformation-vertex.glsl

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Eichelbaum
  • Date: 2011-06-21 10:26:54 UTC
  • Revision ID: james.westby@ubuntu.com-20110621102654-rq0zf436q949biih
Tags: upstream-1.2.5
ImportĀ upstreamĀ versionĀ 1.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//---------------------------------------------------------------------------
 
2
//
 
3
// Project: OpenWalnut ( http://www.openwalnut.org )
 
4
//
 
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
 
6
// For more information see http://www.openwalnut.org/copying
 
7
//
 
8
// This file is part of OpenWalnut.
 
9
//
 
10
// OpenWalnut is free software: you can redistribute it and/or modify
 
11
// it under the terms of the GNU Lesser General Public License as published by
 
12
// the Free Software Foundation, either version 3 of the License, or
 
13
// (at your option) any later version.
 
14
//
 
15
// OpenWalnut is distributed in the hope that it will be useful,
 
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
// GNU Lesser General Public License for more details.
 
19
//
 
20
// You should have received a copy of the GNU Lesser General Public License
 
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
 
22
//
 
23
//---------------------------------------------------------------------------
 
24
 
 
25
#version 120
 
26
 
 
27
#include "WGEColormapping-vertex.glsl"
 
28
 
 
29
#include "WGETransformationTools.glsl"
 
30
 
 
31
#include "WMImageSpaceLIC-Transformation-varyings.glsl"
 
32
 
 
33
/**
 
34
 * How much should the slice be moved along u_vertexShiftDirection?
 
35
 */
 
36
uniform int u_vertexShift;
 
37
 
 
38
/**
 
39
 * The direction along which the slice gets moved
 
40
 */
 
41
uniform vec3 u_vertexShiftDirection;
 
42
 
 
43
/**
 
44
 * Size of input texture in pixels
 
45
 */
 
46
uniform int u_texture0SizeX = 255;
 
47
 
 
48
/**
 
49
 * Size of input texture in pixels
 
50
 */
 
51
uniform int u_texture0SizeY = 255;
 
52
 
 
53
/**
 
54
 * Size of input texture in pixels
 
55
 */
 
56
uniform int u_texture0SizeZ = 255;
 
57
 
 
58
/**
 
59
 * Size of input noise texture in pixels
 
60
 */
 
61
uniform int u_texture1SizeX = 255;
 
62
 
 
63
/**
 
64
 * Size of input noise texture in pixels
 
65
 */
 
66
uniform int u_texture1SizeY = 255;
 
67
 
 
68
/**
 
69
 * Size of input noise texture in pixels
 
70
 */
 
71
uniform int u_texture1SizeZ = 255;
 
72
 
 
73
#ifdef NOISE3D_ENABLED
 
74
/**
 
75
 * The "virtual" resolution of the 3D noise texture in u_texture1Sampler
 
76
 */
 
77
uniform float u_noise3DResoultuion = 3.0;
 
78
#endif
 
79
 
 
80
/**
 
81
 * Vertex Main. Simply transforms the geometry. The work is done per fragment.
 
82
 */
 
83
void main()
 
84
{
 
85
    // Calculate the real vertex coordinate in openwalnut-scene-space
 
86
    vec4 vertex = ( vec4( u_vertexShiftDirection.xyz, 0.0 ) * u_vertexShift ) + gl_Vertex;
 
87
 
 
88
    // Allow the colormapper to do some precalculations with the real vertex coordinate in ow-scene-space
 
89
    colormapping( vertex );
 
90
 
 
91
    // for easy access to texture coordinates
 
92
    // NOTE: The vertex is specified in ow-scene-space. The texture matrix was set by WGEDataTexture for the dataset and transforms the vertex in
 
93
    // ow-scene-space to the textures space.
 
94
    gl_TexCoord[0] = gl_TextureMatrix[0] * vertex;
 
95
 
 
96
    // some light precalculations
 
97
    v_normal = gl_Normal;
 
98
 
 
99
    // if we use 3d noise textures and auto resolution feature:
 
100
#ifdef NOISE3D_ENABLED
 
101
    vec4 vec1 = vec4( float( u_texture0SizeX ) / float( u_texture1SizeX ),
 
102
                      float( u_texture0SizeY ) / float( u_texture1SizeY ),
 
103
                      float( u_texture0SizeZ ) / float( u_texture1SizeZ ), 0.0 );
 
104
    v_noiseScaleFactor = vec1.xyz;
 
105
#ifdef NOISE3DAUTORES_ENABLED
 
106
    vec4 vecMV = gl_ModelViewMatrix * vec4( vec3( 1.0 ), 0.0 ); // if the resolution should be modified, use the scaling info from the MV matrix
 
107
    v_noiseScaleFactor *= u_noise3DResoultuion * length( vecMV.xyz );
 
108
#endif
 
109
#endif
 
110
    // also get the coordinates of the light
 
111
    vec4 lpos = gl_LightSource[0].position; // this simply doesn't work well with OSG
 
112
    lpos = vec4( 0.0, 0.0, 1000.0, 1.0 );
 
113
    v_lightSource = worldToLocal( lpos ).xyz;
 
114
 
 
115
    // transform the view direction to texture space, which equals object space
 
116
    // Therefore use two points, as we transform a vector
 
117
    vec4 camPos    = vec4( 0.0, 0.0, -1.0, 0.0 );
 
118
    v_viewDir = worldToLocal( camPos ).xyz;
 
119
 
 
120
    // transform position
 
121
    gl_Position = gl_ModelViewProjectionMatrix * vertex;
 
122
}
 
123