robcupisz / LightShafts

A light shafts (volumetric shadows) effect for Unity.
1.3k stars 162 forks source link

Sprite rendering order, behind light shafts. #3

Closed JacobDuaneJohnson closed 10 years ago

JacobDuaneJohnson commented 10 years ago

The light shafts seem to render in front of the sprite renderer, causing any sprite based object to always appear behind the shafts even when the sprite is in front.

image

robcupisz commented 10 years ago

Yea, that will happen if the sprite doesn't write depth.

So one option you have is to make the sprite's shader write depth. If it also writes depth into the shadowmap, it'll get a volumetric shadow.

Another option - if you know the sprite is always completely in front of the light shafts - is to force the sprite the render after light shafts. One way to do that is to render it with a different camera. Or trigger its rendering from LightShafts.cs:OnRenderObject(), but that's not very clean.

JacobDuaneJohnson commented 10 years ago

Great thanks for the tip!