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

SCM Repository

[diderot] View of /branches/pure-cfg/test/bug-lookup.diderot
ViewVC logotype

View of /branches/pure-cfg/test/bug-lookup.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1068 - (download) (annotate)
Tue May 3 19:01:56 2011 UTC (8 years, 8 months ago) by glk
File size: 3451 byte(s)
slightly simpler
//
// HEY (BUG) compiling this gets:
/* 
...
probeElem: d2/dxdz in 3D space
probeElem: d2/dxdy in 3D space
probeElem: d2/dx2 in 3D space

*** BACK-TRACE ***
GOTO   common/phase-timer.sml:74.9-80.7: PhaseTimer.withTimer[2]
          (from: ???)
GOTO   driver/main.sml:69.46-126.7: Main.doFile[2]
          (from: driver/main.sml:69.27-126.8: Main.doFile[2])
CALL   driver/main.sml:69.9-126.8: Main.doFile[2]
          (from: common/phase-timer.sml:76.13-76.16: PhaseTimer.withTimer[2].y)

c-target/tree-to-c.sml:42.22-42.63: Fail: lookup(_, l_rayVec_6)

uncaught exception Fail [Fail: lookup(_, l_rayVec_6)]
  raised at common/phase-timer.sml:76.50-76.52
  raised at trace-debug-profile/back-trace.sml:207.12
  raised at common/phase-timer.sml:76.50-76.52
  raised at c-target/tree-to-c.sml:42.22-42.63
*/

field#2(3)[] F = load("../data/vfrhand-nohip.nhdr") ⊛ bspln3;

// 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 = 320;
int imgResV = 240;
real rayStep = 0.2;
real valOpacMin = 400.0;        // 400.0 for skin, 1150.0 for bone
real valOpacMax = 700.0;        // 700.0 for skin, 1450.0 for bone
vec3 lightVspDir = [0.9, -2.5, -1.5];
vec3 lightRGB = [1.0, 1.0, 1.0];
real cthick = 3.0;

// (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*3.1415926536/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);

    real rayN = camVspNear;
    real rayTransp = 1.0;
    output real out = 0.0;

    update {
       vec3 pos = camEye + rayN*rayVec;
       if (inside (pos,F)) {
          // ########## BEGIN per-sample code
          real val = F(pos);
          if (val > valOpacMin) {  // we have some opacity 
              vec3 grad = ∇F(pos); 
              vec3 norm = normalize(-grad);
              real alpha = min(1.0, lerp(0.0, 1.0, valOpacMin, val, valOpacMax));
              tensor[3,3] H = -∇(∇F)(pos);
              tensor[3,3] P = identity[3] - norm⊗norm;
              tensor[3,3] G = (P•H•P)/|grad|;
              real disc = max(0.0, sqrt(2.0*|G|^2 - trace(G)^2));
              real k1 = (trace(G) + disc)/2.0;
              real k2 = (trace(G) - disc)/2.0;
              real km = sqrt(k1^2 + k2^2);
              out = km;
              rayTransp = rayTransp*(1.0 - alpha);
          }
          // ##########  END  per-sample code
       }
       if (rayTransp < 0.01) {  // early ray termination
           stabilize;
       }
       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