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.

Examples

var s=taccgl.ssc();
s.color = function () {return "col = vec3(1.0,0.0,0.0);" }
var b=taccgl.actor("testimg").sc(s).dur(2).start();
RUN

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.

Examples

var s=taccgl.ssc('ShaderSample1');var b=taccgl.actor("testimg").sc(s).dur(2).start(); RUN
<script id="ShaderSample1" type="x-gsgl/x-shader">
:color
col = vec3(1.0,0.0,0.0);
</script>
 
These methods are called by compile.
Please Add a Comment or Question, click here!