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.3 $ $Date: 2020/02/24 21:25:51 $ 00014 * 00015 ***************************************************************************/ 00021 00023 #version 110 00024 00025 // 00026 // Vertex shader varying and uniform variable definitions for data 00027 // supplied by VMD. 00028 // 00029 uniform int vmdprojectionmode; 00030 uniform int vmdtexturemode; 00031 uniform float vmdspritesize; 00032 00033 // 00034 // Outputs to fragment shader 00035 // 00036 varying vec3 oglcolor; 00037 varying vec3 V; 00038 00042 void main(void) { 00043 // transform vertex to Eye space for user clipping plane calculations 00044 vec4 ecpos = gl_ModelViewMatrix * gl_Vertex; 00045 gl_ClipVertex = ecpos; 00046 00047 // pass along vertex color for use fragment shading, 00048 // fragment shader will get an interpolated color. 00049 oglcolor = vec3(gl_Color); 00050 00051 // setup fog coordinate for fragment shader 00052 gl_FogFragCoord = abs(ecpos.z); 00053 00054 // compute sphere radius scaling factor 00055 #if 0 00056 float spscale = vmdspritesize * 10.0; 00057 #else 00058 vec4 ospos = gl_ModelViewMatrix * vec4(0.0, 0, 0, 1.0); 00059 vec4 rspos = gl_ModelViewMatrix * vec4(1.0, 0, 0, 1.0); 00060 float spscale = vmdspritesize * 250.0 * 00061 length((vec3(ospos) / ospos.w) - (vec3(rspos) / rspos.w)); 00062 #endif 00063 if (vmdprojectionmode == 1) { 00064 // set view direction vector from eye coordinate of vertex, for 00065 // perspective views 00066 V = normalize(vec3(ecpos) / ecpos.w); 00067 00068 // compute point size 00069 gl_PointSize = max(1.0, min(1024.0, spscale / -(ecpos.z/ecpos.w))); 00070 } else { 00071 // set view direction vector with constant eye coordinate, used for 00072 // orthographic views 00073 V = vec3(0.0, 0.0, -1.0); 00074 00075 // compute point size 00076 gl_PointSize = max(1.0, min(1024.0, spscale)); 00077 } 00078 00079 #if 0 00080 // mode 0 disables texturing 00081 // mode 1 enables texturing, emulating GL_MODULATE, with linear texgen 00082 // mode 2 enables texturing, emulating GL_REPLACE, with linear texgen 00083 if (vmdtexturemode != 0) { 00084 // transform texture coordinates as would be done by linear texgen 00085 gl_TexCoord[0].s = dot(ecpos, gl_EyePlaneS[0]); 00086 gl_TexCoord[0].t = dot(ecpos, gl_EyePlaneT[0]); 00087 gl_TexCoord[0].p = dot(ecpos, gl_EyePlaneR[0]); 00088 gl_TexCoord[0].q = dot(ecpos, gl_EyePlaneQ[0]); 00089 } 00090 #endif 00091 00092 // transform vertex to Clip space 00093 #if 1 00094 // not all drivers support ftransform() yet. 00095 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 00096 #else 00097 // We should exactly duplicate the fixed-function pipeline transform 00098 // since VMD renders the scene in multiple passes, some of which must 00099 // continue to use the fixed-function pipeline. 00100 gl_Position = ftransform(); 00101 #endif 00102 00103 } 00104 00105 00106
1.2.14 written by Dimitri van Heesch,
© 1997-2002