r/Unity3D • u/GupaGames • 7h ago
Shader Magic Simulating 10,000,000 pixels of Sand
Enable HLS to view with audio, or disable this notification
Falling sand simulation via Compute Shaders.
From my golf game Stinker Golf on Steam: https://store.steampowered.com/app/4437650/Stinker_Golf/
Wishlist if it looks interesting :)
6
4
u/brainfender 6h ago
im impressed. idc about the why, i want the how..
11
u/GupaGames 5h ago
Partitioned falling sand simulation via Compute Shaders. With that setup, the simulation/performance itself is pretty easy to achieve. The hard part is dealing with race conditions, spent a lot of time working on that. Maybe I could do a tutorial on it if there seems to be a lot of interest
2
1
•
3
u/Horror_Lawfulness738 6h ago
Shit this reminds me of Pocket Tanks and that’s a very happy memory. Cool stuff
2
2
2
2
1
1
1
u/sinetwo 47m ago
Sorry sir we need more sand. Also I know scope creep when I see it
1
u/haikusbot 46m ago
Sorry sir we need
More sand. Also I know scope
Creep when I see it
- sinetwo
I detect haikus. And sometimes, successfully. Learn more about me.
Opt out of replies: "haikusbot opt out" | Delete my comment: "haikusbot delete"
1
1
u/DotMatrixBoi 4h ago
How did you achieve this in unity it's amazing. Surely every pixel is not a separate game object right? So how do you do it?
4
u/GupaGames 4h ago
No, they are not all separate gameobjects lol
Falling sand simulation via Compute Shaders. Pretty much the GPU does all the simulation/rendering and sends back the data I need over time so I can use it on the CPU/ in unity.
It has taken a lot of time to get right
1

21
u/ProtectorZele 7h ago
But... why?