Drop shader to Resolve

LYGIA Shader Library

Tired of searching, porting and/or reimplementing the same functions over and over? LYGIA is a shader library of reusable functions that can be include easily on your projects. LYGIA is very granular, designed for reusability, performance and flexibility. And can be easily be added to any projects and frameworks.

How to use it?

In your shader #include the functions you need:

#ifdef GL_ES precision mediump float; #endif uniform vec2 u_resolution; uniform float u_time; #include "lygia/space/ratio.glsl" #include "lygia/math/decimation.glsl" #include "lygia/draw/circle.glsl" void main(void) { vec3 color = vec3(0.0); vec2 st = gl_FragCoord.xy/u_resolution.xy; st = ratio(st, u_resolution); color = vec3(st.x,st.y,abs(sin(u_time))); color = decimation(color, 20.); color += circle(st, .5, .1); gl_FragColor = vec4(color, 1.0); }

LYGIA Locally

If you are working locally on an ecosystem that can resolve #include dependencies, just clone LYGIA in your project relative to the shader you are loading:

    git clone https://github.com/patriciogonzalezvivo/lygia.git

or as a submodule:

    git submodule add https://github.com/patriciogonzalezvivo/lygia.git

LYGIA on the cloud

If you are working on a cloud platform probably you want to resolve the dependencies without needing to install anything. Just add a link to https://lygia.xyz/resolve.js (JS) or https://lygia.xyz/resolve.esm.js (ES6 module):

    <!-- as a JavaScript source -->
    <script src="https://lygia.xyz/resolve.js"></script>

    <!-- Or as a ES6 module -->
    <script type="module">
        import resolveLygia from "https://lygia.xyz/resolve.esm.js"

To then resolve the dependencies by passing a string or strings[] to resolveLygia() or resolveLygiaAsync():

    // 1. FIRST

    // Sync resolver, one include at a time
    vertSource = resolveLygia(vertSource);
    fragSource = resolveLygia(fragSource);

    // OR.

    // ASync resolver, all includes in parallel calls
    vertSource = resolveLygiaAsync(vertSource);
    fragSource = resolveLygiaAsync(fragSource);

    // 2. SECOND

    // Use the resolved source code 
    shdr = createShader(vertSource, fragSource);

Integrations examples

Learn more about how to use it from this examples:

For more information, guidance or feedback about using LYGIA, join #Lygia channel on shader.zone discord.

How is it organized?

The functions are divided in different categories:

Flexible how?

There are some functions whose behaviour can be changed using the #defines keyword before including it. For example, gaussian blurs are usually are done in two passes. By default, these are performed on their 1D version, but in the case you are interested on using a 2D kernel, all in the same pass, you will need to add the GAUSSIANBLUR_2D keyword this way:

    #define GAUSSIANBLUR_2D
    #include "filter/gaussianBlur.glsl"

    void main(void) {

        vec2 pixel = 1./u_resolution;
        color = gaussianBlur(u_tex0, uv, pixel, 9);

Design Principles

Here you can find some implementations on different languages: * C++: - VERA's routines for resolving GLSL dependencies. * Python - Small and simple routing to resolve includes * JavaScript: - vanilla JS online resolver This small file brings resolveLygia() which takes a string or string[] and parse it solving all the #include dependencies into a single string you can load on your shaders. - vite glsl plugin by Ustym Ukhman. Imports .glsl local dependencies, or load inline shaders through vite - esbuild glsl plugin by Ricardo Matias. Import local .glsl dependencies through esbuild. - webpack glsl plugin by Ryan Grieve. Import local .glsl dependencies through webpack.

    // which includes


    original_author: <FULL NAME>
    description: [DESCRIPTION + URL]
    use: <vec2> myFunc(<vec2> st, <float> x [, <float> y])
        - MYFUNC_TYPE

    #ifndef FNC_MYFUNC
    #define FNC_MYFUNC

    float myFunc(float in) {
        return in;


    #ifndef MYFUNC_TYPE
    #define MYFUNC_TYPE vec4

    #define MYFUNC_SAMPLER_FNC(TEX, UV) texture2D(TEX, UV)

    #ifndef FNC_MYFUNC
    #define FNC_MYFUNC
    MYFUNC_TYPE myFunc(sampler2D tex, vec2 st) {
        return MYFUNC_SAMPLER_FNC(tex, st);

    use: myFunc(<vec2> st, <vec2|float> x[, <float> y])

    #ifndef FNC_MYFUNC
    #define FNC_MYFUNC
    vec2 myFunc(vec2 st, vec2 x) {
        return st * x;

    vec2 myFunc(vec2 st, float x) {
        return st * x;

    vec2 myFunc(vec2 st, float x, float y) {
        return st * vec2(x, y);


LYGIA have a long way to go. Your support will be appreciated and rewarded (all contributors are automatically added to the commercial license ). This support can take multiple forms:


LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore any non-commercial rule of the Prosperity Licensed software.

Comming soon will be possible to get a permanent comercial license hook to a single and specific version of LYGIA.


Created and mantain by Patricio Gonzalez Vivo( Mastodon | Twitter | Instagram | GitHub ) and every direct or indirect contributors to the GitHub. This library has been built over years, and in many cases on top of the work of brillant and generous people like: Inigo Quiles, Morgan McGuire, Alan Wolfe, Hugh Kennedy, Matt DesLauriers and many others.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository