1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
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.
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.
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/>.
23
//---------------------------------------------------------------------------
27
#include "WGEColormapping-vertex.glsl"
29
#include "WGETransformationTools.glsl"
31
#include "WMImageSpaceLIC-Transformation-varyings.glsl"
34
* How much should the slice be moved along u_vertexShiftDirection?
36
uniform int u_vertexShift;
39
* The direction along which the slice gets moved
41
uniform vec3 u_vertexShiftDirection;
44
* Size of input texture in pixels
46
uniform int u_texture0SizeX = 255;
49
* Size of input texture in pixels
51
uniform int u_texture0SizeY = 255;
54
* Size of input texture in pixels
56
uniform int u_texture0SizeZ = 255;
59
* Size of input noise texture in pixels
61
uniform int u_texture1SizeX = 255;
64
* Size of input noise texture in pixels
66
uniform int u_texture1SizeY = 255;
69
* Size of input noise texture in pixels
71
uniform int u_texture1SizeZ = 255;
73
#ifdef NOISE3D_ENABLED
75
* The "virtual" resolution of the 3D noise texture in u_texture1Sampler
77
uniform float u_noise3DResoultuion = 3.0;
81
* Vertex Main. Simply transforms the geometry. The work is done per fragment.
85
// Calculate the real vertex coordinate in openwalnut-scene-space
86
vec4 vertex = ( vec4( u_vertexShiftDirection.xyz, 0.0 ) * u_vertexShift ) + gl_Vertex;
88
// Allow the colormapper to do some precalculations with the real vertex coordinate in ow-scene-space
89
colormapping( vertex );
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;
96
// some light precalculations
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 );
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;
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;
120
// transform position
121
gl_Position = gl_ModelViewProjectionMatrix * vertex;