mightymandel v16

GPU-based Mandelbrot set explorer

fpxx_escaped_geom.glsl
Go to the documentation of this file.
1 // mightymandel -- GPU-based Mandelbrot Set explorer
2 // Copyright (C) 2012,2013,2014,2015 Claude Heiland-Allen
3 // License GPL3+ http://www.gnu.org/licenses/gpl.html
4 
5 layout(points) in;
6 layout(points, max_vertices = 1) out;
7 uniform double loger2;
8 uniform double pxs;
9 uniform dvec2 center;
10 uniform double radius;
11 uniform double aspect;
12 in dvec4 cne1[1];
13 #ifdef DE
14 in dvec4 zdz1[1];
15 #else
16 in dvec2 zdz1[1];
17 #endif
18 in double err1[1];
19 flat out vec4 ida1;
20 void main() {
21  bool escaped = ! (cne1[0].w <= 0.0);
22  if (escaped) {
23  double z2 = cmag2(zdz1[0].xy);
24  float logz2 = log(float(z2));
25  float i = float(1.0 + cne1[0].z - clamp(double(log2(float(logz2 / loger2))), 0.00001, 0.99999));
26 #ifdef DE
27  double dz2 = cmag2(zdz1[0].zw);
28  float d = float(logz2 * sqrt(z2 / dz2) * pxs);
29 #else
30  float d = 0.0;
31 #endif
32  float e = float(err1[0]);
33  ida1 = vec4(i, e, d, 0.0);
34  dvec2 pos = (cne1[0].xy - center) / radius * dvec2(aspect, 1.0);
35  gl_Position = vec4(pos, 0.0, 1.0);
36  EmitVertex();
37  EndPrimitive();
38  }
39 }