SCM Repository
Annotation of /benchmarks/programs/mandelbrot/bmark-diderot.diderot
Parent Directory
|
Revision Log
Revision 1908 - (view) (download)
1 : | jhr | 1908 | // bmark-diderot.diderot |
2 : | // | ||
3 : | // COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu) | ||
4 : | // All rights reserved. | ||
5 : | // | ||
6 : | // compute Mandelbrot set image | ||
7 : | // | ||
8 : | |||
9 : | // unu quantize -b 8 -i rgb.nrrd -o mandel.png | ||
10 : | |||
11 : | // Global definitions | ||
12 : | int reso = 2000; | ||
13 : | int maxiter = 2000; | ||
14 : | vec2 center = [-1.2, -0.3]; // [0.0,0.0] for whole thing | ||
15 : | real fov = 0.15; // 2.0 for whole thing | ||
16 : | |||
17 : | // Strand definition | ||
18 : | strand mandel (vec2 c) { | ||
19 : | vec2 z = [0.0, 0.0]; | ||
20 : | int iter = 0; | ||
21 : | output vec3 rgb = [0.0, 0.0, 0.0]; | ||
22 : | update { | ||
23 : | z = [z[0]^2 - z[1]^2, 2.0*z[0]*z[1]] + c; // z = z^2 + c | ||
24 : | iter += 1; | ||
25 : | if (z•z > 4.0) { | ||
26 : | // point has escaped; set color based on iteration | ||
27 : | real t = 11.0*real(iter)^0.2; | ||
28 : | rgb = [sin(t), sin(t + 2.0*π/3.0), sin(t - 2.0*π/3.0)]; | ||
29 : | rgb = ([1.7, 1.7, 1.7] + rgb)/2.7; | ||
30 : | stabilize; | ||
31 : | } | ||
32 : | else if (iter > maxiter) | ||
33 : | stabilize; | ||
34 : | } | ||
35 : | } | ||
36 : | |||
37 : | // Strand initialization | ||
38 : | initially [ mandel([lerp(center[0]-fov, center[0]+fov, 1.0, real(crIdx), real(reso)), | ||
39 : | lerp(center[1]-fov, center[1]+fov, 1.0, real(ciIdx), real(reso))]) | ||
40 : | | ciIdx in 1..reso, crIdx in 1..reso ]; |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |