Unity Shuriken Custom Light Setup

Hey!

Had been struggling for some time with a simple custom light setup and normal maps in Unity using its Shuriken particle system.

I wanted my smoke particle to receive light from one direction and use the normal map to add details to it.

The problem I ran in to was that it wasn’t shading correctly at all when I rotated the particle.
It was all fine as long as the particle didn’t rotate, or the camera didn’t rotate.

CustomLight_NotRotating

But when I rotated the particle the lighting stayed the same.

CustomLight_Lit

What was later discovered was that Shuriken particles do not have Tangent data vertex streams by default, so that needed to be manually added.

image

Now, transforming the Light Vector from World to Tangent space worked as it was intended and the particle will rotate about and getting the shading coming from the right direction.

This was the end result of getting the light to shade the particle in the right direction:

CustomLight_Solved

The smoke flipbook and normal map was rendered using Embergen.

I’m so thankful to @Deathrey and @R0i3in on the Discord server who helped me narrow this down to the core problem!

10 Likes

@jqarlsson Hi, Looks very nice!!! I guess one thing, I am not getting it, where in the shader are you binding the tangent stream?

Hey!

You do that in the Shuriken Particle System → Render → Custom Vertex Stream checkbox → then add the Tangent on the + icon.

The light direction is transformed from World space to Tangent space and without enabling that data on the particle system it wont work when rotating the particle.

I see! Thank you, for the explanation!

1 Like