Carna Version 3.3.3
Loading...
Searching...
No Matches
cutting-plane.frag
1#version 330
2
3/*
4 * Copyright (C) 2010 - 2015 Leonid Kostrykin
5 *
6 * Chair of Medical Engineering (mediTEC)
7 * RWTH Aachen University
8 * Pauwelsstr. 20
9 * 52074 Aachen
10 * Germany
11 *
12 */
13
14uniform sampler3D huVolume;
15uniform mat4 modelTexture;
16uniform float minIntensity;
17uniform float maxIntensity;
18uniform int invert;
19
20in vec4 modelSpaceCoordinates;
21
22layout( location = 0 ) out vec4 _gl_FragColor;
23
24
25// ----------------------------------------------------------------------------------
26// Basic Sampling
27// ----------------------------------------------------------------------------------
28
29float intensityAt( vec3 p )
30{
31 return texture( huVolume, p ).r;
32}
33
34
35// ----------------------------------------------------------------------------------
36// Fragment Procedure
37// ----------------------------------------------------------------------------------
38
39void main()
40{
41 if( abs( modelSpaceCoordinates.x ) > 0.5 || abs( modelSpaceCoordinates.y ) > 0.5 || abs( modelSpaceCoordinates.z ) > 0.5 )
42 {
43 discard;
44 }
45
46 vec4 textureCoordinates = modelTexture * modelSpaceCoordinates;
47 float intensity = intensityAt( textureCoordinates.xyz );
48 float f = step( minIntensity, intensity ) * ( 1 - step( maxIntensity, intensity ) ) * ( intensity - minIntensity ) / ( maxIntensity - minIntensity );
49 f = f + step( maxIntensity, intensity );
50 f = ( 1 - invert ) * f + invert * ( 1 - f );
51
52 _gl_FragColor = vec4( f, f, f, 1 );
53}