Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/pure-cfg/test/vr-curv-quad.diderot
ViewVC logotype

Diff of /branches/pure-cfg/test/vr-curv-quad.diderot

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 913, Thu Apr 21 18:54:26 2011 UTC revision 1082, Wed May 4 08:12:24 2011 UTC
# Line 3  Line 3 
3  // Demonstration of curvature-based transfer functions in volume rendering  // Demonstration of curvature-based transfer functions in volume rendering
4  //  //
5  // process output with:  // process output with:
6  // 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  // 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-quad.png
7    
8  image(3)[] img = load("../data/quad-patches-pad.nrrd");  field#2(3)[] F = bspln3 ⊛ load("../data/quad-patches-pad.nrrd");
9  field#2(3)[] F = img ⊛ bspln3;  field#0(2)[3] RGB = tent ⊛ load("../data/txf/2d-bow.nrrd");
 image(2)[3] imgRGB = load("../data/hue.nhdr");  
 field#0(2)[3] RGB = imgRGB ⊛ tent;  
10    
11  // set camera, image, and rendering parameters  // set camera, image, and rendering parameters
12  vec3 camEye = [183.021, -411.857, 686.458];  vec3 camEye = [183.021, -411.857, 686.458];
# Line 56  Line 54 
54         vec3 pos = camEye + rayN*rayVec;         vec3 pos = camEye + rayN*rayVec;
55         if (inside (pos,F)) {         if (inside (pos,F)) {
56            real val = F(pos);            real val = F(pos);
57              if (val > valOpacMin) {  // we have some opacity
58            vec3 grad = -∇F(pos);            vec3 grad = -∇F(pos);
59            vec3 norm = normalize(grad);            vec3 norm = normalize(grad);
           if (val > valOpacMin) {  // we have some opacity  
60                // begin curvature computation                // begin curvature computation
61                tensor[3,3] H = -∇(∇F)(pos);                tensor[3,3] H = ∇(∇F)(pos);
62                tensor[3,3] P = identity[3] - norm⊗norm;                // HEY (BUG) replace with: identity[3] - norm⊗norm
63                tensor[3,3] G = (P•H•P)/|grad|;                // when 3x3 matrix subtraction is working
64                  tensor[3,3] P = identity[3] + (-1.0*norm⊗norm);
65                  tensor[3,3] G = -(P•H•P)/|grad|;
66                real disc = max(0.0, sqrt(2.0*|G|^2 - trace(G)^2));                real disc = max(0.0, sqrt(2.0*|G|^2 - trace(G)^2));
67                real k1 = (trace(G) + disc)/2.0;                real k1 = (trace(G) + disc)/2.0;
68                real k2 = (trace(G) - disc)/2.0;                real k2 = (trace(G) - disc)/2.0;
69                // finished curvature computation; begin finding sample RGBA                // finished curvature computation; begin finding sample RGBA
70                k1 = max(-1.0, min(1.0, 4.2*k1));                k1 = max(-1.0, min(1.0, 5.0*k1));
71                k2 = max(-1.0, min(1.0, 4.2*k2));                k2 = max(-1.0, min(1.0, 5.0*k2));
72                vec3 matRGB = RGB([k1,k2]) if inside([k1,k2],RGB)                vec3 matRGB = RGB([k1,k2]);
                             else [1.0,0.0,1.0];  
73                real alpha = min(1.0, lerp(0.0, 1.0,                real alpha = min(1.0, lerp(0.0, 1.0,
74                                           valOpacMin, val, valOpacMax));                                           valOpacMin, val, valOpacMax));
75                real ld = max(0.0, norm • lightDir);                real ld = max(0.0, norm • lightDir);

Legend:
Removed from v.913  
changed lines
  Added in v.1082

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0