mightymandel v16

GPU-based Mandelbrot set explorer

fp64_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 flat out vec3 ida1;
19 #ifdef DE
20 flat out dvec4 zdz;
21 #else
22 flat out dvec2 zdz;
23 #endif
24 void main() {
25  bool escaped = ! (cne1[0].w <= 0.0);
26  if (escaped) {
27  double z2 = cmag2(zdz1[0].xy);
28  double logz2 = double(log(float(z2)));
29  float i = float(1.0 + cne1[0].z - clamp(double(log2(float(logz2 / loger2))), 0.00001, 0.99999));
30 #ifdef DE
31  double dz2 = cmag2(zdz1[0].zw);
32  float d = float(logz2 * sqrt(z2 / dz2) * pxs);
33 #else
34  float d = 0.0;
35 #endif
36  ida1 = vec3(i, 0.0, d);
37  gl_Position = vec4(vec2((cne1[0].xy - center) / radius * dvec2(aspect, 1.0)), 0.0, 1.0);
38  EmitVertex();
39  EndPrimitive();
40  }
41 }