IsosurfaceRaytracer.vs 2.88 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
//---------------------------------------------------------------------------
//
// 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/>.
//
//---------------------------------------------------------------------------

25 26
#version 120

27 28
#include "transformationTools.fs"

29 30 31 32
/////////////////////////////////////////////////////////////////////////////
// Varyings
/////////////////////////////////////////////////////////////////////////////

33
#include "IsosurfaceRaytracer.varyings"
34

35 36 37 38
/////////////////////////////////////////////////////////////////////////////
// Uniforms
/////////////////////////////////////////////////////////////////////////////

39 40 41
// texture containing the data
uniform sampler3D tex0;

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
/////////////////////////////////////////////////////////////////////////////
// Attributes
/////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// Variables
/////////////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// Functions
/////////////////////////////////////////////////////////////////////////////

/**
 * Main entry point of the vertex shader.
 */
void main()
{
59 60
    // for easy access to texture coordinates
    gl_TexCoord[0] = gl_MultiTexCoord0;
61
    v_normal = gl_Normal;
62 63

    // in texture space, the starting point simply is the current surface point in texture space
64
    v_rayStart = gl_TexCoord[0].xyz; // this equals gl_Vertex!
65

66 67
    // transform the ray direction to texture space, which equals object space
    // Therefore use two points, as we transform a vector
68 69
    vec4 camLookAt = vec4( 0.0, 0.0, -1.0, 1.0 );
    vec4 camPos    = vec4( 0.0, 0.0, 0.0, 1.0 );
70 71 72 73
    v_ray = worldToLocal( camLookAt, camPos ).xyz;

    // also get the coordinates of the light
    vec4 lpos = gl_LightSource[0].position;
74
    lpos = vec4( 0.0, 0.0, 1000.0, 1.0 );
75
    v_lightSource = worldToLocal( lpos ).xyz;
76

77 78
    // Simply project the vertex
    gl_Position = ftransform();
79
    gl_FrontColor = gl_Color;
80 81
}