• April 19, 2021, 12:54:28 AM

Login with username, password and session length

Author Topic:  Menger sponge out of frames in less than 20 lines + renders  (Read 99 times)

0 Members and 1 Guest are viewing this topic.

Offline kronpano

  • Moderator
  • ******
  • Posts: 47
    • BrowserSynth
Menger sponge out of frames in less than 20 lines + renders
« on: September 25, 2020, 11:36:41 AM »
One thing that always strikes me about StructureSynth and L-systems in general

Small amounts of code generate huge amounts of objects - well - that's recursion for you.

The following script generates a Menger sponge made out of cube-frames
A depth of 2 creates 252 objects,
   depth of 3 creates 5052 objects,
   depth of 4 creates 101052 objects
and depth of 5 - well - crashes the program

Code: [Select]
set colorpool list:yellow,blue,white,red
set maxobjects 200000
set seed 10

{s 10}R1

rule R1 md 4 {
2 * {rx 180} 2 *{ry 180} 2 * { x 0.6} 1 * {x -0.9 y 0.3 z 0.3 s 0.28 } R1
2 * {rx 90} 2 * {rx 180} 1 * {x -0 y 0.3 z 0.3 s 0.29 } R1
2 * {rx 90} 4 * {rz 90} 1 * {x -0.3 y 0.3 z 0 s 0.3 } R1
{color random}frame
}

rule frame{
4 * {rx 90}framesides
}

rule framesides {
{ s 0.1 1.1 0.1 x 5 z -5 } box
{ s 0.1 1.1 0.1 x -5 z -5 } box
{ s 1 0.1 0.1 y 5 z -5 } box
}

The only peculiarity in this script is the sizing to s 0.28 and s 0.29 - this is just to prevent surfaces of different colour to be overlayed at the exact same location since that sometimes causes problems for rendering engines. It also gives quite nice - tiny offsets in the final render.

Both images were rendered from the same exported object - one using a normal perspective camera and the other a orthographic camera.

Linkback: https://fractalforums.org/index.php?topic=3785.0


There are no comments for this topic. Do you want to be the first?

xx
Menger sponge

Started by ArtIco on Fractal Image Gallery

0 Replies
307 Views
Last post December 21, 2017, 11:33:39 AM
by ArtIco
clip
menger sponge 4D

Started by mclarekin on Code Snippets (fragments)

0 Replies
136 Views
Last post April 16, 2020, 02:40:15 PM
by mclarekin
xx
inverted Menger Sponge C

Started by mclarekin on Fractal Image Gallery

0 Replies
180 Views
Last post September 26, 2018, 11:22:38 AM
by mclarekin
xx
Menger sponge-building up

Started by Nintendokater on Fractal movie gallery

4 Replies
294 Views
Last post January 27, 2019, 02:06:36 PM
by Nintendokater
xx
menger sponge color 2

Started by mclarekin on Fractal Image Gallery

0 Replies
262 Views
Last post March 19, 2018, 04:19:41 AM
by mclarekin