SCM Repository
View of /branches/pure-cfg/test/vr-curv-quad.diderot
Parent Directory
|
Revision Log
Revision 1025 -
(download)
(annotate)
Sun May 1 15:48:57 2011 UTC (9 years, 8 months ago) by glk
File size: 4564 byte(s)
Sun May 1 15:48:57 2011 UTC (9 years, 8 months ago) by glk
File size: 4564 byte(s)
bug in field expressions
// vr-curv // // Demonstration of curvature-based transfer functions in volume rendering // // process output with: // unu reshape -i mip.txt -s 4 480 345 | overrgb -i - -b 0.1 0.15 0.2 -g 1.2 -o - | unu quantize -b 8 -min 0 -max 255 -o vr-curv.png //image(3)[] img = load("../data/quad-patches-pad.nrrd"); //field#2(3)[] F = img ⊛ bspln3; //image(2)[3] imgRGB = load("../data/hue.nhdr"); //field#0(2)[3] RGB = imgRGB ⊛ tent; // HEY (bug) : trying to do load and convolve in one line, twice, // to produce effect of four lines above, but get: // /usr/bin/gcc -std=gnu99 -m64 -c -DNDEBUG -g -O2 -Wformat -Wreturn-type -Wuninitialized -D_THREAD_SAFE -I/Users/gk/diderot/diderot/pure-cfg/src/include -I/Users/gk/diderot/teem/arch/darwin.64/include vr-curv-quad.c // vr-curv-quad.c:30: error: conflicting types for ‘G__t’ // vr-curv-quad.c:29: error: previous declaration of ‘G__t’ was here // vr-curv-quad.c: In function ‘Diderot_InitGlobals’: field#2(3)[] F = load("../data/quad-patches-pad.nrrd") ⊛ bspln3; field#0(2)[3] RGB = load("../data/hue.nhdr") ⊛ tent; // set camera, image, and rendering parameters vec3 camEye = [183.021, -411.857, 686.458]; vec3 camAt = [55.4037, 40.2407, 4.32732]; vec3 camUp = [0.0, 0.0, 1.0]; real camNear = -42.0; real camFar = 42.0; real camFOV = 7.15; int imgResU = 480; int imgResV = 345; real rayStep = 0.2; real valOpacMin = -0.25; real valOpacMax = -0.10; vec3 lightVspDir = [0.9, -2.5, -2.5]; vec3 lightRGB = [1.0, 1.0, 1.0]; real phongKa = 0.1; real phongKd = 0.7; real phongKs = 0.3; real phongSp = 45.0; // (boilerplate) computation of camera and light info 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*3.1415926536/360.0)*camDist; real camUmax = camVmax*real(imgResU)/real(imgResV); vec3 lightDir = normalize(lightVspDir[0]*camU + lightVspDir[1]*camV + lightVspDir[2]*camN); 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; real rayN = camVspNear; real rayTransp = 1.0; vec3 rayRGB = [0.0, 0.0, 0.0]; output vec4 outRGBA = [0.0, 0.0, 0.0, 0.0]; update { vec3 pos = camEye + rayN*rayVec; if (inside (pos,F)) { real val = F(pos); if (val > valOpacMin) { // we have some opacity vec3 grad = -∇F(pos); vec3 norm = normalize(grad); // begin curvature computation tensor[3,3] H = -∇(∇F)(pos); tensor[3,3] P = identity[3] - norm⊗norm; tensor[3,3] G = (P•H•P)/|grad|; real disc = max(0.0, sqrt(2.0*|G|^2 - trace(G)^2)); real k1 = (trace(G) + disc)/2.0; real k2 = (trace(G) - disc)/2.0; // finished curvature computation; begin finding sample RGBA k1 = max(-1.0, min(1.0, 4.2*k1)); k2 = max(-1.0, min(1.0, 4.2*k2)); vec3 matRGB = RGB([k1,k2]) if inside([k1,k2],RGB) else [1.0,0.0,1.0]; real alpha = min(1.0, lerp(0.0, 1.0, valOpacMin, val, valOpacMax)); real ld = max(0.0, norm • lightDir); real hd = max(0.0, norm • normalize(lightDir + normalize(camEye - pos))); // Phong shading vec3 pntRGB = (phongKa*matRGB + phongKd*ld*modulate(matRGB, lightRGB) + phongKs*hd^phongSp*lightRGB); // composite with existing ray color and transparency rayRGB = rayRGB + rayTransp*alpha*pntRGB; rayTransp = rayTransp*(1.0 - alpha); } } if (rayTransp < 0.01) { // early ray termination rayTransp = 0.0; outRGBA = [rayRGB[0], rayRGB[1], rayRGB[2], 1.0 - rayTransp]; stabilize; } if (rayN > camVspFar) { outRGBA = [rayRGB[0], rayRGB[1], rayRGB[2], 1.0 - rayTransp]; stabilize; } rayN = rayN + rayStep; } /* 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 |