- Home /
Rendering a Mandelbrot fractal - how do I find a middle ground between performance and precision?
So right now I am rendering a Mandelbrot fractal on the GPU with a surface shader, but since it's GPU-executed, I can only use floats to describe the fractal. Is there any methodology/workaround to allow me for more precise results (namely higher zoom values) without reducing the FPS to 1?
Answer by Bunny83 · Nov 07, 2021 at 09:33 PM
Not really, no. Shaders are optimised for 32 bit floats and most GPUs don't have support for doubles. Even doubles have their limits and just extends the possible zoom level a bit more (in essence double the zoom level). We had already a question about that some years ago.
To get infinite zoom you would need to use an infinite precision floating point type. Maybe it's possible to off-load certain operations to the GPU with compute shaders. Though it would get quite complicated quickly. Maybe you find a library which handles this part for you.
This is a parallel renderer I've made some years ago. It only runs on the CPU and performs one iteration per frame, but on every pixel. Of course this requires a bit more memory since you have to store the current complex number for every pixel as well as the current iteration count. Though I think it's a neat approach ^^. The renderer actually uses a List of active "pixels" and removes them once they settled on a color.
Thank you very much! That's essentially what I was looking for - I wanted to see if offloading this entire thingto CPU would even be worth it. Technically you're right, a compute shader could help speed it all up, but then what could it actually do if there's literally one single distinct operation that needs to be done and that operation would require a double precision number. I will look into the parallel renderer you linked tomorrow isnce it's getting really late ;) Thank you!
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to automate unity editor screen grabs 0 Answers
Trouble with Procedural Mesh Normals (normals are inverted) 1 Answer
Trouble with Inaccurate Mesh Collider 0 Answers