Logo by reallybigname - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Check out the originating "3d Mandelbulb" thread here
 
*
Welcome, Guest. Please login or register. November 30, 2025, 12:46:44 PM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1]   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Bubble Tea  (Read 556 times)
Description: Julia set of a rational function coloured with distance estimate and atom domain
0 Members and 1 Guest are viewing this topic.
claude
Fractal Bachius
*
Posts: 563



WWW
« on: November 20, 2016, 07:46:49 AM »



Code:
// Created: Sun Nov 20 06:09:53 2016
#include "Progressive2D.frag"
#include "Complex.frag"
#info Rational Mandelbrot or Julia with Distance Estimation and Atom Domains
#group Mandelbrot
uniform int  Iterations; slider[10,200,5000]
uniform bool Julia; checkbox[false]
uniform float JuliaX; slider[-10,0,10]
uniform float JuliaY; slider[-10,0,10]

// dual complex numbers for automatic differentiation
vec4 mul(vec4 a, vec4 b) {
  return vec4(cMul(a.xy, b.xy), cMul(a.xy, b.zw) + cMul(a.zw, b.xy));
}
vec4 div(vec4 a, vec4 b) {
  return vec4(cDiv(a.xy, b.xy), cDiv(cMul(a.zw, b.xy) - cMul(a.xy, b.zw), cMul(b.xy, b.xy)));
}

// from http://gamedev.stackexchange.com/a/59808
vec3 hsv2rgb(vec3 c) {
  vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
  vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
  return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}

vec3 color(vec2 p) {
  // critical point
/*
  vec2 z0 = vec2(0.0);
*/
  vec2 z0 = vec2(pow(0.009/2.0, 1.0/3.0), 0.0);

  // initialisation
  vec4 c = Julia ? vec4(JuliaX, JuliaY, 0.0, 0.0) : vec4(p, dFdx(p));
  vec4 z = Julia ? vec4(p, dFdx(p)) : vec4(z0, 1.0, 0.0);
  int i = 0;
  int j = 0;
  float minl = 1.0 / 0.0;

  // main loop
  for (i = 0; i < Iterations; i++) {
    // iteration formula
/*
    z = mul(z, z) + c;
*/
    z = mul(z, z) + div(vec4(0.009, 0.0, 0.0, 0.0), z) + c;

    // atom domains
    float l = dot(z.xy,z.xy);
    if (l < minl) {
      j = i;
      minl = l;
    }

    // bailout
    if (l > 1.0e10) break;
  }
  if (i == Iterations) return vec3(0.0, 0.0, 0.0);

  // distance estimator shading with atomain colour
  float r = length(z.xy);
  float dr = length(z.zw);
  float de = 2.0 * r * log2(r) / dr;
  return vec3(tanh(clamp(de, 0.0, 4.0))) * hsv2rgb(vec3(float(j) * 0.05, 0.5, 1.0));
}


#preset Default
Gamma = 2.08335
Brightness = 1
Contrast = 1
Saturation = 1
Center = 0.00018,-0.1439975
Zoom = 132
ToneMapping = 1
Exposure = 1
AARange = 2
AAExp = 1
GaussianAA = true
Iterations = 5000
JuliaX = -1.059908
JuliaY = -0.0460829
Julia = true
#endpreset

Inspired by https://en.wikibooks.org/wiki/Pictures_of_Julia_and_Mandelbrot_Sets/Computer_programs

* 2016-11-20_bubble_tea.frag (2 KB - downloaded 46 times.)

* 2016-11-20_bubble_tea_small.jpg (229.79 KB, 640x480 - viewed 89 times.)
Logged
Pages: [1]   Go Down
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Bubble of chaos 2d Art DarkBeam 0 1954 Last post April 10, 2011, 04:47:11 PM
by DarkBeam
Bubble ice Mandelbulb3D Gallery bib 0 2018 Last post August 19, 2011, 01:22:14 AM
by bib
Bubble pit Mandelbulb3D Gallery bib 0 2402 Last post August 28, 2011, 11:41:04 AM
by bib
Bubble Structure Images Showcase (Rate My Fractal) element90 0 991 Last post September 07, 2011, 11:59:08 AM
by element90
Bubble Universes Mandelbulb3D Gallery Fractured Fractals 0 852 Last post October 31, 2011, 04:47:46 PM
by Fractured Fractals

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.242 seconds with 24 queries. (Pretty URLs adds 0.009s, 2q)