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

SCM Repository

[diderot] View of /branches/staging/test/vr-lite.diderot
ViewVC logotype

View of /branches/staging/test/vr-lite.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1934 - (download) (annotate)
Fri Jun 29 20:02:12 2012 UTC (7 years, 1 month ago) by jhr
File size: 1811 byte(s)
  merging changes from vis12 branch
// vr-lite.diderot
//
// simple diffuse-only volume rendering with head-light, with an
// opacity function that varies linearly between two values
//

input real stepSz = 0.1;	// size of steps
input vec3 eye;			// location of eye point
input vec3 orig;		// location of pixel (0,0)
input vec3 cVec;		// vector between pixels horizontally
input vec3 rVec;		// vector between pixels vertically
input real valOpacMin;          // highest value with opacity 0.0
input real valOpacMax;          // lowest value with opacity 1.0 
// valOpacMin,Max pairs for sample datasets:
// txs.nrrd 0.15, 0.35
// vfrhand-nohip.nhdr, for skin: 200, 500
// vfrhand-nohip.nhdr, for bone: 1330, 1630

input image(3)[] img = image("../data/vfrhand-nohip.nhdr");

field#2(3)[] F = img ⊛ bspln3;

strand RayCast (int row, int col)
{
    vec3 pos = orig + real(row)*rVec + real(col)*cVec;
    vec3 dir = normalize(pos - eye);
    real t = 0.0;
    real transp = 1.0;
    real gray = 0.0;
    output vec4	rgba = [0.0, 0.0, 0.0, 0.0];

    update
    {
        pos = pos + stepSz*dir;
        if (inside (pos,F)) {
            real val = F(pos);
            vec3 norm = -normalize(∇F(pos));
            if (val > valOpacMin) {  // we have some opacity 
                real opac = min(1.0, lerp(0.0, 1.0, valOpacMin, val, valOpacMax));
                gray = gray + transp*opac*max(0.0, -dir • norm);
                transp = transp*(1.0 - opac);
            }
        }
        if (transp < 0.01) {  // early ray termination
            transp = 0.0;
            stabilize;
        }
        if (t > 40.0) {
            stabilize;
        }
        t = t + stepSz;
    }

     stabilize {
        rgba = [gray, gray, gray, 1.0-transp];
     }

    /* render: output rgba */
}

initially [ RayCast(r, c) | r in 0..199, c in 0..199 ];

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0