LibCarna Version 3.4.0
Loading...
Searching...
No Matches
mr.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 mask;
18uniform mat4 modelTexture;
19uniform bool ignoreColor;
20uniform vec4 color;
21
22in vec4 modelSpaceCoordinates;
23
24layout( location = 0 ) out vec4 _gl_FragColor;
25
26
27// ----------------------------------------------------------------------------------
28// Fragment Procedure
29// ----------------------------------------------------------------------------------
30
31void main()
32{
33 if( abs( modelSpaceCoordinates.x ) > 0.5 || abs( modelSpaceCoordinates.y ) > 0.5 || abs( modelSpaceCoordinates.z ) > 0.5 )
34 {
35 discard;
36 }
37
38 vec4 textureCoordinates = modelTexture * modelSpaceCoordinates;
39 float intensity = texture( mask, textureCoordinates.xyz ).r;
40 if( intensity > 0 )
41 {
42 if( ignoreColor )
43 {
44 _gl_FragColor = vec4( intensity, 0, 0, 1.0 );
45 }
46 else
47 {
48 _gl_FragColor = vec4( color );
49 }
50 }
51 else
52 {
53 discard;
54 }
55}