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

SCM Repository

[diderot] Diff of /branches/fem/test/mandel.diderot
ViewVC logotype

Diff of /branches/fem/test/mandel.diderot

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

revision 1970, Sun Jul 15 14:20:23 2012 UTC revision 1971, Sun Jul 15 16:24:43 2012 UTC
# Line 12  Line 12 
12    
13  // Global definitions  // Global definitions
14  input int reso = 2000;  input int reso = 2000;
15  input real escape = 4.0;  input real escape = 4;
16  input int maxiter = 2000;  input int maxiter = 2000;
17  input vec2 center = [-1.2, -0.3]; // [0.0,0.0] for whole thing  input vec2 center = [-1.2, -0.3]; // [0.0,0.0] for whole thing
18  input real fov = 0.16; // 2.0 for whole thing  input real fov = 0.16; // 2.0 for whole thing
19    
20  // Strand definition  // Strand definition
21  strand mandel(vec2 c) {  strand mandel(vec2 c) {
22     vec2 z = [0.0, 0.0];     vec2 z = [0, 0];
23     int iter = 0;     int iter = 0;
24     output vec3 rgb = [0.0, 0.0, 0.0];     output vec3 rgb = [0, 0, 0];
25     update  {     update  {
26        z = [z[0]^2 - z[1]^2, 2.0*z[0]*z[1]] + c; // z = z^2 + c        z = [z[0]^2 - z[1]^2, 2.0*z[0]*z[1]] + c; // z = z^2 + c
27        iter += 1;        iter += 1;
28        if (|z| > escape) {        if (|z| > escape) {
29           // point has escaped; set continuous color from iter and radius           // point has escaped; set continuous color from iter and radius
30           real t = 4.0*log(real(iter) - log2(log(|z|)/log(escape)));           real t = 4*log(real(iter) - log2(log(|z|)/log(escape)));
31           rgb = [sin(-t), cos(t), sin(t)];           rgb = [sin(-t), cos(t), sin(t)];
32           rgb = ([1.8, 1.8, 1.8] + rgb)/2.8;           rgb = ([1.8, 1.8, 1.8] + rgb)/2.8;
33           stabilize;           stabilize;
34        }        }
35        if (iter > maxiter) {        if (iter > maxiter) {
36           rgb = [0.0, 0.0, 0.0];           rgb = [0, 0, 0];
37           stabilize;           stabilize;
38        }        }
39     }     }
40  }  }
41    
42  // Strand initialization  // Strand initialization
43  initially [ mandel([lerp(center[0]-fov, center[0]+fov,  initially [ mandel([lerp(center[0]-fov, center[0]+fov, 1, crIdx, reso),
44                           1.0, real(crIdx), real(reso)),                      lerp(center[1]-fov, center[1]+fov, 1, ciIdx, reso)])
                     lerp(center[1]-fov, center[1]+fov,  
                          1.0, real(ciIdx), real(reso))])  
45              | ciIdx in 1..reso, crIdx in 1..reso ];              | ciIdx in 1..reso, crIdx in 1..reso ];

Legend:
Removed from v.1970  
changed lines
  Added in v.1971

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