Skip to content

kig/shader-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shader Runner

This is a small runner and build system for ShaderToy-style multibuffer shaders. See src/shaders for an example shader (the buffer_x.glsl -ones), see src/runner.ts for the runner script.

Rainbow-colored sphere

Example shader output

The build script uses esbuild, spglsl and html-minifier to do fast builds (~1 second) and has a watch mode for creating dev builds on file changes (these run in <1s).

The build output is a single HTML file based on the template in static/index.html. The build script inlines css/style.css and src/runner.ts into the HTML after compiling and minifying them. The resulting HTML is further minified with html-minifier.

You can import shaders into runner.ts like below:

const myVertexSource = require('./shaders/foo.vert.glsl');
const myFragmentSource = require('./shaders/foo.frag.glsl');

The shaders are minified and inlined to the compiled script as strings. The minifying step uses spglsl to compile the shaders in optimize mode, which does error checking and minification.

The HTML template and runner.ts use the fxhash generative seed template for generating reproducible random outputs.

Usage

# Install dependencies
yarn

# Start watch mode -- the generated files go to `watch/` and you can serve them with `serve watch`
yarn watch

# Do a build in `build/`. Test with `serve build`
yarn build

License

MIT

Ilmari Heikkinen 2022

About

Runner script and optimized build pipeline for ShaderToy-style multibuffer WebGL2 fragment shaders

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors