Skip to content

Commit 9aa71e5

Browse files
committed
Added comments to shaders to help with debugging with WebGL Inspector.
1 parent e49d45e commit 9aa71e5

6 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/pixi/renderers/webgl/shaders/ComplexPrimitiveShader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ PIXI.ComplexPrimitiveShader = function(gl)
3535
* @type Array
3636
*/
3737
this.fragmentSrc = [
38-
38+
'// ComplexPrimitiveShader Fragment Shader.',
3939
'precision mediump float;',
4040

4141
'varying vec4 vColor;',
@@ -51,6 +51,7 @@ PIXI.ComplexPrimitiveShader = function(gl)
5151
* @type Array
5252
*/
5353
this.vertexSrc = [
54+
'// ComplexPrimitiveShader Vertex Shader.',
5455
'attribute vec2 aVertexPosition;',
5556
//'attribute vec4 aColor;',
5657
'uniform mat3 translationMatrix;',

src/pixi/renderers/webgl/shaders/PixiFastShader.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ PIXI.PixiFastShader = function(gl)
3535
* @type Array
3636
*/
3737
this.fragmentSrc = [
38+
'// PixiFastShader Fragment Shader.',
3839
'precision lowp float;',
3940
'varying vec2 vTextureCoord;',
4041
'varying float vColor;',
@@ -50,6 +51,7 @@ PIXI.PixiFastShader = function(gl)
5051
* @type Array
5152
*/
5253
this.vertexSrc = [
54+
'// PixiFastShader Vertex Shader.',
5355
'attribute vec2 aVertexPosition;',
5456
'attribute vec2 aPositionCoord;',
5557
'attribute vec2 aScale;',

src/pixi/renderers/webgl/shaders/PixiShader.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ PIXI.PixiShader = function(gl)
3636
* @type Array
3737
*/
3838
this.fragmentSrc = [
39+
'// PixiShader Fragment Shader.',
3940
'precision lowp float;',
4041
'varying vec2 vTextureCoord;',
4142
'varying vec4 vColor;',
42-
'uniform sampler2D uSampler;',
43+
'varying float vTextureIndex;',
44+
'uniform sampler2D uSamplerArray[16];',
4345
'void main(void) {',
44-
' gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;',
46+
' gl_FragColor = texture2D(uSamplerArray[0], vTextureCoord) * vColor ;',
4547
'}'
4648
];
4749

@@ -219,7 +221,8 @@ PIXI.PixiShader.prototype.initSampler2D = function(uniform)
219221

220222
var gl = this.gl;
221223

222-
gl.activeTexture(gl['TEXTURE' + this.textureCount]);
224+
// No need to do string manipulation for this.
225+
gl.activeTexture(gl.TEXTURE0 + this.textureCount);
223226
gl.bindTexture(gl.TEXTURE_2D, uniform.value.baseTexture._glTextures[gl.id]);
224227

225228
// Extended texture data
@@ -369,21 +372,26 @@ PIXI.PixiShader.prototype.destroy = function()
369372
* @type String
370373
*/
371374
PIXI.PixiShader.defaultVertexSrc = [
375+
'// Default Vertex Shader',
376+
'// With multi-texture rendering',
372377
'attribute vec2 aVertexPosition;',
373378
'attribute vec2 aTextureCoord;',
374379
'attribute vec4 aColor;',
380+
'attribute float aTextureIndex;',
375381

376382
'uniform vec2 projectionVector;',
377383
'uniform vec2 offsetVector;',
378384

379385
'varying vec2 vTextureCoord;',
380386
'varying vec4 vColor;',
387+
'varying float vTextureIndex;',
381388

382389
'const vec2 center = vec2(-1.0, 1.0);',
383390

384391
'void main(void) {',
385392
' gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);',
386393
' vTextureCoord = aTextureCoord;',
387394
' vColor = vec4(aColor.rgb * aColor.a, aColor.a);',
395+
' vTextureIndex = aTextureIndex;',
388396
'}'
389397
];

src/pixi/renderers/webgl/shaders/PrimitiveShader.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ PIXI.PrimitiveShader = function(gl)
3535
* @type Array
3636
*/
3737
this.fragmentSrc = [
38+
'// PrimitiveShader Fragment Shader.',
3839
'precision mediump float;',
3940
'varying vec4 vColor;',
4041

@@ -49,6 +50,7 @@ PIXI.PrimitiveShader = function(gl)
4950
* @type Array
5051
*/
5152
this.vertexSrc = [
53+
'// PrimitiveShader Vertex Shader.',
5254
'attribute vec2 aVertexPosition;',
5355
'attribute vec4 aColor;',
5456
'uniform mat3 translationMatrix;',

src/pixi/renderers/webgl/shaders/StripShader.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ PIXI.StripShader = function(gl)
3535
* @type Array
3636
*/
3737
this.fragmentSrc = [
38+
'//StripShader Fragment Shader.',
3839
'precision mediump float;',
3940
'varying vec2 vTextureCoord;',
4041
// 'varying float vColor;',
@@ -53,6 +54,7 @@ PIXI.StripShader = function(gl)
5354
* @type Array
5455
*/
5556
this.vertexSrc = [
57+
'//StripShader Vertex Shader.',
5658
'attribute vec2 aVertexPosition;',
5759
'attribute vec2 aTextureCoord;',
5860
'uniform mat3 translationMatrix;',

src/pixi/renderers/webgl/utils/WebGLSpriteBatch.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ PIXI.WebGLSpriteBatch = function()
136136
* @type AbstractFilter
137137
*/
138138
this.defaultShader = new PIXI.AbstractFilter([
139+
'//WebGLSpriteBatch Fragment Shader.',
139140
'precision lowp float;',
140141
'varying vec2 vTextureCoord;',
141142
'varying vec4 vColor;',

0 commit comments

Comments
 (0)