SCM Repository
View of /benchmarks/programs/vr-lite-cam/bmark-diderot.diderot
Parent Directory
|
Revision Log
Revision 1604 -
(download)
(annotate)
Thu Nov 3 21:01:37 2011 UTC (10 years, 7 months ago) by glk
File size: 2811 byte(s)
Thu Nov 3 21:01:37 2011 UTC (10 years, 7 months ago) by glk
File size: 2811 byte(s)
removing code from other test
// bmark-diderot.diderot // // COPYRIGHT (c) 2011 The Diderot Project (http://diderot-language.cs.uchicago.edu) // All rights reserved. // // simple volume renderer, now with a single directional light, // Phong shading, and the new camera. // string dataFile = "../../data/vfrhand-nohip.nhdr"; 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 = 480; int imgResV = 345; real rayStep = 0.1; real valOpacMin = 400.0; // 400.0 for skin, 1150.0 for bone real valOpacMax = 700.0; // 700.0 for skin, 1450.0 for bone real camDist = |camAt - camEye|; real camVspNear = camDist + camNear; real camVspFar = camDist + camFar; 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 = [0.9, -1.0, -2.5]; vec3 lightDir = normalize(lightVspDir[0]*camU + lightVspDir[1]*camV + lightVspDir[2]*camN); real phongKa = 0.05; real phongKd = 0.80; real phongKs = 0.20; real phongSp = 50.0; field#2(3)[] F = bspln3 ⊛ load(dataFile); 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 toEye = normalize(-rayVec); real rayN = camVspNear; real rayTransp = 1.0; real rayGrey = 0.0; output vec4 outRGBA = [0.0, 0.0, 0.0, 0.0]; update { vec3 rayPos = camEye + rayN*rayVec; if (inside (rayPos,F)) { real val = F(rayPos); if (val > valOpacMin) { // we have some opacity vec3 grad = ∇F(rayPos); // (here as easy target for optimization) vec3 norm = normalize(-∇F(rayPos)); 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 + toEye)); real pnt = phongKa + phongKd * ld + phongKs * hd^phongSp; rayGrey += rayTransp*alpha*pnt; rayTransp = rayTransp*(1.0 - alpha); } } if (rayTransp < 0.01) { // early ray termination rayTransp = 0.0; stabilize; } if (rayN > camVspFar) { stabilize; } rayN += rayStep; } stabilize { outRGBA = [rayGrey, rayGrey, rayGrey, 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 |