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 3291 - (view) (download)

1 : jhr 1938 /*! \file mandel.diderot
2 :     *
3 :     * \author Gordon Kindlmann
4 :     */
5 : glk 1904
6 : jhr 1938 /*
7 : jhr 3291 * This code is part of the Diderot Project (http://diderot-language.cs.uchicago.edu)
8 :     *
9 :     * COPYRIGHT (c) 2015 The University of Chicago
10 : jhr 1938 * All rights reserved.
11 :     */
12 : glk 1904
13 : glk 1894 // ../bin/diderotc --exec mandel.diderot && ./mandel && unu quantize -b 8 -i rgb.nrrd -o mandel.png
14 : glk 1893
15 :     // Global definitions
16 : glk 1904 input int reso = 2000;
17 : jhr 1971 input real escape = 4;
18 : glk 1904 input int maxiter = 2000;
19 :     input vec2 center = [-1.2, -0.3]; // [0.0,0.0] for whole thing
20 : glk 1948 input real fov = 0.16; // 2.0 for whole thing
21 : glk 1893
22 : jhr 2143 function real coord (real x, int idx) = lerp(x - fov, x + fov, 1, idx, reso);
23 :    
24 : glk 1893 // Strand definition
25 : jhr 1971 strand mandel (vec2 c) {
26 :     vec2 z = [0, 0];
27 : glk 1893 int iter = 0;
28 : jhr 1971 output vec3 rgb = [0, 0, 0];
29 : glk 1893 update {
30 :     z = [z[0]^2 - z[1]^2, 2.0*z[0]*z[1]] + c; // z = z^2 + c
31 :     iter += 1;
32 : glk 1948 if (|z| > escape) {
33 :     // point has escaped; set continuous color from iter and radius
34 : glk 1972 real t = 4*log(iter - log2(log(|z|)/log(escape)));
35 : glk 1948 rgb = [sin(-t), cos(t), sin(t)];
36 :     rgb = ([1.8, 1.8, 1.8] + rgb)/2.8;
37 : glk 1893 stabilize;
38 :     }
39 :     if (iter > maxiter) {
40 : jhr 1971 rgb = [0, 0, 0];
41 : glk 1893 stabilize;
42 :     }
43 :     }
44 :     }
45 :    
46 :     // Strand initialization
47 : jhr 2143 initially [ mandel([coord(center[0], crIdx), coord(center[1], ciIdx)])
48 : glk 1897 | ciIdx in 1..reso, crIdx in 1..reso ];

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