Updated PixiShader to use standard uniform naming conventions (1f, 2f, 2fv, etc). Added support for multiple sampler2D calls, allowing multi-texture shaders. Added support for Linear, Repeat, Nearest, Audio and Keyboard textures. Updated all the examples to use the new uniform naming convention. Updated Gruntfile to use the renamed GrayFilter and fixed indexAll in Example 15 to use the GrayFilter as well.

This commit is contained in:
photonstorm 2013-11-20 16:19:25 +00:00
parent d7ce761608
commit 49fff52fc8
19 changed files with 12914 additions and 12406 deletions

View file

@ -60,7 +60,7 @@ module.exports = function(grunt) {
'<%= dirs.src %>/loaders/SpineLoader.js',
'<%= dirs.src %>/filters/AbstractFilter.js',
'<%= dirs.src %>/filters/ColorMatrixFilter.js',
'<%= dirs.src %>/filters/GreyFilter.js',
'<%= dirs.src %>/filters/GrayFilter.js',
'<%= dirs.src %>/filters/DisplacementFilter.js',
'<%= dirs.src %>/filters/PixelateFilter.js',
'<%= dirs.src %>/filters/BlurXFilter.js',

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -13,7 +13,7 @@
<script src="../../bin/pixi.dev.js"></script>
<script src="dat.gui.min.js"></script>
<script src="pixi.js"></script>
<!-- <script src="pixi.js"></script> -->
</head>
<body>
<script>
@ -71,11 +71,11 @@
////
var greyFilter = new PIXI.GreyFilter();
var grayFilter = new PIXI.GrayFilter();
var greyFolder = gui.addFolder('Grey');
greyFolder.add(filtersSwitchs, '4').name("apply");
greyFolder.add(greyFilter, 'grey', 0, 1).name("Grey");
var grayFolder = gui.addFolder('Gray');
grayFolder.add(filtersSwitchs, '4').name("apply");
grayFolder.add(grayFilter, 'gray', 0, 1).name("Gray");
////
@ -124,7 +124,7 @@
crossHatchFolder.add(filtersSwitchs, '9').name("apply");
// var filterCollection = [blurFilter, pixelateFilter, invertFilter, greyFilter, sepiaFilter, twistFilter, dotScreenFilter, //colorStepFilter, crossHatchFilter];
// var filterCollection = [blurFilter, pixelateFilter, invertFilter, grayFilter, sepiaFilter, twistFilter, dotScreenFilter, //colorStepFilter, crossHatchFilter];
var rgbSplitterFilter = new PIXI.RGBSplitFilter();
@ -132,7 +132,7 @@
rgbSplitFolder.add(filtersSwitchs, '10').name("apply");
var filterCollection = [displacementFilter, blurFilter, pixelateFilter, invertFilter, greyFilter, sepiaFilter, twistFilter, dotScreenFilter, colorStepFilter, crossHatchFilter, rgbSplitterFilter];
var filterCollection = [displacementFilter, blurFilter, pixelateFilter, invertFilter, grayFilter, sepiaFilter, twistFilter, dotScreenFilter, colorStepFilter, crossHatchFilter, rgbSplitterFilter];
// create an new instance of a pixi stage
@ -267,7 +267,7 @@
overlay.tilePosition.x = count * -10//blurAmount * 40;
overlay.tilePosition.y = count * -10
renderer.render(stage);
requestAnimFrame( animate );
}

View file

