SCM Repository
View of /benchmarks/programs/illust-vr/bmark-diderot.diderot
Parent Directory
|
Revision Log
Revision 3052 -
(download)
(annotate)
Thu Mar 12 13:50:38 2015 UTC (7 years, 2 months ago) by jhr
File size: 4011 byte(s)
Thu Mar 12 13:50:38 2015 UTC (7 years, 2 months ago) by jhr
File size: 4011 byte(s)
update benchmarks for new image syntax and library-oriented build model
// illust-vr // // Demonstration of "illustrative volume rendering" // // process output with: // unu reshape -i illust-vr.txt -s 4 640 480 | overrgb -i - -b 0.1 0.15 0.2 -g 1.2 -o - | unu quantize -b 8 -min 0 -max 255 -o illust-vr.png //field#2(3)[] F = bspln3 ⊛ image("../data/vfrhand-nohip.nhdr"); field#2(3)[] F = bspln3 ⊛ image("../../data/vfrhand-nohip-smooth.nrrd"); field#0(1)[] silho = tent ⊛ image("../../data/txf/silho.nrrd"); field#0(1)[] shade = tent ⊛ image("../../data/txf/shade.nrrd"); field#0(2)[] rival = tent ⊛ image("../../data/txf/ridgvall.nrrd"); field#0(2)[] alpha = tent ⊛ image("../../data/txf/alpha-bone.nrrd"); // image("../data/txf/alpha-skin.nrrd"); field#0(1)[3] depth = tent ⊛ image("../../data/txf/depth.nrrd"); // set camera, image, and rendering parameters vec3 camEye = [127.331, -1322.05, 272.53]; vec3 camAt = [63.0, 82.6536, 98.0]; vec3 camUp = [0.9987, 0.0459166, -0.0221267]; real camNear = -78.0; real camFar = 78.0; real camFOV = 5.0; int imgResU = 640; int imgResV = 480; real rayStep = 0.15; /* int imgResU = 480; int imgResV = 360; real rayStep = 1.0; */ vec3 lightVspDir = [-2.0, -3.0, -2.0]; real sthick = 0.4; real refStep = 1.5; // (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*π/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; vec3 vv = -normalize(rayVec); 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); vec3 grad = -∇F(pos); real gmag = |grad|; real aa = alpha([max(0.0, min(2000.0, val)), max(0.0, min(900.0, gmag))]); if (aa > 0.0) { // we have some opacity vec3 norm = grad/gmag; aa = 1.0 - pow(1.0-aa, rayStep/refStep); real gray = 1.0; gray *= shade(norm • lightDir); tensor[3,3] Proj = identity[3]; tensor[3,3] Gten = identity[3]; tensor[3,3] Hess = ∇⊗∇F(pos); Proj = identity[3] - norm⊗norm; Gten = -(Proj•Hess•Proj)/gmag; real kv = max(0.0, min(1.0/sthick, (vv•Gten•vv)/(vv•Proj•vv))); real vdn = vv•norm; vdn = vdn*(1.0 + 2.0*vdn*vdn); // limit silhouette on front-facing surfaces gray *= silho(max(0.0, min(2.0, vdn^2 + (sthick*(kv - 1.0/sthick))^2))); real disc = max(0.0, sqrt(2.0*|Gten|^2 - trace(Gten)^2)); real k1 = (trace(Gten) + disc)/2.0; real k2 = (trace(Gten) - disc)/2.0; gray *= rival([min(0.55, |Gten|)/0.55, atan2(k2,k1)]); vec3 matRGB = depth(lerp(0.0, 1.0, camVspNear, rayN, camVspFar)); rayRGB = rayRGB + rayTransp*aa*gray*matRGB; rayTransp = rayTransp*(1.0 - aa); } } if (rayTransp < 0.01) { // early ray termination rayTransp = 0.0; stabilize; } if (rayN > camVspFar) { stabilize; } rayN = rayN + rayStep; } stabilize { rayRGB = 0.9*rayRGB; outRGBA = [rayRGB[0], rayRGB[1], rayRGB[2], 1.0-rayTransp]; } } 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 |