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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2872 - (download) (annotate)
Thu Feb 26 15:35:28 2015 UTC (4 years, 3 months ago) by jhr
File size: 1750 byte(s)
  working on curve-lic code
/*! \file rcast.diderot
 *
 * \author John Reppy
 *
 * This Diderot program implements a raycast to find the isosurface in a 3D image.
 */

/*
 * COPYRIGHT (c) 2015 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * 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