volmetrics
diff src/volume.cc @ 16:add30e2d5253
foo
author | Eleni Maria Stea <elene.mst@gmail.com> |
---|---|
date | Mon, 03 Feb 2014 02:52:46 +0200 |
parents | 77a376198d38 |
children | 4e120dcd55ec |
line diff
1.1 --- a/src/volume.cc Mon Feb 03 01:30:47 2014 +0200 1.2 +++ b/src/volume.cc Mon Feb 03 02:52:46 2014 +0200 1.3 @@ -178,6 +178,14 @@ 1.4 x = (x - low) / (high - low); 1.5 return x * x * (3.0 - 2.0 * x); 1.6 } 1.7 + 1.8 +float transfer_function(float x, float low_thres, float high_thres) 1.9 +{ 1.10 + float dt = 0.25 * (high_thres - low_thres); 1.11 + return smoothstep(x, low_thres - dt, low_thres + dt) * 1.12 + (1 - smoothstep(x, high_thres - dt, high_thres + dt)); 1.13 +} 1.14 + 1.15 static float cb_eval(float x, float y, float z) 1.16 { 1.17 const Image *img = cur_vol->get_slice_by_z((z + 1) / 2.0); 1.18 @@ -187,8 +195,7 @@ 1.19 int py = (y + 1) / 2.0 * img->get_height(); 1.20 1.21 float val = pixels[px + img->get_width() * py]; 1.22 - float dt = 0.25 * (high_thres - low_thres); 1.23 - return smoothstep(val, low_thres - dt, low_thres + dt) * (1 - smoothstep(val, high_thres - dt, high_thres + dt)); 1.24 + return transfer_function(val, low_thres, high_thres); 1.25 } 1.26 1.27 static void cb_vertex(float x, float y, float z)