🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

glslify

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glslify

A node.js-style module system for GLSL!

7.1.1
latest
Version published
Weekly downloads
241K
8.22%
Maintainers
19
Weekly downloads
 
Created

What is glslify?

glslify is a module system for GLSL (OpenGL Shading Language) that allows you to write modular shader code. It enables you to import and export GLSL code, making it easier to manage and reuse shader code across different projects.

What are glslify's main functionalities?

Importing GLSL Modules

This feature allows you to import GLSL code from other files, making it easier to manage and reuse shader code. The `glslify` function takes the path to a GLSL file and returns the shader code as a string.

const glslify = require('glslify');
const shader = glslify('./shader.glsl');

Using GLSL Modules

You can use `glslify` to import both vertex and fragment shaders, allowing you to modularize your shader code. This makes it easier to maintain and update your shaders.

const glslify = require('glslify');
const vertexShader = glslify('./vertex.glsl');
const fragmentShader = glslify('./fragment.glsl');

Inlining GLSL Code

You can also inline GLSL code directly within your JavaScript files using template literals. This is useful for small shaders or for quick prototyping.

const glslify = require('glslify');
const shader = glslify(`
  precision mediump float;
  void main() {
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
  }
`);

Transforming GLSL Code

glslify supports transforming GLSL code using plugins. In this example, the `glslify-hex` plugin is used to transform the GLSL code. This allows you to extend the functionality of glslify with custom transformations.

const glslify = require('glslify');
const shader = glslify('./shader.glsl', { transform: ['glslify-hex'] });

Other packages similar to glslify

FAQs

Package last updated on 02 Sep 2020

Did you know?

Socket

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.

Install

Related posts