Skip to content

Shader builder for javascript cas. I think that all of javascript-cas's GLSL related code should be moved here

License

Notifications You must be signed in to change notification settings

EquationIO/jsc-shader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsc-shader

Shader builder for javascript cas. I think that all of javascript-cas's GLSL related code should be moved here

Usage

var c = new M.Context();
c.x = M('x', c);
c.y = m('x^2', c);

var s = new M.Expression.Shader(shaderSource).inject({
  f: {
    arguments: [c.x],
    restrict: [t],
    type: 'f',
    value: c.y
  }
});

// 'type' based on https://github.com/mrdoob/three.js/wiki/Uniforms-types

Example shader source

/* spec: webgl */
precision highp float;

uniform float t;
uniform vec3 colorDiffuse;
varying vec3 vCoord;

float f(float x, float y);

#import f(x,y)

void main() {
  gl_FragColor = vec4(colorDiffuse.rgb, f(vCoord.x, vCoord.y));
}

About

Shader builder for javascript cas. I think that all of javascript-cas's GLSL related code should be moved here

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published