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/sum-ghp/sum-ghp.diderot
ViewVC logotype

View of /branches/vis15/src/tests/rtest/tests/sum-ghp/sum-ghp.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: 1651 byte(s)
  working on merge: updating tests with new version 2 syntax
#version 2.0
/*! \file sum-ghp.diderot
 *
 * \author Gordon Kindlmann
 *
 * does summation of view-space components of Hessian • gradient
 */

/*
 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
 *
 * COPYRIGHT (c) 2015 The University of Chicago
 * 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 ⊛ load_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 out = [0.0,0.0,0.0];

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

create_array { 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