cantucci icon indicating copy to clipboard operation
cantucci copied to clipboard

Use optimized, non-trigonometric version as mandelbulb DE

Open LukasKalbertodt opened this issue 8 years ago • 2 comments

There is a version of the mandelbulb DE that doesn't use trigonometric functions, such as sin or atan, which should boost performance a bit. The formulas can be found here:

Mirrored images (as the original was sorta down):

low_power high_power

TODO:

  • [ ] Power 1
  • [ ] Power 2
  • [ ] Power 3
  • [ ] Power 4
  • [ ] Power 5
  • [ ] Power 6
  • [ ] Power 7
  • [X] Power 8
  • [ ] Maybe power -1
  • [ ] Maybe power -2

Before we implement all those powers, we should wait for the DSL to be finished. We don't want to implement this in both, Rust and GLSL...

LukasKalbertodt avatar Feb 22 '17 11:02 LukasKalbertodt

I quickly tested this in https://github.com/LukasKalbertodt/cantucci/commit/f56fc9794a22454dc75c4463577a053e1f792ef3 and https://github.com/LukasKalbertodt/cantucci/commit/97fcef60648ecec558faa1390c5ed2bd59a81520 : the optimized version was a lot slower :open_mouth:

LukasKalbertodt avatar Feb 28 '17 14:02 LukasKalbertodt

~~I hand optimized the non-trig version by replacing all powf() calls with repeated multiplication in #30 (luckily the only powers we raise to are 2, 4, 6 and 8). Turns out it's a lot faster to do x * x * x * x than x.powf(4.0) (if I remember correctly, around factor 100). However, LLVM does not perform this optimization (only for a power of 2). I am not sure why, but the x * x * ... * x version probably looses more precision in the process than with powf().~~

~~Anyway, as you can read in #30, the new version is around twice as fast as the general trigonometric version. I don't think there are many possible improvements left, this code should be pretty optimal (I'd love to be proven wrong, though!).~~

This was just stupid. Of course there is powi() which is a lot faster for variable powers and is optimized perfectly for constant powers.

LukasKalbertodt avatar Mar 02 '17 17:03 LukasKalbertodt