Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /branches/tash/test/vr-rgb.diderot
ViewVC logotype

Annotation of /branches/tash/test/vr-rgb.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3217 - (view) (download)

1 : jhr 1115 // vr-rgb.diderot
2 :     //
3 :     // simple diffuse-only volume rendering with R, G, B
4 :     // lights at positive X, Y, Z
5 :     //
6 :    
7 :     real stepSz = 0.05;
8 :     vec3 eye = [25.0, 15.0, 10.0];
9 :     vec3 orig = [8.83877,2.5911,7.65275];
10 :     vec3 cVec = [-0.0151831,0.0278357,0.0];
11 :     vec3 rVec = [0.0074887,0.00408474,-0.0305383];
12 :     real valOpacMin = 0.3; // highest value with opacity 0.0
13 :     real valOpacMax = 0.4; // lowest value with opacity 1.0
14 :     vec3 Rdir = [1.0,0.0,0.0];
15 :     vec3 Gdir = [0.0,1.0,0.0];
16 :     vec3 Bdir = [0.0,0.0,1.0];
17 :    
18 : jhr 1927 input image(3)[] img = load ("../data/txs-pad3.nrrd");
19 : jhr 1115
20 :     //field#2(3)[] F = img ⊛ bspln3;
21 :     //field#1(3)[] F = img ⊛ ctmr;
22 :     field#1(3)[] F = img ⊛ c1tent;
23 :    
24 :     strand RayCast (int row, int col)
25 :     {
26 :     vec3 pos = orig + real(row)*rVec + real(col)*cVec;
27 :     vec3 dir = normalize(pos - eye);
28 :     real t = 0.0;
29 :     real transp = 1.0;
30 :     real RR = 0.0;
31 :     real GG = 0.0;
32 :     real BB = 0.0;
33 :     output vec4 rgba = [0.0, 0.0, 0.0, 0.0];
34 :    
35 :     update
36 :     {
37 :     pos = pos + stepSz*dir;
38 :     if (inside (pos,F)) {
39 :     real val = F@pos;
40 :     vec3 norm = -normalize(∇F@pos);
41 :     if (val > valOpacMin) { // we have some opacity
42 :     real opac = min(1.0, lerp(0.0, 1.0, valOpacMin, val, valOpacMax));
43 :     RR = RR + transp*opac*max(0.0, Rdir • norm);
44 :     GG = GG + transp*opac*max(0.0, Gdir • norm);
45 :     BB = BB + transp*opac*max(0.0, Bdir • norm);
46 :     transp = transp*(1.0 - opac);
47 :     }
48 :     }
49 :     if (t > 20.0 || transp < 0.01) {
50 :     rgba = [RR, GG, BB, 1.0-transp];
51 :     stabilize;
52 :     }
53 :     t = t + stepSz;
54 :     }
55 :     }
56 :    
57 :     initially [ RayCast(r, c) | r in 0..199, c in 0..199 ];

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0