Procedural Image Based Scattering
Exploration into procedurally scattering cubes based on a reference image, and scaling them to compositionally balance each other. This project was made with Unity.
Given a reference image and an arbitrary starting point, this algorithm aims to scatter points that flow along related colors of the image. The next cube’s position is chosen to be one of 8 neighboring points ( at a given step size ) that minimizes the following two values:
Difference in color value.
Dot product of the previous and current direction of motion. This is so that the cubes are inclined to move in a flowing pattern.
Then the cubes size is calculated by maximizing the equilibrium of the position and sizes of the previous N cubes, following the logic of the talk Creativity of Rules and Patterns: Designing Procedural Systems.
The results are interesting, but in the future I would like to take this exploration and tune it for a specific goal, such as alien cities, forests, or caves. It would also be cool to optimize the problem for a first person view, instead of only thinking of the 2D top down scattering problem.
Open the Demo scene in the Unity project, and press play. You can move around the sphere and press G to generate a new scattering starting at the cubes position.
Reference Tex - replace this image with the desired reference image. You should also replace the image in the
Base Plane Material if you want to visualize the texture behind the generation.
Cube Mat - the material for the generated cubes.
Starting Pos Helper - the game object who’s position determines the starting point of the algorithm.
Generated Cube Count- how many cubes to generate.
Flow Amount - how much weight should be on the angular difference during minimization.
Step Size - how far away the neighboring points should be sampled.
Randomness - how much randomness to apply to the neighboring point sampling.
Cubes To Balance - the number of previous cubes to bring to equillibrium when calculating the current cube scale.
Cycle Scale - check this if you want the scales to be randomly cycled.
Check out https://codercat.tk for other projects 😃