New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

glsl-conditional-loader

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glsl-conditional-loader

Webpack loader for conditional includes in glsl files

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

glsl conditional loader

A webpack loader for glsl files that support conditional #include tags. The loader loads a function that receives a properties object.

Configuration

In webpack.config:

module:{
    rules:{
        {
            test: /\.(glsl|frag|vert)$/,
            use: [
                {
                    loader: 'glsl-conditional-loader',
                    options: {
                        verbose: false, //default = false
                        es5: true //default = true
                    },
                }
            ],
        }
    }
}
options
  • verbose : when true, log messages will be printer to terminal during parsing
  • es5 : when false, an es6 arrow function will be used with template literals. when true, a regular es5 function with string concatenation will be used.

Usage

In glsl files

in your .glsl files, include other files with the #include tag and relative path add if statement to make this include conditional.


#include ./path/to/other.glsl

#include ./path/to/shaderA.glsl if shaderToUse==="A"
#include ./path/to/shaderB.glsl if shaderToUse==="B"
#include ./path/to/shaderC.glsl if shaderToUse==="A" && isUsingC === true

The loader substitutes the first line with the content of "./path/to/other.glsl" and substitutes the second line only if in the options object, the property 'shaderToUse' is 'A'.

You can use #include tags in included files recursively. Circular dependency will throw an error.

In javascript
const shaderCreator = require('./path/to/shader');
shaderSource = shaderCreator({
    shaderToUse: "A",
    isUsingC: false
});

Keywords

FAQs

Package last updated on 16 Sep 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc