Best way to display a 2d pixel 'sandbox' simulation

Godot Verion



So you may or may not have seen games in the genre I’m talking about, but basically, it’s a simulation where each pixel can interact with those around it (e.g. lava pixel turns to stone pixel on contact with water.) You can think of the way the world is in the old artillery game Scorched Earth, where the terrain is made of pixels affected by gravity. Obviously I’m thinking of a more advanced simulation, but the basic concept of a pixel world is still there.

My question is, what’s the best way to visualize this simulation? I can think of a few ways, but I don’t know which is the most efficient/correct.

I’m mainly curious as to whether it would be better to use a tilemap, and then simply display the simulation by setting and deleting tiles, which would only be one pixel in size, OR to have each pixel be its own sprite, and to control those via script.

I suppose it could also be possible to have the sandbox represented by a single texture, with the pixels altered via writing to the texture, but I doubt this method would be ideal.

Any help or feedback is appreciated, as I’ve always wondered how those pixel simulations manage simulating and displaying fairly large numbers of seemingly-independently behaving pixels. Perhaps computers are just faster than I give them credit for.

I feel like a the simulation of pixel physics need to happen in more basic data structures, preferably in native code, unless you leverage the physics engine.

Then once all your simulation is done the particles are given to something that will render it. You probably want to be able to do sub pixel movement. So I wouldnt think a tilemap would work here. I think your best option would be to use a shader. But I don’t have much experience with this at all.

Look into noita and cortex command they do this sort of thing.

Yea… I think definitely a shader. If a shader can look at adjacent pixels.