glsl-auto-ui

0.0.3 • Public • Published

glsl-auto-ui

This is experimental module, if something doesn't work don't get angry and post an issue. PR's are more than welcome!

Automatic DAT.GUI generation from GLSL uniforms.

screenshot

Just name your UI uniforms starting with "ui": "uiColorModifier", etc. Currently only supports float, vec2, vec3, vec4.

Uniforms default to 0.01 (to fix bug where float sliders in DAT.GUI display only 0 or 1). Uniforms are normalized to 0.0 - 1.0, you can always multiple, subtract, add, etc. in GLSL code.

Installation

$ npm install glsl-auto-ui

Usage

const { generateUI, updateGLSLToyShaderUniforms } = require('glsl-auto-ui');
 
// get shader from somewhere
const glslify = require('glslify');
const shader  = glslify('./shader.frag');
 
const { GUI } = require('dat-gui');
const gui     = new GUI();
 
// generate UI using DAT GUI instance, and shader string
// you don't need glslify, you just have to pass the shader string here
let params = generateUI(gui, shader);
 
// currently only "supports" gl-toy
const toy = require('gl-toy');
 
toy(shader, (gl, shader) => {
  updateGLSLToyShaderUniforms(shader.uniforms, params);
});

This code will not really work, because DAT.GUI needs to be created after gl-toy, look into examples/gl-toy for more info.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.3
    10
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.3
    10
  • 0.0.2
    2
  • 0.0.1
    1

Package Sidebar

Install

npm i glsl-auto-ui

Weekly Downloads

3

Version

0.0.3

License

MIT

Last publish

Collaborators

  • szymon_k