Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. 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.
  2.  
  3. However commendable and awesome this is, it hits one of the fundamental difficulties with our rendering setup.
  4. In pseudocode, we currently do this:
  5. [code]
  6. for every object in view
  7. for every light affecting the object
  8. compute light contributions[/code]
  9.  
  10. 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.
  11.  
  12. 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.
  13. In pseudocode, it looks like this:
  14. [code]
  15. create depth buffer
  16. create normal buffer
  17. create auxiliary buffers 1 - n
  18.  
  19. for every object
  20. load geometry into GPU memory
  21. load textures
  22. render depth data into depth buffer
  23. render surface normals into normal buffer (using normal map, if applicable)
  24. render diffuse map colour data into aux1
  25. render glow data into aux2
  26. /* Note: This step isn't as expensive as it looks, given that on OGL2 capable hardware,
  27. we can write all this data into the appropriate buffers with a single shader invocation */
  28.  
  29. for every light
  30. load depth buffer
  31. load normal buffer
  32. create light geometry (quads for directional lights, cubes/spheres for point lights)
  33. render light geometry
  34. compare depth values with geometry
  35. if geometry is within light influence, render colour data into aux3
  36.  
  37. create composite data
  38. final colour = (aux1 * aux3) + aux2[/code]
  39.  
  40. This setup allows for a (theoretically) unlimited number of lights in the scene, without the performance impact you get with a traditional forward renderer.
  41.  
  42. 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