/*************************************************************************** *cr *cr (C) Copyright 1995-2004 The Board of Trustees of the *cr University of Illinois *cr All Rights Reserved *cr ***************************************************************************/ /*************************************************************************** * RCS INFORMATION: * * $RCSfile: vmd.vert,v $ * $Author: johns $ $Locker: $ $State: Exp $ * $Revision: 1.15 $ $Date: 2004/12/04 00:46:44 $ * *************************************************************************** * DESCRIPTION: * This file contains the VMD OpenGL vertex shader implementing * the vertex portion of per-pixel lighting with phong highlights etc. ***************************************************************************/ #define TEXTURE 1 // // Vertex shader varying and uniform variable definitions for data // supplied by VMD. // uniform float vmdprojectionmode; // perspective=1 orthographic=0 uniform int vmdtexturemode; // VMD texture mode // // Outputs to fragment shader // varying vec3 oglnormal; // output interpolated normal to frag shader varying vec3 oglcolor; // output interpolated color to frag shader varying vec3 V; // output view direction vector // // VMD Vertex Shader // void main(void) { // transform vertex to Clip space #if 1 // not all drivers support ftransform() yet. gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; #else // We should exactly duplicate the fixed-function pipeline transform // since VMD renders the scene in multiple passes, some of which must // continue to use the fixed-function pipeline. gl_Position = ftransform(); #endif #if 0 // transform vertex to Eye space for user clipping plane calculations // XXX ATI driver can't handle this yet, they use fixed-function clipping gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex; #endif // transform, normalize, and output normal. oglnormal = normalize(gl_NormalMatrix * gl_Normal); // pass along vertex color for use fragment shading, // fragment shader will get an interpolated color. oglcolor = vec3(gl_Color); if (vmdprojectionmode) { // set view direction vector from eye coordinate of vertex, for // perspective views V = normalize(vec3(gl_ModelViewMatrix * gl_Vertex)); } else { // set view direction vector with constant eye coordinate, used for // orthographic views V = vec3(0.0, 0.0, -1.0); } #ifdef TEXTURE gl_TexCoord[0] = gl_MultiTexCoord0; if (vmdtexturemode == 1) { // transform texture coordinates, or generate them vec4 eyepos = gl_ModelViewMatrix * gl_Vertex; gl_TexCoord[0].s = dot(eyepos, gl_EyePlaneS[0]); gl_TexCoord[0].t = dot(eyepos, gl_EyePlaneT[0]); gl_TexCoord[0].p = dot(eyepos, gl_EyePlaneR[0]); gl_TexCoord[0].q = dot(eyepos, gl_EyePlaneQ[0]); } #endif }