lunedì 24 agosto 2015

Day 52: Spot lights

Today I wrote a lot of stuff.

I started by creating everything needed for the spot lights, by duplicating the point light classes (and shaders) already there.

In the meanwhile I also refactored a bit the Point light and Directional light classes.

Then I implemented all the different things that are different in spot lights compared to the other kinds of lights.

The main problem I had (and actually still have) is how to set the field of view of the spot light...apparently it is not the angle,but  the arccos of the angle, for reasons that are still unknown to me...So in the end I used this method, but, with very narrow fileds (close to 0), the arccos tends to infinite, so i manually set a value of the fov for these values, because the resulting shadows were messy...
Oh and I cannot use field higher then 90 degrees, but 90 is quite a lot anywhay for spot lights.
I don't know if there are better solutions, but now everything works fine, and I don't want to lose my sleep over it.

One last thing to do, not even really necessary, is to change the bounding box of the spot lights.
Right now they uses the same spherical box of the point_lights, but with this method a lot of space inside the sphere is rendered for no reason.
I should use a parallelepiped / cone and rotate it in the direction pointed by the light.


Nessun commento:

Posta un commento