4 * Copyright (C) 2010 - 2015 Leonid Kostrykin
6 * Chair of Medical Engineering (mediTEC)
7 * RWTH Aachen University
14uniform sampler3D huVolume;
15uniform mat4 modelTexture;
16uniform float stepLength;
17uniform float waterAttenuation;
18uniform float lowerThreshold;
19uniform float upperThreshold;
20uniform float upperMultiplier;
22in vec4 modelSpaceCoordinates;
24layout( location = 0 ) out vec4 _gl_FragColor;
27// ----------------------------------------------------------------------------------
29// ----------------------------------------------------------------------------------
31float intensityAt( vec3 p )
33 return texture( huVolume, p ).r;
37// ----------------------------------------------------------------------------------
39// ----------------------------------------------------------------------------------
43 if( abs( modelSpaceCoordinates.x ) > 0.5 || abs( modelSpaceCoordinates.y ) > 0.5 || abs( modelSpaceCoordinates.z ) > 0.5 )
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;
55 _gl_FragColor = vec4( summand, 0, 0, 1 );