Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

vmd.vert

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2011 The Board of Trustees of the
00004  *cr                        University of Illinois
00005  *cr                         All Rights Reserved
00006  *cr
00007  ***************************************************************************/
00008 /***************************************************************************
00009  * RCS INFORMATION:
00010  *
00011  *      $RCSfile: vmd.vert,v $
00012  *      $Author: johns $        $Locker:  $             $State: Exp $
00013  *      $Revision: 1.28 $       $Date: 2010/12/16 04:10:13 $
00014  *
00015  ***************************************************************************
00016  * DESCRIPTION:
00017  *  This file contains the VMD OpenGL vertex shader implementing
00018  *  the vertex portion of per-pixel lighting with phong highlights etc.
00019  ***************************************************************************/
00020 
00021 // requires GLSL version 1.10
00022 #version 110
00023 
00024 //
00025 // Vertex shader varying and uniform variable definitions for data
00026 // supplied by VMD. 
00027 //
00028 uniform int vmdprojectionmode;   // perspective=1 orthographic=0
00029 uniform int   vmdtexturemode;    // VMD texture mode
00030 
00031 // 
00032 // Outputs to fragment shader
00033 //
00034 varying vec3 oglnormal;          // output interpolated normal to frag shader
00035 varying vec3 oglcolor;           // output interpolated color to frag shader
00036 varying vec3 V;                  // output view direction vector
00037 
00038 //
00039 // VMD Vertex Shader
00040 //
00041 void main(void) {
00042   // transform vertex to Eye space for user clipping plane calculations
00043   vec4 ecpos = gl_ModelViewMatrix * gl_Vertex;
00044   gl_ClipVertex = ecpos;
00045 
00046   // transform, normalize, and output normal.
00047   oglnormal = normalize(gl_NormalMatrix * gl_Normal);
00048 
00049   // pass along vertex color for use fragment shading,
00050   // fragment shader will get an interpolated color.
00051   oglcolor = vec3(gl_Color);
00052 
00053   // setup fog coordinate for fragment shader
00054   gl_FogFragCoord = abs(ecpos.z);
00055 
00056   if (vmdprojectionmode == 1) {
00057     // set view direction vector from eye coordinate of vertex, for 
00058     // perspective views
00059     V = normalize(vec3(ecpos) / ecpos.w);
00060   } else {
00061     // set view direction vector with constant eye coordinate, used for
00062     // orthographic views
00063     V = vec3(0.0, 0.0, -1.0);
00064   }
00065 
00066   // mode 0 disables texturing
00067   // mode 1 enables texturing, emulating GL_MODULATE, with linear texgen
00068   // mode 2 enables texturing, emulating GL_REPLACE, with linear texgen
00069   if (vmdtexturemode != 0) {
00070     // transform texture coordinates as would be done by linear texgen
00071     gl_TexCoord[0].s = dot(ecpos, gl_EyePlaneS[0]);
00072     gl_TexCoord[0].t = dot(ecpos, gl_EyePlaneT[0]);
00073     gl_TexCoord[0].p = dot(ecpos, gl_EyePlaneR[0]);
00074     gl_TexCoord[0].q = dot(ecpos, gl_EyePlaneQ[0]);
00075   }
00076 
00077   // transform vertex to Clip space
00078 #if 1
00079   // not all drivers support ftransform() yet.
00080   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
00081 #else
00082   // We should exactly duplicate the fixed-function pipeline transform 
00083   // since VMD renders the scene in multiple passes, some of which must
00084   // continue to use the fixed-function pipeline.
00085   gl_Position = ftransform(); 
00086 #endif
00087 
00088 }
00089 
00090 
00091 

Generated on Sat May 26 01:48:33 2012 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002