All examples · Shaders and post

Per-sprite uniforms

What this example shows

One material, fifteen sprites, fifteen different settings of it. The effect compiles once; each sprite passes its own uniforms, which are laid over the material's every frame. Without this, varying a single number would mean a material per sprite, and a material per sprite is a compile of the identical shader per sprite.

It is not free, and the cost is worth knowing: a sprite that brings its own numbers is a draw of its own, because a batch writes one set of them. Fifteen is nothing. The title is a text carrying the same material, and all of its letters carry the same one, so it stays a single draw rather than one per character.

Starting