Compute shaders are used, as the name suggests, for general mathematical calculations. They are executed in (local) groups of a defined, three-dimensional size, which may have access to a common set of data. At the same time, many local groups can be executed to generate results faster.
Writing compute shaders
How to do it...
- Create a text file. Select a name for the file, but use a comp extension for it (for example, shader.comp).
- Insert #version 450 in the first line of the file.
- Using an input layout qualifier, define the size of the local workgroup:
layout( local_size_x = <x size>, local_size_y = <y size>, local_size_z = <z size> ) in;
- Define uniform variables that correspond to descriptor resources created in the application. To define...