Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.createProgramObject = function(vetexShaderSource, fragmentShaderSource) {
- var vertexShaderObject = this.ctx.createShader(this.ctx.VERTEX_SHADER);
- this.ctx.shaderSource(vertexShaderObject, vetexShaderSource);
- this.ctx.compileShader(vertexShaderObject);
- if (!this.ctx.getShaderParameter(vertexShaderObject, this.ctx.COMPILE_STATUS)) {
- throw this.ctx.getShaderInfoLog(vertexShaderObject);
- }
- var fragmentShaderObject = this.ctx.createShader(this.ctx.FRAGMENT_SHADER);
- this.ctx.shaderSource(fragmentShaderObject, fragmentShaderSource);
- this.ctx.compileShader(fragmentShaderObject);
- if (!this.ctx.getShaderParameter(fragmentShaderObject, this.ctx.COMPILE_STATUS)) {
- throw this.ctx.getShaderInfoLog(fragmentShaderObject);
- }
- var programObject = this.ctx.createProgram();
- this.ctx.attachShader(programObject, vertexShaderObject);
- this.ctx.attachShader(programObject, fragmentShaderObject);
- this.ctx.linkProgram(programObject);
- if (!this.ctx.getProgramParameter(programObject, this.ctx.LINK_STATUS)) {
- throw ("Error linking shaders:" + this.ctx.getProgramInfoLog(programObject));
- }
- return programObject;
- };
- attribute vec3 aVertexPosition;
- attribute vec4 aVertexColor;
- uniform mat4 uModelViewMatrix;
- uniform mat4 uProjectionMatrix;
- uniform float uPointSize;
- //for undetermined point attenuation feature
- // uniform vec3 uAttenuation;
- uniform vec3 uBias;
- uniform vec3 uScale;
- uniform int uCEMode;
- varying vec4 vColor;
- void main(void) {
- if(uCEMode == 1) {
- //use bias and scale unifroms for min max color enhancement
- vColor = (aVertexColor - vec4(uBias, 0.0)) * vec4(uScale, 1.0);
- }
- else {
- vColor = aVertexColor;
- }
- vec4 ecPos4 = uModelViewMatrix * vec4(aVertexPosition, 1.0);
- //make points larger as they get further away from the viewer
- //helps to make the cloud look less sparse when far enough to only see
- //the first level or two of the octree
- gl_PointSize = length(ecPos4) / uPointSize * 3.0;
- //for undetermined point attenuation feature
- // float attn = uAttenuation[0] + (uAttenuation[1] * dist) + (uAttenuation[2] * dist * dist);
- // gl_PointSize = (attn > 0.0 && attn < uPointSize) ? uPointSize * sqrt(1.0/attn) : uPointSize;
- gl_Position = uProjectionMatrix * ecPos4;
- }
- varying highp vec4 vColor;
- void main(void) {
- gl_FragColor = vColor;
- }
- Uncaught Error linking shaders:Varyings with the same name but different type, or statically used varyings in fragment shader are not declared in vertex shader: vColor
- #ifdef GL_FRAGMENT_PRECISION_HIGH
- precision highp float;
- #else
- precision mediump float;
- #endif
Add Comment
Please, Sign In to add comment