Gist 8b0da6e9acc76b7251547a0ad1dad5f1
✓ Published0🌍 Public
FFrozenfire92
Last edited Oct 4, 2016
Created on Oct 9, 2016
This shader example demonstrates a technique for snapping pixel-art sprites to a fixed pixel grid in a 3D game engine. It shows how vertex positions are aligned to integer multiples of a tunable “pixels per unit” value prior to rendering, preventing visual distortion or shimmering when sprites are placed in world space. The code is written for Unity’s proprietary shader language and uses a Cginc/UnityCG-style vertex and fragment program, aligning object-space vertices before passing them through the standard MVP matrix. The shader samples a main texture and optionally an external alpha texture, tinting the result with a `_Color` property.
AI-generated description