Page 1 of 1

Figuring width and height of textures

Posted: Sat Feb 04, 2017 3:52 am
by darkshadow1809
Hi there,

Simple question. I've recently gotten some custom graphics from Yuokitani he has done an fantastic job but how would I go about figuring out the following things?

Width
Height
Shift
Scale

http://johnsmith.ktec.de/factorio/mods/ ... _sheet.png
http://johnsmith.ktec.de/factorio/mods/ ... _sheet.png

^

Re: Figuring width and height of textures

Posted: Sat Feb 04, 2017 4:35 am
by keyboardhack
width = (sprites along x axis) / (texture width)
height = (sprites along y axis) / (texture height)
shift i have no idea but YuokiTani made a tool to calculate it viewtopic.php?f=135&t=12171&p=82661&hil ... ift#p81858
scale depends on what size you want the building to have in game. a 32x32 image of a chest with scale = 1 will have the size 1x1 tile. with scale = 2 the size will be 2x2. the formula is: scale(tileSize, imageSize) = tileSize / (imageSize / 32)

s33_sheet:
  • width = 4 / 1024 = 256
  • height = 4 / 1024 = 256
  • scale with a tile size of 4x4 the scale should be scale(4, 256) = 0.5, with tile size 3 scale(3, 256) = 0.375
s44_sheet
  • width = 4 / 1280 = 320
  • height = 4 / 1280 = 320
  • scale with tile size 4 scale(4, 320) = 0.4, with tile size 3 scale(3, 320) = 0.3

Re: Figuring width and height of textures

Posted: Sat Feb 04, 2017 5:32 am
by darkshadow1809
keyboardhack wrote:width = (sprites along x axis) / (texture width)
height = (sprites along y axis) / (texture height)
shift i have no idea but YuokiTani made a tool to calculate it viewtopic.php?f=135&t=12171&p=82661&hil ... ift#p81858
scale depends on what size you want the building to have in game. a 32x32 image of a chest with scale = 1 will have the size 1x1 tile. with scale = 2 the size will be 2x2. the formula is: scale(tileSize, imageSize) = tileSize / (imageSize / 32)

s33_sheet:
  • width = 4 / 1024 = 256
  • height = 4 / 1024 = 256
  • scale with a tile size of 4x4 the scale should be scale(4, 256) = 0.5, with tile size 3 scale(3, 256) = 0.375
s44_sheet
  • width = 4 / 1280 = 320
  • height = 4 / 1280 = 320
  • scale with tile size 4 scale(4, 320) = 0.4, with tile size 3 scale(3, 320) = 0.3
Ohh that makes a lot more sense. Lol thanks a lot man!

Re: Figuring width and height of textures

Posted: Sun Feb 05, 2017 3:59 pm
by darkfrei
And some method for cropping empty space by sprites for sprite sheet?

Re: Figuring width and height of textures

Posted: Sun Feb 05, 2017 11:05 pm
by keyboardhack
darkfrei wrote:And some method for cropping empty space by sprites for sprite sheet?
If you mean going from this
Image
to this
Image

Then the game already does that for you when it loads the mod. With a zipped mod it probably only takes a dozen bytes extra per texture so it's probably not worth doing yourself.

Re: Figuring width and height of textures

Posted: Mon Feb 06, 2017 6:21 am
by darkfrei
keyboardhack wrote: Then the game already does that for you when it loads the mod. With a zipped mod it probably only takes a dozen bytes extra per texture so it's probably not worth doing yourself.
Also, I can render 512x512 pixels sprites with 128x128 pixels entities, for example, 64 frames pro sprite sheet without problem with memory?

I think nobody need too much free space on the sprite.