HackerPoet / PySpace

GLSL Fractal Ray Marcher in Python
MIT License
1.16k stars 149 forks source link

How to increase the transformation amount #17

Open coalaura opened 4 years ago

coalaura commented 4 years ago

I would like to render some of the fractals in more detail (More transformations) how would i do that?

MCGamer00000 commented 4 years ago

I have found that increasing the number of iterations makes the fractals more detailed. For example, in the Menger Sponge, this is the original code

obj = Object()

for _ in range(8):

    obj.add(FoldAbs())

    obj.add(FoldMenger())

    obj.add(FoldScaleTranslate(3, (-2,-2,0)))

    obj.add(FoldPlane((0,0,-1.0), -1.0))

obj.add(Box(2.0, color=(.2,.5,1)))

return obj

and here is a much more detailed piece.

obj = Object()

for _ in range(16):

    obj.add(FoldAbs())

    obj.add(FoldMenger())

    obj.add(FoldScaleTranslate(3, (-2,-2,0)))

    obj.add(FoldPlane((0,0,-1.0), -1.0))

obj.add(Box(2.0, color=(.2,.5,1)))

return obj

Notice how the 8 was made into 16.. That makes the amount of iterations of the fractal increase. Note that due to certain problems, when zoomed in enough, you can't add any more iterations. I'm not exactly sure how one could fix that issue though.

ksgustafson commented 4 years ago

I know there are perturbation methods for zooming on 2d mandelbrot, not sure exactly how those translate to these fractals though. I think you would need to work out the math for these specific ones to implement deeper zooms