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

SCM Repository

[diderot] Annotation of /branches/vis12-cl/test/vr-kcomp2.diderot
ViewVC logotype

Annotation of /branches/vis12-cl/test/vr-kcomp2.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1118 - (view) (download)
Original Path: trunk/test/vr-kcomp2.diderot

1 : jhr 1115 // process output with:
2 :     // unu reshape -i mip.txt -s 4 200 200 | overrgb -i - -b 0.1 0.15 0.2 -o - | unu quantize -b 8 -min 0 -max 255 -o vr-kcomp2.png
3 :    
4 :     vec3 camEye = [25.0, 10.0, 8.0];
5 :     vec3 camAt = [0.0, 0.0, 0.0];
6 :     vec3 camUp = [0.0, 0.0, 1.0];
7 :     real camNear = -1.0;
8 :     real camFar = 1.0;
9 :     real camFOV = 4.5;
10 :     int imgResU = 200;
11 :     int imgResV = 200;
12 :     real rayStep = 0.01;
13 :     real valOpacMin = 0.08; // highest value with opacity 0.0
14 :     real valOpacMax = 0.09; // lowest value with opacity 1.0
15 :    
16 :     real camDist = |camAt - camEye|;
17 :     real camVspNear = camNear + camDist;
18 :     real camVspFar = camFar + camDist;
19 :     vec3 camN = normalize(camAt - camEye);
20 :     vec3 camU = normalize(camN × camUp);
21 :     vec3 camV = camN × camU;
22 :     real camVmax = tan(camFOV*3.1415926536/360.0)*camDist;
23 :     real camUmax = camVmax*real(imgResU)/real(imgResV);
24 :    
25 :     vec3 lightVspDir = [-1.0, -1.0, -3.5];
26 :     vec3 lightDir = normalize(lightVspDir[0]*camU + lightVspDir[1]*camV + lightVspDir[2]*camN);
27 :    
28 :     real phongKa = 0.02;
29 :     real phongKd = 0.60;
30 :     real phongKs = 0.40;
31 :     real phongSp = 30.0;
32 :    
33 :     image(3)[] img = load ("../data/vox1-9.nrrd");
34 :     field#1(3)[] Fc1 = img ⊛ ctmr;
35 :     field#1(3)[] Fc0 = img ⊛ c1tent;
36 :    
37 :     strand RayCast (int ui, int vi)
38 :     {
39 :     real rayU = lerp(-camUmax, camUmax, -0.5, real(ui), real(imgResU)-0.5);
40 :     real rayV = lerp(-camVmax, camVmax, -0.5, real(vi), real(imgResV)-0.5);
41 :     vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist;
42 : jhr 1118 vec3 vv = normalize(-rayVec);
43 : jhr 1115
44 :     real rayN = camVspNear;
45 :     // ########## BEGIN per-ray initialization
46 :     real transp = 1.0;
47 :     real gray = 0.0;
48 :     int myui = ui;
49 :     int myvi = vi;
50 :     output vec4 rgba = [0.0, 0.0, 0.0, 0.0];
51 :     // ########## END per-ray initialization
52 :    
53 :     update
54 :     {
55 :     vec3 rayPos = camEye + rayN*rayVec;
56 :     if (inside (rayPos,Fc1)) {
57 :     // ########## BEGIN per-sample code
58 :     // HEY (BUG?): are fields allowed in conditional expressions?
59 :     // uncaught exception Fail [Fail: bogus field binding F027D = RHS(_t0277)]
60 :     // raised at high-il/high-opt.sml:74.18-76.11
61 :     field#1(3)[] F = Fc0 if (myui + myvi < imgResU) else Fc1;
62 :     real val = F@rayPos;
63 :     vec3 norm = normalize(-∇F@rayPos);
64 :     if (val > valOpacMin) { // we have some opacity
65 :     real opac = min(1.0, lerp(0.0, 1.0, valOpacMin, val, valOpacMax));
66 :     real ld = lightDir • norm;
67 : jhr 1118 real hd = norm • normalize(lightDir + vv);
68 : jhr 1115 real mat = ( phongKa
69 :     + phongKd*(ld if ld > 0.0 else 0.0)
70 :     + phongKs*(hd^phongSp if hd > 0.0 else 0.0));
71 :     gray = gray + transp*opac*mat;
72 :     transp = transp*(1.0 - opac);
73 :     }
74 :     // ########## END per-sample code
75 :     }
76 :     if (transp < 0.01) { // early ray termination
77 :     transp = 0.0;
78 :     // HEY (BUG) stabilize function not working
79 :     // setting rgba should be done there
80 :     rgba = [gray, gray, gray, 1.0-transp];
81 :     stabilize;
82 :     }
83 :     if (rayN > camVspFar) {
84 :     // HEY (BUG) (same as above)
85 :     rgba = [gray, gray, gray, 1.0-transp];
86 :     stabilize;
87 :     }
88 :     rayN = rayN + rayStep;
89 :     }
90 :    
91 :     stabilize {
92 :     // rgba = [gray, gray, gray, 1.0-transp];
93 :     }
94 :    
95 :     /* render: output maxval */
96 :     }
97 :    
98 :     initially [ RayCast(ui, vi) | vi in 0..(imgResV-1), ui in 0..(imgResU-1) ];

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