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

SCM Repository

[diderot] View of /branches/vis12-cl/test/vr-phong.diderot
ViewVC logotype

View of /branches/vis12-cl/test/vr-phong.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1116 - (download) (annotate)
Thu May 5 04:49:02 2011 UTC (8 years, 2 months ago) by jhr
Original Path: trunk/test/vr-phong.diderot
File size: 1732 byte(s)
  more merging of pure-cfg changes back into trunk
// vr-phong.diderot
//
// volume rendering example in Diderot
//

//input string dataFile;		// name of dataset
//input string txfFile;		// name of transfer-function file
string dataFile = "../data/txs.nrrd";
string txfFile = "../data/dummy-txf-rgba.nrrd";
input real stepSz;		// size of steps
input vec3 lightDir;
input vec3 lightRGB;
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 ka;
input real kd;
input real ks;
input real sh;

field#2(3)[] F = bspln3 (*) load(dataFile);
field#0(1)[4] txf = tent ⊛ load(txfFile);

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

    update
    {
        if (inside (pos,F)) {
           real val = F@pos;
           vec3 norm = normalize(-∇F@pos);
           vec3 halfDir = normalize(lightDir - dir);
           vec4 matRGBA = txf@val;
           vec3 matRGB = [matRGBA[0],matRGBA[1],matRGBA[2]];
           real ldotn = lightDir • norm;
           real hdotn = halfDir • norm;
           vec3 pntRGB = (ka + kd*ldotn)*modulate(matRGB,lightRGB) + ks*hdotn^sh*lightRGB;
           rayRGB = rayRGB + rayTransp*matRGBA[3]*pntRGB;
           rayTransp = rayTransp*(1.0 - matRGBA[3]);
        }
	if (t > 1.0 || rayTransp < 0.01) // a little odd; ray terminates at length=1
	    stabilize;
	pos = pos + stepSz*dir;
        t = t + stepSz;
    }

}

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

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