mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
fliprot revived
This commit is contained in:
@@ -458,7 +458,7 @@ internal object BlocksDrawer {
|
||||
(fillThis * 16f - 0.5f).floorToInt().coerceIn(0, 15)
|
||||
}
|
||||
else if (treeLeavesTiles.binarySearch(rawTileNum) >= 0) {
|
||||
getNearbyTilesInfoTrees(x, y, mode)//.swizzle8(rawTileNum, hash)
|
||||
getNearbyTilesInfoTrees(x, y, mode).swizzle8(rawTileNum, hash)
|
||||
}
|
||||
else if (treeTrunkTiles.binarySearch(rawTileNum) >= 0) {
|
||||
hash = 0
|
||||
@@ -466,17 +466,17 @@ internal object BlocksDrawer {
|
||||
}
|
||||
else if (platformTiles.binarySearch(rawTileNum) >= 0) {
|
||||
hash %= 2
|
||||
getNearbyTilesInfoPlatform(x, y)//.swizzleH2(rawTileNum, hash)
|
||||
getNearbyTilesInfoPlatform(x, y).swizzleH2(rawTileNum, hash)
|
||||
}
|
||||
else if (wallStickerTiles.binarySearch(rawTileNum) >= 0) {
|
||||
hash = 0
|
||||
getNearbyTilesInfoWallSticker(x, y)
|
||||
}
|
||||
else if (connectMutualTiles.binarySearch(rawTileNum) >= 0) {
|
||||
getNearbyTilesInfoConMutual(x, y, mode)//.swizzle8(rawTileNum, hash)
|
||||
getNearbyTilesInfoConMutual(x, y, mode).swizzle8(rawTileNum, hash)
|
||||
}
|
||||
else if (connectSelfTiles.binarySearch(rawTileNum) >= 0) {
|
||||
getNearbyTilesInfoConSelf(x, y, mode, rawTileNum)//.swizzle8(rawTileNum, hash)
|
||||
getNearbyTilesInfoConSelf(x, y, mode, rawTileNum).swizzle8(rawTileNum, hash)
|
||||
}
|
||||
else {
|
||||
0
|
||||
@@ -521,10 +521,13 @@ internal object BlocksDrawer {
|
||||
val breakingStage = if (mode == TERRAIN || mode == WALL || mode == ORES) (breakage / maxHealth).coerceIn(0f, 1f).times(BREAKAGE_STEPS).roundToInt() else 0
|
||||
|
||||
// draw a tile
|
||||
writeToBuffer(mode, bufferBaseX*2+0, bufferBaseY*2+0, thisTileX+0, thisTileY+0, breakingStage, hash)
|
||||
writeToBuffer(mode, bufferBaseX*2+1, bufferBaseY*2+0, thisTileX+1, thisTileY+0, breakingStage, hash)
|
||||
writeToBuffer(mode, bufferBaseX*2+0, bufferBaseY*2+1, thisTileX+0, thisTileY+2, breakingStage, hash)
|
||||
writeToBuffer(mode, bufferBaseX*2+1, bufferBaseY*2+1, thisTileX+1, thisTileY+2, breakingStage, hash)
|
||||
val offsets = subtileOffsetsBySwizzleIndex[hash]
|
||||
/*TL*/writeToBuffer(mode, bufferBaseX*2+offsets[0].x, bufferBaseY*2+offsets[0].y, thisTileX+0, thisTileY+0, breakingStage, hash)
|
||||
/*TR*/writeToBuffer(mode, bufferBaseX*2+offsets[1].x, bufferBaseY*2+offsets[1].y, thisTileX+1, thisTileY+0, breakingStage, hash)
|
||||
/*BR*/writeToBuffer(mode, bufferBaseX*2+offsets[2].x, bufferBaseY*2+offsets[2].y, thisTileX+1, thisTileY+2, breakingStage, hash)
|
||||
/*BL*/writeToBuffer(mode, bufferBaseX*2+offsets[3].x, bufferBaseY*2+offsets[3].y, thisTileX+0, thisTileY+2, breakingStage, hash)
|
||||
|
||||
|
||||
tempRenderTypeBuffer[bufferBaseY, bufferBaseX] = (nearbyTilesInfo or rawTileNum.shl(16)).toLong()
|
||||
}
|
||||
}
|
||||
@@ -546,6 +549,30 @@ internal object BlocksDrawer {
|
||||
arrayOf(6,5,4,3,2,1,0,7), /* hfCW 270 */
|
||||
)
|
||||
|
||||
private val subtileOffsetsBySwizzleIndex = arrayOf(
|
||||
// index: TL->TR->BR->BL
|
||||
arrayOf(Point2i(0,0),Point2i(1,0),Point2i(1,1),Point2i(0,1)), /* normal */
|
||||
arrayOf(Point2i(1,0),Point2i(0,0),Point2i(0,1),Point2i(1,1)), /* horz flip */
|
||||
arrayOf(Point2i(1,0),Point2i(1,1),Point2i(0,1),Point2i(0,0)), /* CW 90 */
|
||||
arrayOf(Point2i(0,0),Point2i(0,1),Point2i(1,1),Point2i(1,0)), /* hfCW 90 */
|
||||
arrayOf(Point2i(1,1),Point2i(0,1),Point2i(0,0),Point2i(1,0)), /* CW 180 */
|
||||
arrayOf(Point2i(0,1),Point2i(1,1),Point2i(1,0),Point2i(0,0)), /* hfCW 180 */
|
||||
arrayOf(Point2i(0,1),Point2i(0,0),Point2i(1,0),Point2i(1,1)), /* CW 270 */
|
||||
arrayOf(Point2i(1,1),Point2i(1,0),Point2i(0,0),Point2i(0,1)), /* hfCW 270 */
|
||||
)
|
||||
|
||||
/*private val subtileOffsetsBySwizzleIndex = arrayOf(
|
||||
// index: TL->TR->BR->BL
|
||||
arrayOf(Point2i(0,0),Point2i(1,0),Point2i(1,1),Point2i(0,1)), /* normal */
|
||||
arrayOf(Point2i(1,0),Point2i(0,0),Point2i(0,1),Point2i(1,1)), /* horz flip */
|
||||
arrayOf(Point2i(0,1),Point2i(0,0),Point2i(1,0),Point2i(1,1)), /* CW 90 */
|
||||
arrayOf(Point2i(1,1),Point2i(1,0),Point2i(0,0),Point2i(0,1)), /* hfCW 90 */
|
||||
arrayOf(Point2i(1,1),Point2i(0,1),Point2i(0,0),Point2i(1,0)), /* CW 180 */
|
||||
arrayOf(Point2i(0,1),Point2i(1,1),Point2i(1,0),Point2i(0,0)), /* hfCW 180 */
|
||||
arrayOf(Point2i(1,0),Point2i(1,1),Point2i(0,1),Point2i(0,0)), /* CW 270 */
|
||||
arrayOf(Point2i(0,0),Point2i(0,1),Point2i(1,1),Point2i(1,0)), /* hfCW 270 */
|
||||
)*/
|
||||
|
||||
private fun Int.swizzle8(tile: Int, hash: Int): Int {
|
||||
var ret = 0
|
||||
swizzleMap8[hash].forEachIndexed { index, ord ->
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
@@ -44,8 +40,15 @@ const vec2 haalf = vec2(0.5, 0.5);
|
||||
|
||||
out vec4 fragColor;
|
||||
|
||||
ivec2 tileNumberToXY(int tileNumber) {
|
||||
return ivec2(tileNumber % int(tilesInAtlas.x), tileNumber / int(tilesInAtlas.x));
|
||||
ivec4 tileNumberToXY(int tileNumber) {
|
||||
int tileX = tileNumber % int(tilesInAtlas.x);
|
||||
int tileY = tileNumber / int(tilesInAtlas.x);
|
||||
return ivec4(
|
||||
tileX, // tileX
|
||||
tileY, // tileY
|
||||
tileX % 2, // quadrant-x (0, 1)
|
||||
tileY % 2 // quadrant-y (0, 1)
|
||||
);
|
||||
}
|
||||
|
||||
// return: ivec3(tileID, breakage, fliprot)
|
||||
@@ -62,8 +65,8 @@ ivec3 _colToInt(vec4 map1, vec4 map2) {
|
||||
|
||||
return ivec3(
|
||||
(col1.r << 16) | (col1.g << 8) | col1.b, // tile
|
||||
0,//col2.b, // breakage
|
||||
0//col2.g // fliprot
|
||||
col2.b, // breakage
|
||||
col2.g // fliprot
|
||||
);
|
||||
}
|
||||
|
||||
@@ -103,8 +106,12 @@ void main() {
|
||||
int tile = tbf.x;
|
||||
int breakage = tbf.y;
|
||||
int flipRot = tbf.z;
|
||||
ivec2 tileXY = tileNumberToXY(tile);
|
||||
ivec2 breakageXY = tileNumberToXY(breakage + 5); // +5 is hard-coded constant that depends on the contents of the atlas
|
||||
ivec4 tileXYnQ = tileNumberToXY(tile);
|
||||
ivec4 breakageXYnQ = tileNumberToXY(breakage + 5); // +5 is hard-coded constant that depends on the contents of the atlas
|
||||
ivec2 tileXY = tileXYnQ.xy;
|
||||
ivec2 tileQ = tileXYnQ.zw;
|
||||
ivec2 breakageXY = breakageXYnQ.xy;
|
||||
ivec2 breakageQ = breakageXYnQ.zw;
|
||||
|
||||
// calculate the UV coord value for texture sampling //
|
||||
|
||||
@@ -130,11 +137,13 @@ void main() {
|
||||
vec4 finalColor = fma(mix(finalTile, finalBreakage, finalBreakage.a), bc.xxxy, finalTile * bc.yyyx);
|
||||
|
||||
// fragColor = mix(colourFilter, colourFilter * finalColor, mulBlendIntensity);
|
||||
fragColor = finalTile;
|
||||
|
||||
vec4 quadrantOverlay = vec4(tileQ.x, tileQ.y, 0.0, 1.0);
|
||||
fragColor = finalTile;// * quadrantOverlay;
|
||||
|
||||
|
||||
// SUBTILE fixme:
|
||||
// - breakage tile samples wrong coord -- needs bigtile-to-subtile adaptation
|
||||
// - somehow make fliprot work again -- needs bigtile-to-subtile adaptation
|
||||
// - figure out which quadrant the tile is in -- legacy support
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user