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

SCM Repository

[diderot] Annotation of /trunk/rtest/tests/sum-grad/sum-grad.diderot
ViewVC logotype

Annotation of /trunk/rtest/tests/sum-grad/sum-grad.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1194 - (view) (download)

1 : glk 1189
2 : glk 1194 // sum-grad:
3 :     //
4 :     // does summation of view-space components gradient
5 :    
6 : glk 1189 vec3 camEye = [6.65584, 13.2759, 8.55225];
7 :     vec3 camAt = [0.0, 0.0, 0.0];
8 :     vec3 camUp = [0.0, 0.0, 1.0];
9 :     real camNear = -1.0;
10 :     real camFar = 1.0;
11 :     real camFOV = 6.0;
12 :     int imgResU = 320;
13 :     int imgResV = 240;
14 : glk 1193 real rayStep = 0.03;
15 : glk 1189
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*π/360.0)*camDist;
23 :     real camUmax = camVmax*real(imgResU)/real(imgResV);
24 :    
25 :     field#1(3)[] F = ctmr ⊛ load("../../data/ring.nrrd");
26 :    
27 :     strand RayCast (int ui, int vi) {
28 :     real rayU = lerp(-camUmax, camUmax, -0.5, real(ui), real(imgResU)-0.5);
29 :     real rayV = lerp(-camVmax, camVmax, -0.5, real(vi), real(imgResV)-0.5);
30 :     vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist;
31 :    
32 :     real rayN = camVspNear;
33 :     output vec3 sum = [0.0,0.0,0.0];
34 :    
35 :     update {
36 :     vec3 rayPos = camEye + rayN*rayVec;
37 :     if (inside (rayPos,F)) {
38 :     vec3 grad = ∇F(rayPos);
39 :     // we're summing the view-space components of the gradient
40 :     sum = sum + [grad•camU, grad•camV, grad•camN];
41 :     }
42 :     if (rayN > camVspFar)
43 :     stabilize;
44 :     rayN = rayN + rayStep;
45 :     }
46 :     }
47 :    
48 :     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