Running a compute shader – desaturation (grayscale)
The first task we will tackle is a simple conversion of an input image to grayscale (color desaturation); the input image can be an image file or any texture resource (such as a rendered scene). The formula is used in subsequent recipes for filters, such as the Sobel edge detector.
Getting ready
For this recipe we just need to have a Direct3D device and device context available, and an image to process. The image used for illustration here is available within the downloadable content from Packt's website.
How to do it…
First we will prepare our input and output shader resources. The compute shader will take a Shader Resource View (SRV) of a Texture2D
variable as input and an Unordered Access View ...
Get Direct3D Rendering Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.