SCM Repository
View of /examples/curve-lic/rcast.diderot
Parent Directory
|
Revision Log
Revision 3349 -
(download)
(annotate)
Tue Oct 27 15:16:36 2015 UTC (6 years, 8 months ago) by jhr
File size: 1803 byte(s)
Tue Oct 27 15:16:36 2015 UTC (6 years, 8 months ago) by jhr
File size: 1803 byte(s)
making copyrights consistent for all code in the repository
/*! \file rcast.diderot * * \author John Reppy * * This Diderot program implements a raycast to find the isosurface in a 3D image. */ /* * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu) * * COPYRIGHT (c) 2015 The University of Chicago * All rights reserved. */ // the 3D image that we are working with field#2(3)[] F = bspln3 ⊛ image("data/vfrhand-nohip-smooth.nrrd"); // set camera, image, and rendering parameters vec3 camEye = [127.331, -1322.05, 272.53]; vec3 camAt = [63.0, 82.6536, 98.0]; vec3 camUp = [0.9987, 0.0459166, -0.0221267]; real camNear = -78.0; real camFar = 78.0; real camFOV = 5.0; int imgResU = 640; int imgResV = 480; real rayStep = 0.15; // (boilerplate) computation of camera and light info real camDist = |camAt - camEye|; real camVspNear = camNear + camDist; real camVspFar = camFar + camDist; vec3 camN = normalize(camAt - camEye); vec3 camU = normalize(camN × camUp); vec3 camV = camN × camU; real camVmax = tan(camFOV*π/360.0)*camDist; real camUmax = camVmax*real(imgResU)/real(imgResV); vec3 lightDir = normalize(lightVspDir[0]*camU + lightVspDir[1]*camV + lightVspDir[2]*camN); strand RayCast (int ui, int vi) { real rayU = lerp(-camUmax, camUmax, -0.5, real(ui), real(imgResU)-0.5); real rayV = lerp(-camVmax, camVmax, -0.5, real(vi), real(imgResV)-0.5); vec3 rayVec = (camDist*camN + rayU*camU + rayV*camV)/camDist; vec3 vv = -normalize(rayVec); output real rayN = camVspNear; update { vec3 pos = camEye + rayN*rayVec; if (inside (pos,F)) { real val = F(pos); if (|val - isoval| < threshold) { if (vv • ∇F(pos) > 0) { // isosurface facing the viewer } } } else { rayN = nan; stabilize; } } }
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |