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

SCM Repository

[diderot] Annotation of /branches/pure-cfg/test/bug-lookup.diderot
ViewVC logotype

Annotation of /branches/pure-cfg/test/bug-lookup.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1066 - (view) (download)

1 : glk 1066 //
2 :     // HEY (BUG) compiling this gets:
3 :     /*
4 :     probeElem: d2/dxdz in 3D space
5 :     probeElem: d2/dxdy in 3D space
6 :     probeElem: d2/dx2 in 3D space
7 :    
8 :     *** BACK-TRACE ***
9 :     GOTO common/phase-timer.sml:74.9-80.7: PhaseTimer.withTimer[2]
10 :     (from: ???)
11 :     GOTO driver/main.sml:69.46-126.7: Main.doFile[2]
12 :     (from: driver/main.sml:69.27-126.8: Main.doFile[2])
13 :     CALL driver/main.sml:69.9-126.8: Main.doFile[2]
14 :     (from: common/phase-timer.sml:76.13-76.16: PhaseTimer.withTimer[2].y)
15 :    
16 :     c-target/tree-to-c.sml:42.22-42.63: Fail: lookup(_, l_rayVec_6)
17 :    
18 :     uncaught exception Fail [Fail: lookup(_, l_rayVec_6)]
19 :     raised at common/phase-timer.sml:76.50-76.52
20 :     raised at trace-debug-profile/back-trace.sml:207.12
21 :     raised at common/phase-timer.sml:76.50-76.52
22 :     raised at c-target/tree-to-c.sml:42.22-42.63
23 :     */
24 :    
25 :     field#2(3)[] F = load("../data/vfrhand-nohip.nhdr") ⊛ bspln3;
26 :    
27 :     // set camera, image, and rendering parameters
28 :     vec3 camEye = [127.331, -1322.05, 272.53];
29 :     vec3 camAt = [63.0, 82.6536, 98.0];
30 :     vec3 camUp = [0.9987, 0.0459166, -0.0221267];
31 :     real camNear = -78.0;
32 :     real camFar = 78.0;
33 :     real camFOV = 5.0;
34 :     int imgResU = 320;
35 :     int imgResV = 240;
36 :     real rayStep = 0.2;
37 :     real valOpacMin = 400.0; // 400.0 for skin, 1150.0 for bone
38 :     real valOpacMax = 700.0; // 700.0 for skin, 1450.0 for bone
39 :     vec3 lightVspDir = [0.9, -2.5, -1.5];
40 :     vec3 lightRGB = [1.0, 1.0, 1.0];
41 :     real cthick = 3.0;
42 :    
43 :     // (boilerplate) computation of camera and light info
44 :     real camDist = |camAt - camEye|;
45 :     real camVspNear = camNear + camDist;
46 :     real camVspFar = camFar + camDist;
47 :     vec3 camN = normalize(camAt - camEye);
48 :     vec3 camU = normalize(camN × camUp);
49 :     vec3 camV = camN × camU;
50 :     real camVmax = tan(camFOV*3.1415926536/360.0)*camDist;
51 :     real camUmax = camVmax*real(imgResU)/real(imgResV);
52 :     vec3 lightDir = normalize(lightVspDir[0]*camU +
53 :     lightVspDir[1]*camV +
54 :     lightVspDir[2]*camN);
55 :    
56 :    
57 :     strand RayCast (int ui, int vi) {
58 :     real rayU = lerp(-camUmax, camUmax, -0.5, real(ui), real(imgResU)-0.5);
59 :     real rayV = lerp(-camVmax, camVmax, -0.5, real(vi), real(imgResV)-0.5);
60 :     vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist;
61 :     vec3 vv = -normalize(rayVec);
62 :    
63 :     real rayN = camVspNear;
64 :     real rayTransp = 1.0;
65 :     vec3 rayRGB = [0.0, 0.0, 0.0];
66 :     output vec4 outRGBA = [0.0, 0.0, 0.0, 0.0];
67 :    
68 :     update {
69 :     vec3 pos = camEye + rayN*rayVec;
70 :     if (inside (pos,F)) {
71 :     // ########## BEGIN per-sample code
72 :     real val = F(pos);
73 :     if (val > valOpacMin) { // we have some opacity
74 :     vec3 grad = ∇F(pos);
75 :     vec3 norm = normalize(-grad);
76 :     real alpha = min(1.0, lerp(0.0, 1.0, valOpacMin, val, valOpacMax));
77 :     tensor[3,3] H = -∇(∇F)(pos);
78 :     tensor[3,3] P = identity[3] - norm⊗norm;
79 :     tensor[3,3] G = (P•H•P)/|grad|;
80 :     real disc = max(0.0, sqrt(2.0*|G|^2 - trace(G)^2));
81 :     real k1 = (trace(G) + disc)/2.0;
82 :     real k2 = (trace(G) - disc)/2.0;
83 :     real km = sqrt(k1^2 + k2^2);
84 :     rayRGB = [km, 0.0, 0.0];
85 :     rayTransp = rayTransp*(1.0 - alpha);
86 :     }
87 :     // ########## END per-sample code
88 :     }
89 :     if (rayTransp < 0.01) { // early ray termination
90 :     rayTransp = 0.0;
91 :     rayRGB = 0.6*rayRGB;
92 :     outRGBA = [rayRGB[0], rayRGB[1], rayRGB[2], 1.0-rayTransp]; /* FIXME */
93 :     stabilize;
94 :     }
95 :     if (rayN > camVspFar) {
96 :     rayRGB = 0.6*rayRGB;
97 :     outRGBA = [rayRGB[0], rayRGB[1], rayRGB[2], 1.0-rayTransp]; /* FIXME */
98 :     stabilize;
99 :     }
100 :     rayN = rayN + rayStep;
101 :     }
102 :    
103 :     /* render: output maxval */
104 :     }
105 :    
106 :     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