- The Blend
- Posts
- Simulation Science
Simulation Science
Learn how a simulation works, from the inside out.
We have a bunch of new subscribers—thanks for coming everybody!
In The Blend, we break down 1 Blender technique each week in a micro-lesson.
The Blend aims to become the world's #1 Blender newsletter. Enjoy the ride!
Portal made in Blender 3.5 (simulation branch)
This portal is a simulation.
"Simulation" sounds pretty complicated, but it's not.
A simulation is a simple system that does the same operation over and over again, once per frame.
It's like a loop: each frame uses the result of the last one as a starting point.
Here's an example.
Our input geometry is a cube.
For each frame, the simulation will take the input geometry and add 1 to the Z position of every vertex.
When we run the simulation, the cube will move along the Z axis, by 1 unit each frame. Then it sends the updated geometry back into the simulation as the input for the next frame.
Make sense?
Now, we can make it more complicated. Instead of just changing the last frame's geometry, the simulation can add new geometry.
Every frame, the simulation could join a new cube into the existing cube geometry. It would go like this:
Frame 1: Cube
Frame 2: Cube Cube
Frame 3: Cube Cube Cube
Of course this would be boring, because each new cube would be in the exact same position. We can fix that though!
Let's add a new object, called The Brush. The Brush is an Empty object—we only need it for its position.
Now, every frame, let's have the simulation add a new cube at The Brush's location.
If we run this simulation, and move The Brush around, you'll be "painting" cubes. The simulation still adds a new cube every single frame, at The Brush's location.
Let's build it in Blender.
You'll need the 3.5 alphasimulation build for this (go here and scroll down until you see a build called geometry-nodes-simulation. Get that one.)
Go to the Geometry Nodes tab and hit New. This is where you'll set up the simulation.
The Group Input node is the object's geometry (a cube.)
Add a Simulation Output node then a Simulation Input node. Connect them between the Group input and output nodes.
Add a Join Geometry node between the Simulation nodes. Any node connected between the Simulation nodes is part of the simulation and will run every frame.
Add a Set Position node and connect the Group Input(the cube) to it. Plug the Set Position into the Join node, so that it's added again every frame.
Now we just need The Brush! Add a new Empty to the scene and name it The Brush. Click + drag it from the Outliner into your node tree (it'll become an Object Info node.) Switch the node to Relative mode and plug it into the Offset on the Set Position.
Here's a picture to make things clear:
The Final Node Setup
Now hit play and move The Brush around—you're painting cubes!
See how that works? Every frame, a new cube is added at The Brush's location.
This is all within one object, though. It's like adding new geometry in Edit Mode—they're not separate objects.
Try editing your object so it's not a cube anymore, and see how that paints!
Now you understand the basics of how a simulation works. The portal simulation is a little more complicated.
Here's the basics:
We start with 1000 points arranged in a kinda random circle shape. Then we store a vector attribute called Velocity on each point.
What's an attribute?
An attribute is a value that is stored in your geometry. For example, each point's position is an attribute. Using the Named Attribute nodes, you can store and retrieve your own attributes.
Now, every frame, we do some math and update the Velocity attribute. Then we use that to update each particle's position (with a plain old Set Position node.) Then we join in 1000 new particles.
Also, we have another attribute, called Age, which is a simple number that we add 1 to every frame.
By checking a point's Age each frame, we can see how old it is and delete it if it's too old.
The most complicated part is the math for calculating the velocity—and adding in noise and randomness for interest.
I'm explaining the whole portal in an upcoming tutorial—subscribe here to get it when it come out!
P.S. I didn't invent this portal—I learned how to make it in this great video by Cartesian Caramel. He breaks it down in extreme detail—you learn a ton in this video! It's a bit long (3h), but worth if it you want to learn a lot.
The Fine Print
Know anybody who likes Blender? They'll probably think you're awesome if you forward them this email.
If someone forwarded this to you, then sign up here—unless you trust them to forward it again next week!
P. S. Have a topic you want covered? I'm always open to new ideas—reply to this email with your suggestions!
Reply