removing branching on tiling shader, improving performance

Now tga export needs extra care, but boy that 5 FPS improvement
This commit is contained in:
minjaesong
2018-07-03 22:17:34 +09:00
parent 7f332db2b3
commit a702aac12f
5 changed files with 14 additions and 10 deletions

View File

@@ -0,0 +1 @@
Air tile (tile 0,0) must have colour of 0x00000000, NOT 0xFFFFFF00. You can modify the tga file directly to correct bad exporter behaviour.

Binary file not shown.

View File

@@ -23,14 +23,11 @@ uniform sampler2D backgroundTexture;
uniform ivec2 tilesInAtlas = ivec2(256, 256);
uniform ivec2 atlasTexSize = ivec2(4096, 4096);
ivec2 tileSizeInPx = atlasTexSize / tilesInAtlas;
uniform vec4 colourFilter = vec4(1, 1, 1, 1);
uniform ivec2 cameraTranslation = ivec2(0, 0);
uniform int tileSizeInPx = 16;
vec4 nocolour = vec4(0,0,0,0);
ivec2 getTileXY(int tileNumber) {
@@ -75,8 +72,10 @@ void main() {
// TODO blend a breakage (0xrrggbb where 0xr0 -- upper 4 bits of int_red component)
if (tileXY.x == 0 && tileXY.y == 0)
// if statements considered harmful
// --definitely not Dijkstra
/*if (tileXY.x == 0 && tileXY.y == 0)
gl_FragColor = nocolour;
else
else*/
gl_FragColor = colourFilter * texture2D(tilesAtlas, finalUVCoordForTile);
}