SHDR

Debug glsl fragment shaders on the CPU

2017 - present
glsl
javascript
openGL
webGL

shdr (2017 - present)

Debug glsl fragment shaders on the CPU

An experimental emulator for glsl fragment shaders that runs on the CPU. shdr is useful when standard GPU debugging methods won't cut it; it lets you inspect variables on a standard CPU debugger. The shader output can also be exported to a png file.

Motivations

To debug glsl, the usual method is to simply dump suspect variables out to gl_FragColor. This provides fast visual feedback for where things might be going wrong. It is usually the best method for debugging glsl, and is particularly useful in conjunction with a tool like ShaderToy.

This debugging method stops being effective when your shaders become more complex, particularly when you need to debug multiple variables. Sometimes, you just want to look at your variables in a standard debugger, or to dump them out to the console.

I think the Visual Studio Code javascript debugger is the best available for any IDE or programming language, and it's what I've been testing this on. Javascript is also a good choice as an emulation language, since it already has very similar syntax to glsl.

This library may also be useful as a server-based program that can be used to generate static images with glsl, particularly in cases when an OpenGL context is impossible to create.