Saturday 6 March 2010

Multiple shadows and a multitude of shaders


Last night I finally touched the code again after a week of extreme unproductiveness, and started playing around a bit more with the shadow rendering. The plan was to setup a system that could render a shadow map per light. However I realized I had totaly forgotten to add a proper projection matrix to the shadows, which worked decently with directional lights but of course didn't work at all with spot lights, and I had a lot of problems with getting that to work.
I got it to work in the end though but the system isn't quite finished yet, there's still some hard coded stuff and the code really needs a clean up. My big dilemma now is how to set up my shader library; as every object can be affected by a variable number of shadows and lights it might be a bit to expensive to process all lights and shadows for every object, but from I've heard if-statements might be even more expensive so the most optimised way would be to create different shaders for every number of shadows and lightmaps that affects the mesh. Even if I don't create seperate shaders per number of shadows it's starting to get a bit out hand to just copy paste my shaders whenever I need a small change somewhere so I really need someway to structure up a proper shader library.

No comments:

Post a Comment