From 57667f14afb5eb850832b919acd921393ea3bed8 Mon Sep 17 00:00:00 2001 From: Domino Goupil <1er@live.ca> Date: Fri, 4 Oct 2019 03:58:00 -0400 Subject: [PATCH 1/5] Add CLI arguments and avoid temp files --- README.md | 61 ++++++++----------------------------------------------- bleed.sh | 25 ++++++++++++++++++++--- 2 files changed, 31 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 552d474..3ea3183 100644 --- a/README.md +++ b/README.md @@ -1,62 +1,19 @@ # tile-bleed-margin-generator -Automatically stretch out the 1px edge of each tile in a sprite sheet to compensate for tile bleed in 2D game development. -## bleed.sh +Automatically stretch out the 1px edge of each tile in a tile sheet to compensate for tile bleed in 2D game development. -Change the script to be specific to your case. +This should solve rounding errors which can cause tiles to slightly bleed into their neighbors, such as the very common "gap between tiles" problem in Unity. -### You'll need to figure out a few things: +## Dependencies -1. First you need to know how big your tiles are; mine are *16x16* (`TILE_SIZE = 16`) -2. then how big your spritesheet is; mine is *640x576* (`SPRITESHEET_WIDTH = 640`, `SPRITESHEET_HEIGHT = 576`) -3. How many columns there are: -``` -COLUMN_COUNT = (SPRITESHEET_WIDTH / TILE_SIZE) -``` +This script depends on ImageMagick (tested using ImageMagick 7). `convert`, `montage` and `identify` must be in your PATH. -so mine is: `(640/16)` +Until someone makes a Windows version (`.cmd` or `.ps`) you should be able to run it using bash in the Windows Subsystem for Linux. -4. How many rows there are: +## Sample usage -``` -ROW_COUNT = (SPRITESHEET_HEIGHT / TILE_SIZE) -``` + ./bleed.sh input.png output.png 16 -so mine is: `(576/16)` +...where `input.png` is a tile sheet with 16x16 tiles without any gap between tiles. If your tiles are not square, you can specify a tile height as a 4th argument. -5. How many tiles are in the spritesheet: - -``` -NUMBER_OF_TILES = COLUMN_COUNT * ROW_COUNT -``` - -so in my case I had to do: `(640/16)*(576/16)` which is 1440. - -``` -NUMBER_OF_TILES = 1440 -``` - -6. You need the file name of the spritesheet too. - -That's all you need. so now: - -### Modify the script to your case - -1. Change all instances of `16` to your `TILE_SIZE` -2. Change `spritesheet.png` to your file -3. Change all instances of `1439` to your `NUMBER_OF_TILES - 1` so in my case it was *`1439`* instead of `1440`. (This is due to indexing starting at 0) -4. Change all instances of `48` to your `TILESIZE` multiplied by 3 (`TILESIZE * 3` so mine was `16*3`) -5. Change all instances of `40` to your `COLUMN_COUNT` -6. Change all instances of `36` to your `ROW_COUNT` - -Make sure your script is in the same directory as the file, open Terminal and `cd` to this folder and run: - -`sh bleed.sh` - -you should now have loads of files, but the only one you are interested in is: - -`spritesheet-bleed.png` - -## TODO: Improvements - -Make all of these calculations automatic and based on arguments. +The resulting `output.png` can then be used by some game engines specifying a 2px gap between tiles, and perhaps 1px offset from the top left corner for the first tile. diff --git a/bleed.sh b/bleed.sh index 4f3a6ce..d331da6 100644 --- a/bleed.sh +++ b/bleed.sh @@ -1,3 +1,22 @@ -convert -crop 16x16 spritesheet.png sprite.png -convert sprite-{0..1439}.png -set option:distort:viewport 48x48-16-16 -virtual-pixel Edge -filter point -distort SRT 0 +repage sprite-bleed.png -montage sprite-bleed-{0..1439}.png -tile 40x36 -geometry 48x48+0+0 -background none spritesheet-bleed.png +#!/bin/bash + +if [ $# -lt 3 ] + then + echo "usage: SOURCE DESTINATION TILEWIDTH [TILEHEIGHT]" + exit +fi + +sourcepath=$1 +destpath=$2 +tilew=$3 +tileh=${4:-$3} + +sourcew=`identify -format %w $sourcepath` +sourceh=`identify -format %h $sourcepath` +columns=$(($sourcew / $tilew)) +rows=$(($sourceh / $tileh)) +newtilew=$(($tilew + 2)) +newtileh=$(($tileh + 2)) + +convert -crop ${tilew}x${tileh} $sourcepath -define distort:viewport=${newtilew}x${newtileh}-1-1 -filter point -distort SRT 0 +repage miff:- | +montage - -tile ${columns}x${rows} -geometry +0+0 -background none $destpath From f235d5722ff71c7f660a58902b5c11f94e444ee9 Mon Sep 17 00:00:00 2001 From: Domino Goupil <1er@live.ca> Date: Thu, 10 Oct 2019 17:01:51 -0400 Subject: [PATCH 2/5] Better CLI, custom gaps, bleed and margins --- README.md | 15 ++-- bleed.sh | 236 +++++++++++++++++++++++++++++++++++++++++++++++++---- input.png | Bin 0 -> 4807 bytes output.png | Bin 0 -> 434 bytes 4 files changed, 229 insertions(+), 22 deletions(-) create mode 100644 input.png create mode 100644 output.png diff --git a/README.md b/README.md index 3ea3183..0ccead9 100644 --- a/README.md +++ b/README.md @@ -2,18 +2,21 @@ Automatically stretch out the 1px edge of each tile in a tile sheet to compensate for tile bleed in 2D game development. -This should solve rounding errors which can cause tiles to slightly bleed into their neighbors, such as the very common "gap between tiles" problem in Unity. +This should solve rounding errors which can cause tiles to slightly bleed into their neighbors, such as the very common "gap between tiles" problem in Unity. The script was forked cjonasw's but I added so many features that it ended up quite different from the original. ## Dependencies -This script depends on ImageMagick (tested using ImageMagick 7). `convert`, `montage` and `identify` must be in your PATH. +This script was written for bash and depends on ImageMagick (tested using `ImageMagick 6.9.7-4`). The `convert`, `montage` and `identify` commands must be in your PATH. -Until someone makes a Windows version (`.cmd` or `.ps`) you should be able to run it using bash in the Windows Subsystem for Linux. +Until someone makes a Windows version (`.cmd` or `.ps`) you should be able to run it on Windows 10 using bash in the Windows Subsystem for Linux, provided you've installed ImageMagick within your virtual linux. ## Sample usage - ./bleed.sh input.png output.png 16 + ./bleed.sh input.png output.png --tile-size 16 16 --bleed 3 --input-gap 4 4 --output-gap 1 1 --input-offset 20 20 --output-offset 3 3 -...where `input.png` is a tile sheet with 16x16 tiles without any gap between tiles. If your tiles are not square, you can specify a tile height as a 4th argument. +The script determines the number of tiles based on the size of the file. It ignores content above and the the left of the specified `--input-offset`, and any leftover space that is smaller than a tile on the bottom right. See the sample files in the repository. -The resulting `output.png` can then be used by some game engines specifying a 2px gap between tiles, and perhaps 1px offset from the top left corner for the first tile. +## Known issues + +- Unknown options or options with the wrong number of parameters produce unclear error messages. +- The `--help` flag doesn't work properly because the command fails on missing arguments first. Mitigated by showing the usage on missing arguments. \ No newline at end of file diff --git a/bleed.sh b/bleed.sh index d331da6..e78665a 100644 --- a/bleed.sh +++ b/bleed.sh @@ -1,22 +1,226 @@ #!/bin/bash -if [ $# -lt 3 ] - then - echo "usage: SOURCE DESTINATION TILEWIDTH [TILEHEIGHT]" - exit +usage() { + cat <<-EOM + Usage: bleed INPUT_FILE OUTPUT_FILE [OPTIONS...] + + Extends the edge of of every tile in a tileset by 1px to avoid issues with + neighboring tile bleeding and gaps between rendered tiles. + + Tested with ImageMagick 6.9.7-4 + + Options must appear after the positional arguments: + -t, --tile-size XX YY the size of the tiles + (defaults to 16x16) + -b, --bleed XX how much bleeding should be produced around + each generated tile + (defaults to 1) + -g, --input-gap XX YY the horizontal and vertical gap between + tiles in the input image + (defaults to 0x0) + -o, --input-offset XX YY the offset of the first tile from the + top left corner of the input image + (defaults to 0x0) + -G, --output-gap XX YY the horizontal and vertical gap to leave + between tiles in the output image as + transparent pixels + (defaults to 0x0) + -O, --output-offset XX YY the margins added to the output image + (defaults to 0x0) + -f, --force overwrite the output file if it exists + -v, --verbose display computations during execution + -h, --help display this help text and exit + EOM +} + + +#### INITIALIZE VARIABLES + +positional_args=() + +input_path= +input_tile_width=16 +input_tile_height=16 +input_offset_x=0 +input_offset_y=0 +input_gap_x=0 +input_gap_y=0 + +output_path= +output_offset_x=0 +output_offset_y=0 +output_gap_x=0 +output_gap_y=0 +output_bleed=1 + + +#### PARSE ARGUMENTS + +if [[ $# -lt 2 ]] ; then + echo "Missing arguments." + usage + exit 1 +fi + +input_path=$1 +shift +output_path=$1 +shift + +while [[ $# > 0 ]] ; do + case $1 in + -t | --tile-size ) + shift + input_tile_width=$1 + shift + input_tile_height=$1 + ;; + -b | --bleed ) + shift + output_bleed=$1 + ;; + -g | --input-gap ) + shift + input_gap_x=$1 + shift + input_gap_y=$1 + ;; + -o | --input-offset ) + shift + input_offset_x=$1 + shift + input_offset_y=$1 + ;; + -G | --output-gap ) + shift + output_gap_x=$1 + shift + output_gap_y=$1 + ;; + -O | --output-offset ) + shift + output_offset_x=$1 + shift + output_offset_y=$1 + ;; + -f | --force ) + force=true + ;; + -v | --verbose ) + verbose=true + ;; + -fv | -vf ) + force=true + verbose=true + ;; + -h | --help ) + usage + exit + ;; + * ) + # todo: make sure --help flag is always checked + echo "Incorrect option sequence." >&2 + usage >&2 + exit 1 + esac + shift +done + + +#### VALIDATE ARGUMENTS + +if [[ ! -f $input_path ]] ; then + echo "Input file not found." >&2; exit 1 +fi + +if [[ -e $output_path && $force != true ]] ; then + echo "A file with the specified output path already exists." >&2; exit 1 fi -sourcepath=$1 -destpath=$2 -tilew=$3 -tileh=${4:-$3} +int_regex='^[0-9]+$' +assert_int() { + if ! [[ $2 =~ $int_regex ]] ; then + echo "$1 must be an integer" >&2; exit 1 + fi +} +assert_coords() { + if ! [[ $2 =~ $int_regex && $3 =~ $int_regex ]] ; then + echo "$1 must be two integers separated by a space" >&2; exit 1 + fi +} + +assert_coords "--tile-size" $input_tile_width $input_tile_height +assert_int "--bleed" $output_bleed +assert_coords "--input-gap" $input_gap_x $input_gap_y +assert_coords "--input-offset" $input_offset_x $input_offset_y +assert_coords "--output-gap" $output_gap_x $output_gap_y +assert_coords "--output-offset" $output_offset_x $output_offset_y + + +#### BEGIN COMPUTATION + +# ENABLE VERBOSE MODE IF DESIRED +if [[ $verbose == true ]] ; then + set -x +fi + +# GET IMAGE SIZE +input_file_width=`identify -format %w $input_path` +input_file_height=`identify -format %h $input_path` + +# CROP MARGINS +input_right_margin=$(( ($input_file_width + $input_gap_x - $input_offset_x) % ($input_tile_width + $input_gap_x) )) +input_bottom_margin=$(( ($input_file_height + $input_gap_y - $input_offset_y) % ($input_tile_height + $input_gap_y) )) +input_usefull_width=$(( $input_file_width - $input_offset_x - $input_right_margin )) +input_usefull_height=$(( $input_file_height - $input_offset_y - $input_bottom_margin )) +crop_margins_geometry="${input_usefull_width}x${input_usefull_height}+${input_offset_x}+${input_offset_y}" + +# SLICE INTO TILES +slice_width=$(($input_tile_width + $input_gap_x)) +slice_height=$(($input_tile_height + $input_gap_y)) +slice_to_tiles_geometry="${slice_width}x${slice_height}" + +# REMOVE TILE GAP +crop_tile_gap_geometry="${input_tile_width}x${input_tile_width}+0+0" + +# ADD BLEEDING +bleeding_width=$(($input_tile_width + (2 * $output_bleed) )) +bleeding_height=$(($input_tile_height + (2 * $output_bleed) )) +distort_bleed_geometry="${bleeding_width}x${bleeding_height}-${output_bleed}-${output_bleed}" + +# ADD TILE GAP +output_tile_width=$(($bleeding_width + $output_gap_x )) +output_tile_height=$(($bleeding_height + $output_gap_y )) +output_tile_geometry="${output_tile_width}x${output_tile_height}+0+0" + +# MERGE TILES +columns=$(( ($input_file_width + $input_gap_x - $input_offset_x) / ($input_tile_width + $input_gap_x) )) +rows=$(( ($input_file_height + $input_gap_y - $input_offset_y) / ($input_tile_height + $input_gap_y) )) + +# REMOVE LAST GAP +output_usefull_width=$(( ($output_tile_width * $columns) - $output_gap_x )) +output_usefull_height=$(( ($output_tile_height * $rows) - $output_gap_y )) +crop_extra_gap_geometry="${output_usefull_width}x${output_usefull_height}+0+0" + +# ADD MARGIN +output_total_width=$(($output_usefull_width + (2 * $output_offset_x) )) +output_total_height=$(($output_usefull_height + (2 * $output_offset_y) )) +output_size_geometry="${output_total_width}x${output_total_height}" + +# DISABLE VERBOSE OUTPUT +{ set +x; } 2>/dev/null + -sourcew=`identify -format %w $sourcepath` -sourceh=`identify -format %h $sourcepath` -columns=$(($sourcew / $tilew)) -rows=$(($sourceh / $tileh)) -newtilew=$(($tilew + 2)) -newtileh=$(($tileh + 2)) +#### SUBMIT TASK TO IMAGEMAGICK -convert -crop ${tilew}x${tileh} $sourcepath -define distort:viewport=${newtilew}x${newtileh}-1-1 -filter point -distort SRT 0 +repage miff:- | -montage - -tile ${columns}x${rows} -geometry +0+0 -background none $destpath +convert $input_path \ + -crop $crop_margins_geometry +repage +gravity \ + -crop $slice_to_tiles_geometry +repage \ + -crop $crop_tile_gap_geometry +repage \ + -define distort:viewport=$distort_bleed_geometry -filter point -distort SRT 0 +repage \ + -background none -extent $output_tile_geometry miff:- | +montage - -tile ${columns}x${rows} -geometry +0+0 -background none +repage miff:- | +convert - \ + -crop $crop_extra_gap_geometry +repage \ + -gravity center -background none -extent $output_size_geometry \ + $output_path \ No newline at end of file diff --git a/input.png b/input.png new file mode 100644 index 0000000000000000000000000000000000000000..8dee02ca0029b68858c1a13fb2acca16ce44f455 GIT binary patch literal 4807 zcmV;&5;*ONP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O?WzmMgarh5us}UIKDh4&pi5ftT;EfM%NE@Qq}9 zC^4YXK*d|P&`-^O|FzV=_zSLRTezDOtZo+%pZ3{h1WNu&W>xGrg?UwJhTO+SEk9O5ZEEUzIl)jeO-4@m~-nZ=iy2M zVbZu3z(njF5XLw>prdiYM5B|n$r$XI@lQo^>%47vz=U9jQ48NV7jaIuvN!i6v*+4i z&oIz}BLXRsa19BBv%C+)Px6@UKo_g-3 z*I|bnr2mK`sgXw+b(%>iO+UkoGtE59tczG%Zuu2fTxsQ1R=s=e^6IPC%oopn_L{l8 zCLZ&9UV3;4y>Q{uYIbKm{;#%rVQisH6|Bn!o++AV;M2{Tul ztJI{|&*oxSvjK;#t$`6%#gNw!mv4hTCe;di8#au_2mbSA*z-+l*6%;nZze`JDz4eP|CwSb<>TD68Z1;~ot;)o8^=ne+FnM0h__D_ItM@^u+1kn|eXKz01pRW^ ztVp7**2^kIVF#?%XLqwU-|NfO>Shl%t;C2E)pJE<_71U-sYZ|LQYkj-tgMTxH)f-{ zTXVKGv1A)No~&bcY!KV*J1M{n$-il00qLw=Gjz5#YpRY~L$e>3oa>!wy^%XEkCx}i zeWo@-4Sm!`JeFXAq0ozlkYs{(H1Tm*YLQtl(zJ=kHC%V3X(LJRd?Z5suv0IciEctl zk2rgS`6XL>$XHSVWP`Y7LPm)eW-p#vXdT}%Zg$tEL|c&e@B1z-bwU9!PDaWUwE>lA z0_NZwNYG?Wz3K?w&4?!CPyi`c8$Hf325Gihl+;ust)4>~(}bD!0xn6-KmyA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zDPLDnr`$I{7uE=tDWohX{lfDM~cbC#JYKU zL29Txds%XV3ioa?Qd8k3-RZy zZF0Bv6&l|{Kt1JC`PL_-I8wLaoWjWg(b@~UnhPCmh??1HW#wl zi^ISzKAlbf-y1(Gx!-fk$c04 zof+V^EC_PJ}mXJd1y_y z6soxj%NL}lYZSH@Jd8xxW4MZHJ0+lo&dqK%vaGWTu@1J4peV+Ni^)?<0DsMMEG`c$ zk)GR9jIju_YWEfEe*PMs?^V|6RVVz@Ie$8?>}vmQ!}a)7zns`yl;^8%3TDtlgi34O zVwyQzJ~mX;;m;*|4GH+7iukBbB z?bpL`EhC(904${>!WjoZIG|3?iu9s?p5uUq4p1h*!T~W3paulh0Br;r2b=)FRzWr# za9#@1j^{vda)7ONyJdENvl{UFylr{y5rB5=cxphy6jT#P*YwlN?%yiHDh#Nb1Eyir zG>qyUz*fh@Ilxh#L9>*SxEI$0bY*a9N_2%91sWq z2VB4b=;RtO?|ODWT@YOmE}#pd3qo{3bU`S{0q7ur*XRAc?wM9CThEfmUDvxr3R+CC zC7b6=dAXSjqjs0ibL11&l;;W9B34qlIQ z05t#s000O806+i$00IC25C8yx0B}<^xf^=qu3_%IS6c550Ob5t6z^!=b0&|K+X2~&ir0SEv9KmY&$0ssII004jh000DlKEzBoSp3*_p_c!yOA4X} hAOHXW0RRA~R(~gj(`8x@c)kDt002ovPDHLkV1l|lCdmK* literal 0 HcmV?d00001 diff --git a/output.png b/output.png new file mode 100644 index 0000000000000000000000000000000000000000..e5e44184dba59297efc5b5bf880115cb90bea2f7 GIT binary patch literal 434 zcmeAS@N?(olHy`uVBq!ia0vp^i9qbd!2%>1Q$F1VQY`6?zK#qG8~eHcB(ehe3dtTp zz6=aiY77hwEes65fIW6x!wK;uw-~@9m9)T+Ido3>SNU{NKMuTwhg-P1ri}S*%yL zZcpdJoR%w&mT}vcz3*l5Z>uS!jG=2U4_U^W|+h3koJ%4rBLKm0LPp{nfZ=F|v zr>Nu4?W3CwE^Ec8EQx5X3^{*Dtaxpsx=^#a5Ri1-SHCJ(I^)UJ^QsZ7!dF_IC76Uc zjQA3tB{Ma0vZx8na7X|#_!2pM0>nY2LIH;}SO`UK!lfIGY!juH-gR1E2K0q$iEBhj zN@7W>RdP`(kYX@0FtpS)GytLyLo+K=Q!4`_T>}#<1B0N)7muK5$jwj5OsmALL3v+h Q1yBQnr>mdKI;Vst0I{=+n*aa+ literal 0 HcmV?d00001 From d06b82adf188bfb81497e59c14c2b310b991d38b Mon Sep 17 00:00:00 2001 From: Domino Goupil <1er@live.ca> Date: Thu, 10 Oct 2019 17:06:59 -0400 Subject: [PATCH 3/5] Fix indentation in usage message --- bleed.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bleed.sh b/bleed.sh index e78665a..93c1c98 100644 --- a/bleed.sh +++ b/bleed.sh @@ -27,7 +27,7 @@ usage() { (defaults to 0x0) -O, --output-offset XX YY the margins added to the output image (defaults to 0x0) - -f, --force overwrite the output file if it exists + -f, --force overwrite the output file if it exists -v, --verbose display computations during execution -h, --help display this help text and exit EOM From c2c985b2e878c95c17b09b272189876952d34873 Mon Sep 17 00:00:00 2001 From: DominoPivot <1er@live.ca> Date: Thu, 10 Oct 2019 20:01:22 -0400 Subject: [PATCH 4/5] Fix missing words in description --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0ccead9..84f1f6f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Automatically stretch out the 1px edge of each tile in a tile sheet to compensate for tile bleed in 2D game development. -This should solve rounding errors which can cause tiles to slightly bleed into their neighbors, such as the very common "gap between tiles" problem in Unity. The script was forked cjonasw's but I added so many features that it ended up quite different from the original. +This should solve rounding errors which can cause tiles to slightly bleed into their neighbors, such as the very common "gap between tiles" problem in Unity. The script started as a fork but I added so many features that it ended up quite different from [the original](https://github.com/cjonasw/tile-bleed-margin-generator). ## Dependencies @@ -19,4 +19,4 @@ The script determines the number of tiles based on the size of the file. It igno ## Known issues - Unknown options or options with the wrong number of parameters produce unclear error messages. -- The `--help` flag doesn't work properly because the command fails on missing arguments first. Mitigated by showing the usage on missing arguments. \ No newline at end of file +- The `--help` flag doesn't work properly because the command fails on missing arguments first. Mitigated by showing the usage on missing arguments. From e05462956f3e9d37ca6813c2a7509b8730a7a9ef Mon Sep 17 00:00:00 2001 From: DominoPivot <1er@live.ca> Date: Fri, 1 Jan 2021 18:30:04 -0500 Subject: [PATCH 5/5] Mentioned the Unity plugin by chonkypixel --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 84f1f6f..a423bf8 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ Automatically stretch out the 1px edge of each tile in a tile sheet to compensat This should solve rounding errors which can cause tiles to slightly bleed into their neighbors, such as the very common "gap between tiles" problem in Unity. The script started as a fork but I added so many features that it ended up quite different from [the original](https://github.com/cjonasw/tile-bleed-margin-generator). +Alternatively, you might want to look at chonkypixel's solution which is integrated in the Unity editor. I haven't tested it myself, but it has a UI which does exactly the same thing. https://assetstore.unity.com/packages/2d/textures-materials/tiles/2d-tile-gap-fixing-tool-157060 + ## Dependencies This script was written for bash and depends on ImageMagick (tested using `ImageMagick 6.9.7-4`). The `convert`, `montage` and `identify` commands must be in your PATH.