Code Monkey home page Code Monkey logo

glslmin's Introduction

glslmin

A CLI for minifying GLSL (WebGL) 1.00 shaders.

Supports bundling multiple shaders into a single file with #ifdef guards (so you only have to make one request for shader assets in WebGL).

Supports "safe" word configuration -- by default, only "main" (and attribute/varying/uniform declaration) is safe.

Pipeable, if you're into that.

installation

$ npm install -g glslmin

usage


$ glslmin
# prints help

$ glslmin file.glsl
# prints file, minified

$ glslmin file.glsl -o file.min.glsl
# outputs minified data to file.min.glsl

$ glslmin file.glsl file2.glsl -o file.min.glsl
# outputs minified data for each file, surrounded by #ifdef guards

$ cat file.glsl | glslmin
# outputs minified data

# see help for more options!

license

MIT

glslmin's People

Contributors

chrisdickinson avatar arcanis avatar

Stargazers

 avatar  avatar Cat  avatar Frederic avatar Tim van Scherpenzeel avatar Rin Tepis avatar Yi Shen avatar Chun-Hao Lien avatar Joohun, Maeng avatar Mykola Konyk avatar Hiroyuki ANAI avatar Brett Camper avatar Ricky Reusser avatar Yosh avatar Michael Anthony avatar я котик пур-пур avatar Jean-Marc Le Roux avatar  avatar Mikola Lysenko avatar Brad Pillow avatar Peter Sulatycke avatar minhyung ko avatar Ben Adams avatar  avatar Daniel Heinrich avatar Cecile Muller avatar Erik Unger avatar Hugh Kennedy avatar Paul Neave avatar Tuan Kuranes avatar Wraithan avatar André Fiedler avatar David Sheets avatar  avatar John Drinkwater avatar Tom Beddard avatar Daniel Lindsley avatar

Watchers

Hugh Kennedy avatar James Cloos avatar Denisko Redisko avatar Michael Anthony avatar Jean-Philippe Deblonde avatar Peter Sulatycke avatar Jacques KAISER avatar Patryk Falba avatar  avatar

Forkers

gre mcanthony

glslmin's Issues

Another corner case

  1. comment right after '{', eg: {//comment
  2. comma separated statement in a line. eg: a=b, d=e;

user defined struct not handled

User defined struct identifiers are minified when defined, but aren't added to the symbol table.
(Same issue for structure fields)

input :

    struct Sphere {vec3 pos};Sphere a;a.pos=vec3(1);

output :

    struct a{vec3 b;};Sphere c;c.pos=vec3(1);

An easy workaround is to minify with option --safe Sphere --safe pos

Corner case

void main(vec2 test) {
    float x;
    test.x;
}

will break :

void main(vec2 a) {
    float b;
    a.b;
}

(The field name should not be changed)

Process hangs with no output

Hello,

I just installed using npm.
The process seems to be frozen or waiting forever., on any commands or even no command.

OS: Linux 6.3.9-arch1-1
Node: v20.3.1

Is there something I'm missing?

'do' keyword not protected

I'm writing quite long shaders, that have many variables (hence the need to minify them).

The keyword 'do' isn't protected, and one of my shader once minified end up with

    float do;

within its source, which causes compilation to crash.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.