Repolode
patriciogonzalezvivo

patriciogonzalezvivo/lygia

A granular shader function library for GLSL, HLSL, Metal, WGSL, WebGL and CUDA, with each file holding one reusable function.

Stars
3,480
Forks
226
Open issues
26
Last commit
14 days ago

What is it?

LYGIA is a shader library of reusable functions for math, color, space transforms, noise, signed distance fields, drawing, filtering and lighting. Each file holds a single function, so developers can include only what a shader needs using a standard #include directive.

The library is organized by language, with separate files for GLSL, HLSL, Metal, WGSL and CUDA, and the same functions are maintained across them. Some functions can be tuned at compile time with #define options, such as switching a Gaussian blur to a 2D kernel or changing its sampling function.

LYGIA can be used locally by cloning the repository or as a git submodule, installed through npm, or resolved online via a hosted resolver script for browser-based platforms such as CodePen. The repository also includes a prune.py script to keep only the languages a project needs.

Key features

  • 01Granular design with one function per file across multiple shading languages.
  • 02Resolves #include dependencies locally or through a hosted online resolver.
  • 03Functions can be configured with #define options before inclusion.
  • 04Supports versioned includes to pin to earlier LYGIA releases.
  • 05Includes a prune.py script to keep only the languages you need.
  • 06Ships an npm package for JavaScript projects.

Use cases

  • Adding noise, easing or color utilities to a WebGL or WebGPU project without writing them from scratch.
  • Porting a shader from GLSL to HLSL, Metal or WGSL while reusing the same helper functions.
  • Building generative art or creative coding sketches in p5.js, Three.js or Unity.
  • Sharing shader code online in CodePen or Observable with dependencies resolved automatically.

Quick start

  1. 1

    Clone LYGIA into your project next to the shader that includes it

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

    Or download it without git history using degit

    npx degit https://github.com/patriciogonzalezvivo/lygia.git lygia
  3. 3

    In your shader, #include the functions you need, such as "lygia/space/ratio.glsl"

Things to know

  • It is a shader function library, not a standalone application, so you must integrate it into your own shader pipeline.
  • The license is dual-licensed and not a plain open-source license, so check the license terms before commercial use.

Topics

FAQ

What is lygia?
A granular shader function library for GLSL, HLSL, Metal, WGSL, WebGL and CUDA, with each file holding one reusable function. LYGIA is a shader library of reusable functions for math, color, space transforms, noise, signed distance fields, drawing, filtering and lighting. Each file holds a single function, so developers can include only what a shader needs using a standard #include directive.
Is lygia free to use? What license does it have?
lygia is open source under the Other license. Check the license terms before using it in commercial products.
Is lygia still maintained?
Actively maintained. The last commit to lygia was on Oct 24, 2026.
What can I use lygia for?
Adding noise, easing or color utilities to a WebGL or WebGPU project without writing them from scratch. Porting a shader from GLSL to HLSL, Metal or WGSL while reusing the same helper functions. Building generative art or creative coding sketches in p5.js, Three.js or Unity. Sharing shader code online in CodePen or Observable with dependencies resolved automatically.
How do I install lygia?
Clone LYGIA into your project next to the shader that includes it: git clone https://github.com/patriciogonzalezvivo/lygia.git Or download it without git history using degit: npx degit https://github.com/patriciogonzalezvivo/lygia.git lygia In your shader, #include the functions you need, such as "lygia/space/ratio.glsl"
Where can I get lygia?
The source code and installation instructions are on GitHub: https://github.com/patriciogonzalezvivo/lygia

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects