OpenGL:渲染多于8个灯,怎么样? [英] OpenGL: Rendering more than 8 lights, how?
问题描述
我应该如何在OpenGL中实现超过8个灯?
我想有效地呈现无限量的灯。
那么,这是什么首选方法呢?
延迟着色。
没有任何灯光。相反,将法线和世界位置连同纹理像素一起存储到多个帧缓冲区(所谓的渲染目标)。如果你使用多个渲染目标扩展,你甚至可以在一个单一的通行证。
一旦你准备好你的缓冲区,你开始渲染一堆全屏四边形,每个都有一个像素着色器程序,读取法线和位置并计算一个或多个光源的光。
由于光是相加的,您可以渲染为
最后一步是在灯光和未照亮的纹理之间进行合成帧缓冲区。
这或多或少是最先进的方法。使用这样的系统获得雾和透明度是一个挑战。
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?
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.
这篇关于OpenGL:渲染多于8个灯,怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!