Title: Small trick for Ultra Fractal formulas/colourings Post by: David Makin on March 31, 2009, 01:46:03 AM Hi,
Ever wanted to pass more than just the z value from a formula to a colouring in Ultra Fractal ? Well here's a way to do it - it's not perfect as it's a bit restrictive, is a noticeable overhead if used too much and degrades the accuracy of the z value concerned when used and requires that both the formula and colouring concerned understand what's going on *but* when needs must.... This is what I've used for passing a bailout type from a formula to a colouring - (integer) range 0 to 200 (max. possible range as implimented below 0 to 255) - I used it to pass the bailout type as part of the initial z value (I wanted the colouring to know the bailout type before iterating because the colouring has separate options for divergent/convergent/periodic and knowing the bailout type first avoids calculating for all possibilities). Formula:- ; store the bailout type in #z float m = abs(real(#z))/512.0 ; scale by 512 if m<1e-200 ; make sure it's not zero (so that the log works) m = 1e-200 endif m = m + (bailout+256)*2.0^(ceil(log(m)/log(2.0))) ; add 256 to value if real(#z)<0.0 m = -m endif #z = m + flip(imag(#z)) Colouring:- ; recover the bailout type and original value of #z float m = abs(real(#z)) int n = 2.0^ceil(log(m)/log(2.0)-9) ; -9 as 512 is 2^9 int k = floor(m/n) m = 512.0*(m - n*k) ; scale by 512 bailout = k - 256 ; remove the 256 if real(#z)<0.0 m = -m endif #z = m + flip(imag(#z)) Obviously you could do a similar thing to pass a different value as part of imag(z) - or reduce the loss of accuracy in the z value by splitting your extra value between real(z) and imag(z). Note that the above allows passing a value from 0 to 255 which requires 256 adding to the value which means adjusting the real(z) value by 512 i.e. 2^9 hence the values used above. For a range from 0 to (2^n)-1 you need to add 2^n to your value and scale by 2^(n+1). Obviously it is possible to do it for reals instead of integers, you'd just have to convert them to integers of a given number of bits first and adjust the code to add your custom conversion float<>int. Title: Re: Small trick for Ultra Fractal formulas/colourings Post by: David Makin on April 07, 2009, 01:25:48 AM I should add that there is another way that has less overhead in terms of rendering time but requires more user input - namely modifying the formula so that the "max iterations" value actually used by the formula is less than that defined by the user - eg. if it is effectively one less than the value defined in the standard UF "Maximum Iterations" field then the formula has one extra loop iteration free in which to pass any value it likes as the final z value to the colouring - of course this is still subject to the colouring understanding what the formula is doing. |