2D lights and particle systems.

I'm trying to get a particle system to respond to 2D lights.

I have a top down game with a particle cloud overlay. I am using 2D lights for night and day.

I need transparency for the clouds to fade in and out. Using the URP default unlit particle shader I get that. Once it goes to night time the areas the clouds are over become lighter. I want the opposite, or at least the clouds to become darker.

If I use a lit particle shader I loose my fading, and the light does nothing to the clouds.

I can do this by changing the start color of the cloud particles, and I would have to loop through all the other clouds to darken the ones that are already active. I would need to do this for every particle system I want affected by the light. This is not scalable in any performant way and I know I will want other particles to be affected by light.

I'm thinking it has to do with the renderer and I might need to create a second camera using a different renderer or maybe a render feature.

Is there any way to get the particles to be affected by a 2D light?

I've added the tag "particles" because the 2D team don't work on the particle system. With a bit of luck a particle dev will see it and respond to you.

1 Like

You need a 2d-lit material. Here’s how particle Shader Graph was done in the Lost Crypt demo, using a ShaderGraph starting from the Sprite Lit template.[quote=“Lo-renzo, post:2, topic: 865901, username:Lo-renzo”]
Take a look at this. It’s from Unity’s Lost Crypt tech demo.

For the “Main Texture,” you need to create a texture property on the Blackboard. In the Reference field, put “_MainTex” without the quotes.
[/quote]The HDR Tint Intensity could be left out. Or you could rename it “Day Night” so you’d have a variable you could change fro script to help with coloring the clouds at different times of day. The VertexColor node might be optional too… I think Sprite Lit shader graphs receive VertexColor automatically.


Thanks Lo-renzo. I will give it a try.

@Lo-renzo unfortunately this makes my particles black. Very strange, I need it to have color. It should darken when there is less light, but not black the whole time.

Edit: The material icon shows color for the particle texture, so it shouldn't turn black.

Do you have a Global Light? Have you set the HDR Intensity (or replacement) to non-zero? I've used this exact thing just fine.

Yes I have a global light. I have set the HDR intensity to white, still comes out black. It doesn’t make any sense at this point the material shows it’s working but the particle system will not add color.

If I make the graph Sprite Custom Lit, I get color back but it isn't affected by the global light and it doesn't fade.

Well I feel stupid now. It would help if the light was targeting the cloud layer. No light and it goes black, which now makes total sense. Also the HDR intensity is not needed at all, I took it out of the graph.

Thank you for the graph Lo-renzo.

Hi @Lo-renzo ! I’d like to create my own material as you have shown. How would I go about using the base Unity Sprite Lit template?

In the Graph Inspector (make sure this is toggled on)
In the Graph Settings (this is a tab within the Graph Inspector)
Set the Material to be Sprite Lit

This is the default setting if you start from right clicking in your Project window then go
Create > Shader Graph > URP > Sprite Lit Shader Graph

Thank you @Lo-renzo !