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

SCM Repository

[diderot] View of /trunk/rtest/tests/sum-ghp/sum-ghp.diderot
ViewVC logotype

View of /trunk/rtest/tests/sum-ghp/sum-ghp.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2636 - (download) (annotate)
Tue May 27 16:18:36 2014 UTC (5 years, 1 month ago) by jhr
File size: 1579 byte(s)
  Merging changes from vis12 branch (via staging).  The main change is the new
  syntax for inputs (especially image inputs).
/*! \file sum-ghp.diderot
 *
 * \author Gordon Kindlmann
 *
 * does summation of view-space components of Hessian • gradient
 */

/*
 * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu)
 * All rights reserved.
 */

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.06; // HEY: this is large only because program is slow

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#2(3)[] F = bspln3 ⊛ 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 vec3 sum = [0.0,0.0,0.0];

    update {
        vec3 rayPos = camEye + rayN*rayVec;
        if (inside (rayPos,F)) {
          vec3 prod = ∇⊗∇F(rayPos) • ∇F(rayPos);
          sum = sum + [prod•camU, prod•camV, prod•camN];
	}
        if (rayN > camVspFar) 
            stabilize;
        rayN = rayN + rayStep;
    }
}

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