SCM Repository
View of /branches/staging/rtest/tests/vr-taxi/vr-taxi.diderot
Parent Directory
|
Revision Log
Revision 1977 -
(download)
(annotate)
Mon Jul 16 20:04:34 2012 UTC (9 years, 10 months ago) by jhr
File size: 2984 byte(s)
Mon Jul 16 20:04:34 2012 UTC (9 years, 10 months ago) by jhr
File size: 2984 byte(s)
merged in changes from vis12 branch, including ": operator support and implicit coercions.
/*! \file vr-taxi.diderot * * \author Gordon Kindlmann * * volume renders test axis dataset */ /* * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu) * All rights reserved. */ vec3 camEye = [35.1699, 30.3308, 18.77]; vec3 camAt = [5.26698, 4.74983, 4.66349]; vec3 camUp = [0, 0, 1]; real camNear = -2.0; real camFar = 4.0; real camFOV = 9.5; int imgResU = 320; int imgResV = 240; real rayStep = 0.1; real valOpacMin = 0.2; real valOpacMax = 0.5; vec3 backRGB = [0.8, 0.9, 1.0]; 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)*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); vec3 lightRGB = [1.0, 0.9, 0.8]; real phongKa = 0.05; real phongKd = 0.65; real phongKs = 0.45; real phongSp = 50.0; field#1(3)[] F = ctmr ⊛ image("../../data/taxi.nrrd"); 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; vec3 rayRGB = [0, 0, 0]; output vec3 out = [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)); // contrived assignment of RGB from XYZ, only sensible vec3 matRGB = [lerp(0.2, 1.0, 1.0, rayPos[0], 8.0)^0.8, lerp(0.2, 1.0, 1.0, rayPos[1], 8.0)^0.8, lerp(0.2, 1.0, 1.0, rayPos[2], 8.0)^0.8]; vec3 pntRGB = (phongKa*matRGB + phongKd*ld*modulate(matRGB, lightRGB) + phongKs*hd^phongSp*lightRGB); rayRGB = rayRGB + rayTransp*alpha*pntRGB; rayTransp = rayTransp*(1 - alpha); } } if (rayTransp < 0.001) { // early ray termination out = rayRGB; stabilize; } if (rayN > camVspFar) { out = lerp(rayRGB, backRGB, rayTransp); stabilize; } rayN = rayN + rayStep; } } 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 |