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

SCM Repository

[diderot] View of /tests/vis12-bugs/src/bug033.diderot
ViewVC logotype

View of /tests/vis12-bugs/src/bug033.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4640 - (download) (annotate)
Tue Sep 27 20:54:47 2016 UTC (2 years, 10 months ago) by glk
File size: 1931 byte(s)
initial result of svn export --username anonsvn --password=anonsvn https://svn.smlnj-gforge.cs.uchicago.edu/svn/diderot/branches/vis15/src/tests/
/*

BUG: bogus warning messages about unused variables.
Running "diderotc --exec bug033.diderot" generates:

[bug033.diderot:12.1-65.0] Warning: global variable 'FF1' declared at [bug033.diderot:13.1-14.0]  is unused
[bug033.diderot:12.1-65.0] Warning: strand output variable 'rgb' declared at [bug033.diderot:37.1-63.0]  is unused

*/

// volume dataset
field#0(3)[] FF0 = tent ⊛ image("../data/tinyvol-0.nrrd");
field#0(3)[] FF1 = tent ⊛ image("../data/tinyvol-1.nrrd");

// set camera and image parameters
vec3 camEye = [2563.99, 1974.37, -20373.6];
vec3 camAt = [2563.99, 1974.37, 491.554];
vec3 camUp = [0.0, -1.0, 0.0];
real camNear = -700.0;
real camFar = 700.0;
real camFOV = 5.38;
int imgResU = 100;
int imgResV = 100;
real rayStep = 0.2;

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

// RayCast(ui,vi) computes rendered color for pixel (ui,vi)
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;
    real mip0 = 0.0;
    real mip1 = 0.0;
    output vec3 rgb=[0,0,0];

    update {
       vec3 pos = camEye + rayN*rayVec;
       if (inside (pos,FF0)) {
          mip0 = max(mip0, FF0(pos));
          mip1 = max(mip1, FF1(pos));
       }
       if (rayN > camVspFar) {
          stabilize;
       }
       rayN = rayN + rayStep;
    }

    stabilize {
       rgb=[mip1, 0.7*mip0, 0.5*mip1];
    }
}

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