SCM Repository
[diderot] / trunk / test / vr-kcomp.diderot |
View of /trunk/test/vr-kcomp.diderot
Parent Directory
|
Revision Log
Revision 1118 -
(download)
(annotate)
Thu May 5 04:57:49 2011 UTC (9 years, 9 months ago) by jhr
File size: 3257 byte(s)
Thu May 5 04:57:49 2011 UTC (9 years, 9 months ago) by jhr
File size: 3257 byte(s)
One more update from pure-cfg
// process output with: // unu reshape -i mip.txt -s 4 200 200 | overrgb -i - -b 0.1 0.15 0.2 -o - | unu quantize -b 8 -min 0 -max 255 -o vr-kcomp.png vec3 camEye = [25.0, 10.0, 8.0]; vec3 camAt = [0.0, 0.0, 0.0]; vec3 camUp = [0.0, 0.0, 1.0]; real camNear = -1.0; real camFar = 1.0; real camFOV = 4.5; int imgResU = 200; int imgResV = 200; real rayStep = 0.01; real valOpacMin = 0.08; // highest value with opacity 0.0 real valOpacMax = 0.09; // lowest value with opacity 1.0 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); vec3 lightVspDir = [-1.0, -1.0, -3.5]; vec3 lightDir = normalize(lightVspDir[0]*camU + lightVspDir[1]*camV + lightVspDir[2]*camN); real phongKa = 0.02; real phongKd = 0.60; real phongKs = 0.40; real phongSp = 30.0; image(3)[] img = load ("../data/vox1-9.nrrd"); field#1(3)[] Fc1 = img ⊛ ctmr; field#1(3)[] Fc0 = img ⊛ c1tent; 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; vec3 vv = normalize(-rayVec); real rayN = camVspNear; // ########## BEGIN per-ray initialization real transp = 1.0; real gray = 0.0; output vec4 rgba = [0.0, 0.0, 0.0, 0.0]; // ########## END per-ray initialization update { vec3 rayPos = camEye + rayN*rayVec; if (inside (rayPos,Fc1)) { // ########## BEGIN per-sample code real val = 0.0; vec3 norm = [0.0,0.0,0.0]; if (ui + vi < imgResU) { val = Fc0@rayPos; norm = normalize(-∇Fc0@rayPos); } else { val = Fc1@rayPos; norm = normalize(-∇Fc1@rayPos); } if (val > valOpacMin) { // we have some opacity real opac = min(1.0, lerp(0.0, 1.0, valOpacMin, val, valOpacMax)); real ld = lightDir • norm; real hd = norm • normalize(lightDir + vv); real mat = ( phongKa + phongKd*(ld if ld > 0.0 else 0.0) + phongKs*(hd^phongSp if hd > 0.0 else 0.0)); gray = gray + transp*opac*mat; transp = transp*(1.0 - opac); } // ########## END per-sample code } if (transp < 0.01) { // early ray termination transp = 0.0; // HEY (BUG) stabilize function not working // setting rgba should be done there rgba = [gray, gray, gray, 1.0-transp]; stabilize; } if (rayN > camVspFar) { // HEY (BUG) (same as above) rgba = [gray, gray, gray, 1.0-transp]; stabilize; } rayN = rayN + rayStep; } stabilize { // rgba = [gray, gray, gray, 1.0-transp]; } /* render: output maxval */ } initially [ 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 |