fix: halfassed new spritebatch

This commit is contained in:
minjaesong
2023-09-14 23:37:32 +09:00
parent d6fea9889e
commit 9f38e32d47
2 changed files with 5 additions and 11 deletions

View File

@@ -103,6 +103,8 @@ public class UnpackedColourSpriteBatch extends SpriteBatch {
* @param size The max number of sprites in a single batch. Max of 8191.
* @param defaultShader The default shader to use. This is not owned by the SpriteBatch and must be disposed separately. */
public UnpackedColourSpriteBatch (int size, ShaderProgram defaultShader) {
super(size, defaultShader);
// 32767 is max vertex index, so 32767 / 4 vertices per sprite = 8191 sprites max.
if (size > 8191) throw new IllegalArgumentException("Can't have more than 8191 sprites per batch: " + size);
@@ -116,7 +118,7 @@ public class UnpackedColourSpriteBatch extends SpriteBatch {
projectionMatrix.setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
vertices = new float[size * 4 * 8];
vertices = new float[size * 48];
int len = size * 6;
short[] indices = new short[len];
@@ -1222,7 +1224,7 @@ public class UnpackedColourSpriteBatch extends SpriteBatch {
renderCalls++;
totalRenderCalls++;
int spritesInBatch = idx / 20;
int spritesInBatch = idx / 48;
if (spritesInBatch > maxSpritesInBatch) maxSpritesInBatch = spritesInBatch;
int count = spritesInBatch * 6;

View File

@@ -2,7 +2,7 @@
in vec4 v_color; // lightCol
in vec4 v_generic; // gamma values
in vec4 v_generic; // gamma values [rgb gam, a gam, 0, 0]
in vec2 v_texCoords;
uniform sampler2D u_texture;
out vec4 fragColor;
@@ -12,14 +12,6 @@ const vec2 boolean = vec2(0.0, 1.0);
uniform vec4 shadeCol;
void main() {
// vertex colour format:
// rrrrrrMM ggggggLL bbbbbbAA aaaaaaaa
// where:
// rrrrrr: 6-bit red component
// gggggg: 6-bit green component
// bbbbbb: 6-bit blue component
// MMLL: index to the rgbGammas
// AA: index to the aGammas
vec4 cloudCol = v_color;
float rgbGamma = v_generic.x;
float aGamma = v_generic.y;