
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
@raycaster/shaders
Advanced tools
LYGIA is a shader library of reusable functions that will let you prototype, port or ship a project in just few minutes. It's very granular, flexible and efficient. Support multiple shading languages and can easily be added to any project, enviroment or framework of your choice.
Here are a couple of integrations examples:
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/decimate.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 = decimate(color, 20.);
color += circle(st, .5, .1);
gl_FragColor = vec4(color, 1.0);
}
Then you need to resovle this dependencies, the fastest way would be to drag&drop your shader file here:
The other options is using a local version that then you can bundle into your project, or use the server to resolve the dependencies online.
If you are working locally in an environment that can resolve #include dependencies, just clone LYGIA into 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
or you may clone LYGIA without the git history and reduce the project size (9MB+) with the following command:
npx degit https://github.com/patriciogonzalezvivo/lygia.git lygia
If you are working on a cloud platform you probably 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"
</script>
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);
This this function can also resolve dependencies to previous versions of LYGIA by using this pattern lygia/vX.X.X/... on you dependency paths. For example:
#include "lygia/v1.0.0/math/decimation.glsl"
#include "lygia/v1.1.0/math/decimation.glsl"
Learn more about LYGIA and how to use it from these examples:
For more information, guidance, or feedback about using LYGIA, join #Lygia channel on shader.zone discord.
The functions are divided into different categories:
math/: general math functions and constants: PI, SqrtLength(), etc.space/: general spatial operations: scale(), rotate(), etc.color/: general color operations: luma(), saturation(), blend modes, palettes, color space conversion, and tonemaps.animation/: animation operations: easinggenerative/: generative functions: random(), noise(), etc.sdf/: signed distance field functions.draw/: drawing functions like digits(), stroke(), fill, etc/.sample/: sample operationsfilter/: typical filter operations: different kind of blurs, mean and median filters.distort/: distort sampling operationslighting/: different lighting models and functions for foward/deferred/raymarching renderinggeometry/: operation related to geometries: intersections and AABB accelerating structures.morphological/: morphological filters: dilation, erosion, alpha and poisson fill.There are some functions whose behavior 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 if you are interested in 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);
...
}
#include "path/to/file.*lsl" which is defined by Khronos GLSL standard and requires a typical C-like pre-compiler MACRO which is easy to implement with just basic string operations to resolve dependencies.Here you can find some implementations on different languages:
C#:
. GLSLIncludes a small utility to add the include feature to glsl by z0rg.
C++:
. VERA's routines for resolving GLSL dependencies.
Python:
JavaScript:
. vanilla JS (online resolver) This small file brings resolveLygia() which takes a string or string[] and parses it, solving all the #include dependencies into a single string you can load on your shaders. It also has a resolveLygiaAsync() version that resolves all the dependencies in parallel. Both support dependencies to previous versions of LYGIA by using this pattern lygia/vX.X.X/... on you dependency paths.
. npm module (online resolver) by Eduardo Fossas. This is bring the same resolveLygia() and resolveLygiaAsync() function but as a npm module.
. vite glsl plugin (local bundle) by Ustym Ukhman. Imports .glsl local dependencies, or load inline shaders through vite.
. esbuild glsl plugin (local bundle) by Ricardo Matias. Imports local .glsl dependencies through esbuild.
. webpack glsl plugin (local bundle) by Ryan Grieve that imports local .glsl dependencies through webpack.
myFunc.glsl contains myFunct(). There are some files that just include a collection of files inside a folder with the same name. For example: color/blend.glsl
// which includes
color/blend/*.glsl
*.glsl) and HLSL (*.hlsl), but we are slowly extending to WGSL (*.wgsl), CUDA (*.cuh) and Metal (*.msl). math/mirror.glsl
math/mirror.hlsl
math/mirror.wgsl
math/mirror.msl
math/mirror.cuh
#define options
/*
contributors: <FULL NAME>
description: [DESCRIPTION + URL]
use: <vec2> myFunc(<vec2> st, <float> x [, <float> y])
options:
- MYFUNC_TYPE
- MYFUNC_SAMPLER_FNC()
*/
FNC_ is followed with the function name:
#ifndef FNC_MYFUNC
#define FNC_MYFUNC
float myFunc(float in) {
return in;
}
#endif
#defines. Probably the most frequent use is templating the sampling function for reusability. The #define options start with the name of the function, in this example MYFUNC_. They are added as options: in the header.
#ifndef MYFUNC_TYPE
#define MYFUNC_TYPE vec4
#endif
#ifndef MYFUNC_SAMPLER_FNC
#define MYFUNC_SAMPLER_FNC(TEX, UV) texture2D(TEX, UV)
#endif
#ifndef FNC_MYFUNC
#define FNC_MYFUNC
MYFUNC_TYPE myFunc(SAMPLER_TYPE tex, vec2 st) {
return MYFUNC_SAMPLER_FNC(tex, st);
}
#endif
SAMPLER_TYPE, mat4, mat3, mat2, vec4, vec3, vec2, float, ivec4, ivec3, ivec2, int, bool
/*
...
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);
}
#endif
LYGIA has 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 belongs to those that support it. For that it uses a 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 License software.
It's also possible to get a permanent commercial license hooked to a single and specific version of LYGIA.
If you have doubts please reaching out to patriciogonzalezvivo at gmail dot com
Created and mantained 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 brilliant and generous people like: Inigo Quiles, Morgan McGuire, Alan Wolfe, Hugh Kennedy, Matt DesLauriers, and many others.
Sign up for the news letter below, join the LYGIA's channel on Discord or follow the Github repository
FAQs
Unknown package
We found that @raycaster/shaders demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.