Floating dust particles - receving shadows

How to create dust particles that receive shadows?

I know that transparent material cannot receive shadows…how can we make dust particles that can receive them with transparency?

Any help would be greatly appreciated.

If you’re already using 2017.3, you can use the new Particles/Standard shader (usually Unlit is enough) with Fade mode for your dust particle and enable Cast Shadow in particle system renderer module.

That won’t make them receive shadows, only cast them, which isn’t what the op is asking for.

The short version is you can’t.

The long version is with Unity’s default forward renderer it does not supply the necessary information to transparent materials to do what you want. So you either have to collect that data on your own from Unity’s shadow map passes, or generate it yourself in some form. An old common technique is to setup something akin to a projector where you supply an static image of some kind and a projection matrix to the particle’s shader and material. Usually the use case for this would be something like sun light through open windows, if you have a mask texture that roughly matches the shape of the windows, the position of the window, and the direction of the light, you can fake shadow receiving particles.

You could also render your own shadow maps, which are basically the same idea as above, but you render depth maps from the light’s point of view. I believe there are some assets on the store that already do this for particles.

The last option is look at using the new Scriptable Render Pipeline renderers. Those do pass the necessary shadow data to all passes.

1 Like

Thanks for the detailed explanation

I think I may try cutout or fade rendering to see if that can give me enough light without too much black around the edges.

Btw, why is it that they don’t support this? I’m guessing that its too expensive?

Do you have screenshot example of games that does it?

Find any game from the late 90’s or 00’s that has this effect, if they have individual particles that appear in the light from the window, this is most likely how they did it. The other option is if the windows are boxy they may just be spawning particles in the right shape.

edit: One note, for games before ~2002 this “projection” was likely done on the CPU by manually setting up the UVs on the particle mesh since this predates what we think of today as shaders. The effect also wasn’t popular until the late 00’s since it was expensive. Most games used poly extrusions, like this example from Half-Life 2: Lost Coast (2004):

Similar techniques can be found in pretty much any early 3d “hardware accelerated” game. Here’s another from Quake 3 Arena (1999):

Using the “texture projection” method on particles was possible, but expensive, so it’s rare to see in a shipping game. I know for sure people were doing it with Unreal Engine 2.0 games, but I can’t find any screenshots of it. There was a user made level for Unreal Tournament 2004 that could be considered the first to ever use GI that had the effect. They rendered out all of the lightmaps in 3ds Max, and rendered out those projection textures to do lighting on the player and particle effects.

I’ve never tried it… so might be a bad suggestion… but could some low res approximation perhaps be achieved with Light Probe Proxy Volumes?

1 Like

Yep, LPPVs would work here for static lighting. Though it’s probably a bit slower, and won’t be as sharp when using a reasonably sized LPPV volume density vs a texture projection, it would at least be mostly automated. That would work with the now built in Particle Standard shader out of the box.

1 Like

I’ve worked on multiple AAA games that did this. It’s in no way too costly. You just do it only where you need. You can even push it to the vertex shader if you multi tap it to blur. I’ve found generating a lookup into the shadow mapping hard in unity. It’d be great to get some support on this. Maybe a convienence for world position to in shadow or not? It really makes a big difference for things like big smoke flipbooks

Honestly i’m still curious why unity doesn’t have projected static/Baked shadow until now. i know that it is might be storage intensive just like lightmap, but it still usefull and can be downsampled as it is a texture