LibCarna Version 3.4.0
Loading...
Searching...
No Matches
mip_colorization.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 sampler2D mip;
18uniform sampler1D colorMap;
19uniform float minIntensity;
20uniform float maxIntensity;
21
22in vec2 textureCoordinates;
23
24layout( location = 0 ) out vec4 _gl_FragColor;
25
26#define EPS 1e-16
27
28
29// ----------------------------------------------------------------------------------
30// Fragment Procedure
31// ----------------------------------------------------------------------------------
32
33void main()
34{
35 float intensity = texture( mip, textureCoordinates ).r;
36
37 /* Discard fragments which are outside of the volume.
38 */
39 if( intensity < 0 )
40 {
41 discard;
42 }
43
44 /* Apply intensity clipping.
45 */
46 intensity = clamp(
47 ( intensity - minIntensity + EPS ) / ( maxIntensity - minIntensity + EPS )
48 , 0.0, 1.0 );
49
50 /* Query color in `colorMap` and write result.
51 */
52 _gl_FragColor = texture( colorMap, intensity );
53}