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

vmdspheresprite.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: vmdspheresprite.vert,v $
00012  *      $Author: johns $        $Locker:  $             $State: Exp $
00013  *      $Revision: 1.2 $       $Date: 2011/06/03 17:55:55 $
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 uniform float vmdspritesize;      // VMD sprite sphere size 
00031 
00032 // 
00033 // Outputs to fragment shader
00034 //
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   // pass along vertex color for use fragment shading,
00047   // fragment shader will get an interpolated color.
00048   oglcolor = vec3(gl_Color);
00049 
00050   // setup fog coordinate for fragment shader
00051   gl_FogFragCoord = abs(ecpos.z);
00052 
00053   // compute sphere radius scaling factor
00054 #if 0
00055   float spscale = vmdspritesize * 10.0;
00056 #else
00057   vec4 ospos = gl_ModelViewMatrix * vec4(0.0, 0, 0, 1.0);
00058   vec4 rspos = gl_ModelViewMatrix * vec4(1.0, 0, 0, 1.0);
00059   float spscale = vmdspritesize * 250.0 * 
00060                   length((vec3(ospos) / ospos.w) - (vec3(rspos) / rspos.w));
00061 #endif
00062   if (vmdprojectionmode == 1) {
00063     // set view direction vector from eye coordinate of vertex, for 
00064     // perspective views
00065     V = normalize(vec3(ecpos) / ecpos.w);
00066 
00067     // compute point size
00068     gl_PointSize = max(1.0, min(1024.0, spscale / -(ecpos.z/ecpos.w)));
00069   } else {
00070     // set view direction vector with constant eye coordinate, used for
00071     // orthographic views
00072     V = vec3(0.0, 0.0, -1.0);
00073 
00074     // compute point size
00075     gl_PointSize = max(1.0, min(1024.0, spscale));
00076   }
00077 
00078 #if 0
00079   // mode 0 disables texturing
00080   // mode 1 enables texturing, emulating GL_MODULATE, with linear texgen
00081   // mode 2 enables texturing, emulating GL_REPLACE, with linear texgen
00082   if (vmdtexturemode != 0) {
00083     // transform texture coordinates as would be done by linear texgen
00084     gl_TexCoord[0].s = dot(ecpos, gl_EyePlaneS[0]);
00085     gl_TexCoord[0].t = dot(ecpos, gl_EyePlaneT[0]);
00086     gl_TexCoord[0].p = dot(ecpos, gl_EyePlaneR[0]);
00087     gl_TexCoord[0].q = dot(ecpos, gl_EyePlaneQ[0]);
00088   }
00089 #endif
00090 
00091   // transform vertex to Clip space
00092 #if 1
00093   // not all drivers support ftransform() yet.
00094   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
00095 #else
00096   // We should exactly duplicate the fixed-function pipeline transform 
00097   // since VMD renders the scene in multiple passes, some of which must
00098   // continue to use the fixed-function pipeline.
00099   gl_Position = ftransform(); 
00100 #endif
00101 
00102 
00103 }
00104 
00105 
00106 

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