Book Image

Direct3D Rendering Cookbook

By : Justin Stenning, Justin Stenning
Book Image

Direct3D Rendering Cookbook

By: Justin Stenning, Justin Stenning

Overview of this book

Table of Contents (19 chapters)
Direct3D Rendering Cookbook
About the Author
About the Reviewers
Further Reading

Incorporating multisample anti-aliasing

One of the problems with classic deferred rendering is that to support the built-in hardware anti-aliasing, we must implement some extra shader code to correctly sample from the MSAA G-Buffer. More recent improvements in Direct3D have made this problem easy to solve by using the SV_SampleIndex and SV_Coverage pixel shader system-value semantics to run the shader for each sample and to determine which samples are covered by the current fragment.

Getting ready

It is necessary that all render targets are created with multisampling enabled. This includes the render targets of the G-Buffer, the depth buffer, and also the light accumulation buffer of the light renderer. Our implementations of the GBuffer and LightRenderer classes already support multisampling provided we pass in the correct sample description to the GBuffer constructor, for example, new SampleDescription(4, 0).

Our existing ScreenAlignedQuadRenderer must be modified to use the multisampling...