指向多个渲染目标
使用多个渲染目标有什么意义吗?难道不能先绘制一个渲染目标并将其存储在纹理中,然后再清除目标并再次使用它吗?
Is there any point in using multiple render targets? Couldn't one just draw to one render target and store that in a texture before clearing the target and using it again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
了解 MRT 的关键是您不会将完全相同的数据绘制到所有渲染目标。
像素着色器只能输出 4 个浮点值,通常您将使用这 4 个值在给定点生成颜色。然而,您可能想要输出深度数据或普通数据,因此您使用这 4 个浮点值来表示您可能需要的其他信息。
优点是使用 MRT,您只需绘制一次场景并输出到各个渲染目标,因此在一个渲染通道中,您可以输出到一个渲染目标,该渲染目标将接收漫反射颜色数据,另一个渲染目标将接收普通数据,第三个渲染目标将接收深度数据。请参阅下文以更好地理解我的意思:
这实际上是 RGBA 值变为其他值的情况事物,例如 RGB,因为正在绘制的多边形法线的 X、Y、Z。
使用 MRT 有一些问题,例如所有渲染目标必须具有相同的位深度,并且您确实开始使用它来推动 GPU 纹理填充率,但总体而言,优点胜过缺点。
The key thing to understand about MRT is that you're not drawing the exact same data out to all the render targets.
A pixel shader can only output 4 floating point values, typically you'll use these 4 values to generate a colour at that given point. However you may want to output depth data or normal data instead, so you use those 4 floating point values to represent other information you might need.
The advantage is with MRT you only need to draw the scene once and output to the various render targets, so in one render pass you can output to one render target which will recieve the diffuse colour data, another render target will recieve the normal data, and a third render target will recieve depth data. See below to get a better understanding of what I mean:
It's really a case of the RGBA values becoming other things, for example the RGB because X,Y,Z of the normal of the polygon being drawn.
There are some catches with using MRT, such as all your render targets have to have the same bit depth and you do start pushing your GPUs texture fillrate with it but overall the advantages outway the pitfalls.
当您想要渲染一件几何体并将不同的输出收集到单独的渲染目标中时,将使用多个渲染目标。
如今,这项技术主要用于实现延迟着色。在延迟着色中,多个渲染目标存储照明信息,例如表面法线、镜面反射颜色和镜面指数,以及深度和漫反射颜色信息。组合渲染目标的集合称为 G 缓冲区。
请参阅6800 Leagues Under the Sea (Hargreaves & Harris 2004) 用于延迟着色和 G 缓冲液的底漆。
Multiple render targets are used when you want to render one piece of geometry and collect different outputs into separate render targets.
Today this technology is primarily used to implement deferred shading. In deferred shading the multiple render targets store lighting information, such as surface normal, specular color and specular exponent, as well as depth and diffuse color information. The set of combined render targets is referred to as a G-Buffer.
See 6800 Leagues Under the Sea (Hargreaves & Harris 2004) for a primer of Deferred Shading and G-Buffers.