jeske / SimpleScene

Simple 3D scene manager in C# and OpenTK / OpenGL
https://github.com/jeske/SimpleScene/wiki
Other
173 stars 69 forks source link

Multi-pass lighting: More than 8 lights #5

Open mcmonkey4eva opened 9 years ago

mcmonkey4eva commented 9 years ago

It would be amazing if you used multi-pass lighting and etc. techniques I know very little about to allow more than 8 lights at one time. The rough idea, as I've read it, is that you render the scene with the first 8 GL lights, then with the next set, then the next, and keep going until all lights are rendered. ... There's probably a better way to render large numbers of lights. Thus why I'm asking you, the much more skilled-with-OpenGL developer, to look into the possibilities.

jeske commented 9 years ago

No, you don't render the scene with the 8 GL lights over and over. That doesn't really work.

Right now the most popular forms of multi-pass lighting are deferred shading and deferred lighting, and I plan to include one of them at some point. The scene is rendered once into a non-lit framebuffer format called a g-buffer (z, diffuse, and surface-normal for each screen-space pixel). Then each light is "rendered" as a polygonal shape, using the g-buffer data to compute it's contribution to the final scene. This allows efficient creation of hundreds of lights for the fixed-cost of one (or two) extra rendering passes.

https://en.wikipedia.org/wiki/Deferred_shading

If you want to be really blown away, you can look at this bleeding edge research on how to use the latest hardware features (virtual textures) to also support tens or hundreds of unique shadow maps, at least for point lights.

http://www.cse.chalmers.se/~olaolss/main_frame.php?contents=publication&id=clustered_with_shadows