Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Okay, as those of you who frequent IRC know, a newcomer named Valathil is currently working on improving our render pipeline to handle more lights in shader mode.
- However commendable and awesome this is, it hits one of the fundamental difficulties with our rendering setup.
- In pseudocode, we currently do this:
- [code]
- for every object in view
- for every light affecting the object
- compute light contributions[/code]
- Now, there's a reason why OpenGL is limited to 8 lights in most implementations. It's because computing the light contributions in a single pass is very expensive, you need a LOT of shader instructions to do this correctly in a per-pixel process, making the shader bigger and bigger.
- Now, after reading up on the matter, it is my belief that we can move FSO to a deferred rendering setup. For those who don't know, a deferred renderer works in a vastly different way to the standard forward renderer.
- In pseudocode, it looks like this:
- [code]
- create depth buffer
- create normal buffer
- create auxiliary buffers 1 - n
- for every object
- load geometry into GPU memory
- load textures
- render depth data into depth buffer
- render surface normals into normal buffer (using normal map, if applicable)
- render diffuse map colour data into aux1
- render glow data into aux2
- /* Note: This step isn't as expensive as it looks, given that on OGL2 capable hardware,
- we can write all this data into the appropriate buffers with a single shader invocation */
- for every light
- load depth buffer
- load normal buffer
- create light geometry (quads for directional lights, cubes/spheres for point lights)
- render light geometry
- compare depth values with geometry
- if geometry is within light influence, render colour data into aux3
- create composite data
- final colour = (aux1 * aux3) + aux2[/code]
- This setup allows for a (theoretically) unlimited number of lights in the scene, without the performance impact you get with a traditional forward renderer.
- In FSO, given that we already keep track of 256 lights, this could greatly increase realism and overall shininess. An added benefit is that shadows are trivial to implement in a setup like this (or rather, that's what the smart guys who wrote the papers I'm reading claim).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement