Shader

Stacker

About

Sprite stacking is a 2.5D technique done by drawing cross sections of a 3D object at a slight offset for each layer.

Traditionally, this is done by drawing each layer as a seperate sprite. Shader stacker speeds up this process by calculating each pixel on the GPU. The library is written in GLSL for the Godot engine and includes support for viewing models directly in the scene editor.

Get the code on Github or add the package through the Godot Asset Library.

Documentation

Getting Started

Download the library either by adding the repository to your Godot project or through the asset manager. If you want to learn through example, open example.tscn and take a look.

Creating a Stacked Sprite Sheet

MagicaVoxel is free and supports exporting to one with the slice option. Other software exists and you also have the option of making one from scratch.

Stacked Sprite

A template scene exists in the scenes folder of the library. Instantiate one of them in your scene.

Set your slice sheet via the slice_sheet variable in the inspector. Then set the amount of rows and columns your sheet has. For MagicaVoxel exports, you just need to set the row value to be equal to the Z value of your model.

Z index is dynamically calculate to maintain perspective. If you wish to set the z value manually, enable the static_z option.

center is used to center the sprite around a layer other than the bottom-most one. Handy for making holes.

If anything ever looks off in the editor, try closing and re-opening the scene.

Billboards

Billboards are sprites that always face the camera. You'll want to make objects billboards if they require more detail than sprite stacking can handle. Things like the player or enemies are common choices for this. It can be handy to convert spherical objects to billboards to improve performance.

Billboards have two options in the inspector.

static_z stops the z index from being calculate dynamically. Handy if the billboard is a child of an object which does dynamically calculate it's index.

parent_bonded treats the billboard as if it is attached to a parent stacked sprite. Maintining its perspective when the camera is rotating. Ex: Leaves child of a tree = bonded. Player child of a level = not bonded.

SsGlobals

Make sure this is autoloaded as a singleton in your project. This manages the cam_pitch which you can adjust to make your game more isometric. Currently it uses the Moppin_ method which is extremely slow.

Inspirations

These projects do not use the Shader Stacker library, but played a big part in inspiring me to make it. They're great examples of how cool the effect can be.