LibCarna Version 3.4.0
Loading...
Searching...
No Matches
cutting-plane.frag
1#version 330
2
3/*
4 * Copyright (C) 2010 - 2016 Leonid Kostrykin
5 *
6 * Chair of Medical Engineering (mediTEC)
7 * RWTH Aachen University
8 * Pauwelsstr. 20
9 * 52074 Aachen
10 * Germany
11 *
12 *
13 * Copyright (C) 2021 - 2025 Leonid Kostrykin
14 *
15 */
16
17uniform sampler3D intensities;
18uniform sampler1D colorMap;
19uniform float minIntensity;
20uniform float maxIntensity;
21uniform mat4 modelTexture;
22
23in vec4 modelSpaceCoordinates;
24
25layout( location = 0 ) out vec4 _gl_FragColor;
26
27#define EPS 1e-16
28
29
30// ----------------------------------------------------------------------------------
31// Basic Sampling
32// ----------------------------------------------------------------------------------
33
34float intensityAt( vec3 p )
35{
36 return texture( intensities, p ).r;
37}
38
39
40// ----------------------------------------------------------------------------------
41// Fragment Procedure
42// ----------------------------------------------------------------------------------
43
44void main()
45{
46 if( abs( modelSpaceCoordinates.x ) > 0.5 || abs( modelSpaceCoordinates.y ) > 0.5 || abs( modelSpaceCoordinates.z ) > 0.5 )
47 {
48 discard;
49 }
50
51 vec4 textureCoordinates = modelTexture * modelSpaceCoordinates;
52 float intensity = intensityAt( textureCoordinates.xyz );
53
54 /* Apply intensity clipping.
55 */
56 intensity = clamp(
57 ( intensity - minIntensity + EPS ) / ( maxIntensity - minIntensity + EPS )
58 , 0.0, 1.0 );
59
60 /* Query color in `colorMap` and write result.
61 */
62 _gl_FragColor = vec4( texture( colorMap, intensity ).rgb, 1 );
63}