HTML5 Canvas 2D Library

ShaderGeneration Methods

There are various methods used for generation of the shader source code. Each of these methods generate part of the source and return that as a string. You can override these methods in order to customize the shaders.


var s=taccgl.ssc();
s.color = function () {return "col = vec3(1.0,0.0,0.0);" }

In the above example the color method is overridden, returning shader code "col = vec3(1.0,0.0,0.0)" which assign the color red to each pixel.

This can however be written in a much more readable way by supplying the id of an HTML script element to the ssc method. The script can contain one or more sections, each starting with a colon ':' followed by the name of a method. This will override the named method to generate the following code into the shader.


var s=taccgl.ssc('ShaderSample1');var"testimg").sc(s).dur(2).start();
<script id="ShaderSample1" type="x-gsgl/x-shader">
col = vec3(1.0,0.0,0.0);
These methods are called by compile.