All examples · Shaders and post

Shader file

What this example shows

An effect in its own file, which is how one stops belonging to the scene that first needed it. A scene keeps the key, never the source, so the same effect can be shared between scenes, opened in an editor that colours it, and changed without touching a line of game code.

The file is ordinary WGSL with a few comment lines on top: @shader says which family it is for, @uniform declares a knob and its default, and @wgsl / @glsl open the two halves. The header is read from the whole file and never from inside a half, because a contract written twice is two things that can drift.

Left is the file as written. Middle is the same file with the scene having the last word on two of its knobs. Right is a second file, for models.

Starting