From 486e3f5101842c4b310e8a3eb916ce6f30c40277 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Thu, 2 Jan 2025 15:29:33 +0700 Subject: [PATCH] [Tileset] Add missing tile variants. --- .../node_tiler_tileset/node_tiler_tileset.gml | 32 ++++++++++++------- shaders/sh_draw_tile_map/sh_draw_tile_map.fsh | 18 +++++------ 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/scripts/node_tiler_tileset/node_tiler_tileset.gml b/scripts/node_tiler_tileset/node_tiler_tileset.gml index 48a02d8fb..f0c8cc55a 100644 --- a/scripts/node_tiler_tileset/node_tiler_tileset.gml +++ b/scripts/node_tiler_tileset/node_tiler_tileset.gml @@ -456,16 +456,22 @@ function Node_Tile_Tileset(_x, _y, _group = noone) : Node(_x, _y, _group) constr selecting_surface_tile = surface_verify(selecting_surface_tile, _sel_sw, _sel_sh); var _ty = _yy + _tsh + ui(8); - var _th = ui(48); - _h += ui(8) + _th; var _sx = _x + ui(8); var _sy = _ty + ui(8); - var _ss = (_th - ui(16)) / _sel_sh; + var _ss = ui(32) / _sel_sh; var _sw = _ss * _sel_sw; var _sh = _ss * _sel_sh; - + + var _vv = [ 0, 0b0011, 0b0010, 0b0001, 0b0100, 0b0111, 0b0110, 0b0101 ]; + var p = array_length(_vv) + var _col = max(1, floor((_w - ui(8)) / (_sw + ui(8)))); + var _row = brush.brush_width * brush.brush_height == 1? ceil((p + 1) / _col) : 1; + + var _th = ui(8) + (_sh + ui(8)) * _row; + _h += ui(8) + _th; + draw_sprite_stretched_ext(THEME.ui_panel_bg, 1, _x, _ty, _w, _th, COLORS.node_composite_bg_blend, 1); var _shov = _hover && point_in_rectangle(_m[0], _m[1], _sx, _sy, _sx + _sw, _sy + _sh); @@ -496,14 +502,13 @@ function Node_Tile_Tileset(_x, _y, _group = noone) : Node(_x, _y, _group) constr _sx += _sw + ui(8); - if(brush.brush_width * brush.brush_height != 1) - return _h; - - var _bb = brush.brush_indices[0][0]; - var _variences = [ 0, 1, 2, 3, 8, 16 ]; + if(brush.brush_width * brush.brush_height != 1) return _h; - for( var v = 0, p = array_length(_variences); v < p; v++ ) { - var _var = _variences[v]; + var _bb = brush.brush_indices[0][0]; + var _vi = 1; + + for( var v = 0; v < p; v++ ) { + var _var = _vv[v]; surface_set_shader(selecting_surface, sh_draw_tile_brush, true, BLEND.over); shader_set_f("index", _bb[0]); @@ -536,6 +541,11 @@ function Node_Tile_Tileset(_x, _y, _group = noone) : Node(_x, _y, _group) constr _bb[1] = _var; _sx += _sw + ui(8); + if(++_vi >= _col) { + _sx = _x + ui(8); + _sy += _sh + ui(8); + _vi = 0; + } } #endregion diff --git a/shaders/sh_draw_tile_map/sh_draw_tile_map.fsh b/shaders/sh_draw_tile_map/sh_draw_tile_map.fsh index 7fbfa84ba..28011b9e1 100644 --- a/shaders/sh_draw_tile_map/sh_draw_tile_map.fsh +++ b/shaders/sh_draw_tile_map/sh_draw_tile_map.fsh @@ -42,16 +42,16 @@ void main() { texTx = vec2(mod(index, tileAmo.x), floor(index / tileAmo.x)) * tileSize; tileTx = mod(px, tileSize) / tileSize; - float vari = samIdx.g + 0.1; - float mRotation = mod(floor(vari), 4.); - float mFlipH = mod(floor(vari / 8.), 2.); - float mFlipV = mod(floor(vari / 16.), 2.); + float vari = samIdx.g + 0.1; + float mRot = mod(floor(vari), 4.); + float mFlipH = mod(floor(vari / 4.), 2.); + float mFlipV = mod(floor(vari / 8.), 2.); - if(mFlipH == 1.) tileTx.x = 1. - tileTx.x; - if(mFlipV == 1.) tileTx.y = 1. - tileTx.y; - if(mRotation == 1.) tileTx = vec2(tileTx.y, 1. - tileTx.x); - if(mRotation == 2.) tileTx = 1. - tileTx; - if(mRotation == 3.) tileTx = vec2(1. - tileTx.y, tileTx.x); + if(mFlipH == 1.) tileTx.x = 1. - tileTx.x; + if(mFlipV == 1.) tileTx.y = 1. - tileTx.y; + if(mRot == 1.) tileTx = vec2(tileTx.y, 1. - tileTx.x); + if(mRot == 2.) tileTx = 1. - tileTx; + if(mRot == 3.) tileTx = vec2(1. - tileTx.y, tileTx.x); vec2 samTx = texTx + tileTx * tileSize; gl_FragColor = texture2D( tileTexture, samTx / tileTextureDim );