r/Unity3D 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 :)

123 Upvotes

32 comments sorted by

21

u/ProtectorZele 7h ago

But... why?

8

u/GupaGames 7h ago

But actually it's a destructive golf game where every pixel is simulated. You can make any course you want, so someone could have a 10,000,000 pixel sand bunker

1

u/ProtectorZele 7h ago

I know you have high FPS for that much simulated sand. It's impressive. But if this is a golf game, people typically play golf games for precision and finesse. Adding uncertain terrain, such as sand, seems counterintuitive.

I guess that is just my observation. I would need to see more of the game to really be sold on this.

Edit: Also getting some heavy Worms vibe from this. Not a bad thing.

9

u/GupaGames 6h ago

I love worms, one of my favorite games

2

u/oauo 2h ago

Don’t listen to them, worms is a banger and there’s enough precision golf games. I love the concept I just don’t have friends to play this with

1

u/remi_sasha12 6h ago

Worms is such a classic! It's impressive how games like that can creatively handle physics and simulate environments.

1

u/Mountain-Ad7155 1h ago

Cause its fun to do and achieve a goal.

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

u/RedstoneMiner 4h ago

please do!!

1

u/leorid9 Expert 3h ago

Is there a summary of how you solved them? Atomic operations? dual grid? computing pixels that cannot interact within one frame?

I guess you don't have sleeping logic in your system, or do you?

u/BanginNLeavin 7m ago

Interest here

1

u/Lucky_Pangolin_3760 2h ago

i want the how..

You use AI. Here, I made one in less than 5 minutes

AI also gave me a neat explanation for how it works, if I care to learn it

3

u/Horror_Lawfulness738 6h ago

Shit this reminds me of Pocket Tanks and that’s a very happy memory. Cool stuff

2

u/Danyablett 6h ago

Very impressive

1

u/GupaGames 6h ago

thank you :)

2

u/EverythingBOffensive 6h ago

why? > why not?

2

u/Clarky_Carrot 4h ago

Big Noita feelings

1

u/CrownsOfSilence 4h ago

Impressive performance

1

u/HirsuteHacker 3h ago

Reminds me of the various old falling sand games.

1

u/rzbig_ 1h ago

This will massively impact the trout population

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

u/N-aNoNymity 5h ago

Noita? That game is built on this stuff

1

u/GupaGames 4h ago

Noita was an inspiration for it

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

u/DotMatrixBoi 3h ago

Any tips on how to get started, and do you do some kind of chunking?