forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkSurfaceLICPainter_GeomVs.glsl
78 lines (67 loc) · 1.98 KB
/
vtkSurfaceLICPainter_GeomVs.glsl
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
//=========================================================================
//
// Program: Visualization Toolkit
// Module: vtkSurfaceLICPainter_vs1.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.
//
//=========================================================================
#version 120
varying vec4 vColor;
varying vec2 vProjectedVF;
varying vec3 vMaskCriteria;
// 0/1, when 1 V is projected to surface for |V| computation.
uniform float uMaskOnSurface;
// from vtkColorMaterialHelper
gl_MaterialParameters getMaterialParameters();
// from vtkLightingHelper
vec4 singleColor(gl_MaterialParameters m, vec3 surfacePosEyeCoords, vec3 n);
/**
Compute vertext color
*/
vec4 colorFrontFace()
{
vec4 heyeCoords = gl_ModelViewMatrix * gl_Vertex;
vec3 eyeCoords = heyeCoords.xyz / heyeCoords.w;
vec3 n = normalize(gl_NormalMatrix * gl_Normal);
return singleColor(getMaterialParameters(), eyeCoords,n);
}
/**
Project "vector" onto the surface.
*/
vec3 projectOnSurface(vec3 vector)
{
vec3 normal = normalize(gl_Normal);
float k = dot(normal, vector);
return (vector - (k*normal));
}
/**
get fragment mask criteria. Fragment masking should be applied according to
the original vector field and in those units. If it is not then masked fragments
will not match pseudo color plots.
*/
vec3 getMaskCriteria( vec3 vector )
{
if (uMaskOnSurface == 0)
{
return vector;
}
else
{
return projectOnSurface(vector);
}
}
void main()
{
vec3 vf = projectOnSurface(gl_MultiTexCoord0.stp);
vProjectedVF = (gl_NormalMatrix * vf).xy;
vMaskCriteria = getMaskCriteria(gl_MultiTexCoord0.stp);
vColor = colorFrontFace();
gl_Position = ftransform();
}