I think i have most things working in a reasonable way now.
In this screenshot is one directional, three point and four (yes four) spot lights with shadows and four more point lights without shadows. (if too many shadow casters are declared the shader won’t compile at some point)
Here are the changes i had to make in the engine:
One part are array textures as render targets and the other part was fixing a bug with shader generation.
The multiplicity for array variables was ignored in some cases, so i fixed that.
If there are no objections i will make a pull request.
The Shadow renderer can still be found here:
I created a new shadow renderer which handles all light types, a maximum number and resolution for each light type needs to be specified.
I would like to change the need of a special shadow material, currently i’m using it to set the number of lights already rendered, which is used in the shader to evaluate the correct shadow map for each light.
I’m also using a special light filter which will sort the shadow casting lights to the front in a specific order, but i don’t see a way around that.
Currently there are no special shadow filters available. (Filtering is somehow broken for spot and point lights anyway, but i didn’t look into that yet.)
Then i have a bunch of material parameters which are used by the shadow renderer and it would be nice if the user using the shader node would only have to connect the parts which actually interact with the rest of the shader,
maybe declaring material parameters as part of the shader node or something.
If someone wants to try it i hope i was succesfull in using gradle, it should be only necessary to perform a gradlew install with my engine changes and then the shadow project should work. (I’m using a nvidia 670m card with windows, so I’m fully expecting this to not work at all with AMD and/or OSX )