News for hackers. Stuff that matters.
Re:The quest to decode the Mandelbrot set by QuadmasterXLII on Saturday January 27, 2024 @07:28AM (#39154978)
If you want to keep zooming in the browser and have snappy gpu accelerated performance while basically never hitting “reached limit of numerical precision,” check out https://mandeljs.hgreer.com . The math to make this possible gets pretty funky: I go over the tricks I used at https://www.hgreer.com/JavascriptMandelbrot/
Re:The quest to decode the Mandelbrot set by sapiogram on Saturday January 27, 2024 @01:42PM (#39158457)
No scrolling with the scroll wheel though :(
Re:The quest to decode the Mandelbrot set by QuadmasterXLII on Saturday January 27, 2024 @01:52PM (#39158559)
The whole thing is a tower of spaghetti bit hacks in the name of depth and speed. Embarassingly, it actually can't actually render zoom levels that aren't powers of two and I'm not sure how to change that.
Re:The quest to decode the Mandelbrot set by LoganDark on Saturday January 27, 2024 @07:17PM (#39161220)
Can you make it so that the position you clicked stays at the same position after each zoom, rather than centering it on your cursor? That way you can click multiple times to zoom in on the same point.
Re:The quest to decode the Mandelbrot set by tda on Sunday January 28, 2024 @02:00AM (#39163188)
Thanks for creating this, I had some fun exploring the set. What does the scale parameter stand for?
Re:The quest to decode the Mandelbrot set by QuadmasterXLII on Sunday January 28, 2024 @05:53AM (#39164409)
The color of each pixel is

    fragColor = vec4(vec3(cos(c), cos(1.1214 * c) , cos(.8 * c)) / 2. + .5, 1.);
Where c is the number of iterations divided by the scale.
Re:The quest to decode the Mandelbrot set by tweetle_beetle on Sunday January 28, 2024 @03:08PM (#39169332)
That really is very fast!

(I don't know if this is a known compromise of your technique (I couldn't find it mentioned), but I occassionally get a ring of varying thickness centred in the render with an inverted coluring to the rest of the pixels, or sometimes a solid colour. It varies is size and comes and goes without an obvious correlation to zoom level.)

Re:The quest to decode the Mandelbrot set by QuadmasterXLII on Sunday January 28, 2024 @05:08PM (#39170300)
Yeah, I've been chasing that for a while. I've traced it to subnormal float handling. Here's the scenario: if you multiply the 32 bit float float 1 x 2^-127 by 1/8, you can't get 1x2^-130 because 130 isn't representable in a 8 bit exponent. On the CPU or a modern GPU, this is special cased to result in a "subnormal" float: .125 x 2^-127. However, this adds a ton of extra complexitity to the FPU. Old GPUs just gave up and say "It's zero." WebGL standardized on the old GPU behavior, so a modern GPU running webgl sets a flag to behave like the old GPUs.

I'm representing complex numbers as (real_mantissa + i * imag_mantissa) * 2^exp where real_mantissa and imag_mantissa are themselves 32 bit floats, and I can reduce the frequency of the colored rings in my shader by keeping the mantissas around ~1000 instead of ~1 (and reducing the exponent to keep the value the same) so that they are less likely to go subnormal, but I can't seem to get rid of the colored rings entirely.

I don't actually know the pathway through the code from subnormal underflow -> colored rings, but if you run a CUDA renderer with the same algorithm, the rings appear when you set the flag for "round subnormal floats to zero."

Re:The quest to decode the Mandelbrot set by rini17 on Monday January 29, 2024 @07:29AM (#39175485)
Wow nice! Though I seem to get artifacts both in Brave and Firefox on Android: https://imgur.com/a/vo2ZVOQ

https://mandeljs.hgreer.com/?;re=-0.751165720536567020384363...