I created a shader quine, a fragment shader without input (textures or models) that produces a copy of its own source code as its output, on Shadertoy.

You can find (the full source of) the fragment shader here: https://www.shadertoy.com/view/MlGcRz.

The ‘trick’ of this shader is contained in the data of array c. The shader can decode array c to get font-data and display characters, decode a part of the data that contains the shader code itself, and finally, the shader is also able to display the data of the array as the data itself.

A much better, more extensive, and very readable explanation of (a slightly longer version of) this shader can be found in this blog post: “Dissecting a Shader Quine“.

Similar posts

If you like this post, you may also like one of my other posts:

A shader quine