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 743 - (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 : glk 742 real valOpacMin = 0.3; // highest value with opacity 0.0
14 :     real valOpacMax = 0.4; // lowest value with opacity 1.0
15 : glk 668 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 : glk 742 //field#2(3)[] F = img ⊛ bspln3;
22 :     //field#1(3)[] F = img ⊛ ctmr;
23 : glk 743 // HEY (bug) upon trying to use this kernel with differentiation
24 :     // uncaught exception Match [nonexhaustive match failure]
25 :     // raised at mid-to-low/mid-to-low.sml:161.6
26 :     field#1(3)[] F = img ⊛ c1tent;
27 : glk 668
28 :     strand RayCast (int row, int col)
29 :     {
30 :     vec3 pos = orig + real(row)*rVec + real(col)*cVec;
31 :     vec3 dir = (pos - eye)/|pos - eye|;
32 :     real t = 0.0;
33 :     real transp = 1.0;
34 :     real RR = 0.0;
35 :     real GG = 0.0;
36 :     real BB = 0.0;
37 :     output vec4 rgba = [0.0, 0.0, 0.0, 0.0];
38 :    
39 :     update
40 :     {
41 :     pos = pos + stepSz*dir;
42 :     if (inside (pos,F)) {
43 :     real val = F@pos;
44 :     vec3 grad = ∇F@pos;
45 :     vec3 norm = -grad/|grad|;
46 :     if (val > valOpacMin) { // we have some opacity
47 :     real opac =
48 :     1.0 if (val > valOpacMax)
49 :     else (val - valOpacMin)/(valOpacMax - valOpacMin);
50 :     RR = RR + transp*opac*max(0.0, dot(Rdir,norm));
51 :     GG = GG + transp*opac*max(0.0, dot(Gdir,norm));
52 :     BB = BB + transp*opac*max(0.0, dot(Bdir,norm));
53 :     transp = transp*(1.0 - opac);
54 :     }
55 :     }
56 :     if (t > 20.0 || transp < 0.01) {
57 :     rgba = [RR, GG, BB, 1.0-transp];
58 :     stabilize;
59 :     }
60 :     t = t + stepSz;
61 :     }
62 :     }
63 :    
64 :     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