[Tutorial] sprites.png sizing

Discussion about Mods for Prison Architect

Moderator: NBJeff

Puman
level1
level1
Posts: 48
Joined: Fri Aug 29, 2014 1:21 pm

[Tutorial] sprites.png sizing

Postby Puman » Mon Nov 10, 2014 7:53 pm

A few people have complained that my last mods have had faulty graphics when combined with other mods so I did some research into how sprites.png is handled by the engine. I also found that people have proposed that the solution would be to create larger 'master' sprites.png for their mods, my research show that solution has actually made the problem worse.

All mods together must share a total space of 2048x2048 pixels (this is mentioned in the games debug log). The sprites.png of all mods are packed into this limited space, when the space runs out the next mods will get rather random graphics.

I did an experiment with a number of mods to confirm this theory. In the experiment I loaded a number of mods with large sprites.png files and then noted when the graphics started becoming faulty. Look at the middle example below, the first four mods will work fine, the fifth mod will not, because it doesn't fit anywhere.

Now if the creators of those mods had used smaller sprites.png files, just enough to fit their graphics in, all mods would easily have fitted and there would have been space to spare for a bunch of other mods as in the rightmost picture.

Image

These are the rules you should follow when creating a sprites.png file if you want it to play better together with other mods:
keep it as small as possible
use sides that are 32, 64, 128, 256, 512, 1024 or 2048 pixels wide
keep it as square as possible without wasting space (for example 256x512 is better than 128x1024)

I hope we can get more mods active at the same time in the future by adhering to this :D
Last edited by Puman on Tue Nov 11, 2014 6:20 pm, edited 3 times in total.
elDiablo
level5
level5
Posts: 3111
Joined: Thu Mar 14, 2002 12:23 pm
Location: London, UK

Re: [Tutorial] sprites.png sizing

Postby elDiablo » Tue Nov 11, 2014 8:50 am

This is an excellent and informative post. I would say don't worry about keeping them square. In your third example you show a sprite.png that is 512x256. If the mod doesn't need to use the extra space, then making it square would double the size of the sprite and waste space. The packing algorithm will probably be modified at some point to improve the overall performance of this, and we always want to keep wasted space to a minimum.
User avatar
HookerHeels
level1
level1
Posts: 42
Joined: Mon Aug 19, 2013 7:23 am
Location: Texarkana, Texas.

Re: [Tutorial] sprites.png sizing

Postby HookerHeels » Tue Nov 11, 2014 9:34 am

elDiablo wrote:This is an excellent and informative post. I would say don't worry about keeping them square. In your third example you show a sprite.png that is 512x256. If the mod doesn't need to use the extra space, then making it square would double the size of the sprite and waste space. The packing algorithm will probably be modified at some point to improve the overall performance of this, and we always want to keep wasted space to a minimum.



And more materials (multiple tilesets.png)
Puman
level1
level1
Posts: 48
Joined: Fri Aug 29, 2014 1:21 pm

Re: [Tutorial] sprites.png sizing

Postby Puman » Tue Nov 11, 2014 6:05 pm

elDiablo wrote:This is an excellent and informative post. I would say don't worry about keeping them square. In your third example you show a sprite.png that is 512x256. If the mod doesn't need to use the extra space, then making it square would double the size of the sprite and waste space. The packing algorithm will probably be modified at some point to improve the overall performance of this, and we always want to keep wasted space to a minimum.

It is true you should prioritize not wasting space, I was thinking more along the lines, don't make it 32x2048, because then the next modder who choose to do his sprite 2048x32 would not fit :D
I edited the post to clarify that, thanks.
elDiablo
level5
level5
Posts: 3111
Joined: Thu Mar 14, 2002 12:23 pm
Location: London, UK

Re: [Tutorial] sprites.png sizing

Postby elDiablo » Wed Nov 12, 2014 9:11 am

Ah, I understand now. Yes, good point.
Mercury002
level1
level1
Posts: 19
Joined: Wed Feb 11, 2015 11:25 pm

