//============================================================================= // // Project: SharpImage // Module: shader-vm.frag // Language: OpenGL Shading Language (GLSL) // Author: Dan Mueller // Date: $Date: 2007-07-06 10:57:00 +1000 (Fri, 06 Jul 2007) $ // Revision: $Revision: 2 $ // // Copyright (c) Queensland University of Technology (QUT) 2007. // All rights reserved. // // This software is distributed WITHOUT ANY WARRANTY; without even // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the copyright notices for more information. // //============================================================================= uniform sampler3D sam3Tex0; // Sampler for transfer function uniform sampler3D sam3Tex1; // Sampler for value image uniform sampler3D sam3Tex2; // Sampler for gradient image varying vec3 pos3Tex1; // Current coord of value image varying vec3 pos3Tex2; // Current coord of gradient image uniform float fSamplingRate; // Current sampling rate // Adjust the alpha value for the current sampling rate float adjustAlphaForSamplingRate( float a ) { return 1.0 - pow( 1.0 - a, 1.0 / fSamplingRate ); } void main() { // Interpolate images float value = texture3D( sam3Tex1, pos3Tex1 ).a; float gradmag = texture3D( sam3Tex2, pos3Tex2 ).a; // Interpolate transfer function vec3 pos3Tf = vec3( value, 1.0-gradmag, 0.0 ); vec4 val4Tf = texture3D( sam3Tex0, pos3Tf ); // Discard if no contribution if (val4Tf.a <= 0.0) discard; // Adjust alpha for sampling rate val4Tf.a = adjustAlphaForSamplingRate( val4Tf.a ); // Set color gl_FragColor = val4Tf; }