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

SCM Repository

[diderot] Annotation of /examples/curve-lic/rcast.diderot
ViewVC logotype

Annotation of /examples/curve-lic/rcast.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2869 - (view) (download)

1 : jhr 2865 /*! \file rcast.diderot
2 :     *
3 :     * \author John Reppy
4 :     *
5 :     * This Diderot program implements a raycast to find the isosurface in a 3D image.
6 :     */
7 :    
8 :     /*
9 :     * COPYRIGHT (c) 2015 The Diderot Project (http://diderot-language.cs.uchicago.edu)
10 :     * All rights reserved.
11 :     */
12 :    
13 :     // the 3D image that we are working with
14 :     field#2(3)[] F = bspln3 ⊛ image("../data/vfrhand-nohip-smooth.nrrd");
15 :    
16 :     // set camera, image, and rendering parameters
17 :     vec3 camEye = [127.331, -1322.05, 272.53];
18 :     vec3 camAt = [63.0, 82.6536, 98.0];
19 :     vec3 camUp = [0.9987, 0.0459166, -0.0221267];
20 :     real camNear = -78.0;
21 :     real camFar = 78.0;
22 :     real camFOV = 5.0;
23 :     int imgResU = 640;
24 :     int imgResV = 480;
25 :     real rayStep = 0.15;
26 :    
27 :     // (boilerplate) computation of camera and light info
28 :     real camDist = |camAt - camEye|;
29 :     real camVspNear = camNear + camDist;
30 :     real camVspFar = camFar + camDist;
31 :     vec3 camN = normalize(camAt - camEye);
32 :     vec3 camU = normalize(camN × camUp);
33 :     vec3 camV = camN × camU;
34 :     real camVmax = tan(camFOV*π/360.0)*camDist;
35 :     real camUmax = camVmax*real(imgResU)/real(imgResV);
36 :     vec3 lightDir = normalize(lightVspDir[0]*camU +
37 :     lightVspDir[1]*camV +
38 :     lightVspDir[2]*camN);
39 :    
40 :     strand RayCast (int ui, int vi) {
41 :     real rayU = lerp(-camUmax, camUmax, -0.5, real(ui), real(imgResU)-0.5);
42 :     real rayV = lerp(-camVmax, camVmax, -0.5, real(vi), real(imgResV)-0.5);
43 :     vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist;
44 :     vec3 vv = -normalize(rayVec);
45 :    
46 : jhr 2866 output real rayN = camVspNear;
47 : jhr 2865
48 :     update {
49 :     vec3 pos = camEye + rayN*rayVec;
50 :     if (inside (pos,F)) {
51 :     real val = F(pos);
52 :     if (|val - isoval| < threshold) {
53 :     if (vv • ∇F(pos) > 0) {
54 :     // isosurface facing the viewer
55 :     }
56 :     }
57 :     }
58 : jhr 2869 else {
59 :     rayN = nan;
60 :     stabilize;
61 :     }
62 : jhr 2865 }
63 :    
64 :     }

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