How
do I debug a shader?
Debugging
a shader is a bit complicated because it’s running on the GPU. Typically there’s no easy communication back
to the CPU from the GPU. Shaders don’t provide a “printf” command to output
debugging information to a console.
However,
there are some options:
- In the fragment shader, set the fragment
to a specific colour when a bug occurs (a shader version of “printf”)
- Use transform feedback to debug vertex
shaders
- Use a debugging tool like Nvidia Nsight
- There are other tools like Shader
Maker that
can be used to develop shaders