Today I noticed that what I did in the last couple of days was completely wrong! The shadows are all wrong, and I didn't notice it, even in the screens I took it is clear that something is wrong, but I somehow missed it.
The problem was pretty deep, and I had to convert the light positions with a custom matrix I made that ignores scaling (because the bounding box must be rotated and transleted, but not scaled).
I managed to fix the point light, and then I proceeded with the spot lights which required an even more complex matrix, thankfully I'm starting to getting used to these space conversions.
In the end I managed to fix those as well, and I added a switch to have two different behaviours:
1) Rotate ligths alongside object: The matrix is built so that the light is rotated by the whole hierarchy of objects, on top of its own rotation. This is nice if the light is attached, for instance, to a lamp mesh
2) Rotate lights alongisde the whole hierarchy except the object: On the other end, by setting a simple bool, it is possible to avoid the light to rotate with the object.
Tomorrow I'll fix the directional lights as well, and then I'll be done for good.
The screen captures a scene with lots of spotlights working and with a position dependent on the hierarchy.

Nessun commento:
Posta un commento