Sign in to follow this  

How do you deal with spotlights when you're done with the point lights?

Recommended Posts

mrheisenberg    362
I managed to cull point lights in the compute shader,which is easy,since it's just a center and radius and then accumulate their effect on the surfaces,how should one go after that to implement spotlights?My confusion is in 2 parts:1.are the spotlights accumulated on a seperate pass(run a different version of the compute shader after the one for the point lights) or can I do them all at once,for instance having my Light struct have a lightType and check it's type in the compute shader and branch to the appropriate calculations(that would hurt parallelism I think).And 2 - should I cull them at all?I mean it might not be in the view frustum,but even if it's 10 meters behind you,it can still point at your directiont and have a visible effect inside the frustum.

Share this post

Link to post
Share on other sites
kauna    2922
There are plenty of ways to handle spot lights.

- you may well draw them after your point lights in a separate pass or somehow integrate them so that your compute shader is able to handle them both.

- If you place your lights in a sorted array (the points lights are first and then followed by the spot lights), you may avoid branching a bit since you may just loop over the amount of each light type.

- For easy starter, math wise you may use your point light algorithm to draw spot lights, only thing you'll need to add is the required spot light direction and the inner and outer cone variables. Of course this way there is lots of unnecessary pixels processed.

- Even a point light can be behind you and have a radius of some hundred of meters. Culling spot lights exactly may be just a bit more demanding.

Cheers! Edited by kauna

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this