4 * Copyright (C) 2010 - 2016 Leonid Kostrykin
6 * Chair of Medical Engineering (mediTEC)
7 * RWTH Aachen University
13 * Copyright (C) 2021 - 2025 Leonid Kostrykin
17uniform sampler3D huVolume;
18uniform mat4 modelTexture;
19uniform float stepLength;
20uniform float waterAttenuation;
21uniform float lowerThreshold;
22uniform float upperThreshold;
23uniform float upperMultiplier;
25in vec4 modelSpaceCoordinates;
27layout( location = 0 ) out vec4 _gl_FragColor;
30// ----------------------------------------------------------------------------------
32// ----------------------------------------------------------------------------------
34float intensityAt( vec3 p )
36 return texture( huVolume, p ).r;
40// ----------------------------------------------------------------------------------
42// ----------------------------------------------------------------------------------
46 if( abs( modelSpaceCoordinates.x ) > 0.5 || abs( modelSpaceCoordinates.y ) > 0.5 || abs( modelSpaceCoordinates.z ) > 0.5 )
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;
58 _gl_FragColor = vec4( summand, 0, 0, 1 );