LibCarna Version 3.4.0
Loading...
Searching...
No Matches
drr-accumulation.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 huVolume;
18uniform mat4 modelTexture;
19uniform float stepLength;
20uniform float waterAttenuation;
21uniform float lowerThreshold;
22uniform float upperThreshold;
23uniform float upperMultiplier;
24
25in vec4 modelSpaceCoordinates;
26
27layout( location = 0 ) out vec4 _gl_FragColor;
28
29
30// ----------------------------------------------------------------------------------
31// Basic Sampling
32// ----------------------------------------------------------------------------------
33
34float intensityAt( vec3 p )
35{
36 return texture( huVolume, 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 intensity = intensity + step( upperThreshold, intensity ) * ( upperMultiplier - 1 ) * intensity;
54 float huv = intensity * 4096 - 1024;
55 float mu = waterAttenuation * ( 1 + huv / 1000 );
56 float summand = step( lowerThreshold, intensity ) * mu * stepLength;
57
58 _gl_FragColor = vec4( summand, 0, 0, 1 );
59}