@ -474,7 +474,7 @@ PIXI.DisplayObject.prototype.removeFilter = function(data)
{
//if(!this.filter)return;
//this.filter = false;
console.log("YUOIO")
// console.log("YUOIO")
// modify the list..
var startBlock = data.start;

View file

@ -12,7 +12,7 @@ PIXI.BlurXFilter = function()
// set the uniforms
this.uniforms = {
blur: {type: 'f', value: 1/512},
blur: {type: '1f', value: 1/512},
};
this.fragmentSrc = [

View file

@ -12,7 +12,7 @@ PIXI.BlurYFilter = function()
// set the uniforms
this.uniforms = {
blur: {type: 'f', value: 1/512},
blur: {type: '1f', value: 1/512},
};
this.fragmentSrc = [

View file

@ -17,7 +17,7 @@ PIXI.ColorStepFilter = function()
// set the uniforms
this.uniforms = {
step: {type: 'f', value: 5},
step: {type: '1f', value: 5},
};
this.fragmentSrc = [

View file

@ -12,7 +12,7 @@ PIXI.CrossHatchFilter = function()
// set the uniforms
this.uniforms = {
blur: {type: 'f', value: 1/512},
blur: {type: '1f', value: 1/512},
};
this.fragmentSrc = [

View file

@ -23,10 +23,10 @@ PIXI.DisplacementFilter = function(texture)
//console.log()
this.uniforms = {
displacementMap: {type: 'sampler2D', value:texture},
scale: {type: 'f2', value:{x:30, y:30}},
offset: {type: 'f2', value:{x:0, y:0}},
mapDimensions: {type: 'f2', value:{x:1, y:5112}},
dimensions: {type: 'f4', value:[0,0,0,0]}
scale: {type: '2f', value:{x:30, y:30}},
offset: {type: '2f', value:{x:0, y:0}},
mapDimensions: {type: '2f', value:{x:1, y:5112}},
dimensions: {type: '4fv', value:[0,0,0,0]}
};

View file

@ -17,9 +17,9 @@ PIXI.DotScreenFilter = function()
// set the uniforms
this.uniforms = {
scale: {type: 'f', value:1},
angle: {type: 'f', value:5},
dimensions: {type: 'f4', value:[0,0,0,0]}
scale: {type: '1f', value:1},
angle: {type: '1f', value:5},
dimensions: {type: '4fv', value:[0,0,0,0]}
};
this.fragmentSrc = [

View file

@ -17,7 +17,7 @@ PIXI.GrayFilter = function()
// set the uniforms
this.uniforms = {
gray: {type: 'f', value: 1},
gray: {type: '1f', value: 1},
};
this.fragmentSrc = [

View file

@ -16,7 +16,7 @@ PIXI.InvertFilter = function()
// set the uniforms
this.uniforms = {
invert: {type: 'f', value: 1},
invert: {type: '1f', value: 1},
};
this.fragmentSrc = [

View file

@ -16,9 +16,9 @@ PIXI.PixelateFilter = function()
// set the uniforms
this.uniforms = {
invert: {type: 'f', value: 0},
dimensions: {type: 'f4', value:new Float32Array([10000, 100, 10, 10])},
pixelSize: {type: 'f2', value:{x:10, y:10}},
invert: {type: '1f', value: 0},
dimensions: {type: '4fv', value:new Float32Array([10000, 100, 10, 10])},
pixelSize: {type: '2f', value:{x:10, y:10}},
};
this.fragmentSrc = [

View file

@ -12,10 +12,10 @@ PIXI.RGBSplitFilter = function()
// set the uniforms
this.uniforms = {
red: {type: 'f2', value: {x:20, y:20}},
green: {type: 'f2', value: {x:-20, y:20}},
blue: {type: 'f2', value: {x:20, y:-20}},
dimensions: {type: 'f4', value:[0,0,0,0]}
red: {type: '2f', value: {x:20, y:20}},
green: {type: '2f', value: {x:-20, y:20}},
blue: {type: '2f', value: {x:20, y:-20}},
dimensions: {type: '4fv', value:[0,0,0,0]}
};
this.fragmentSrc = [

View file

@ -18,7 +18,7 @@ PIXI.SepiaFilter = function()
// set the uniforms
this.uniforms = {
sepia: {type: 'f', value: 1},
sepia: {type: '1f', value: 1},
};
this.fragmentSrc = [

View file

@ -12,7 +12,7 @@ PIXI.SmartBlurFilter = function()
// set the uniforms
this.uniforms = {
blur: {type: 'f', value: 1/512},
blur: {type: '1f', value: 1/512},
};
this.fragmentSrc = [

View file

@ -16,9 +16,9 @@ PIXI.TwistFilter = function()
// set the uniforms
this.uniforms = {
radius: {type: 'f', value:0.5},
angle: {type: 'f', value:5},
offset: {type: 'f2', value:{x:0.5, y:0.5}},
radius: {type: '1f', value:0.5},
angle: {type: '1f', value:5},
offset: {type: '2f', value:{x:0.5, y:0.5}},
};
this.fragmentSrc = [

View file

@ -1,119 +1,368 @@
/**
* @author Mat Groves http://matgroves.com/ @Doormat23
* @author Richard Davey http://www.photonstorm.com @photonstorm
*/
/**
* @class PIXI.PixiShader
* @constructor
*/
PIXI.PixiShader = function()
{
// the webGL program..
this.program;
this.fragmentSrc = [
"precision lowp float;",
"varying vec2 vTextureCoord;",
"varying float vColor;",
"uniform sampler2D uSampler;",
"void main(void) {",
"gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;",
"}"
];
/**
* @property {any} program - The WebGL program.
*/
this.program;
/**
* @property {array} fragmentSrc - The fragment shader.
*/
this.fragmentSrc = [
"precision lowp float;",
"varying vec2 vTextureCoord;",
"varying float vColor;",
"uniform sampler2D uSampler;",
"void main(void) {",
"gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor;",
"}"
];
/**
* @property {number} textureCount - A local texture counter for multi-texture shaders.
*/
this.textureCount = 0;
}
/**
* @method PIXI.PixiShader#init
*/
PIXI.PixiShader.prototype.init = function()
{
var program = PIXI.compileProgram(this.vertexSrc || PIXI.PixiShader.defaultVertexSrc, this.fragmentSrc)
var gl = PIXI.gl;
var program = PIXI.compileProgram(this.vertexSrc || PIXI.PixiShader.defaultVertexSrc, this.fragmentSrc)
var gl = PIXI.gl;
gl.useProgram(program);
// get and store the uniforms for the shader
this.uSampler = gl.getUniformLocation(program, "uSampler");
this.projectionVector = gl.getUniformLocation(program, "projectionVector");
this.offsetVector = gl.getUniformLocation(program, "offsetVector");
// get and store the uniforms for the shader
this.uSampler = gl.getUniformLocation(program, "uSampler");
this.projectionVector = gl.getUniformLocation(program, "projectionVector");
this.offsetVector = gl.getUniformLocation(program, "offsetVector");
//this.dimensions = gl.getUniformLocation(this.program, "dimensions");
// get and store the attributes
this.aVertexPosition = gl.getAttribLocation(program, "aVertexPosition");
this.colorAttribute = gl.getAttribLocation(program, "aColor");
this.aTextureCoord = gl.getAttribLocation(program, "aTextureCoord");
this.colorAttribute = gl.getAttribLocation(program, "aColor");
this.aTextureCoord = gl.getAttribLocation(program, "aTextureCoord");
// add those custom shaders!
for (var key in this.uniforms)
{
// get the uniform locations..
// program[key] =
// get the uniform locations..
this.uniforms[key].uniformLocation = gl.getUniformLocation(program, key);
}
this.program = program;
this.program = program;
}
/**
* Updates the shader uniform values.
* Uniforms are specified in the GLSL_ES Specification: http://www.khronos.org/registry/webgl/specs/latest/1.0/
* http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf
*
* @method PIXI.PixiShader#syncUniforms
*/
PIXI.PixiShader.prototype.syncUniforms = function()
{
var gl = PIXI.gl;
for (var key in this.uniforms)
this.textureCount = 1;
var gl = PIXI.gl;
for (var key in this.uniforms)
{
//var
var type = this.uniforms[key].type;
// need to grow this!
if(type == "f")
{
gl.uniform1f(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
if(type == "f2")
{
// console.log(this.program[key])
gl.uniform2f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y);
}
else if(type == "f4")
var type = this.uniforms[key].type;
var transpose = false;
if (this.uniforms[key].transpose)
{
// console.log(this.uniforms[key].value)
transpose = this.uniforms[key].transpose;
}
if (type == "1f")
{
// void uniform1f(WebGLUniformLocation? location, GLfloat x);
gl.uniform1f(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
else if (type == "1fv")
{
// void uniform1fv(WebGLUniformLocation? location, Float32Array v);
// void uniform1fv(WebGLUniformLocation? location, sequence<GLfloat> v);
gl.uniform1fv(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
else if (type == "1i")
{
// void uniform1i(WebGLUniformLocation? location, GLint x);
gl.uniform1i(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
else if (type == "1iv")
{
// void uniform1iv(WebGLUniformLocation? location, Int32Array v);
// void uniform1iv(WebGLUniformLocation? location, sequence<long> v);
gl.uniform1i(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
else if (type == "2f")
{
// void uniform2f(WebGLUniformLocation? location, GLfloat x, GLfloat y);
gl.uniform2f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y);
}
else if (type == "2fv")
{
// void uniform2fv(WebGLUniformLocation? location, Float32Array v);
// void uniform2fv(WebGLUniformLocation? location, sequence<GLfloat> v);
gl.uniform2fv(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
else if (type == "2i")
{
// void uniform2i(WebGLUniformLocation? location, GLint x, GLint y);
gl.uniform2i(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y);
}
else if (type == "2iv")
{
// void uniform2iv(WebGLUniformLocation? location, Int32Array v);
// void uniform2iv(WebGLUniformLocation? location, sequence<long> v);
gl.uniform2iv(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
else if (type == "3f")
{
// void uniform3f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z);
gl.uniform3f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y, this.uniforms[key].value.z);
}
else if (type == "3fv")
{
// void uniform3fv(WebGLUniformLocation? location, Float32Array v);
// void uniform3fv(WebGLUniformLocation? location, sequence<GLfloat> v);
gl.uniform3fv(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
else if (type == "3i")
{
// void uniform3i(WebGLUniformLocation? location, GLint x, GLint y, GLint z);
gl.uniform3i(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y, this.uniforms[key].value.z);
}
else if (type == "3iv")
{
// void uniform3iv(WebGLUniformLocation? location, Int32Array v);
// void uniform3iv(WebGLUniformLocation? location, sequence<long> v);
gl.uniform3iv(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
else if (type == "4f")
{
// void uniform4f(WebGLUniformLocation? location, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
gl.uniform4f(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y, this.uniforms[key].value.z, this.uniforms[key].value.w);
}
else if (type == "4fv")
{
// void uniform4fv(WebGLUniformLocation? location, Float32Array v);
// void uniform4fv(WebGLUniformLocation? location, sequence<GLfloat> v);
gl.uniform4fv(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
else if(type == "mat4")
{
gl.uniformMatrix4fv(this.uniforms[key].uniformLocation, false, this.uniforms[key].value);
}
else if(type == "sampler2D")
{
// first texture...
var texture = this.uniforms[key].value;
gl.activeTexture(gl.TEXTURE1);
gl.bindTexture(gl.TEXTURE_2D, texture.baseTexture._glTexture);
gl.uniform1i(this.uniforms[key].uniformLocation, 1);
// activate texture..
// gl.uniformMatrix4fv(this.program[key], false, this.uniforms[key].value);
// gl.uniformMatrix4fv(this.program[key], false, this.uniforms[key].value);
}
else if (type == "4i")
{
// void uniform4i(WebGLUniformLocation? location, GLint x, GLint y, GLint z, GLint w);
gl.uniform4i(this.uniforms[key].uniformLocation, this.uniforms[key].value.x, this.uniforms[key].value.y, this.uniforms[key].value.z, this.uniforms[key].value.w);
}
else if (type == "4iv")
{
// void uniform4iv(WebGLUniformLocation? location, Int32Array v);
// void uniform4iv(WebGLUniformLocation? location, sequence<long> v);
gl.uniform4iv(this.uniforms[key].uniformLocation, this.uniforms[key].value);
}
else if (type == "mat2")
{
// void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value);
// void uniformMatrix2fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> value);
gl.uniformMatrix2fv(this.uniforms[key].uniformLocation, transpose, this.uniforms[key].value);
}
else if (type == "mat3")
{
// void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value);
// void uniformMatrix3fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> value);
gl.uniformMatrix3fv(this.uniforms[key].uniformLocation, transpose, this.uniforms[key].value);
}
else if (type == "mat4")
{
// void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, Float32Array value);
// void uniformMatrix4fv(WebGLUniformLocation? location, GLboolean transpose, sequence<GLfloat> value);
gl.uniformMatrix4fv(this.uniforms[key].uniformLocation, transpose, this.uniforms[key].value);
}
else if (type == "sampler2D")
{
if (this.uniforms[key].value.baseTexture.hasLoaded)
{
var texture = this.uniforms[key].value.baseTexture._glTexture;
var image = this.uniforms[key].value.baseTexture.source;
var format = gl.RGBA;
if (this.uniforms[key].format && this.uniforms[key].format == 'luminance')
{
format = gl.LUMINANCE;
}
gl.activeTexture(gl['TEXTURE' + this.textureCount]);
if (this.uniforms[key].wrap)
{
if (this.uniforms[key].wrap == 'no-repeat' || this.uniforms[key].wrap === false)
{
this.createGLTextureLinear(gl, image, texture);
}
else if (this.uniforms[key].wrap == 'repeat' || this.uniforms[key].wrap === true)
{
this.createGLTexture(gl, image, format, texture);
}
else if (this.uniforms[key].wrap == 'nearest-repeat')
{
this.createGLTextureNearestRepeat(gl, image, texture);
}
else if (this.uniforms[key].wrap == 'nearest')
{
this.createGLTextureNearest(gl, image, texture);
}
else if (this.uniforms[key].wrap == 'audio')
{
this.createAudioTexture(gl, texture);
}
else if (this.uniforms[key].wrap == 'keyboard')
{
this.createKeyboardTexture(gl, texture);
}
}
else
{
this.createGLTextureLinear(gl, image, texture);
}
gl.uniform1i(this.uniforms[key].uniformLocation, this.textureCount);
this.textureCount++;
}
}
}
};
/**
* Binds the given texture and image data. The texture is set to REPEAT.
* Code based on Effects.js from ShaderToy.com
* @method PIXI.PixiShader#createGLTexture
*/
PIXI.PixiShader.prototype.createGLTexture = function(gl, image, format, texture)
{
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
gl.texImage2D(gl.TEXTURE_2D, 0, format, gl.RGBA, gl.UNSIGNED_BYTE, image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
gl.generateMipmap(gl.TEXTURE_2D);
}
/**
* Binds the given texture and image data. The texture is set to CLAMP_TO_EDGE.
* Code based on Effects.js from ShaderToy.com
* @method PIXI.PixiShader#createGLTextureLinear
*/
PIXI.PixiShader.prototype.createGLTextureLinear = function(gl, image, texture)
{
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
}
/**
* Binds the given texture and image data. The texture is set to REPEAT with NEAREST.
* Code based on Effects.js from ShaderToy.com
* @method PIXI.PixiShader#createGLTextureNearestRepeat
*/
PIXI.PixiShader.prototype.createGLTextureNearestRepeat = function(gl, image, texture)
{
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.REPEAT);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.REPEAT);
}
/**
* Binds the given texture and image data. The texture is set to CLAMP_TO_EDGE with NEAREST.
* Code based on Effects.js from ShaderToy.com
* @method PIXI.PixiShader#createGLTextureNearest
*/
PIXI.PixiShader.prototype.createGLTextureNearest = function(gl, image, texture)
{
gl.bindTexture(gl.TEXTURE_2D, texture);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
}
/**
* Binds the given texture data. The texture is set to CLAMP_TO_EDGE with LUMINANCE. Designed for use with real-time audio data.
* Code based on Effects.js from ShaderToy.com
* @method PIXI.PixiShader#createAudioTexture
*/
PIXI.PixiShader.prototype.createAudioTexture = function(gl, texture)
{
gl.bindTexture(gl.TEXTURE_2D, texture );
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR );
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR );
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE );
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE) ;
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, 512, 2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, null);
}
/**
* Binds the given texture data. The texture is set to CLAMP_TO_EDGE with LUMINANCE. Designed for use with keyboard input data.
* Code based on Effects.js from ShaderToy.com
* @method PIXI.PixiShader#createKeyboardTexture
*/
PIXI.PixiShader.prototype.createKeyboardTexture = function(gl, texture)
{
gl.bindTexture(gl.TEXTURE_2D, texture );
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST );
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST );
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE );
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE) ;
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, 256, 2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, null);
}
PIXI.PixiShader.defaultVertexSrc = [
"attribute vec2 aVertexPosition;",
"attribute vec2 aTextureCoord;",
"attribute float aColor;",
"uniform vec2 projectionVector;",
"uniform vec2 offsetVector;",
"varying vec2 vTextureCoord;",
"varying float vColor;",
"attribute vec2 aVertexPosition;",
"attribute vec2 aTextureCoord;",
"attribute float aColor;",
"const vec2 center = vec2(-1.0, 1.0);",
"void main(void) {",
"gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);",
"vTextureCoord = aTextureCoord;",
"vColor = aColor;",
"}"
"uniform vec2 projectionVector;",
"uniform vec2 offsetVector;",
"varying vec2 vTextureCoord;",
"varying float vColor;",
"const vec2 center = vec2(-1.0, 1.0);",
"void main(void) {",
"gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);",
"vTextureCoord = aTextureCoord;",
"vColor = aColor;",
"}"
];