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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3349 - (view) (download)

1 : jhr 2636 /*! \file sum-ghp.diderot
2 :     *
3 :     * \author Gordon Kindlmann
4 :     *
5 :     * does summation of view-space components of Hessian • gradient
6 :     */
7 : glk 1192
8 : jhr 2636 /*
9 : jhr 3349 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
10 :     *
11 :     * COPYRIGHT (c) 2015 The University of Chicago
12 : jhr 2636 * All rights reserved.
13 :     */
14 : glk 1194
15 : glk 1192 vec3 camEye = [6.65584, 13.2759, 8.55225];
16 : jhr 2636 vec3 camAt = [0, 0, 0];
17 :     vec3 camUp = [0, 0, 1];
18 : glk 1192 real camNear = -1.0;
19 :     real camFar = 1.0;
20 :     real camFOV = 6.0;
21 :     int imgResU = 320;
22 :     int imgResV = 240;
23 : glk 1193 real rayStep = 0.06; // HEY: this is large only because program is slow
24 : glk 1192
25 :     real camDist = |camAt - camEye|;
26 :     real camVspNear = camNear + camDist;
27 :     real camVspFar = camFar + camDist;
28 :     vec3 camN = normalize(camAt - camEye);
29 :     vec3 camU = normalize(camN × camUp);
30 :     vec3 camV = camN × camU;
31 :     real camVmax = tan(camFOV*π/360.0)*camDist;
32 :     real camUmax = camVmax*real(imgResU)/real(imgResV);
33 :    
34 : jhr 2636 field#2(3)[] F = bspln3 ⊛ image("../../data/ring.nrrd");
35 : glk 1192
36 :     strand RayCast (int ui, int vi) {
37 :     real rayU = lerp(-camUmax, camUmax, -0.5, real(ui), real(imgResU)-0.5);
38 :     real rayV = lerp(-camVmax, camVmax, -0.5, real(vi), real(imgResV)-0.5);
39 :     vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist;
40 :    
41 :     real rayN = camVspNear;
42 :     output vec3 sum = [0.0,0.0,0.0];
43 :    
44 :     update {
45 :     vec3 rayPos = camEye + rayN*rayVec;
46 :     if (inside (rayPos,F)) {
47 : jhr 1383 vec3 prod = ∇⊗∇F(rayPos) • ∇F(rayPos);
48 : glk 1192 sum = sum + [prod•camU, prod•camV, prod•camN];
49 :     }
50 :     if (rayN > camVspFar)
51 :     stabilize;
52 :     rayN = rayN + rayStep;
53 :     }
54 :     }
55 :    
56 :     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