Carna Version 3.3.3
Loading...
Searching...
No Matches
drr-accumulation.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 stepLength;
17uniform float waterAttenuation;
18uniform float lowerThreshold;
19uniform float upperThreshold;
20uniform float upperMultiplier;
21
22in vec4 modelSpaceCoordinates;
23
24layout( location = 0 ) out vec4 _gl_FragColor;
25
26
27// ----------------------------------------------------------------------------------
28// Basic Sampling
29// ----------------------------------------------------------------------------------
30
31float intensityAt( vec3 p )
32{
33 return texture( huVolume, p ).r;
34}
35
36
37// ----------------------------------------------------------------------------------
38// Fragment Procedure
39// ----------------------------------------------------------------------------------
40
41void main()
42{
43 if( abs( modelSpaceCoordinates.x ) > 0.5 || abs( modelSpaceCoordinates.y ) > 0.5 || abs( modelSpaceCoordinates.z ) > 0.5 )
44 {
45 discard;
46 }
47
48 vec4 textureCoordinates = modelTexture * modelSpaceCoordinates;
49 float intensity = intensityAt( textureCoordinates.xyz );
50 intensity = intensity + step( upperThreshold, intensity ) * ( upperMultiplier - 1 ) * intensity;
51 float huv = intensity * 4096 - 1024;
52 float mu = waterAttenuation * ( 1 + huv / 1000 );
53 float summand = step( lowerThreshold, intensity ) * mu * stepLength;
54
55 _gl_FragColor = vec4( summand, 0, 0, 1 );
56}