I'm working on a 2D game with realistic deferred lighting. Since I'm rendering the lights after the scene is rendered, I need a way to cull lighting calculations if there is an object, such as a tree, obstructing the area being lit. After doing some reading, my best bet for deferred rendering is to use a depth buffer. I've been searching the internet for ways to have a depth buffer with 2D graphics but really have not found anything helpful. I found glPolygonOffset
but I really have no clue if that is what I want, or if there is another way to set a z value for the polygons. Thanks for any help
Depth buffer in 2D
2.1k views Asked by rcapote At
1
Your misconception lies in thinking "3D == perspective". To generate a depth buffer your scene needs, well, depth. But that's no problem. What you refer to as "2D" probably just means lack of perspective. So by using a ortho projection and placing your objects on layers at various depth you can generate a depth buffer with data usefull for deferred lighting.