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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1673 - (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 :     input string dataFile = "../data/txs-pad3.nrrd";
8 :     real stepSz = 0.05;
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.3; // highest value with opacity 0.0
14 :     real valOpacMax = 0.4; // 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 :     //field#1(3)[] F = img ⊛ ctmr;
23 :     field#1(3)[] F = img ⊛ c1tent;
24 :    
25 :     strand RayCast (int row, int col)
26 :     {
27 :     vec3 pos = orig + real(row)*rVec + real(col)*cVec;
28 :     vec3 dir = normalize(pos - eye);
29 :     real t = 0.0;
30 :     real transp = 1.0;
31 :     real RR = 0.0;
32 :     real GG = 0.0;
33 :     real BB = 0.0;
34 :     output vec4 rgba = [0.0, 0.0, 0.0, 0.0];
35 :    
36 :     update
37 :     {
38 :     pos = pos + stepSz*dir;
39 :     if (inside (pos,F)) {
40 :     real val = F@pos;
41 :     vec3 norm = -normalize(∇F@pos);
42 :     if (val > valOpacMin) { // we have some opacity
43 :     real opac = min(1.0, lerp(0.0, 1.0, valOpacMin, val, valOpacMax));
44 :     RR = RR + transp*opac*max(0.0, Rdir • norm);
45 :     GG = GG + transp*opac*max(0.0, Gdir • norm);
46 :     BB = BB + transp*opac*max(0.0, Bdir • norm);
47 :     transp = transp*(1.0 - opac);
48 :     }
49 :     }
50 :     if (t > 20.0 || transp < 0.01) {
51 :     rgba = [RR, GG, BB, 1.0-transp];
52 :     stabilize;
53 :     }
54 :     t = t + stepSz;
55 :     }
56 :     }
57 :    
58 :     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