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

SCM Repository

[diderot] View of /tests/glk-tests/new/lic2d.diderot
ViewVC logotype

View of /tests/glk-tests/new/lic2d.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4640 - (download) (annotate)
Tue Sep 27 20:54:47 2016 UTC (2 years, 9 months ago) by glk
File size: 1369 byte(s)
initial result of svn export --username anonsvn --password=anonsvn https://svn.smlnj-gforge.cs.uchicago.edu/svn/diderot/branches/vis15/src/tests/
#version 2

/*
$DDRO_HOME/branches/vis12/bin/diderotc --exec lic2d.diderot \
$DDRO_HOME/branches/charisee/bin/diderotc lic2d.diderot \
 && ./lic2d \
 && unu project -i rgb.nrrd -a 1 -m mean \
     | unu quantize -b 8 -min 0.2% -max 0.2% -o _lic2d.png \
 && unu resample -i _lic2d.png -s = /1.5 /1.5 -o lic2d.png \
 && xv lic2d.png

*/

int sizeX = 1020*2;
int sizeY = 561*2;
real h0 = 0.003;   // step size of integration
int stepNum = 80;  // steps taken up or downstream
real stdv = sqrt(1.0/stepNum);

field#1(2)[2] V = bspln3 ⊛ load_image("flow.nrrd");
field#1(2)[2] nV = normalize(V);
field#0(2)[] R = tent ⊛ load_image("rand.nrrd");
field#0(1)[3] cmap = tent ⊛ load_image("cmap.nrrd");
strand LIC(vec2 x0, real sign) {
  real h = sign*h0;
  vec2 x = x0;
  int step = 0;
  real sum = R(x0)/2;
  output vec3 rgb = [0,0,0];
  update {
    x += h*nV(x + 0.5*h*nV(x)); // Midpoint method
    if (step == stepNum || !inside(x, R))
      stabilize;
    sum += R(x);
    step += 1;
  }
  stabilize {
    sum *= sqrt(|V(x0)|)/stepNum;
    real gray = lerp(0, 1, -stdv, sum, stdv);
    rgb = cmap(∇×V(x0)) * clamp(0, 1, gray);
  }
}
create_array { LIC([lerp(0, 6.78, -0.5, xi, sizeX-0.5),
                 lerp(0, 3.72, -0.5, yi, sizeY-0.5)],
                 lerp(-1, 1, 0, si, 1))
            | yi in 0..(sizeY-1), xi in 0..(sizeX-1),
              si in 0..1 }

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