ScratchFX

A browser-based scratch-off game designed to feel like scratching a real lottery ticket.

Highlights

  • Real-time scratch interaction that reveals prize

  • Weighted prize system that mirrors real lottery odds

  • Mouse and touch input for precise, responsive control

  • Runs directly in the browser with no installation required

View Source Code
Play Now!
Scratch FX: Shader vs Object Instantiation
Tap to expand

A short breakdown of ScratchFX’s shift from object spawning to a shader-driven scratch effect.

Core Goal

Reveal a hidden image through player input while keeping the effect responsive and performant.

Initial Approach

Mask prefabs were instantiated at the cursor while scratching, visually erasing the surface through overlapping objects.

Instantiate(maskPrefab, clickPosition, Quaternion.identity);
Why It Didn’t Scale

Per-frame instantiation introduced unnecessary overhead and scene clutter, and made tuning scratch behavior harder than it needed to be.

Final Approach

A custom shader samples a scratch mask texture and drives transparency directly in the material, revealing the image without spawning objects.

col.a *= (1 - mask);
Result

Cleaner logic, predictable performance, and faster iteration by turning the scratch effect into a data-driven visual system.