简体   繁体   English

延迟阴影问题

[英]Questions Deferred Shading

I just have some questions about deferred shading. 我只是对延迟着色有一些疑问。 I have gotten to the point where I have the Color, Position ,Normal and textures from the Multiple Render Targets. 我已经到了可以从多个渲染目标获得颜色,位置,法线和纹理的地步。 My questions pertain to what I do next. 我的问题与下一步工作有关。 To make sure that I have gotten the correct data from the textures I have put a plane on the screen and rendered the textures onto that plane. 为了确保从纹理中获取了正确的数据,我在屏幕上放置了一个平面并将纹理渲染到该平面上。 What I don't understand is how to manipulate those textures so that the final output is shaded with lighting. 我不了解的是如何操作这些纹理,以便最终输出被光照着色。 Do I need to render a plane or a quad that takes up the screen and apply all the calculations onto that plane? 我是否需要渲染一个占据屏幕的平面或四边形并将所有计算应用于该平面? If I do that I am kind of confused how I would be able to get multiple lights to work this way since the "plane" would be a renderable object so for each light I would need to re-render the plane. 如果这样做,我会感到困惑,因为“平面”将是一个可渲染的对象,因此我将如何使多个光源以这种方式工作,因此对于每个光源,我都需要重新渲染该平面。 Am I thinking of this incorrectly? 我是不是在想这个错误?

You need to render some geometry to represent the area covered by the light(s). 您需要渲染一些几何图形以表示被灯光覆盖的区域。 The lighting term for each pixel of the light is accumulated into a destination render target. 光线的每个像素的照明条件累积到目标渲染目标中。 This gives you your lit result. 这给您点燃的结果。

There are various ways to do this. 有多种方法可以做到这一点。 To get up and running, a simple / easy (and hellishly slow) method is to render a full-screen quad for each light. 要启动并运行,一种简单/简单(且非常慢的方法)的方法是为每个光源渲染全屏四边形。

Basically: 基本上:

  • Setup: Render all objects into the g-buffer, storing the various object properties (albedo, specular, normals, depth, whatever you need) 设置:将所有对象渲染到g缓冲区中,存储各种对象属性(反照率,镜面反射,法线,深度,所需的任何东西)
  • Lighting: For each light: 照明:对于每个照明:
    • Render some geometry to represent the area the light is going to cover on screen 渲染一些几何图形以表示光将要在屏幕上覆盖的区域
    • Sample the g-buffer for the data you need to calculate the lighting contribution (you can use the vpos register to find the uv) 采样g缓冲区以获取计算照明贡献所需的数据(可以使用vpos寄存器查找uv)
    • Accumulate the lighting term into a destination render target (the backbuffer will do nicely for simple cases) 将照明条件累积到目标渲染目标中(在简单情况下,后缓冲效果很好)

Once you've got this working, there's loads of different ways to speed it up (scissor rect, meshes that tightly bound the light, stencil tests to avoid shading 'floating' regions, multiple lights drawn at once and higher level techniques such as tiling). 一旦完成这项工作,就会有许多不同的方式来加快它的速度(剪刀矩形,紧密绑定光的网格物体,模版测试以避免阴影“浮动”区域,一次绘制多个光源以及更高水平的技术,例如平铺)。

There's a lot of different slants on Deferred Shading these days, but the original technique is covered thoroughly here : http://http.download.nvidia.com/developer/presentations/2004/6800_Leagues/6800_Leagues_Deferred_Shading.pdf 如今,“递延着色”有很多不同的倾向,但是原始技术已在此处进行了全面介绍: http : //http.download.nvidia.com/developer/presentations/2004/6800_Leagues/6800_Leagues_Deferred_Shading.pdf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM