• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Graphics Are sprites cropped when put into texture pages?

YanBG

Member
I'm using png frames for the character animations and they have transparency. This is how the game looks now: http://media.indiedb.com/images/games/1/44/43236/Screenshot_5.png
I render blender models with a script that creates .sprite files for direct use in GM:S and it's just a few clicks but i had to crop each one manually in the resource tree.

The problem is that my game became too heavy(26 texture pages) and i still have to put more environmental objects, so i was thinking about re-rendering the characters in smaller resolution/size(maybe even a mobile port) because they are pretty big now. With half the size, less frames per animation and 5 angles instead of 8 they would use 4-5 times less space. The rendering would be a lot faster as well but i wonder how much manual work i have to do in GM:S itself, e.g. would they get cropped automaticly or there will be more texture pages and lag because of the transparent space?

Also recently i started to get "out of Memory Error" while compiling the texture pages on a fresh run of the game. Any ideas why is that, maybe my graphics card can't take anymore?
 

Phil Strahl

Member
Also recently i started to get "out of Memory Error" while compiling the texture pages on a fresh run of the game. Any ideas why is that, maybe my graphics card can't take anymore?
Without knowing about your coding, you might have a memory leak somewhere, e.g. by not freeing any surfaces/sprites that you don't you need? It might help to create textures and sprites as needed and not have them present right from the start. Granted, this means more coding work.

GM:S Creates the all texture pages each time you compile, so ideally there's no wasted space on the texture pages, unless you have lots of transparency around your sprites with stray pixels at the edges, or don't allow cropping on the corresponding texture page. What might help is enabling "Create Textures on demand" in Global Game Settings > Windows > Graphics > Advanced. What can also help is to limit the size of the texture pages to more but smaller ones.

About cropping your sprites: To my knowledge, the "safest" way is to manually do it inside GM:S editor (or maybe Parakeet 2, if you use it) to make sure your origins and collision masks are like they should. Alternatively, you could write your own tool that outputs GM:S compatible sprites, but again: Lots of work, there might be already something like this out there. Still, you'd have to import those sprites to GM:S (and wire them up the corresponding objects, etc.).
 

RangerX

Member
Each time your script creates a sprite I think GMS puts it on a new texture page.
If that's the case you're better prepare all your sprites as spritesheets and have them in your ressource tree from the start. This way they get compiled and auto-cropped in the less texture pages possible.
 

Phil Strahl

Member
Each time your script creates a sprite I think GMS puts it on a new texture page.
Not quite. Usually it gets put on the "Default" sheet, but you can create as much as you need. Still, if the sprites exceed the resolution, a new page will be added to the sheet with the same resolution. So if you overshoot by just 1 sprite that won't fit, there's another texture page allocated in memory, mostly empty but for the exceeding sprite.

EDIT: I didn't read your reply properly, since I thought you were talking about *manually* adding a sprite. Where it is placed on when created via script I don't know either. Sorry for wisecracking there ;)
 
Last edited:

RangerX

Member
Not quite. Usually it gets put on the "Default" sheet, but you can create as much as you need. Still, if the sprites exceed the resolution, a new page will be added to the sheet with the same resolution. So if you overshoot by just 1 sprite that won't fit, there's another texture page allocated in memory, mostly empty but for the exceeding sprite.

EDIT: I didn't read your reply properly, since I thought you were talking about *manually* adding a sprite. Where it is placed on when created via script I don't know either. Sorry for wisecracking there ;)
Since GMS does it for particles and sprites or background loaded at runtime, I would bet it does the same when you create a sprite or background at runtime.
 

YanBG

Member
Thank you guys for the answers! First, i'm sorry for not explaining the .sprite making process, here is the blender script: http://gmc.yoyogames.com/index.php?showtopic=657241&hl=+blender++script it makes them in gmx format and they contain the origins, image count etc, the actual frames are in "images" folder. Then i drag and drop the .sprite.gmx into the resource tree. They are inside the project and they are not icluded files.

Without knowing about your coding, you might have a memory leak somewhere, e.g. by not freeing any surfaces/sprites that you don't you need? It might help to create textures and sprites as needed and not have them present right from the start. Granted, this means more coding work.
It heppens only when making the cache and the game doesn't start, then if i run the 2nd time all works and if i export the game to installer etc it plays without any issue.
GM:S Creates the all texture pages each time you compile, so ideally there's no wasted space on the texture pages, unless you have lots of transparency around your sprites with stray pixels at the edges, or don't allow cropping on the corresponding texture page. What might help is enabling "Create Textures on demand" in Global Game Settings > Windows > Graphics > Advanced. What can also help is to limit the size of the texture pages to more but smaller ones.
There are no stray pixels, but their dimensions are about twice as big before cropping because i don't change the camera for all angles and animations(when they die they fall to one side and need more space), it's hard to notice the size but here are original render and the cropped one from the game: http://imgur.com/a/TWadF
Wow i haven't noticed the option to "Create Textures on demand", thanks i will try it tomorrow!
For the size of texture pages: i have the free version(GM:S) and i can't edit that.
About cropping your sprites: To my knowledge, the "safest" way is to manually do it inside GM:S editor (or maybe Parakeet 2, if you use it) to make sure your origins and collision masks are like they should. Alternatively, you could write your own tool that outputs GM:S compatible sprites, but again: Lots of work, there might be already something like this out there. Still, you'd have to import those sprites to GM:S (and wire them up the corresponding objects, etc.).
I was doing the manual cropping so far, haven't used Parakeet 2, what you can tell me about it? Since i use too many sprites they are all referenced in the code and replacing them wouldn't matter as long as they use the same names.
Each time your script creates a sprite I think GMS puts it on a new texture page.
If that's the case you're better prepare all your sprites as spritesheets and have them in your ressource tree from the start. This way they get compiled and auto-cropped in the less texture pages possible.
Spritesheets sounds interesting but how would i code it so different objects draw the right parts and even animations, with sprite_add? Also would it increase or reduce memory usage?
Not quite. Usually it gets put on the "Default" sheet, but you can create as much as you need. Still, if the sprites exceed the resolution, a new page will be added to the sheet with the same resolution. So if you overshoot by just 1 sprite that won't fit, there's another texture page allocated in memory, mostly empty but for the exceeding sprite.
Default sheet?
 

RangerX

Member
You already have all your sprites in the resources tree so that's good. This means they are put into textures pages by default when you compile your game. GameMaker assemble all of them as close as possible respecting transparent space around them into texture pages of the maximum size you indicated in the global options (see graphic tabs and also you can organise to texture pages by grouping your graphics ressources in the texture groups tab)

I don't know about the tool you're using to convert your sprites but let's say you have a way to make a spritesheet, you can import them into your ressource tree like this:

- create a sprite
- in the properties, click "create from strip" (I think it needs to be an image format here)
- fill in the necessary information (number of images per columns and rows, sizes, offsets, etc)
 

YanBG

Member
I can't see "create from strip", is it something from the Pro version?

Just noticed that "out of Memory Error" comes right after compiling the sound which is after the texture pages. My sounds are 100mb(voice acting, music etc), so i'll see if replacing wav with mp3 and reducing the size would help.
 

YanBG

Member
Ok i reduced the audio size and "Out of Memory", during fresh compiling, seized to exist. I wonder if it was due to my old sound card, does the compiler run the audio through it?
 
Top