Skip to content

Commit 1c062e3

Browse files
committed
Test removing a, b, c, d components from vertex
1 parent 05ff84f commit 1c062e3

3 files changed

Lines changed: 32 additions & 32 deletions

File tree

v3/src/renderer/webgl/batches/sprite/SpriteBatch32.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var SpriteBatch32 = function (game, gl, manager)
1414
{
1515
gl.getExtension('OES_element_index_uint');
1616
CONST.INDEX_SIZE = 4;
17-
CONST.MAX_SPRITES = 100000;
17+
CONST.MAX_SPRITES = 2000;
1818

1919
this.game = game;
2020
this.type = PHASER_CONST.WEBGL;
@@ -91,13 +91,13 @@ SpriteBatch32.prototype = {
9191
//CreateAttribDesc(gl, program, 'a_color', 3, 5121, true, CONST.VERTEX_SIZE, 36)
9292
CreateAttribDesc(gl, program, 'a_position', 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 0),
9393
CreateAttribDesc(gl, program, 'a_tex_coord', 2, gl.FLOAT, false, CONST.VERTEX_SIZE, 8),
94-
CreateAttribDesc(gl, program, 'transform_a', 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 16),
95-
CreateAttribDesc(gl, program, 'transform_b', 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 20),
96-
CreateAttribDesc(gl, program, 'transform_c', 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 24),
97-
CreateAttribDesc(gl, program, 'transform_d', 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 28),
98-
CreateAttribDesc(gl, program, 'transform_tx', 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 32),
99-
CreateAttribDesc(gl, program, 'transform_ty', 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 36),
100-
CreateAttribDesc(gl, program, 'a_color', 3, gl.UNSIGNED_BYTE, true, CONST.VERTEX_SIZE, 40)
94+
//CreateAttribDesc(gl, program, 'transform_a', 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 16),
95+
//CreateAttribDesc(gl, program, 'transform_b', 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 20),
96+
//CreateAttribDesc(gl, program, 'transform_c', 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 24),
97+
//CreateAttribDesc(gl, program, 'transform_d', 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 28),
98+
CreateAttribDesc(gl, program, 'transform_tx', 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 16),
99+
CreateAttribDesc(gl, program, 'transform_ty', 1, gl.FLOAT, false, CONST.VERTEX_SIZE, 20),
100+
CreateAttribDesc(gl, program, 'a_color', 3, gl.UNSIGNED_BYTE, true, CONST.VERTEX_SIZE, 24)
101101
];
102102

103103
var vertexArray = new VertexArray(CreateBuffer(gl, gl.ARRAY_BUFFER, gl.STREAM_DRAW, null, vertexDataBuffer.getByteCapacity()), attribArray);
@@ -172,10 +172,10 @@ SpriteBatch32.prototype = {
172172
vertexBufferF32[vertexOffset++] = y;
173173
vertexBufferF32[vertexOffset++] = uvs.x0;
174174
vertexBufferF32[vertexOffset++] = uvs.y0;
175-
vertexBufferF32[vertexOffset++] = a;
176-
vertexBufferF32[vertexOffset++] = b;
177-
vertexBufferF32[vertexOffset++] = c;
178-
vertexBufferF32[vertexOffset++] = d;
175+
//vertexBufferF32[vertexOffset++] = a;
176+
//vertexBufferF32[vertexOffset++] = b;
177+
//vertexBufferF32[vertexOffset++] = c;
178+
//vertexBufferF32[vertexOffset++] = d;
179179
vertexBufferF32[vertexOffset++] = tx;
180180
vertexBufferF32[vertexOffset++] = ty;
181181
vertexBufferU32[vertexOffset++] = vertexColor.topLeft;
@@ -184,10 +184,10 @@ SpriteBatch32.prototype = {
184184
vertexBufferF32[vertexOffset++] = y + height;
185185
vertexBufferF32[vertexOffset++] = uvs.x1;
186186
vertexBufferF32[vertexOffset++] = uvs.y1;
187-
vertexBufferF32[vertexOffset++] = a;
188-
vertexBufferF32[vertexOffset++] = b;
189-
vertexBufferF32[vertexOffset++] = c;
190-
vertexBufferF32[vertexOffset++] = d;
187+
//vertexBufferF32[vertexOffset++] = a;
188+
//vertexBufferF32[vertexOffset++] = b;
189+
//vertexBufferF32[vertexOffset++] = c;
190+
//vertexBufferF32[vertexOffset++] = d;
191191
vertexBufferF32[vertexOffset++] = tx;
192192
vertexBufferF32[vertexOffset++] = ty;
193193
vertexBufferU32[vertexOffset++] = vertexColor.bottomLeft;
@@ -196,10 +196,10 @@ SpriteBatch32.prototype = {
196196
vertexBufferF32[vertexOffset++] = y + height;
197197
vertexBufferF32[vertexOffset++] = uvs.x2;
198198
vertexBufferF32[vertexOffset++] = uvs.y2;
199-
vertexBufferF32[vertexOffset++] = a;
200-
vertexBufferF32[vertexOffset++] = b;
201-
vertexBufferF32[vertexOffset++] = c;
202-
vertexBufferF32[vertexOffset++] = d;
199+
//vertexBufferF32[vertexOffset++] = a;
200+
//vertexBufferF32[vertexOffset++] = b;
201+
//vertexBufferF32[vertexOffset++] = c;
202+
//vertexBufferF32[vertexOffset++] = d;
203203
vertexBufferF32[vertexOffset++] = tx;
204204
vertexBufferF32[vertexOffset++] = ty;
205205
vertexBufferU32[vertexOffset++] = vertexColor.bottomRight;
@@ -208,10 +208,10 @@ SpriteBatch32.prototype = {
208208
vertexBufferF32[vertexOffset++] = y;
209209
vertexBufferF32[vertexOffset++] = uvs.x3;
210210
vertexBufferF32[vertexOffset++] = uvs.y3;
211-
vertexBufferF32[vertexOffset++] = a;
212-
vertexBufferF32[vertexOffset++] = b;
213-
vertexBufferF32[vertexOffset++] = c;
214-
vertexBufferF32[vertexOffset++] = d;
211+
//vertexBufferF32[vertexOffset++] = a;
212+
//vertexBufferF32[vertexOffset++] = b;
213+
//vertexBufferF32[vertexOffset++] = c;
214+
//vertexBufferF32[vertexOffset++] = d;
215215
vertexBufferF32[vertexOffset++] = tx;
216216
vertexBufferF32[vertexOffset++] = ty;
217217
vertexBufferU32[vertexOffset++] = vertexColor.topRight;

v3/src/renderer/webgl/batches/sprite/VertexShader.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ module.exports = [
22
'uniform mat4 u_view_matrix;',
33
'attribute vec2 a_position;',
44
'attribute vec2 a_tex_coord;',
5-
'attribute float transform_a;',
6-
'attribute float transform_b;',
7-
'attribute float transform_c;',
8-
'attribute float transform_d;',
5+
//'attribute float transform_a;',
6+
//'attribute float transform_b;',
7+
//'attribute float transform_c;',
8+
//'attribute float transform_d;',
99
'attribute float transform_tx;',
1010
'attribute float transform_ty;',
1111
'attribute vec3 a_color;',
1212
'varying vec2 v_tex_coord;',
1313
'varying vec3 v_color;',
1414
'void main () {',
1515
' vec2 t_position;',
16-
' t_position.x = a_position.x * transform_a + a_position.y * transform_c + transform_tx;',
17-
' t_position.y = a_position.x * transform_b + a_position.y * transform_d + transform_ty;',
16+
' t_position.x = a_position.x + transform_tx;',
17+
' t_position.y = a_position.y + transform_ty;',
1818
' gl_Position = u_view_matrix * vec4(t_position, 1.0, 1.0);',
1919
' v_tex_coord = a_tex_coord;',
2020
' v_color = a_color;',

v3/src/renderer/webgl/batches/sprite/const.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ var VertexShader = require('./VertexShader');
44
var CONST = {
55

66
// VERTEX_SIZE = (sizeof(vec2) * 4) + (sizeof(float) + sizeof(uint32))
7-
VERTEX_SIZE: 44,
7+
VERTEX_SIZE: 28,//44,
88
INDEX_SIZE: 2,
99
SPRITE_VERTEX_COUNT: 4,
1010
SPRITE_INDEX_COUNT: 6,
1111

1212
// How many 32-bit components does the vertex have.
13-
SPRITE_VERTEX_COMPONENT_COUNT: 11,
13+
SPRITE_VERTEX_COMPONENT_COUNT: 7,
1414

1515
// Can't be bigger since index are 16-bit
1616
MAX_SPRITES: 10000,

0 commit comments

Comments
 (0)