Skip to content

MuffinHop/cerho

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cerho

A WebGL demo engine wannabe.

Demo data

A JSON file plus all required shaders. There is one vertex shader (shader.vert) and multiple fragment shaders (of the form *.frag). All required assets are listed in the assets portion of the demo JSON representation.

Parameters

Each Effect (effects object in JSON) and PlaylistEntry (playlist.entries) can contain parameters. These objects are merged prioritizing the entry parameter definitions. The contained floating point values are passed in to the respective fragment shader as shader uniforms.

Example: parameter passing

In this example we assume the effect meatballs is defined in the effects portion of the JSON file.

To pass the parameter flash to a fragment shader you need to first specify the parameter in JSON:

"entries" : [
            {
            "effect" : "meatballs",
            "begin" : 0.0,
            "end" : 15.0,
            "params" : {
                "flash" : 0.5
            }
            }

and also declare it in the fragment shader:

precision mediump float;

uniform float flash;

void main() { 
	gl_FragColor = vec4(flash, flash, flash, 1.0);
}

Uniforms

ShaderToy uniforms:

uniform vec3      iResolution;           // viewport resolution (in pixels)
uniform float     iGlobalTime;           // shader playback time (in seconds)
uniform float     iChannelTime[4];       // channel playback time (in seconds)
uniform vec3      iChannelResolution[4]; // channel resolution (in pixels)
uniform vec4      iMouse;                // mouse pixel coords. xy: current (if MLB down), zw: click
uniform samplerXX iChannel0..3;          // input channel. XX = 2D/Cube
uniform vec4      iDate;                 // (year, month, day, time in seconds)

License

zlib license. See COPYING for more.

About

Cerho Demoengine for Javascript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 77.5%
  • C 20.0%
  • CSS 2.3%
  • Shell 0.2%