forked from scilus/fibernavigator
-
Notifications
You must be signed in to change notification settings - Fork 2
/
fibers.fs
executable file
·73 lines (62 loc) · 1.54 KB
/
fibers.fs
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
varying vec4 VaryingTexCoord0;
#include functions.fs
uniform int dimX, dimY, dimZ;
uniform float voxX, voxY, voxZ;
uniform sampler3D tex;
uniform float threshold;
uniform bool useTex;
uniform bool useOverlay;
uniform bool isDistcoloring;
varying vec4 myColor;
float lookupTex()
{
vec3 v = VaryingTexCoord0.xyz;
v.x = v.x / (float(dimX) * voxX);
v.y = v.y / (float(dimY) * voxY);
v.z = v.z / (float(dimZ) * voxZ);
vec3 col1;
col1.r = clamp(texture3D(tex, v).r, 0.0, 1.0);
if (col1.r < threshold) {
discard;
}
else
return col1.r;
}
void main()
{
vec4 cooloor = myColor;
float value = lookupTex();
if(isDistcoloring)
value = myColor.r;
float newVal;
if (threshold < 1.0)
newVal = (value - threshold) / (1.0 - threshold);
else
newVal = 1.0;
if (useTex)
{
if ( useColorMap == 1 )
cooloor.rgb = colorMap1( newVal );
else if ( useColorMap == 2 )
cooloor.rgb = colorMap2( newVal );
else if ( useColorMap == 3 )
cooloor.rgb = colorMap3( newVal );
else if ( useColorMap == 4 )
cooloor.rgb = colorMap4( newVal );
else if ( useColorMap == 5 )
cooloor.rgb = colorMap5( newVal );
else if ( useColorMap == 6 )
cooloor.rgb = colorMap6( newVal );
else if ( useColorMap == 7 )
cooloor.rgb = colorMap7( newVal );
else
cooloor.rgb = defaultColorMap( newVal );
}
/* cooloor.a = 1.-(1.-newVal)*(1.-newVal);
cooloor.a = newVal*newVal;*/
cooloor.a = newVal * myColor.a;
if ( useOverlay && !isDistcoloring)
gl_FragColor = myColor;
else
gl_FragColor = cooloor;
}