r/GraphicsProgramming • • 42m ago

I added depth occlusion to my GPU particles system

Recently I wanted to make my GPU particle system more dynamic and easier to develop with and given how vital heavy rain is to the tone and visuals of the game, I wanted to make rain be dynamically occluded based on the meshes.

First I flag the meshes which should be occluders, which is shown in the second photo. These occluders are rendered from an orthographic camera. The third photo is the depth texture from this render pass.

Particle emitters can then have a flag for height occlusion and height snap. In the particles compute pass, the depth texture is sampled and remapped to view space to get the distance. For emitters with height occlusion enabled, their lifetime is set to zero if they're greater than this distance. For emitters with height snap, the particles are set to this sampled height.

A limitation of this approach is that wind doesn't really work since the particles aren't actually colliding with anything. If there are any ideas of how to rectify this I'd love to hear them.

Overall, I'm pretty happy with this approach, and it has made iterating on the level much faster.

6 Upvotes

3 comments sorted by

•

u/AutoModerator 42m ago

Recently updated rules. Please check that your post is in compliance with Rules 1, 4, 5, and 6 on the sidebar. TL;DR:

  • No showcases.
  • Disclose AI usage in post or project.
  • Present a topic to talk about, e.g. how something works.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/TreyDogg72 21m ago

Very cool! Perhaps you can get that wind support you’re looking for by just passing a wind speed vector into the shader where you compute the particle effects?

1

u/Zestyclose_End3101 3m ago

Yeah I tried passing a vector, however the problem is that with this approach, the depth acts as a hard wall, which automatically occludes particles below that depth. Which means rain particles that shouldn't be occluded since they went below that depth from the side will end up being cut off. I think to fix this, I would have to rotate the orthographic camera to match the rain direction with the wind, but I wasn't able to get that to work. I may have another crack at it later though.