Graphics Reference
In-Depth Information
by render targets. However, SSAA is certainly effective, and it may be worthwhile to pro-
vide as an option if no other type of AA is implemented.
11.5.2 Multisampled Anti-Aliasing
As mentioned previously, breaking the rendering pipeline into 2 or 3 passes makes it in-
compatible with MSAA. However, we can still use hardware support for MSAA to produce
an antialiased output, without having to resort to supersampling.
Let's start by analyzing the g-buffer pass. If we make our g-buffer render targets
multisampled and enable MSAA while rendering them, this gives us a multisampled de-
scription of the surface and material properties. This means that for pixels where a triangle
doesn't have complete coverage, the g-buffer properties for all triangles that were raster-
ized will be contained in the individual subsamples. Thus, if we sample and light all of
these subsamples individually and then filter or average the results, we would produce an
antialiased image. A sample function for performing this is provided in Listing 11.15.
// Textures
Texture2DMS<float4> NormalTexture
: register( t0 );
Texture2DMS<float4> DiffuseAlbedoTexture
: register ( t1 );
Texture2DMS<float4> SpecularAlbedoTexture
: register ( t2 );
Texture2DMS<float4> PositionTexture
: register ( t3 );
II Helper function for extracting G-Buffer attributes
void GetGBufferAttributes( in float2 screenPos,
in int sslndex,
out float3 normal,
out float3 position,
out float3 diffuseAlbedo,
out float3 specularAlbedo,
out float specularPower )
{
// Determine our indices for sampling the texture based
// on the current screen position
int2 samplePos = int2( screenPos.xy );
normal = NormalTexture. Load ( samplePos, sslndex).xyz;
position = PositionTexture. Load ( samplePos, sslndex).xyz;
diffuseAlbedo = DiffuseAlbedoTexture.Load(samplePos, sslndex).xyz;
float4 spec = SpecularAlbedoTexture. Load (samplePos, sslndex);
specularAlbedo = spec.xyz;
specularPower = spec.w;
}
// Lighting pixel shader that performs MSAA resolve
float4 PSMain( in float4 screenPos : SVPosition ) : SVTargete
Search WWH ::




Custom Search