Skip to content

NullTale/LutLight2D

Repository files navigation

LutLight2D

Dev by NullTale
Itch Twitter Discord Boosty

• Stylized pixel art lighting via color replacement.
It keeps the original colors of the palette and can create unusual stylization effects.

• Web Demo https://nulltale.itch.io/dungeon-tale

• Tested with Unity 2021, 2022, uses Urp 2D Renderer and Shader Graph.

Asset Store Forum

_cover

Examples

Pattern shading Oil6

Sharp gradient shading Fantasy 24

In shadow visible objects Lospec500

In shadow outline FUZZYFOUR

How it works

The general idea is to make each color have its own shading gradient defined manually
like it is done in most pixel art palettes.


The shader does this using a set of Lut tables generated from gradient ramps.
The color for replacement is taken from the tables depending on the brightness from the lighting texture.


Colors from the tables can be taken with interpolation blending, to make smooth transitions.
By specify color ramps and using material options, effects as in the examples can be achieved.


Installation and use

Install via Unity PackageManager

https://github.com/NullTale/LutLight2D.git

Bu default the Shader uses the lighting texture from the Urp 2D Renderer so Urp Asset must be configured.

First needed to create the LutLight2D Asset, it will generate a texture with a set of lut tables for the material.


It will create a material and Grayscale Ramps for it, which should already be enough to apply the material.


Next step is to set the gradient table for each color from the palette.
After the gradients are set, need to press the Bake button to apply the result if it was not done automatically.

Result with the character sprite in the lospec500 palette.

The Ramps file is a common .png which contains shading gradient for each color from the palette, starting from the original, lightest, to the darkest.

Colors also can have alpha channel.


Now the character shaded with black color from the palette, and his light areas like eyes and face are visible in the shadows.
By changing the Color Ramps, unusual materials can be made that are only visible in shadow or light, as in the example for the lospec500 palette.

Examples with other applications can be found in the package samples.