I'm currently playing with writing a rendering engine and implementing a forward rendering pipeline.
I have few doubts on how things should be implemented regarding the render passes as-well as the rendering of multiple lights.
So I'm wondering what is the better approach here:
- Uber shader that is generated dynamically to adjust for the number of lights that currently affect the active scene. This have the nice benefits of only one render pass for the lighting shader so much less binding occurs which is a plus.
- have separate lighting shader for each type of light and have a render pass for each mesh with each type of light, combining in the end the result of (possibly 2 render target that we ping-pong between) with additive blending. This have the nice benefits of separation and more modular and maintainable shader code, but in the other hand the're more render passes and more binding going on and not to mention the ping-pong of additive blending between the render targets.
- Other Ideas that I didn't heard/thought about and would love to hear
Ofcourse there's always room for optimization of both techniques such as ocllusion test, test which point/spot light affect which mesh (relevant to the second technique).
So I'm wondering what is the take on it of modern rendering/game engine and maybe I didn't list what their approach is and would love to hear about it.
Also if you side for one technique or another would like to have your thoughts on the pros and cons.
Thanks in advance!