4 * Copyright (C) 2010 - 2015 Leonid Kostrykin
6 * Chair of Medical Engineering (mediTEC)
7 * RWTH Aachen University
14 uniform sampler3D huVolume;
15 uniform mat4 modelTexture;
16 uniform float stepLength;
17 uniform float waterAttenuation;
18 uniform float lowerThreshold;
19 uniform float upperThreshold;
20 uniform float upperMultiplier;
22 in vec4 modelSpaceCoordinates;
24 out vec4 gl_FragColor;
27 // ----------------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------------
31 float 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 );