OpenGL: Rendering more than 8 lights, how?

╄→尐↘猪︶ㄣ 提交于 2019-12-06 00:24:56

问题


How should I implement more than 8 lights in OpenGL?

I would like to render unlimited amounts of lights efficiently.

So, whats the preferred method for doing this?


回答1:


Deferred shading.

In a nutshell you render your scene without any lights. Instead you store the normals and world positions along with the textured pixels into multiple frame-buffers (so called render targets). You can even do this in a single pass if you use a multiple render-target extension.

Once you have your buffers prepared you start to render a bunch of full-screen quads, each with a pixel shader program that reads out the normals and positions and computes the light for one or multiple light-sources.

Since light is additive you can render as much full-screen quads as you want and accumulate the light for as much light-sources as you want.

A final step does a composition between your light and the unlit textured frame-buffer.

That's more or less the state-of-the-art way to do it. Getting fog and transparency working with such a system is a challenge though.




回答2:


OpenGL lights is a simplistic system, that as far as I know is already in the deprecated list. You should handle lights yourself by writing a shader. Take a look here.



来源:https://stackoverflow.com/questions/1993431/opengl-rendering-more-than-8-lights-how

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!