SCM Repository
[diderot] / branches / charisee_dev / examples / moe / moe-vr-can2.diderot |
View of /branches/charisee_dev/examples/moe/moe-vr-can2.diderot
Parent Directory
|
Revision Log
Revision 3281 -
(download)
(annotate)
Tue Oct 13 17:05:21 2015 UTC (6 years, 7 months ago) by cchiw
File size: 2545 byte(s)
Tue Oct 13 17:05:21 2015 UTC (6 years, 7 months ago) by cchiw
File size: 2545 byte(s)
added by hand ex
// set camera, image, and rendering parameters input vec3 camEye = [-194.602, -4.82922, 910.873]; input vec3 camAt = [-2.36389, 93.121, 661.166]; input vec3 camUp = [0.0745335, -0.946525, -0.313904]; input real camNearAtRel = -50; input real camFarAtRel = 20; input real camFOV = 15.5; input int iresU = 410; input int iresV = 450; input real refStep = 1; input real rayStep = 0.06; input vec3 lightVsp = [-2, -3, -4]; input real phongKa = 0.3; input real phongKd = 0.7; input real thickness = 0.3; field#4(3)[] V = bspln5 ⊛ image("moe-iso-b3i5-small.nrrd"); field#2(3)[] S = ∇V/|∇V| • ∇⊗∇(|∇V|) • ∇V/|∇V|; field#2(3)[] F = -∇(|∇V|) • ∇V/|∇V|; input real smax = -10; function real alpha(real v, real g) = clamp(0, 1, 1.3*(1 - |v|/(g*thickness))); field#0(1)[3] cmap = tent ⊛ image("moe-isobow.nrrd"); function vec3 color(vec3 x) = cmap(clamp(-1200,3300,V(x))); function real mask(vec3 x) = 1.0 if (S(x) < smax) else 0.0; // NOTISO // (boilerplate) computation of camera and light info real camDist = |camAt - camEye|; real camNear = camNearAtRel + camDist; real camFar = camFarAtRel + camDist; vec3 camN = normalize(camAt - camEye); // away vec3 camU = normalize(camN × camUp); // right vec3 camV = camU × camN; // up real camVmax = tan(camFOV*π/360)*camDist; real camUmax = camVmax*iresU/iresV; vec3 light = transpose([camU,camV,camN])•normalize(lightVsp); strand raycast(int ui, int vi) { real rayU = lerp(-camUmax, camUmax, -0.5, ui, iresU-0.5); real rayV = lerp(camVmax, -camVmax, -0.5, vi, iresV-0.5); real rayN = camNear; vec3 rayVec = camN + (rayU*camU + rayV*camV)/camDist; real transp = 1; vec3 rgb = [0,0,0]; output vec4 rgba = [0,0,0,0]; update { vec3 x = camEye + rayN*rayVec; if (inside(x,V)) { real val = F(x); vec3 grad = -∇F(x); real a = alpha(val, |grad|)*mask(x); if (a > 0) { // we have some opacity a = 1 - pow(1-a, rayStep*|rayVec|/refStep); real depth = lerp(1.1, 0.7, camNear, rayN, camFar); real shade = max(0, normalize(grad)•light); rgb += transp*a*depth*(phongKa + phongKd*shade)*color(x); transp *= 1 - a; } } if (transp < 0.01) { // early ray termination transp = 0; stabilize; } if (rayN > camFar) { stabilize; } rayN = rayN + rayStep; } stabilize { real a = 1-transp; if (a > 0) rgba = [rgb[0]/a, rgb[1]/a, rgb[2]/a, a]; } } initially [ raycast(ui, vi) | vi in 0..iresV-1, ui in 0..iresU-1 ];
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |