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

SCM Repository

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

Annotation of /branches/pure-cfg/test/vr-rgb.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 668 - (view) (download)

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