SlightlyMad / VolumetricLights

Volumetric Lights for Unity
BSD 3-Clause "New" or "Revised" License
2.06k stars 304 forks source link

Rendering issue from certain angles. #28

Closed GafferSystems closed 6 years ago

GafferSystems commented 6 years ago

@SlightlyMad If i have shadows enabled for the spotlight, and it doesn't hit any objects, the light stops rendering / turns invisible if viewed from certain angles.

This can be recreated in the spotlight scene, if you rotate the light upwards, then move the camera and the light upwards, at one point it will stop rendering the light, seems like range has something to do with it as well.

Is this a known issue or something new? The rendering's values seems to stay the same, so I couldn't debug it any further.

fan0114 commented 6 years ago

Im having the same issue. It stops working when my character is out of a certain range from my camera. When the volumetric light stops working, the statistics shows that there are 0 shadow casters.

SlightlyMad commented 6 years ago

Yes, that's a known unity limitation. Unity controls when lights are rendered and it disables them when there are no light/shadow receivers as an optimization. Unity doesn't know the light is volumetric and that the volume should still be visible. You can try to add small shadow caster with large bounding box inside light's volume. That should force unity to keep the light on.

GafferSystems commented 6 years ago

@SlightlyMad Thanks for replying! I didn't quite understand the part about a small shadow caster with a large bounding box, but it gave me an idea for a fix and I want to share it. Creating a cube with scale (0, lights rendering distance, 0), and placing it just inside the lights reach seems to trigger shadow casting, forcing the light to stay active. Thanks!

fan0114 commented 6 years ago

@GafferSystems That works perfectly for me. Thanks!

SlightlyMad commented 6 years ago

@GafferSystems Yes, that's basically what I meant. I thought you would create a very small cube to make it virtually invisible and than manually set large bounds on its renderer to make sure it covers light's volume. I didn't know that zero scale would work...