advanced

#38 Parallax Scrolling

Multi-layer scrolling with depth

Parallax scrolling creates depth illusion by moving background layers at different speeds — distant layers scroll slowly while near layers move fast. This shader builds four procedural layers: a twinkling star field, distant mountains, mid-ground hills with tree silhouettes, and a foreground with grass. Each layer offset is uv.x + iTime * speed, where speed increases for nearer layers.

Key Concepts

Try this shader live in the Shader Sandbox editor with real-time preview.
Open in Sandbox

Source Code


    
← Previous 2D Platformer Lighting Next → Portal Vortex

All Tutorials