1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
//VTK::System::Dec
/*=========================================================================
Program: Visualization Toolkit
Module: vtkSphereMapperVS.glsl
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// this shader implements imposters in OpenGL for Spheres
attribute vec4 vertexMC;
attribute vec3 orientMC;
attribute vec4 offsetMC;
attribute float radiusMC;
// optional normal declaration
//VTK::Normal::Dec
//VTK::Picking::Dec
// Texture coordinates
//VTK::TCoord::Dec
uniform mat3 normalMatrix; // transform model coordinate directions to view coordinates
// material property values
//VTK::Color::Dec
// clipping plane vars
//VTK::Clip::Dec
// camera and actor matrix values
//VTK::Camera::Dec
varying vec4 vertexVCVSOutput;
varying float radiusVCVSOutput;
varying float lengthVCVSOutput;
varying vec3 centerVCVSOutput;
varying vec3 orientVCVSOutput;
uniform int cameraParallel;
void main()
{
//VTK::Picking::Impl
//VTK::Color::Impl
//VTK::Normal::Impl
//VTK::TCoord::Impl
//VTK::Clip::Impl
vertexVCVSOutput = MCVCMatrix * vertexMC;
centerVCVSOutput = vertexVCVSOutput.xyz;
radiusVCVSOutput = radiusMC;
lengthVCVSOutput = length(orientMC);
orientVCVSOutput = normalMatrix * normalize(orientMC);
// make sure it is pointing out of the screen
if (orientVCVSOutput.z < 0.0)
{
orientVCVSOutput = -orientVCVSOutput;
}
// make the basis
vec3 xbase;
vec3 ybase;
vec3 dir = vec3(0.0,0.0,1.0);
if (cameraParallel == 0)
{
dir = normalize(-vertexVCVSOutput.xyz);
}
if (abs(dot(dir,orientVCVSOutput)) == 1.0)
{
xbase = normalize(cross(vec3(0.0,1.0,0.0),orientVCVSOutput));
ybase = cross(xbase,orientVCVSOutput);
}
else
{
xbase = normalize(cross(orientVCVSOutput,dir));
ybase = cross(orientVCVSOutput,xbase);
}
vec3 offsets = offsetMC.xyz*2.0-1.0;
vertexVCVSOutput.xyz = vertexVCVSOutput.xyz +
radiusVCVSOutput*offsets.x*xbase +
radiusVCVSOutput*offsets.y*ybase +
0.5*lengthVCVSOutput*offsets.z*orientVCVSOutput;
gl_Position = VCDCMatrix * vertexVCVSOutput;
}
|