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

SCM Repository

[diderot] View of /branches/pure-cfg/test/mip-cam.diderot
ViewVC logotype

View of /branches/pure-cfg/test/mip-cam.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 964 - (download) (annotate)
Mon Apr 25 15:01:00 2011 UTC (8 years, 5 months ago) by jhr
File size: 2166 byte(s)
  Fixed subtracting negative literal bug
// mip-cam
//
// initial demo of what could be boilerplate camera code, 
// for maximum intensity projection
// process output with:
//  unu reshape -i mip.txt -s 320 240 | unu quantize -b 8 -o mip-cam.png


//string dataFile = "../data/txs-pad3.nrrd";
//vec3 camEye = [25.0, 15.0, 10.0];
//vec3 camAt = [3.0, 3.0, 3.0];
//vec3 camUp = [0.0, 0.0, 1.0];
//real camNear = -5.0;
//real camFar = 5.0;
//real camFOV = 18.0;
//int imgResU = 320;
//int imgResV = 240;
//real rayStep = 0.1;

string dataFile = "../data/vfrhand-nohip.nhdr";
vec3 camEye = [127.331, -1322.05, 272.53];
vec3 camAt = [63.0, 82.6536, 101.999];
vec3 camUp = [0.9987, 0.0459166, -0.0221267];
real camNear = -78.0;
real camFar = 78.0;
real camFOV = 5.0;
int imgResU = 320;
int imgResV = 240;
real rayStep = 1.0;

// HEY (want) it would be nice if we could have initializing statements...
// (though motivation for this here has been resolved)
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*3.1415926536/360.0)*camDist;
real camUmax = camVmax*real(imgResU)/real(imgResV);

image(3)[] img = load (dataFile);
//field#2(3)[] F = img ⊛ bspln3;
field#0(3)[] F = img ⊛ tent;

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;
    // ########## BEGIN per-ray initialization
    output real maxval = 0.0; 
    // ##########  END  per-ray initialization

    update
    {
        vec3 rayPos = camEye + rayN*rayVec;
        if (inside (rayPos,F)) {
         // ########## BEGIN per-sample code
          maxval = max(maxval, F(rayPos));
         // ##########  END  per-sample code
	}
        if (rayN > camVspFar)
            stabilize;
        rayN = rayN + rayStep;
    }

    /* render: output maxval */
}

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