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 us开发者_JAVA百科ing it again?
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.
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.
精彩评论