Code Monkey home page Code Monkey logo

lutlight2d's Introduction

LutLight2D

Stylized pixel art lighting shader for Unity2D using a color replacement technique.
It keeps the original colors of the palette and can create unusual stylization effects.

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


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

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

Install via PackageManager https://github.com/NullTale/LutLight2D.git

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.

lutlight2d's People

Contributors

nulltale avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.