An open API service indexing awesome lists of open source software.

https://github.com/alexnardini/flam3_for_sidefx_houdini

The Fractal Flame Algorithm, FLAM3 for SideFX Houdini - aka: FLAM3H™
https://github.com/alexnardini/flam3_for_sidefx_houdini

algorithm apophysis cvex editor flam3 flame fractal fractal-algorithms fractal-flame fractal-flame-editor fractal-geometry fractal-images fractal-rendering fractals houdini procedural procedural-art python sidefx-houdini

Last synced: 2 months ago
JSON representation

The Fractal Flame Algorithm, FLAM3 for SideFX Houdini - aka: FLAM3H™

Awesome Lists containing this project

README

          

## Web

- **[FLAM3H™ website](https://www.alexnardini.net)**
- **[FLAM3H™ youtube](https://www.youtube.com/@alexnardiniITALY/videos)**
- **[FLAM3H™ instagram](https://www.instagram.com/alexnardini/)**

## License
- Software: [GNU GPL v3.0](LICENSE)
- Documentation: [CC BY-SA 4.0](LICENSE.docs)

## Platforms
_One code base, multiple platforms._
- **Win**, **Mac**, **Linux**

## Houdini versions
_The following are Houdini versions where FLAM3H™ is fully functional, tested and supported._
- **H19** to **H20.5**
- **H21**






# The Fractal Flame Algorithm
![FLAM3 Intro image](./img/GITHUB_intro_img.jpg)

`The above fractal Flame image consist of 400M points and rendered with Houdini internal Karma renderer. Originally rendered at 7k resolution.`

## FLAM3 for SideFX Houdini - aka: FLAM3H™
**_A huge special thanks and lots of gratitude toward my family who kept up with me for so long while I was inside the fractal Flame bubble!_**




### Premise

One of the main missions was to pack the entire algorithm and functionalities I desired inside a tool using only Houdini out of the box. No HDK.
As a result, it became a somewhat conservative implementation, it has everything but also some limits as I needed to cut corners everywhere, which became a daunting process to put into balance.

A big commitment I needed to honor was to learn how to do fractal art.
Building a fractal art tool without knowing what a fractal artist needs and feels while doing it is kind of meaningless. And thus, while creating this tool, I engaged in so much fractal art with it that I unavoidably developed a love for the field.
It was important, so I could shape and steer this tool in the right direction.


### Why inside Houdini ?

_Beside being a long time user myself_...
_Following are just few of the advantages of being a Houdini resident_:

- Fractals Come AliveThrough this implementation, fractal Flames are now a real thing within a formal, procedural application,
with all of its data accessible and available for any kind of modification.

- A New FormatThey now exist in a new format that describes them in ways that were previously impossible,
rather than being a rasterized 2D image.

- Decoupled ResolutionIn point cloud format, the "quality" is defined by the number of samples rather than fixed pixels. You can generate a dense point cloud and later decide to render it at 1080p, 4K, or 8K. The point cloud acts as a high-fidelity "source" that preserves the attractor's information independently of the final output resolution.

- Expanding Creative PathwaysThey can connect to any kind of input and spread that information throughout the generation process,
opening up countless possibilities for creative and experimental endeavors.

- Structured USD EntitiesThey are divided into various entities by a hierarchy when inside the USD context.
Point cloud, render properties, handles, shaders, and so on.
These entities are all transferable, changeable, and accessible.

- Advanced Production FrameworkThey become part of a larger ecosystem and benefit from all of its features,
including proceduralism, data handling, animations tools, shading networks, and access to high-end renderers, just to name a few.

- Distributed Rendering CapabilitiesFractal Flames can be computed on a single machine or expand in scope
by sending them to larger render farms.

- Pipeline-Ready AssetsIf version control and review systems are in place,
they can be fed into a pipeline like any other piece of data.

- Democratized Code AccessWithout having to go through the hassle of setting up a C/C++ compiler for every platform and Houdini version, something that is typically handled by a senior software engineer, technical directors (and technical artists) may view and modify the source code.

- Interactive Development FlowThe tool can be modified in-place without affecting the running environment, enabling anyone to add and change its data and toolkits while monitoring the results in real time and ensuring that the updated version will function properly on all platforms that Houdini is running on.




### Description

`FLAM3H™ node OTL documentation`
![FLAM3HOUDINI Karma rendering viewport](./img/FLAM3H_OTL_documentation.jpg)

FLAM3H™ is a high performance implementation of the fractal Flame algorithm
fully developed within the SideFX Houdini environment, no HDK.

- **Supported devices**
It run on GPU as well on CPU.

- **GPU availability**
GPU mode is only available with FLAM3H™ for H20.5 and up.

- **GPU OpenCL**
OpenCL (_-cl-std=CL1.2_) has been used to implement the algorithm so it can fully run on the system GPU device.

It makes real-time fractal flame editing in Houdini possible by running billions of iterations per second on AMD and Nvidia GPUs.

- **GPU performance**
Depending on the GPU device being used in the system, the FLAM3H™ GPU mode (_the default in H20.5 and up_) can be hundreds of times quicker than the CPU (_Cvex_) mode. Tests using an Nvidia RTX 4090 device show throughput ranging from ~40 to ~140 billion iterations per second, which practically enables the creation of high-quality point clouds with hundreds of millions of points in seconds as well as real-time fractal Flame editing within Houdini. A range of Flame settings were tested across 500 million points at 1024 (_the GPU mode iterations default_) and 2048 iterations, respectively.

_Simpler Flames like the Sierpiński triangle which features 3 xforms, weighted probability xform selection, color accumulation and output for position, color ramp lookup value, Alpha and point scale reached ~176 billions iterations per second with a 1 billions points cloud at 4096 iterations each on the same Nvidia RTX 4090 GPU device._

- **CPU**
CPU mode uses Houdini's Cvex (_Callable vector expression language_).

Although Cvex it's not a real-time thing, it will still be a lot of fun if you have a powerful CPU (_two powerful CPUs are even better_).




_Additionally_:

- The code went up and down and finally settled on the most minimalistic version in favor of performance.

- Part of the work is done inside the HDA in the Houdini environment
like attribute binding, UI building, parameter creations, their visibility conditions, the final compile and much more.

- Python has been used to enhance the user experience and add functionalities like:
- copy/paste iterator data
- load/save palette's libraries
- load/save Flame's file format
- responses/automations to user actions
- and much more...

- FLAM3H™ generates a live point cloud of the fractal Flame being worked on, which is the actual render.
From there to the final image, it is left to the users (_aka points rendering_).
With Houdini integrated Karma renderer, you will be able to render the generated fractal Flames in nearly real time.


### Karma render note

From FLAM3H™ [v1.8.98](https://github.com/alexnardini/FLAM3_for_SideFX_Houdini/releases/tag/v1.8.98),

a new custom materialX Shader has been introduced to the FLAM3H™USD HDA to allow proper points color values accumulation. It will perfectly match what third-party implementations refer to as:

_"build a buffer with the histogram or summation/accumulation of every point in every pixel"_.

This custom shader will match the visual quality of the fractal Flames rendered with Apophysis, Fractorium and others.
Fully available only with FLAM3H™USD HDA versions for Houdini H20.5 and up.


`Karma interactive.`

`Sphere Sugar Dragon - Author: Pillemaster`
![FLAM3HOUDINI Karma rendering viewport](./img/FLAM3H_Hviewport_00_Karma.jpg)

`Karma interactive.`

`Worlds - Author: Alessandro Nardini`
![FLAM3HOUDINI Karma rendering viewport](./img/FLAM3H_Hviewport_01_Karma.jpg)

`Karma interactive.`

`Its Pink - Author: Plangkye`
![FLAM3HOUDINI Karma rendering viewport](./img/FLAM3H_Hviewport_02_Karma.jpg)


## Highly inspired by Apophysis and its workflow design

My first curiosity with fractal Flames led me to download and experiment with Apophysis.
Since I knew absolutely nothing about the topic, I gradually began to truly like the way its user interface and workflow process were crafted.
Everything is accessible with a single click, and you get the impression that you can move through your Flame setup quickly and with clarity.

Even though I eventually went into Fractorium,
from the beginning, I intended to incorporate this into FLAM3H™.

Many Apophysis fractal Flames are available for download on the web, and you can load them inside FLAM3H™.
Or you can use Apophysis or Fractorium to author your Flames first and load them back into FLAM3H™. But also the other way around, create your Flames in Houdini and render them inside other applications. You've got choices.

**Download Apophysis 7x here**: [**Apophysis 7x download**](https://sourceforge.net/projects/apophysis7x/)

**Download Fractorium here**: [**Fractorium download**](http://fractorium.com/)


## Viewport live point cloud

FLAM3H™ generate a live point cloud of the fractal Flame you are working on.

Following are some screenshots showing it for a few different Flame presets.

`Dancing Stars - Author: Alessandro Nardini`
![FLAM3HOUDINI viewport](./img/FLAM3H_Hviewport_01_H19.jpg)
`Cool EDisc - Author: Pillemaster`
![FLAM3HOUDINI viewport](./img/FLAM3H_Hviewport_04_H19.jpg)
`Crystal Eggs - Author: Alessandro Nardini`
![FLAM3HOUDINI viewport](./img/FLAM3H_Hviewport_03_H19.jpg)


## Camera sensor

All the render settings required by third-party programs such as Apophysis and Fractorium are stored together with the fractal Flames when they are saved from FLAM3H™.

A portion of the render parameters deal with the camera and how the fractal Flame you just saved is framed.

The FLAM3H™ camera sensor will precisely display the image framing.

Once framed, you can save the Flame and be sure it will be framed the same in all other applications.

![Fractorium to FLAM3HOUDINI 01](./img/FLAM3H_camera_sensor_to_Fractorium_01.jpg)
![Fractorium to FLAM3HOUDINI 01](./img/FLAM3H_camera_sensor_to_Fractorium_02.jpg)
`Camera sensor: FLAM3H™ to Fractorium`


## Load Flames files authored with Apophysis, Fractorium, etc.

Following are some images showing FLAM3H™ rendering some of the Fractorium's example Flame files.
Some have been modified to fit within the available variations. The screenshots show
FLAM3H™ with Houdini Karma interactive on the left, and Fractorium with the same Flame file on the right.

`Chocolate Scaffold in Too Many Dimensions by plangkye. Source: Fractorium`
![Fractorium to FLAM3HOUDINI 01](./img/FractoriumToFLAM3HOUDINI_03.jpg)
`Mountain by tatasz. Source: Fractorium`
![Fractorium to FLAM3HOUDINI 01](./img/FractoriumToFLAM3HOUDINI_01.jpg)
`Bipolar by tatasz. Source: Fractorium`
![Fractorium to FLAM3HOUDINI 02](./img/FractoriumToFLAM3HOUDINI_02.jpg)
`Flipped disk. Source: Fractorium`
![Fractorium to FLAM3HOUDINI 03](./img/FractoriumToFLAM3HOUDINI_00.jpg)


## List of all available variations/plugins

_Note that all the followings, are also available as PRE__ _and/or POST__ _variations._

_`Arch` `Auger` `Bent` `Bent2` `Bipolar` `Blade` `Blob` `Blur` `Boarders` `Bubble` `Butterfly` `Bwraps` `Cell` `Conic` `Cos` `Cosh` `Cosine` `Cot` `Coth` `Cpow` `Crop` `Cross` `Csc` `Csch` `Curl` `Curve` `Cylinder` `Diamond` `Disc` `Disc2` `Edisc` `Elliptic` `Escher` `Ex` `Exp` `Exponential` `Eyefish` `Fan` `Fan2` `Fisheye` `Flower` `Flux` `Foci` `Gaussian_blur` `Glynnia` `Handkerchief` `Heart` `Hemisphere` `Horseshoe` `Hyperbolic` `Julia` `JuliaN` `Juliascope` `Lazysusan` `Linear` `Log` `Loonie` `Mobius` `Modulus` `Ngon` `Noise` `Oscope` `Parabola` `Pdj` `Perspective` `Pie` `Point_symmetry` `Polar` `Polar2` `Polynomial` `Popcorn` `Popcorn2` `Power` `Pre_blur` `Radialblur` `Rays` `Rectangles` `Rings` `Rings2` `Scry` `Sec` `Secant2` `Sech` `Separation` `Sin` `Sinh` `Sinusoidal` `Spherical` `Spiral` `Split` `Splits` `Square` `Stripes` `Supershape` `Swirl` `Tan` `Tangent` `Tanh` `Twintrian` `Unpolar` `Waves` `Waves2` `Wedge` `Wedgejulia` `Wedgesph` `Whorl`_

_They are 106, if you were wondering..._


## User experience

This implementation initially concentrated only on the core algorithm. However, it gradually became apparent that a significant portion of the work needed to be focused on the user experience and how all the algorithm pieces are stitched together in a meaningful way for the user, making this part of the project very time consuming.

Because FLAM3H™ was designed with fractal artists in mind, many internal automation that could be done to provide a seamless and pleasurable experience has been completed.

FLAM3H™ prioritizes the user and their quality of life while using it, from completely automated Xaos and iterators/xforms handling to a slick, practical, and compact user interface.

The workflow is convenient and quick since data can be copied and pasted between iterators/xforms and between various FLAM3H™ nodes.
Along with many other quality-of-life features inside the Houdini environment, third-party tools like Apophysis and Fractorium allow you to interchange data from and to FLAM3H™ simply by copying and pasting from the clipboard, making the process as smooth and comprehensive as possible.

It fully support the *.flame file format for maximun compatibility.

Python and the Houdini's HOM libraries have been used to achieve all of this.

Any parameter that is available in FLAM3H™ can be animated using any of the Houdini procedural paradigms and toolkits. These include but not limited to animation curves, expressions, and procedurally produced data from anywhere in Houdini, such as DOP Simulations, Particles data, CHOPS, and many more.

FLAM3H™ comes with a straightforward utility LOP node call **FLAM3H™USD** to makes it easier to move the fractal Flame point cloud into the USD context Solaris. This node allow to set up and render FLAM3H™ fractal Flames using Houdini's Karma renderer within a few clicks.

To finish, FLAM3H™ features a detailed documentation that is designed to provide you with all the informations you would need. This also extend to generous tooltips for each parameter in the FLAM3H™ Houdini user interface.


## Considerations

Given how expensive it is to compute fractal Flames, it is not surprising that GPUs have performed wonders in this area as well.

The main benefits of being inside Houdini are numerous. Consider the options available to you while animating those Flames with Houdini's procedural approach and toolsets. Additionally, the Python HOM libraries for Houdini can be used to build a pipeline around this tool.

Karma and the built-in Nvidia Optix denoiser make a fantastic combination for rendering fractal Flame images.

As far as I know, there are no switch/case constructors or other types of pointer functions in the CVEX language. I connected hundreds of "if"/"else if" statements to arrive at the chosen variation. Despite my best efforts to partition them, this section ended up becoming somewhat of a bottleneck for the entire implementation.

Python run single threaded here, now that this tool has lots of python code running or when many iterators are created, Houdini's FLAM3H™ user interface becames slow.
I made some effort to make it better, and from [v1.4.75](https://github.com/alexnardini/FLAM3_for_SideFX_Houdini/releases/tag/v1.4.75) I was finally able to start improving the UI performance a fair bit.

All the python automations that are currently in place are really "nice to have" features that improve the workflow by a lot.
There is also a big chunk of python code that deal with making the UI pretty and nice to look at, with lots of icons changing based on the user actions.
A computer processor with strong single-threaded performance would be very helpful here.

Also, I used 128+ iterators in all of my stress tests.
In reality, though, I've never used more than 20 iterators in any of the fractal Flames I've created thus far, nearly all of them used less than 10.

Almost all fractal Flame images on my website and instagram use an average of 64 iterations max,
Some use less, and some use a bit more. A few exceptions went above 128 and up to 256/512.

Some Flames need truly an high number of iterations to be resolved correctly but with the GPU implementation in FLAM3H™ for H20.5 and up you can now run thousands of iterations per point with easy (_assuming the system GPU device is powerful enough_).

Listed below are presets from Chaotica software that were converted to FLAM3H™. They were chosen because some of them are very expensive to solve and because they make use of variations I've already implemented.

Some require thousands of iterations to show you the proper results; some of them require hundreds, and some others are really quick.

_The following screenshots show FLAM3H™ with Houdini Karma interactive on the left, and Fractorium with the same Flame file on the right_.


### Lets start with this gnarl preset:

Iterations needed in FLAM3H™ to resolve: **1280**

`ieddaka gnarl. Author: zuek`
![Chaotica to FLAM3HOUDINI 00](./img/ChaoticaToFLAM3HOUDINI_00.jpg)


### The next two are a bit more speedy:

Iterations needed in FLAM3H™ to resolve: **512**
( potentially a bit less are needed for those but just in case. )

`blue modulus. Author: tatasz`
![Chaotica to FLAM3HOUDINI 01](./img/ChaoticaToFLAM3HOUDINI_01.jpg)

`lazyswirls. Author: meckie`
![Chaotica to FLAM3HOUDINI 02](./img/ChaoticaToFLAM3HOUDINI_02.jpg)


### This one is quick and beautiful:

Iterations needed in FLAM3H™ to resolve: **64**

`majestic. Author: tatasz`
![Chaotica to FLAM3HOUDINI 03](./img/ChaoticaToFLAM3HOUDINI_03.jpg)


### And the last one:

Iterations needed in FLAM3H™ to resolve: **32**

`blurry splits. Author: tatasz`
![Chaotica to FLAM3HOUDINI 04](./img/ChaoticaToFLAM3HOUDINI_04.jpg)

The following is another preset Chaotica software ship with I truly loved ported inside FLAM3H™ and rendered with Karma renderer.

Iterations needed in FLAM3H™ to resolve: **64**

`Golden Dragon - Author: meckie`
![goldenDragon_RENDER_2K_portrait](https://user-images.githubusercontent.com/42110232/237032379-56571708-d00a-4b93-ab2b-ea773700dce5.jpg)

You'll find other scenarios where your iterations number will need to rise up,
especially when relying heavily on containers and such.

However, from all my tests, between 10 and 96 iterations will get you covered for almost all your needs. And don't forget, you can create some beautiful fractal Flames with just six iterations. Here is one I did:

Iterations needed in FLAM3H™ to resolve: **6**

`Knot clusters - Author: Alessandro Nardini`
![Chaotica to FLAM3HOUDINI 04](./img/FLAM3H_knotCluster_HQ_iter_6.jpg)

I could add a lot more functionalities, but this project consumed me for a very long time.
Every aspect of this algorithm, once understood, looks simple on the surface, but they all present challenges on their own. It has been quite a crazy ride to pack everything into this implementation.

It is time to park this project for a little bit, but I really, really loved the long journey on this topic, and I will now forever love fractal Flames as a whole, they are awesome ( and addictive )!


## Example Flame files

Some of the example Flame files I'm using as a proof of correctness and shipped with this implementation were created or authored by some incredible fractal artists using a variety of open source and free apps like Apophysis and Fractorium among the most popular.

Please be sure to check out their gallery:

[tatasz](https://www.deviantart.com/tatasz/gallery),
[plangkye](https://www.deviantart.com/plangkye/gallery),
[Pillemaster](https://www.deviantart.com/pillemaster/gallery),
[Triptychaos](https://www.deviantart.com/triptychaos/gallery),
[TyranWave](https://www.deviantart.com/tyrantwave/gallery),
[Zy0rg](https://www.deviantart.com/zy0rg/gallery)


## References

Reference A: [**Github :: FLAM3 from Scott Draves and Erik Reckase**](https://github.com/scottdraves/flam3)

Reference B: [**Github :: Fractorium from Matt Feemster. Contributors: Michel Mastriani, Simon Detheridge**](https://github.com/mfeemster/fractorium/tree/master)

Reference C: [**Github :: Apophysis 7x from Mark Townsend, Ronald Hordijk, Peter Sdobnov, Piotr Borys, Georg Kiehne**](https://github.com/xyrus02/apophysis-7x)

Reference D: [**PDF :: The Fractal Flame Algorithm publication**](https://flam3.com/flame_draves.pdf)

Reference E: [**WEB :: A more accurate Elliptic variation from Claude Heiland-Allen**](https://mathr.co.uk/blog/2017-11-01_a_more_accurate_elliptic_variation.html)

Reference F: [**WEB :: pseudorandom number generators (PRNGs) from David Blackman and Sebastiano Vigna**](https://prng.di.unimi.it)

Reference G: [**WEB :: xoshiro128+ 1.0, 32-bit generator for 32-bit floating-point numbers from David Blackman and Sebastiano Vigna**](https://prng.di.unimi.it/xoshiro128plus.c)

## Copyrights

_All images and logos copyright (c) 2021 F stands for liFe (and their other respective owners)._