Re: [Tutorial] sprites.png sizing

Postby Mercury002 » Thu Feb 12, 2015 1:55 am

You should use the minimum size required by your mod, as you may add something 64 x 64 pixels or 192 x 64 pixels, using this method would allow for many / multiple mods to be loaded without conflict, use some sorting method in order to pack you mod into the smallest or most efficient space.

I HAVE FOUND THAT THE MAXIMUM SIZE FOR A SINGLE MOD IS 1024 X 1024 ...

... this sucks as I was trying to condense several mods (Going postal, Money Laundering Mod, Aviation, Chad's Drink Mod and several things I am working on) into one mod. Fortunately I managed to get all of the aforementioned mods into this size with plenty of room to spare to fit some ... but no all of the mods I was working on, so I have a second 1024 x 1024 mod which is plenty of room to fit the remaining in with room to spare. It would be easier to allow for one larger mod, even if its 1536 x 1536, as you can fit many sprites into one file and allow you to reference them repeatedly without duplication of one sprite across 2 (or more) mods.

It would be handy to create a Sprites.spritebank so that mods can reference sprites from another mod's sprite file and vice versa, just like objects.spritebank or interface.spritebank work with mods, but again this hasn't been implemented to work for mods as the file name "Sprites.png" is use by all mods and conflict could be an issue, if you could use any file name and link it to a .spritebank it would be better.
JASPer.Gamer.9.0
level3
level3
Posts: 380
Joined: Fri Sep 06, 2013 12:29 am

Re: [Tutorial] sprites.png sizing

Postby JASPer.Gamer.9.0 » Thu Feb 12, 2015 9:39 am

Mercury002 wrote:You should use the minimum size required by your mod, as you may add something 64 x 64 pixels or 192 x 64 pixels, using this method would allow for many / multiple mods to be loaded without conflict, use some sorting method in order to pack you mod into the smallest or most efficient space.

I HAVE FOUND THAT THE MAXIMUM SIZE FOR A SINGLE MOD IS 1024 X 1024 ...

... this sucks as I was trying to condense several mods (Going postal, Money Laundering Mod, Aviation, Chad's Drink Mod and several things I am working on) into one mod. Fortunately I managed to get all of the aforementioned mods into this size with plenty of room to spare to fit some ... but no all of the mods I was working on, so I have a second 1024 x 1024 mod which is plenty of room to fit the remaining in with room to spare. It would be easier to allow for one larger mod, even if its 1536 x 1536, as you can fit many sprites into one file and allow you to reference them repeatedly without duplication of one sprite across 2 (or more) mods.

It would be handy to create a Sprites.spritebank so that mods can reference sprites from another mod's sprite file and vice versa, just like objects.spritebank or interface.spritebank work with mods, but again this hasn't been implemented to work for mods as the file name "Sprites.png" is use by all mods and conflict could be an issue, if you could use any file name and link it to a .spritebank it would be better.

HAVE YOU ASKED THE CREATORS OF THOSE MODS IF YOU ARE ALLOWED TO USE/CHANGE THEM???
User avatar
Chad
level3
level3
Posts: 255
Joined: Wed Sep 26, 2012 8:00 pm

Re: [Tutorial] sprites.png sizing

Postby Chad » Thu Feb 12, 2015 10:00 am

Mercury002 wrote:(...)
... this sucks as I was trying to condense several mods (Going postal, Money Laundering Mod, Aviation, Chad's Drink Mod and several things I am working on) into one mod. Fortunately I managed to get all of the aforementioned mods into this size with plenty of room to spare to fit some ... but no all of the mods I was working on, so I have a second 1024 x 1024 mod which is plenty of room to fit the remaining in with room to spare. It would be easier to allow for one larger mod, even if its 1536 x 1536, as you can fit many sprites into one file and allow you to reference them repeatedly without duplication of one sprite across 2 (or more) mods.
(...)

What Jasper wants to say is the following:
He already tried to combine mods without permission of the original mod creators. Now his reputation here is very very low.

Two things:
- Don't do that. I can only talk for myself but: Don't change my mod in any way without my permission!
- There is no need to combine mods, you can just make a compilation of mods in steam.

JASPer.Gamer.9.0 wrote:(...)HAVE YOU ASKED THE CREATORS OF THOSE MODS IF YOU ARE ALLOWED TO USE/CHANGE THEM???(...)

You really should be the last one complaining about that Jasper...
Mercury002
level1
level1
Posts: 19
Joined: Wed Feb 11, 2015 11:25 pm

Re: [Tutorial] sprites.png sizing

Postby Mercury002 » Thu Feb 12, 2015 11:23 am

For a start I am not releasing the mods ... its for personal use only, to test out my mods whilst still playing with my favourite mods. At no point did I say I was going to steal them or take credit of them.

Some of the mods needed a little work for me to use them, for example the aviation mod, the helicopter used is cartoony and far too small to fit a person in so I changed the sprite was it was making me crazy (... on a side note, once I was happy with the changes I was going to send the sprites to the author), the sprite used too copies of the same helicopter mirrored, left and right, so I created a front, back and left sprite and changed the rotation ... and the helipad to fit a larger helicopter. Okay on the whole I like the idea of the mod but the visual needs work, its an alpha game therefore alpha mods and flaws are to be expected.

The going postal mod is terribly inefficient, there are gaps everywhere, sprites went aligned properly, unused graphics left in and inclusion of duplicate graphics such as the model taken from people.png (if your going to include a new person, at least change the graphics a little form an existing person (i.e. give him a postmaster uniform .. one of the next mod update I think). Additionally the post truck used is obviously taken from somewhere else and enlarged as it is fuzzy and completely different form the rest of the mods graphics.

The money laundering mod is terribly inefficient, there are gaps everywhere.

All of these gaps and inefficiencies meant that I got sprite errors, when using my own mods too. It is surprising that you can remove sooo much waste that people have deliberate left in and free up soo much room for modding, as shown in the first example of this thread (images two and three), once these mods had been condensed down, they all fitted with ease and I still have about 2/3 of modding room free to add stuff.

Now with Chad's mod I was modifying some aspects as a proof of concept. I was trying to add a bit of fire resistance to some of the water parts, ie no fire spread near a water-cooler or water-fountain (this was to include sinks and showers too) after all fire shouldn't burn water and prisoners could use it to protect themselves from fire. I was working on the code before I created the sprites and thought why no just use some of the existing sprites, I would (obviously) include my own sprites and functionalities if it was finished and ready for release.

PS you can remove the model taken from people.png from your mod and reference the sprite by adding the details into the objects.spritebank, you can also remove the "chad's drink mod" and move some things about to make the sprites a little smaller and more efficient, but other wise a good / great mod.

I am creating a mod with a number of changes to or additions to fire, its a little nuts at the moment and OP but lets just say flame throwers are fun / funny / a nightmare. I may release an earlier version as a joke as it was hilarious, long story short prison burned down and every single prisoner in there and a few glitches happened, such as a burning truck driver got into the truck.

I've not known a modding community like this one ... you guys are terrible, everyone is obsessing about there mod and permission, jumping to conclusions and wild accusations. If I see a problem and fix it for my personal use only without changing the ownership or anything else and not affecting anyone else, then I see no problem.

I did see in another forum, someone asked for help to map a sprite to materials.txt and he uploaded the mod sprite, then another user uploaded the mod to steam and told the original creator to just download it and use it, he included the original creator as a co-author. This is clearly wrong as the author did not give permission and the files used were unfinished and of poor quality, thus potentially the original creator had there name to something they didn't want, wasn't finished and was of poor quality and reputation.

Other modding communities seem much more friendly and open, take the civilisation modding community, if you are creating a new mod based upon a previous mod or someone else's, everyone is willing to help. At the moment someone is working on taking a civ 5 mod that created bridges and introducing it into civBE, everyone is helping not hindering.
Mercury002
level1
level1
Posts: 19
Joined: Wed Feb 11, 2015 11:25 pm

Re: [Tutorial] sprites.png sizing

Postby Mercury002 » Thu Feb 12, 2015 11:58 am

Chad wrote:What Jasper wants to say is the following:
He already tried to combine mods without permission of the original mod creators. Now his reputation here is very very low.

Two things:
- Don't do that. I can only talk for myself but: Don't change my mod in any way without my permission!
- There is no need to combine mods, you can just make a compilation of mods in steam.

JASPer.Gamer.9.0 wrote:(...)HAVE YOU ASKED THE CREATORS OF THOSE MODS IF YOU ARE ALLOWED TO USE/CHANGE THEM???(...)

You really should be the last one complaining about that Jasper...


OK now I see why you are alarmed, I just clicked his link and went straight to his most active thread ([MOD DISCONTINUED] The PA Mods Compilation .... viewtopic.php?t=51114)

Yeah I am not doing that, not released and don't indent to release a compilation (I may contact the authors about the problems there sprites are causing and send them the modified / solved files back to them, but something as basic as this would not warrant any recognition such as co-author) This was for personal use only.

as for your two things: (not in order)
- There is no need to combine mods, you can just make a compilation of mods in steam.
xx This whole thread is created to highlight a problem with using multiple mods, the need to make mod sprites smaller and more efficient or you get sprite errors like I was getting. So to combat this I decided to combine mods rather than not use them or get errors. That said, upon reflection your mod wasn't really the problem, the main culprits for wasted space were going postal and money laundering, I just included all mods by default, I could take it out and should no longer get the sprite errors as long as I keep the others in / until they fix it.

- Don't do that. I can only talk for myself but: Don't change my mod in any way without my permission!
xx Far enough I could always a temporary image like a giant pink square as proof of concept or just the stock items, it just really bugs me that the shower room catches fire...

On a side note, I don't really care for recognition (game play comes first) and if you would be so gracious as to allow me to use your mod / sprites I would happily send you the working code (If I can get it working correctly and not over powered) to include into your own mod, under your own name if you want, just don't exclude others form using the same bits of code GNU style.
User avatar
St0l3n_ID
level1
level1
Posts: 16
Joined: Thu Jan 09, 2014 2:47 am

Re: [Tutorial] sprites.png sizing

Postby St0l3n_ID » Sun Mar 15, 2015 1:50 pm

Good Thread, thanks for your efforts :)
Seraruth
level0
Posts: 7
Joined: Fri Feb 06, 2015 10:21 am

Re: [Tutorial] sprites.png sizing

Postby Seraruth » Sat May 09, 2015 5:05 pm

Do I understand it correctly, it's possible to use 16 mods with a sprite size of 512x512? Or are I'm wrong?
Sumurai8
level2
level2
Posts: 92
Joined: Fri Feb 06, 2015 1:08 am

Re: [Tutorial] sprites.png sizing

Postby Sumurai8 » Sun May 10, 2015 9:20 am

Seraruth wrote:Do I understand it correctly, it's possible to use 16 mods with a sprite size of 512x512? Or are I'm wrong?


In theory: yes.
Azzarrel
level0
Posts: 1
Joined: Tue Feb 04, 2014 11:00 pm

Re: [Tutorial] sprites.png sizing

Postby Azzarrel » Sat Jun 27, 2015 11:05 pm

well, this sizing issue really is a shame.
there are many good mods out there i can't use, even it they would work together, just because of their sprites :/
Trixi
level2
level2
Posts: 245
Joined: Wed Mar 04, 2015 9:22 am
Location: Ulm, Germany
Contact:

Re: [Tutorial] sprites.png sizing

Postby Trixi » Fri Aug 07, 2015 3:11 pm

oh thanks for this thread, it explains a lot :)

Return to “Modding”

Who is online

Users browsing this forum: No registered users and 3 guests