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

SCM Repository

[diderot] Annotation of /branches/vis12/test/mandel.diderot
ViewVC logotype

Annotation of /branches/vis12/test/mandel.diderot

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1894 - (view) (download)

1 : glk 1894 // ../bin/diderotc --exec mandel.diderot && ./mandel && unu quantize -b 8 -i rgb.nrrd -o mandel.png
2 : glk 1893
3 :     // Global definitions
4 :     input int reso = 800;
5 :     input int maxiter = 1000;
6 :    
7 :     // Strand definition
8 : glk 1894 strand mandel(int crIdx, int ciIdx) {
9 : glk 1893 vec2 c = [lerp(-2.0, 2.0, 1.0, real(crIdx), real(reso)),
10 :     lerp(-2.0, 2.0, 1.0, real(ciIdx), real(reso))];
11 :     vec2 z = [0.0, 0.0];
12 :     int iter = 0;
13 :     output vec3 rgb = [0.0, 0.0, 0.0];
14 :     update {
15 :     z = [z[0]^2 - z[1]^2, 2.0*z[0]*z[1]] + c; // z = z^2 + c
16 :     iter += 1;
17 :     if (z•z > 4.0) {
18 :     // point has escaped; set color based on iteration
19 :     real t = 11.0*real(iter)^0.2;
20 :     rgb = [sin(t), sin(t + 2.0*π/3.0), sin(t - 2.0*π/3.0)];
21 :     rgb = ([1.2, 1.2, 1.2] + rgb)/2.0;
22 :     stabilize;
23 :     }
24 :     if (iter > maxiter) {
25 :     rgb = [0.0, 0.0, 0.0];
26 :     stabilize;
27 :     }
28 :     }
29 :     }
30 :    
31 :     // Strand initialization
32 : glk 1894 initially [ mandel(crIdx, ciIdx) | ciIdx in 1..reso, crIdx in 1..reso ];

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