11 uniform sampler2D backface_fbo;
12 uniform sampler2D frontface_fbo;
13 uniform sampler3D ref_volumetexture;
14 uniform sampler3D float_volumetexture;
15 uniform sampler1D ref_transferfunction;
16 uniform sampler1D float_transferfunction;
20 uniform
int steps_mode;
21 uniform
float noise_threshold;
22 uniform vec4 ref_phyDimensions;
23 uniform vec4 float_phyDimensions;
24 uniform mat4 inv_registration_matrix;
25 uniform
float blending_factor;
43 vec3 start_position = texture(frontface_fbo,
TexCoord).xyz;
44 vec3 end_position = texture(backface_fbo,
TexCoord).xyz;
46 if (start_position == end_position)
47 fColor = vec4(0.5, 0.5, 0.5,1.0);
50 vec4 color = vec4(0.0);
51 vec4 fusion = vec4(0.0);
52 float ref_density = 0.0;
53 float ref_eq_density = 0.0;
54 float float_density = 0.0;
55 float float_eq_density = 0.0;
57 float accum_alpha = 0.0;
59 vec4 inv = vec4(1. / float_phyDimensions.x, 1. / float_phyDimensions.y,
60 1. / float_phyDimensions.z, 1.0);
63 float length_of_ray_x = (end_position.x - start_position.x) *
float(width);
64 float length_of_ray_y = (end_position.y - start_position.y) *
float(height);
65 float length_of_ray_z = (end_position.z - start_position.z) *
float(depth);
66 float length_of_ray = sqrt(length_of_ray_x * length_of_ray_x + length_of_ray_y * length_of_ray_y + length_of_ray_z * length_of_ray_z);
68 float factor_for_tf_alpha;
72 steps = length_of_ray * 2.0;
73 factor_for_tf_alpha = 2.0;
77 steps = float(steps_mode);
78 factor_for_tf_alpha = steps / length_of_ray;
81 vec3 step = (end_position - start_position) / steps;
83 for (
float i=0.0; i < steps; i+=1.0)
85 vec3 current_position = start_position + i*step;
87 ref_density = texture(ref_volumetexture, current_position).r;
89 if (!first && ref_density >= noise_threshold) {
96 ref_eq_density = ref_density;
98 vec4 ref_tf_color = texture(ref_transferfunction, ref_eq_density);
101 vec4 pt = vec4(ref_phyDimensions.xyz * (current_position), 1.0);
102 vec4 corresp = inv * (inv_registration_matrix * pt);
104 float_density = texture(float_volumetexture, corresp.xyz).r;
106 float_eq_density = float_density;
107 vec4 float_tf_color = texture(float_transferfunction, float_eq_density);
110 fusion.rgb = mix(float_tf_color.rgb, ref_tf_color.rgb, blending_factor);
113 fusion.a = min(ref_tf_color.a,float_tf_color.a);
116 color.rgb = (1-alpha)*color.rgb + fusion.rgb;
117 color.a = mix(fusion.a, 1.0, color.a);
122 fColor = vec4(color.rgb, 1.0);
127 if (accum_alpha == 0.0)
129 fColor = vec4(0.5,0.5,0.5, 1.0);
133 fColor = vec4(color.rgb, 1.0);
void main(void)
Main function.