SCM Repository
[diderot] / trunk / test / vr-phong.diderot |
View of /trunk/test/vr-phong.diderot
Parent Directory
|
Revision Log
Revision 128 -
(download)
(annotate)
Thu Jul 1 17:55:29 2010 UTC (9 years, 5 months ago) by jhr
File size: 1711 byte(s)
Thu Jul 1 17:55:29 2010 UTC (9 years, 5 months ago) by jhr
File size: 1711 byte(s)
Removed type comments, since that information has been collected
// vr.diderot // // volume rendering example in Diderot // input string dataFile; // name of dataset 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; image(3)[] img = load (dataFile); //field#1(3)[] F = convolve (bspln3, img); field#2(3)[] F = convolve (bspln3, img); field#0(1)[4] txf = convolve (tent, load("txf-rgba.nrrd")); actor RayCast (int row, int col) { vec3 pos = orig + real(row)*rVec + real(col)*cVec; vec3 dir = (pos - eye)/|pos - eye|; real t = 0.0; vec3 rayRGB = [0.0, 0.0, 0.0]; real rayTransp = 1.0; update { if (inside (pos,F)) { real val = F@pos; vec3 grad = (D F)@pos; vec3 norm = grad/|grad|; vec3 halfDir = (lightDir - dir)/|lightDir - dir|; vec4 matRGBA = txf@[val]; vec3 matRGB = [matRGBA[0],matRGBA[1],matRGBA[2]]; real ldotn = dot(lightDir, norm); real hdotn = dot(halfDir, norm); vec3 pntRGB = (ka + kd*ldotn)*modulate(matRGB,lightRGB) + ks*pow(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 |