SCM Repository
[diderot] / trunk / test / vr-lite.diderot |
View of /trunk/test/vr-lite.diderot
Parent Directory
|
Revision Log
Revision 309 -
(download)
(annotate)
Tue Aug 17 18:35:35 2010 UTC (11 years, 10 months ago) by glk
File size: 2077 byte(s)
Tue Aug 17 18:35:35 2010 UTC (11 years, 10 months ago) by glk
File size: 2077 byte(s)
initial pass at volume rendering lite
// vr-lite.diderot // // simple diffuse-only volume rendering with head-light, with an // opacity function that varies linearly between two values // input string dataFile; // name of dataset 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 image(3)[] img = load (dataFile); //field#1(3)[] F = convolve (bspln3, img); field#2(3)[] F = img ⊛ bspln3; 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; 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 grad = (∇ F)@pos; vec3 norm = -grad/|grad|; if (val > valOpacMin) { // we have some opacity real opac = 0.0; // dummy initialization if (val > valOpacMax) { opac = 1.0; } else { opac = (val - valOpacMin)/(valOpacMax - valOpacMin); } gray = gray + transp*opac*max(0, dot(-dir,norm)); transp = transp*(1.0 - opac); } } if (transp < 0.01) { // early ray termination transp = 0.0; rgba[0] = gray; rgba[1] = gray; rgba[2] = gray; rgba[3] = 1.0-transp; stabilize; } if (t > 40.0) { // do we have a stabilize() code block? rgba[0] = gray; rgba[1] = gray; rgba[2] = gray; rgba[3] = 1.0-transp; stabilize; } t = t + stepSz; } /* 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 |