Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@luma.gl/shadertools
Advanced tools
@luma.gl/shadertools is a collection of tools for working with WebGL shaders. It provides utilities for shader transpilation, shader module management, and shader debugging, making it easier to develop and manage complex WebGL applications.
Shader Transpilation
This feature allows you to transpile GLSL code to be compatible with different versions of WebGL. The code sample demonstrates how to transpile a simple GLSL fragment shader to WebGL2.
const { transpileShader } = require('@luma.gl/shadertools');
const glslCode = `
void main() {
gl_FragColor = vec4(1.0);
}
`;
const transpiledCode = transpileShader(glslCode, { target: 'webgl2' });
console.log(transpiledCode);
Shader Module Management
This feature helps in managing and assembling shader modules. The code sample shows how to assemble vertex and fragment shaders along with additional shader modules.
const { assembleShaders } = require('@luma.gl/shadertools');
const vs = `
attribute vec4 position;
void main() {
gl_Position = position;
}
`;
const fs = `
void main() {
gl_FragColor = vec4(1.0);
}
`;
const modules = [
{ name: 'module1', vs, fs }
];
const assembledShaders = assembleShaders({ vs, fs, modules });
console.log(assembledShaders);
Shader Debugging
This feature provides tools for parsing and debugging GLSL code. The code sample demonstrates how to parse a simple GLSL fragment shader to get an abstract syntax tree (AST) representation.
const { parseGLSL } = require('@luma.gl/shadertools');
const glslCode = `
void main() {
gl_FragColor = vec4(1.0);
}
`;
const parsedShader = parseGLSL(glslCode);
console.log(parsedShader);
glslify is a module system for GLSL that allows you to write modular and reusable shader code. It is similar to @luma.gl/shadertools in that it helps manage shader code, but it focuses more on modularity and reusability rather than transpilation and debugging.
three.js is a popular 3D library that includes extensive support for shaders. While it is a more comprehensive library for 3D graphics, it also provides utilities for shader management and debugging, similar to @luma.gl/shadertools.
glslang is a reference front-end for GLSL, providing tools for parsing and compiling GLSL code. It is similar to @luma.gl/shadertools in its focus on shader parsing and debugging, but it is more low-level and closer to the Vulkan ecosystem.
This is the shader module system module for luma.gl.
See luma.gl for documentation.
7.4.0-alpha.2
FAQs
Shader module system for luma.gl
The npm package @luma.gl/shadertools receives a total of 169,540 weekly downloads. As such, @luma.gl/shadertools popularity was classified as popular.
We found that @luma.gl/shadertools demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers 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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.