robcupisz / LightShafts

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

[Unity 5.2] LightShafts disappear #11

Open Drommedhar opened 8 years ago

Drommedhar commented 8 years ago

I started using the Light Shafts in our project and found out, that in certain viewing angles the LightShafts disappear. I was able to reproduce this issue with the following setup:

I had a ventilation duct on the top part of a wall (higher than the player camera) and placed a spot light in it, shining out of it. So the light had a -90degree rotation shining directly to the side. If I now walked directly infront of it, looking right in the center of the light shafts, they disappeared.

Would love to use this asset in the project, but this is a no go. Is there anything I can do to prevent this fromo happening?

I will provide some screenshots/video if I get home from work (if needed)

Agilethief commented 8 years ago

One solution would be to edit the lightshafts to always render regardless of if they are in view of the camera or not. IIRC there is a check in the main lightshaft script that checks if the lightshaft is within the frustum of the camera.

This is more expensive however (as I believe it still does the raycasts despite not being on screen)

Drommedhar commented 8 years ago

I will check this out later. As I already want to implement the Pull Request which also disabled the light shafts based of distance (and even if not, I can do this outside the shader), the performance might not be such a big problem.

Will tell if I got this working. Thanks for letting me know ;D

EDIT: Commenting the code in "IsVisible" did the trick and did not cost to much frames with 9 testlights in a scene. Thanks again.