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

SCM Repository

[diderot] View of /branches/vis15/src/tests/rtest/tests/mip/mip.diderot
ViewVC logotype

View of /branches/vis15/src/tests/rtest/tests/mip/mip.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4497 - (download) (annotate)
Sat Sep 3 14:12:36 2016 UTC (2 years, 8 months ago) by jhr
File size: 1884 byte(s)
  working on merge: updating tests with new version 2 syntax
/*! \file mip.diderot
 *
 * \author Gordon Kindlmann
 */

/*
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * All rights reserved.
 */


// mip:
//
// does maximum intensity projection

vec3 camEye = [6.65584, 13.2759, 8.55225];
vec3 camAt = [0, 0, 0];
vec3 camUp = [0, 0, 1];
real camNear = -1.0;
real camFar = 1.0;
real camFOV = 6.0;
int imgResU = 320;
int imgResV = 240;
real rayStep = 0.01;

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);

field#0(3)[] F = tent ⊛ image("../../data/ring.nrrd");

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;

    real rayN = camVspNear;
    output real out = -0.6;

    update {
        vec3 rayPos = camEye + rayN*rayVec;
        if (inside (rayPos,F)) {
          out = max(out, F(rayPos));
	}
        if (rayN > camVspFar) {
if ((ui == 80) && (vi == 60)) {
vec3 v = camDist*camN + rayU*camU + rayV*camV;
print("camU = ", camU, ", camV = ", camV, "\n");
print("rayU = ", rayU, ", rayV = ", rayV, "\n");
print("v = ", v, "\n");
print("rayVec = ", rayVec, "\n");
print("camDist = ", camDist, "\n");
print("camVmax = ", camVmax, "\n");
print("camUmax = ", camUmax, "\n");
}
            stabilize;
	}
        rayN += rayStep;
    }
}

//create_array { RayCast(ui, vi) | vi in 0..(imgResV-1), ui in 0..(imgResU-1) }
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