function createVertexShader() { var vertexShaderSource = [ 'attribute vec3 pos;', 'attribute vec3 fillColor;', 'attribute float fillOpacity;', 'uniform mat4 modelViewMatrix;', 'uniform mat4 projectionMatrix;', 'uniform float pixelWidth;', 'varying vec3 fillColorVar;', 'varying float fillOpacityVar;', 'void main(void)', '{', ' vec4 clipPos = projectionMatrix * modelViewMatrix * vec4(pos.xyz, 1);', ' if (clipPos.w != 0.0) {', ' clipPos = clipPos/clipPos.w;', ' }', ' fillColorVar = fillColor;', ' fillOpacityVar = fillOpacity;', ' gl_Position = clipPos;', '}' ].join('\n'), shader = new vgl.shader(vgl.GL.VERTEX_SHADER); shader.setShaderSource(vertexShaderSource); return shader; }
function createVertexShader() { var vertexShaderSource = [ '#ifdef GL_ES', ' precision highp float;', '#endif', 'attribute vec3 pos;', 'attribute float value;', 'attribute float opacity;', 'uniform mat4 modelViewMatrix;', 'uniform mat4 projectionMatrix;', 'varying float valueVar;', 'varying float opacityVar;', 'void main(void)', '{', /* Don't use z values; something is rotten in one of our matrices */ ' vec4 scrPos = projectionMatrix * modelViewMatrix * vec4(pos.xy, 0, 1);', ' if (scrPos.w != 0.0) {', ' scrPos = scrPos / scrPos.w;', ' }', ' valueVar = value;', ' opacityVar = opacity;', ' gl_Position = scrPos;', '}' ].join('\n'), shader = new vgl.shader(vgl.GL.VERTEX_SHADER); shader.setShaderSource(vertexShaderSource); return shader; }
function createFragmentShader() { var fragmentShaderSource = [ '#ifdef GL_ES', ' precision highp float;', '#endif', 'varying vec4 fillColorVar;', 'void main () {', ' gl_FragColor = fillColorVar;', '}' ].join('\n'), shader = new vgl.shader(vgl.GL.FRAGMENT_SHADER); shader.setShaderSource(fragmentShaderSource); return shader; }
function createFragmentShader() { var fragmentShaderSource = [ '#ifdef GL_ES', ' precision highp float;', '#endif', 'uniform vec4 minColor;', 'uniform vec4 maxColor;', 'uniform float steps;', 'uniform bool stepped;', 'uniform sampler2D sampler2d;', 'varying float valueVar;', 'varying float opacityVar;', 'void main () {', ' vec4 clr;', ' if (valueVar < 0.0) {', ' clr = minColor;', ' } else if (valueVar > steps) {', ' clr = maxColor;', ' } else {', ' float step;', ' if (stepped) {', ' step = floor(valueVar) + 0.5;', ' if (step > steps) {', ' step = steps - 0.5;', ' }', ' } else {', ' step = valueVar;', ' }', ' clr = texture2D(sampler2d, vec2(step / steps, 0.0));', ' }', ' gl_FragColor = vec4(clr.rgb, clr.a * opacityVar);', '}' ].join('\n'), shader = new vgl.shader(vgl.GL.FRAGMENT_SHADER); shader.setShaderSource(fragmentShaderSource); return shader; }
function createFragmentShader() { var shader = new vgl.shader(vgl.GL.FRAGMENT_SHADER); shader.setShaderSource(fragmentShaderSource); return shader; }
function createVertexShader() { var shader = new vgl.shader(vgl.GL.VERTEX_SHADER); shader.setShaderSource(vertexShaderSource); return shader; }