Particle Macro Translucency

Hey everyone, I have a technical challenge for you guys. I am essentially to make macro translucency for my particle system but I am completely stumped as to how I would go about it. Its sort of a combo between masked and translucency. I want to have all the particle alphas combine into a mask, use that mask to overwrite the per particle translucency and then fade out the mask. Here are some images to demonstrate the issue…

As you see, the more particles that overlap, the brighter the alpha.

I want to render the alphas as if they were masked, like this.

Then i want to apply that as a macro mask to all the particles and fade it out with translucency. Here is the final result on a red background.

I had a few different ideas for this. One was to combine the particles into some sort of buffer. The issue with this is i have no idea how to apply that buffer as the opacity of the particle cloud. Also, if the particles need to be rendered before they are put into the buffer, they will still be visible when the buffer is applied overtop. Can you render particle alpha into a buffer without actually drawing the particles?

Another option would be to somehow get the final scene render, apply it as a macro color to all the particles (essentially making them invisible) and then lerp between another color to simulate translucency. This has the benefit of not dealing with opacity at all. However, i didn’t see any “final color” option in the scenetexture material node. There is a base color however, and all the diff render passes so maybe it could be combined manually to get the final scene. Wouldn’t have any scene lighting though.

The last option would be some sort of pixel operation on the material to clamp the brightness of each pixel to the same level and then fade that out. I have NO idea where I would even begin with this one…

Does anyone have any ideas on how this could be achieved?

I have been poking around and i think that the grid2D stuff is potentially a solution. I have been following those awesome tutorial videos from partikel on the grid2D setup and i have managed to get it to inject the texture into the Grid2D and the render target.

So far i have it injecting one particle into the grid2d but the transforms seem to be all messed up. Its also doesnt work with more than one particle.

This whole grid2d setup seems like black magic to me so if anyone has some experience with it any help would be greatly appreciated!


What you’re asking for is genuinely rather difficult.

The most broad solution would be one where you render these particles into their own buffer, then combine that buffer into the scenecolor buffer at some later point in time with a set alpha.
This would work for everything, but as you can imagine setting up these buffers, and combining them is relatively expensive.

Another option is to use a depth buffer to figure out which fragment is closest to the camera an only draw that fragment at the opacity it reports. If the custom depth buffer is not yet in use in your project, you could use it for that. Essentially set the material to draw into the custom depth buffer then for the opacity pin, check the custom depth buffer and draw if the current fragment depth is the same (with some reasonable margin) as the depth recorded in the custom depth buffer. Although, keep in mind that alpha cutoff is used to decided whether or not a fragment draws into the custom depth buffer in the first place.

By rendering the particles into another buffer are you talking about using a scene capture camera and making the particles invisible to everything except that camera? I have seen a few people do setups like that but it seems pretty extensive and expensive. I was hoping for a method that didnt have to deal with those scene captures at all. I do agree that in order for this to work at all i need to accumulate the particles into some kind of buffer, but getting them in there is tricky. Also compositing that buffer back into the scene in such a way that it looks like same as if i had the particles in the world, just with their alpahs combined and modified is also tricky.

I was combing through the discord channel and i found the discussions where partikel and others managed to inject particles into the buffer and them displacing the result so it looked sorta like a 2d fluid simulation. Thats basically what i want to do but the setup is difficult as you mentioned. It looks like it takes a combo of scratchpads and some custom hlsl, something i am clueless about. In their examples they are also just injecting the positions as points with a falloff, whereas i want to inject the sprite texture. The sprite may potentially be randomly rotated and scaled and possibly be using a flipbook. I am unsure on how to get all that data into the grid so i can inject it into the render target buffer.

If there is another way that you know of to add the particles into a buffer without using the scene capture camera i would love to hear it. Once i have that buffer with the accumulated particles i can do some simple material operations on it to clamp all the alpha values and then render that buffer as a translucent surface.


A simplified version of the thing you found on discord would be to simply dump a few interesting sprite parameters into rows of a render target, then render a full screen quad using the RT to position and scale stamped textures.
This too would likely be exceedingly expensive.

Just out of interest, why do you want to do this? It might be better to look for a different approach to your desired look rather than looking for different techniques for the same approach

The reason why i wanted to do this is to get better looking stylized smoke, similar to the types of smoke you see in anime. Attack on titan has some good examples of effects like this. I have experimented with masked but it is too thick and it obscures everything inside the cloud. I want everything to be semi transparent, but not have the particles become more opaque when they stack up.

If there is a way to inject the particles into a render target without using a grid2d and without actually rendering them in the scene that would be great.