Jump to content


Photo

Custom external sprite handling & drawing [GM:S]


  • Please log in to reply
97 replies to this topic

#1 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 10 July 2015 - 08:53 PM

0t5Munw.gif



Game Maker creates an extra texture page for every sprite and subimage that the user loads into their game using the function sprite_add, this often results in terrible performance issues due to hundreds or sometimes even thousands of texture swaps. This collection of scripts is meant to fix this problem by giving full control over custom texture pages, groups and memory management.

Features

  • Custom texture groups for easier organisation and memory management.
  • Easy texture page creation via an algorithm that does everything, you simply have to specify what to load.
  • Image caches for storing, faster loading and sending texture groups via networking.
  • Functions that can be used exactly the same as the GM sprite functions, except the collision specific functions.
  • All GM built in sprite system drawing functionalities and more.

Issues & Limitations
This is optimised for YYC and will be pretty much as fast as built in sprite functionality, however, on the regular windows export it will be still be way faster than sprites that were imported using sprite_add but will be a bit slower than built in sprites.

 

Download

v2.6

DocumentationOnedrive link
ScriptsOnedrive link | Filedropper link ExtensionOnedrive link | Filedropper link

Release notes

 

v2.5

Documentation: Onedrive link

Scripts: Onedrive link | Filedropper link Extension: Onedrive link | Filedropper link

without gml_pragma (slower, for older GM versions). Scripts Onedrive link Extension Onedrive link

Release notes

 

Old Versions

Spoiler

Note: The graphics used in this demo are not mine, they belong to the tigsource user 'Arachne', LINK


Edited by Braffolk, 17 January 2016 - 04:26 PM.

  • 17

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#2 Ruub

Ruub

    Finn The Human

  • GMC Member
  • 762 posts
  • Version:GM:Studio

Posted 10 July 2015 - 09:07 PM

AMAZING. I like to use the build in editor but for specific things this can be sweeeet. :)


  • 0

#3 Squarebit

Squarebit

    GMC Member

  • GMC Member
  • 234 posts
  • Version:GM:Studio

Posted 10 July 2015 - 09:53 PM

Very cool :)


  • 0

OjJP6YH.png

@sqrbt 


#4 HopelessComposer

HopelessComposer

    GMC Member

  • GMC Member
  • 1337 posts
  • Version:GM:Studio

Posted 10 July 2015 - 09:58 PM

Nice work! =)


  • 0

#5 cookieboy

cookieboy

    Seabass (The Human)

  • GMC Member
  • 747 posts
  • Version:GM:Studio

Posted 02 October 2015 - 07:10 PM

One major issue I've noticed is that a majority of the scripts use incorrect accessor syntax. Not a huge deal but most of the scripts use | instead of @ which lead me into a whole ocean of issues. I've since fixed this on my side and can say everything is working great. Excellent work.


  • 0

Vnc5NxB.jpg

Support a fellow GMC member? <3

http://store.steampo...com//app/357650


#6 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 08 October 2015 - 12:22 PM

Release 1.2

  • Added sprite_load_end_dynamic() which will add extra texturepages if the sprites don't fit on one NOTE: this returns a ds_list with backgrounds that should be deleted after usage to avoid a memory leak
  • Fixed an accessor bug that made half of the scripts unusable
  • Added "forceinline" pragma to commonly used scripts to make them run faster in YYC, NOTE: this may inflate the final YYC executable size a bit so if you don't care about speed you can remove it.

Scripts: Onedrive link Extension: Onedrive link Example (.gmz): Onedrive link

 

If you have any suggestions or find any bugs please let me know because otherwise they may not be included or fixed.


Edited by Braffolk, 08 October 2015 - 12:23 PM.

  • 2

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#7 BDMarvel

BDMarvel

    GMC Member

  • GMC Member
  • 335 posts
  • Version:GM:Studio

Posted 02 November 2015 - 12:58 AM

Thanks for creating this Braffolk. And thanks to cookieboy for letting me know about it. I will try my hand at implementing it tomorrow and I expect it will cut down my texture swaps significantly.


  • 1

gmc_sig.pngen_generic_rgb_wo_60.png

"There is nothing which has yet been contrived by man, by which so much happiness is produced as by a good tavern or inn." - Samuel Johnson


#8 autukill

autukill

    GMC Member

  • GMC Member
  • 144 posts
  • Version:GM:Studio

Posted 18 November 2015 - 11:06 PM

cool  :lol:


Edited by autukill, 05 January 2016 - 07:57 AM.

  • 1

#9 cookieboy

cookieboy

    Seabass (The Human)

  • GMC Member
  • 747 posts
  • Version:GM:Studio

Posted 19 November 2015 - 02:13 AM

I would love to have the ability to generate additional texture pages even after the initial load_end. It would make things even more dynamic and useful!


  • 0

Vnc5NxB.jpg

Support a fellow GMC member? <3

http://store.steampo...com//app/357650


#10 zbox

zbox

    GMC Member

  • GMC Member
  • 2618 posts
  • Version:Unknown

Posted 20 November 2015 - 02:00 AM

you mean I dont have to write this thing myself now?? Thankyou, bookmarked :)


  • 0

#11 Annoyed Grunt

Annoyed Grunt

    Right behind you.

  • GMC Member
  • 884 posts
  • Version:GM:Studio

Posted 13 December 2015 - 05:47 PM

Hello, I'm trying to make my own custom texture page system, so I thought giving a look at yours would give me a few handy pointers in the right direction. Is there any specific reason you use backgrounds rather than sprites in your extension? Is it more performant than using sprite functions?


  • 1

Every time somebody uses the term "Roguelike" improperly I cry.

Spoiler

#12 cookieboy

cookieboy

    Seabass (The Human)

  • GMC Member
  • 747 posts
  • Version:GM:Studio

Posted 13 December 2015 - 07:36 PM

Well I would assume the main reason would be that you don't have to check do, 'draw_sprite(sprite,subimage,x,y)' every time you call the texture page. Instead you can just call the image and the coordinates. One less argument maybe makes a minuscule difference.


  • 2

Vnc5NxB.jpg

Support a fellow GMC member? <3

http://store.steampo...com//app/357650


#13 Annoyed Grunt

Annoyed Grunt

    Right behind you.

  • GMC Member
  • 884 posts
  • Version:GM:Studio

Posted 13 December 2015 - 10:20 PM

Well I would assume the main reason would be that you don't have to check do, 'draw_sprite(sprite,subimage,x,y)' every time you call the texture page. Instead you can just call the image and the coordinates. One less argument maybe makes a minuscule difference.

 

Oh, I see, that makes sense. Thank you.


  • 1

Every time somebody uses the term "Roguelike" improperly I cry.

Spoiler

#14 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 18 December 2015 - 04:24 AM

Release 2.0

  • Added texture groups that allow proper memory controlling and organising.
  • Huge performance improvement for YYC exports, it's almost as fast as using built in sprites and nearly 2 times faster than the previous version of the custom external sprite handler. This was optimised for YYC, don't expect it to be as fast on the regular export.
  • Better error checking.
  • Replaced 'external_sprite' in all of the functions with 'image' to shorten code.

I also updated the help section which explains how grouping works and how you can use it. This version may contain bugs so if you find any, please report them.

Scripts: Onedrive link Extension: Onedrive link

 

If you have any suggestions or find any bugs please let me know because otherwise they may not be included or fixed.


Edited by Braffolk, 18 December 2015 - 04:33 AM.

  • 3

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#15 cookieboy

cookieboy

    Seabass (The Human)

  • GMC Member
  • 747 posts
  • Version:GM:Studio

Posted 18 December 2015 - 09:06 AM

An image_system_end() function would be awesome. I had to write a bit of a manual clearing system myself for when my game is restarted via game_restart(). Would love an easy one call function to do it all at once.


  • 0

Vnc5NxB.jpg

Support a fellow GMC member? <3

http://store.steampo...com//app/357650


#16 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 18 December 2015 - 06:59 PM

Release 2.1

  • Renamed image_init() to image_system_init()
  • Added image_system_cleanup() that uninitialises the image system and clears memory from all of the image system data.
  • Added image_get_filename(ind) that returns the file location of the image
  • Fixed a small memory leak.

IMPORTANT: image_system_init() and image_system_cleanup() are automatically called in the extension, only call them if you use the scripts or manually want to reinitialise the image system.
 
Scripts: Onedrive link | Filedropper link Extension: Onedrive link | Filedropper link
 
If you have any suggestions or find any bugs please let me know because otherwise they may not be included or fixed.


Edited by Braffolk, 18 December 2015 - 07:42 PM.

  • 2

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#17 cookieboy

cookieboy

    Seabass (The Human)

  • GMC Member
  • 747 posts
  • Version:GM:Studio

Posted 18 December 2015 - 07:20 PM

Ermagerd, thanks bae! <3


  • 1

Vnc5NxB.jpg

Support a fellow GMC member? <3

http://store.steampo...com//app/357650


#18 Shamanovitch

Shamanovitch

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM:Studio

Posted 28 December 2015 - 10:02 PM

Hello !

Your thing is so awesome I had to dance in front of my computer for having all this memory released. Game Maker's basic loading system is annoying as it loads everything included !

I have a bug report and 2 questions/suggestions :

- First I had to use the system with a shader, and found that the image_get_texturepage was always wrong by being 1 more in the ID than the real thing is. For example, my texture ID variable is this at the moment : texMsk = image_get_texturepage(global.kartaj_stand_msk, frame)-1; (and global.kartaj_stand_msk = image_load_get( "spritereference" );)

 

- I also would like to know how much it takes to create big texture pages from a lot of sprites ? My game is heavy on spritesheets, wouldn't that be too much time creating it on the loading moments ?

- And finally, taking this in consideration, do you think it would be possible to create a system where you can create the texture page infos (which sprite with which ID, width, height and xyorigin) and then have the pages being loaded or unloaded but without creating the graphic thing everytime ? If the texturepage creation processe is quick, then my question is irrelevant.

I just thought that the system would load even faster if you save the texture image and infos (as arrays,cache text or something) and have it being loaded and discarded ingame.


Edited by Shamanovitch, 28 December 2015 - 10:13 PM.

  • 0

#19 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 29 December 2015 - 02:41 PM

Hello !

Your thing is so awesome I had to dance in front of my computer for having all this memory released. Game Maker's basic loading system is annoying as it loads everything included !

I have a bug report and 2 questions/suggestions :

- First I had to use the system with a shader, and found that the image_get_texturepage was always wrong by being 1 more in the ID than the real thing is. For example, my texture ID variable is this at the moment : texMsk = image_get_texturepage(global.kartaj_stand_msk, frame)-1; (and global.kartaj_stand_msk = image_load_get( "spritereference" ) ;)

 

- I also would like to know how much it takes to create big texture pages from a lot of sprites ? My game is heavy on spritesheets, wouldn't that be too much time creating it on the loading moments ?

- And finally, taking this in consideration, do you think it would be possible to create a system where you can create the texture page infos (which sprite with which ID, width, height and xyorigin) and then have the pages being loaded or unloaded but without creating the graphic thing everytime ? If the texturepage creation processe is quick, then my question is irrelevant.

I just thought that the system would load even faster if you save the texture image and infos (as arrays,cache text or something) and have it being loaded and discarded ingame.

Ah that's odd, I'll look into image_get_texturepage. What's wrong with image_load_get tough?

 

I will look into sprite caches and will implement functionality for them. Any other suggestions? :)

 

Edit:

image_get_texturepage seems to work perfectly fine.

JVJyvAN.gif

The 3 images on the left are one small texturepage and the image on the right is the current subimage of the sprite which is also visible on the texturepage. I am not able to reproduce the issue.

 

Edit 2:

It should be fairly fast loading sprites but you can't do it realtime. I just finished implementing functions that allow you to save groups as a single file and reload them from that which is way faster than the default method, so if you are worried about speed then that should solve it.


Edited by Braffolk, 30 December 2015 - 02:58 AM.

  • 0

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#20 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 30 December 2015 - 11:26 PM

Release 2.2

  • Added image_group_exists(group), this returns whether the group specified exists or not.
  • Added image_get_identifier(ind), this returns the identifier set to the image using image_load_add(identifier,...)
  • Added image_get_texture(ind), this returns the texture pointer of the specified image, this should mostly be used for images added with the special image_load_add_3d function, because if the image is a part of a texturegroup, the texturegroups texture will be returned.
  • Added image_group_find_image(group,identifier), this returns the image with the identifier which is specified in image_load_add(identifier,...). If it doesn't exist then it returns -1.
  • Added image_load_add_3d(identifier,fname,subimg,xorig,yorig), this adds the image to the loading queue but the _3d specifies that every subimage will get a separate texture page so that the texture of the image could be used.
  • Added image_cache_create(group), this packs the whole group and all of the data inside a single buffer which can be stored for later usage or used in networking, returns buffer id or -1 if failed.
  • Added image_cache_save(cache,fname), this saves the cache as the specified file.
  • Added image_cache_load(fname), this loads the cache from a file as a buffer and makes sure that it is an image cache file that is supported.
  • Added image_cache_unpack(group,cache), this unpacks the contents of the cache into the group, if the group doesn't exist it will be created, else it will be overwritten. returns false or true.
  • Added image_cache_delete(cache), this deletes the cache from the memory.
  • A few minor bug fixes.

Scripts: Onedrive link | Filedropper link Extension: Onedrive link | Filedropper link
 
If you have any suggestions or find any bugs please let me know because otherwise they may not be included or fixed.


Edited by Braffolk, 01 January 2016 - 05:00 PM.

  • 4

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#21 zbox

zbox

    GMC Member

  • GMC Member
  • 2618 posts
  • Version:Unknown

Posted 01 January 2016 - 06:16 AM

Would be really great if it had support for internet-retrieved images, the only way to do this I presume in it's current state would be to download the images to the disk, wait until each one has finished downloaded and then recreate the texture page with the new ones. 


  • 1

#22 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 01 January 2016 - 04:32 PM

Would be really great if it had support for internet-retrieved images, the only way to do this I presume in it's current state would be to download the images to the disk, wait until each one has finished downloaded and then recreate the texture page with the new ones. 

That's on the to do list already :)

I will probably get it done tomorrow or day after tomorrow.

 

Edit: Somehow managed to leave a function out from the last updates description... Here it is.

  • Added image_get_texture(ind), this returns the texture pointer of the specified image, this should mostly be used for images added with the special image_load_add_3d function, because if the image is a part of a texturegroup, the texturegroups texture will be returned.

Edited by Braffolk, 01 January 2016 - 05:00 PM.

  • 2

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#23 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 03 January 2016 - 06:42 AM

Release 2.3

  • Fixed a small memory leak in image_load_finish function.
  • Added image_stream_start(group,tex_page_width,tex_page_height,sep), this starts the image loading stream that will be used to load images from either your computer or the internet onto the specific image group.
  • Added image_stream_add(group,identifier,fname,subimg,xorig,yorig) and image_stream_add_3d(group,identifier,fname,subimg,xorig,yorig), these is used to add the images into the loading stream.
  • Added image_stream_receive(group), this is used in the “Image loaded” event. This will check if the images have loaded, if the loading fails for an image, the image will be requested again
  • Added image_stream_is_received(group), this returns whether the image stream has finished or not.
  • Added image_stream_is_active(group), this returns whether the image stream for the group specified has been started and is active or not.
  • Added image_stream_finish(group), this sorts all of the loaded images onto texturepages and makes them ready for usage. This will only work if all of the images have been received.
  • Added image_stream_progress(group), this returns a value between 0-1 that shows how much of the group has been loaded. 

I suggest changing all of the image_load functions to the stream functions, I will not be updating the image_load functions and will remove them in a few updates.

The documentation has examples for all of the stream functions.

Documentation: Onedrive link

Scripts: Onedrive link | Filedropper link Extension: Onedrive link | Filedropper link

 

I will change the texture page generation algorithm in the next update to make the stream functions faster
 
If you have any suggestions or find any bugs please let me know because otherwise they may not be included or fixed.


Edited by Braffolk, 03 January 2016 - 06:50 AM.

  • 3

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#24 zbox

zbox

    GMC Member

  • GMC Member
  • 2618 posts
  • Version:Unknown

Posted 03 January 2016 - 07:07 AM

Legend  ::lmao::


  • 1

#25 cookieboy

cookieboy

    Seabass (The Human)

  • GMC Member
  • 747 posts
  • Version:GM:Studio

Posted 03 January 2016 - 02:22 PM

I must say, this is one of the most useful set of scripts I have seen in my entire life time as a GM user. This definitely deserves more attention.
  • 0

Vnc5NxB.jpg

Support a fellow GMC member? <3

http://store.steampo...com//app/357650


#26 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 04 January 2016 - 12:25 PM

Release 2.4

  • Rewrote the image_stream sorting algorithm that gave a massive performance boost to image_stream functions.
  • Removed unneccessary new texturepage creation warnings from image_stream_finish.
  • Fixed a potential memory leak in image_group_destroy and image_system_cleanup that would have occured if those functions were called while an image stream was active.
  • Updated the documentation examples for the image_stream functions that could have potentially caused an error.

Documentation: Onedrive link

Scripts: Onedrive link | Filedropper link Extension: Onedrive link | Filedropper link

 

If you have any suggestions or find any bugs please let me know because otherwise they may not be included or fixed.


Edited by Braffolk, 04 January 2016 - 12:26 PM.

  • 1

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#27 Shamanovitch

Shamanovitch

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM:Studio

Posted 04 January 2016 - 01:10 PM

Hello !

Happy new year ! Awesome additions to the set.

I am still stuck with the image_get_texturepage which returns a higher number than what it should, I don't understand.

I can see with the debug mode that the custom texturepage is created on texture slot 30, but using the function on a freshly created sprite returns 34, then makes everything crash because my shader tries to use a texture which doesn't exist.

I am creating the sprites in an object and trying to get texturepage in another, maybe it's what is making it bug ?

Also, I downloaded EA version to have your script running because I couldn't manage to have it work on the normal version, it was saying that gml_pragma is an unknown function. Is there a way to use it on normal GM or is it too early ?

Cheers


  • 0

#28 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 04 January 2016 - 01:33 PM

Hello !

Happy new year ! Awesome additions to the set.

I am still stuck with the image_get_texturepage which returns a higher number than what it should, I don't understand.

I can see with the debug mode that the custom texturepage is created on texture slot 30, but using the function on a freshly created sprite returns 34, then makes everything crash because my shader tries to use a texture which doesn't exist.

I am creating the sprites in an object and trying to get texturepage in another, maybe it's what is making it bug ?

Also, I downloaded EA version to have your script running because I couldn't manage to have it work on the normal version, it was saying that gml_pragma is an unknown function. Is there a way to use it on normal GM or is it too early ?

Cheers

The gml_pragma function is in the beta already, didn't realise that the stable version didn't have it yet.

For the image_get_texturepage problem, the image_get_texturepage returns the BACKGROUND ID as specified in the documentation.

 

If you need the texture, use image_get_texture.

 

Scripts without gml_pragma:

https://onedrive.liv...ithint=file,gml

extension:

https://onedrive.liv...thint=file,gmez

 

You can simply comment the gml_pragma out in any version, it will work fine.


Edited by Braffolk, 04 January 2016 - 01:36 PM.

  • 0

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#29 Shamanovitch

Shamanovitch

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM:Studio

Posted 04 January 2016 - 05:02 PM

Thanks a lot, you rock.

Just for curiosity, what are gml_pragma used for ? Is it to speed up compilation or something ?

Also can you please explain the difference between image_group_clear and image_group_destroy ? I don't get it.

And last thing, when unpacking a cache into a group, does that delete it or do I have to cache load, cache unpack, then cache delete ?

 

At the moment I am :

- creating the right animations in GM with the editor, then save it as png strips when I like them, then delete the sprite from included asset list

- putting the animation png strip in "included files" at the bottom of asset list (optional)

- using the system to create cache files and save them at first run, then I check if file_exists(working_directory + "***.cache"), and if it returns 1, it unpacks into the group and creates the sprite handles. I am using global.variables for the sprite handles so it feels like its general sprite_indexes

- After first run, when I have a .cache containing everything I want, I delete the included pngs

- Trying to free memory when changing room, currently I am using image_group_destroy(****) and I see memory going a lot lower.

 

Basically, ingame, I would put a "LOADING" screen, then first destroy the previous groups, then do multiple image_group_create, image_cache_load, image_cache_unpack until everything is in memory

 

Is everything okay ? :D

 

Doing the whole game with your scripts, it means it will load super fast for testplay, because Game Maker doesn't need to create all the texturepages (that thing was the longest


  • 0

#30 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 04 January 2016 - 05:50 PM

<snip>

I wouldn't delete the .pngs, you might need them.

image_group_clear empties the group from all of its data, but doesnt actually delete it so you can reload images into it without having to recreate it.

image_group_destroy empties the grup and also destroys it so if you want to use it again, you have to recreate it.

 

No, unpacking the cache into a group does not delete it, it simply unpacks the data into the group but does not change the cache itself.

 

Use the documentation for examples and help on what the functions do. https://onedrive.liv...thint=file,docx

 

 

gml_pragma( "forceinline" ) forces the script to be inline which will speed things up a little bit.


Edited by Braffolk, 04 January 2016 - 05:52 PM.

  • 0

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#31 Shamanovitch

Shamanovitch

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM:Studio

Posted 04 January 2016 - 08:39 PM

I can't seem to have the groups detected in Step Event ... I only tested those. I have a show_message(string(image_group_exists("group"))) which returns 1 in Create and User Defined Event, but 0 in step or draw !

 

EDIT : it's probably me doing crap


Edited by Shamanovitch, 04 January 2016 - 09:43 PM.

  • 0

#32 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 05 January 2016 - 03:24 AM

I can't seem to have the groups detected in Step Event ... I only tested those. I have a show_message(string(image_group_exists("group"))) which returns 1 in Create and User Defined Event, but 0 in step or draw !

 

EDIT : it's probably me doing crap

Can you post the image framework code that you are using from all of the events (except drawing and image_get and image_set)?


Edited by Braffolk, 05 January 2016 - 03:25 AM.

  • 0

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#33 Shamanovitch

Shamanovitch

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM:Studio

Posted 05 January 2016 - 12:28 PM

It is now working, sorry for the false alert. I think the bug was coming because I was pointing to a non-existing .png file to add to the texture page. That was doing an error on the group_finish function, which I could ignore (until I found the files were not spelled right), and after that the group was still created, but only detected in create or custom events. But that was my fault !

 

I am now reworking the whole game with your script. It works like a charm, 350MB taken on the character select, then I press OK and everything gets unloaded and drops to 150MB

 

I am going to make a loading screen, getting the groups loaded one after another and showing a % of the whole thing (based on the whole number of groups to load and the groups currently done).


  • 0

#34 Shamanovitch

Shamanovitch

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM:Studio

Posted 05 January 2016 - 10:40 PM

Hello !

New problems !

My (big) strip png becomes cut on the texturepage, and then, the animation skips frame, and one frame has like a half of the complete image on it.

It only did that on my 2 biggest strips which are around 500x400 and have 21 and 22 subframes.

The origin doesn't change, and on one animation, the missing part of the last frame is filled with a part from another frame,

 

clch13i.png

 

Here, you can see the cut frame. Strangely, there is enough room for the entire frame. But still some are missing. It's like the script has a maximum strip size or something.

 

Cnktf7O.png

 

This is the original strip.

HALP ! Something's wrong I think, haha

Also, I tried changing texture page size (it crashes when I've put 8192x8192 by the way), with 2048 instead of 4096 it was doing exactly the same, with 1024 it was crashing because one sprite in the page is larger than 1024.

Hope you can find a fix, cheers.


  • 1

#35 cookieboy

cookieboy

    Seabass (The Human)

  • GMC Member
  • 747 posts
  • Version:GM:Studio

Posted 06 January 2016 - 12:05 AM

Hello !

New problems !

My (big) strip png becomes cut on the texturepage, and then, the animation skips frame, and one frame has like a half of the complete image on it.

It only did that on my 2 biggest strips which are around 500x400 and have 21 and 22 subframes.

The origin doesn't change, and on one animation, the missing part of the last frame is filled with a part from another frame,

 

clch13i.png

 

Here, you can see the cut frame. Strangely, there is enough room for the entire frame. But still some are missing. It's like the script has a maximum strip size or something.

 

Cnktf7O.png

 

This is the original strip.

HALP ! Something's wrong I think, haha

Also, I tried changing texture page size (it crashes when I've put 8192x8192 by the way), with 2048 instead of 4096 it was doing exactly the same, with 1024 it was crashing because one sprite in the page is larger than 1024.

Hope you can find a fix, cheers.

I was experiencing the same issue and showed Braffolk. I fixed it by scaling down my images but that was a sad fix for me xD


  • 0

Vnc5NxB.jpg

Support a fellow GMC member? <3

http://store.steampo...com//app/357650


#36 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 06 January 2016 - 05:20 AM

Hello !

New problems !

My (big) strip png becomes cut on the texturepage, and then, the animation skips frame, and one frame has like a half of the complete image on it.

It only did that on my 2 biggest strips which are around 500x400 and have 21 and 22 subframes.

The origin doesn't change, and on one animation, the missing part of the last frame is filled with a part from another frame,

<snip>

Also, I tried changing texture page size (it crashes when I've put 8192x8192 by the way), with 2048 instead of 4096 it was doing exactly the same, with 1024 it was crashing because one sprite in the page is larger than 1024.

Hope you can find a fix, cheers.

I've seen that issue before. This is not caused by my code, GM doesn't allow backgrounds larger than 8192 in width or height.

I am looking for workarounds for this issue right now, I'll let you know when I find something.

 

I should be able to rewrite parts of the code so that it bypasses the GM limit.

 

Also, I will add extra safe checks to image_stream_finish to make sure that all of the images have been loaded, if not it will throw you an error.

 

EDIT: Found the fix, I will post the fixed version in a few hours. There's a bump limit though so I can't exactly post it for 48 hours unless someone else posts before me.


Edited by Braffolk, 06 January 2016 - 05:28 AM.

  • 1

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#37 zbox

zbox

    GMC Member

  • GMC Member
  • 2618 posts
  • Version:Unknown

Posted 06 January 2016 - 05:47 AM

it was then when zbox said 'let there be a new version in a post that does not conflict with the bumping rules'


  • 0

#38 cookieboy

cookieboy

    Seabass (The Human)

  • GMC Member
  • 747 posts
  • Version:GM:Studio

Posted 06 January 2016 - 06:17 AM

I just happen to post... :whistle:


  • 1

Vnc5NxB.jpg

Support a fellow GMC member? <3

http://store.steampo...com//app/357650


#39 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 06 January 2016 - 06:37 AM

Release 2.5

  • Fixed a bug that caused image loading to fail for images larger than 8192 pixels in width or height (size of the source image).

Documentation: Onedrive link

Scripts: Onedrive link | Filedropper link Extension: Onedrive link | Filedropper link

 

No gml_pragma (slower, for older GM versions that dont have gml_pragma):

Scripts Onedrive link Extension Onedrive link

If you have any suggestions or find any bugs please let me know because otherwise they may not be included or fixed.


Edited by Braffolk, 06 January 2016 - 09:35 PM.

  • 0

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#40 Shamanovitch

Shamanovitch

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM:Studio

Posted 06 January 2016 - 12:39 PM

Hello, I didn't test the 2.5 yet because I have to edit almost everything in my room to have it working with your framework instead of the built-in !

I am on this since this morning.

I wonder if you could add a function that returns the image's group as a string, as does image_get_identifier(ind) for the identifier. That could be very useful to me, because I am programming a system where it uses another sprite with a shader to get a palette modification.

Cheers

 

EDIT : Another problem

 

I am using a custom script which allows to draw_sprite_pos with an angle, color blending and alpha transparency. It was made for sprites, so I've tried to edit it and replace sprite_get_texture(sprite,subimg) with image_get_texture(image,subimg).

But when doing this, it doesn't take the only subimg as a texture to work with, but instead the entire texturepage the sprite is on, and nothing changes with the subimg changing (no cycle).

I don't get why it doesn't work, because another part of code has image_get_texture, directly in an object instead of a script, to pass it to a shader, and it works, it only takes the right frame and cycles.

 

Here are 2 screens in which I only changed sprite_get_texture :

 

 

RiSAxm3.png

With sprite_get_texture

 

 

 

KFq2edu.png

With image_get_texture

 

Also, if you could create something like this function, that would be cool, but it's not that important since it can be reproduced with the script :

 

draw_image_pos_transform_rotate(sprite_index,image_index,x1,y1,x2,y2,x3,y3,x4,y4,image_angle,image_color,image_alpha)


Edited by Shamanovitch, 06 January 2016 - 08:55 PM.

  • 0

#41 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 06 January 2016 - 09:26 PM

I wonder if you could add a function that returns the image's group as a string, as does image_get_identifier(ind) for the identifier. That could be very useful to me, because I am programming a system where it uses another sprite with a shader to get a palette modification.

 
Not going to happen, image_group_create already returns the image group name as a string and you are using that same string in all of the functions that use groups.
 
 

But when doing this, it doesn't take the only subimg as a texture to work with, but instead the entire texturepage the sprite is on, and nothing changes with the subimg changing (no cycle).
I don't get why it doesn't work, because another part of code has image_get_texture, directly in an object instead of a script, to pass it to a shader, and it works, it only takes the right frame and cycles.

This is explained in the documentation, it would be too slow to extract the texture of the individual subimage from the texturepage so it simply returns the texture of the image group (unless it's added using image_stream_add_3d). There's nothing that I can do about this really, GML does not have proper functions to support this. We just have to hope that they will implement a proper built in sprite handler to the next GM version.
 
I will add extra drawing functions in the next update. Meanwhile you can use image_get_uvs() to get the uvs coordinates of the image on the texturepage, then use those to get the texture of the specific subimage from the texturepage. This should work fine for what you need.


Edited by Braffolk, 06 January 2016 - 09:33 PM.

  • 0

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#42 Shamanovitch

Shamanovitch

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM:Studio

Posted 06 January 2016 - 11:32 PM

Thanks a lot man. Sorry for not having read enough.

 

I managed to get a blending working by editing your image_draw_pos function, add one more argument for the color and replace draw_vertex_texture by draw_vertex_texture_colour !

 

EDIT : is there a hope to see an image_collision_mask(ind, sepmasks, bboxmode, bbleft, bbtop, bbright, bbbottom, kind, tolerance) included and saved in the caches ? I am thinking about how to reproduce a precise collision checking with your system but don't find anything easy to use and compatible with GM's object collision events

At the moment I am loading the sprites that need collisions with sprite_add + sprite_collision_mask, but that's a lot of performance loss, and it will create some problem at one moment

 

EDIT 2 : my alternate method is to create a surface from the draw_image on each draw, then make it a sprite with precise collision checking. But I guess this is super heavy in term of resources ? But, it still has the advantage of not needing to include the sprite. Do you think there is a simpler way to do that ?

 

sprite_delete(sprite_index)
surface_free(surface)
surface = surface_create(image_get_width(current_sprite),image_get_height(current_sprite))
surface_set_target(surface)
draw_clear_alpha(c_black,0)
draw_image(current_sprite,frame,image_get_xoffset(current_sprite),image_get_yoffset(current_sprite))
surface_reset_target()

sprite_index = sprite_create_from_surface(surface,0,0,surface_get_width(surface), surface_get_height(surface), 0, true, 97, 225);
sprite_collision_mask(sprite_index, true, 0, 0, 0, 0, 0, 0, 1);

draw_sprite(sprite_index,image_index,x,y)
 

EDIT 3 : to gain a bit more performance, the surface and sprite creation now only happen when the actual subimage changes, instead of each step, avoiding repeated computing on the same subimg


Edited by Shamanovitch, 07 January 2016 - 02:47 PM.

  • 0

#43 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 07 January 2016 - 03:23 PM

is there a hope to see an image_collision_mask(ind, sepmasks, bboxmode, bbleft, bbtop, bbright, bbbottom, kind, tolerance) included and saved in the caches ?

No. I could include the functionality to add collision boxes to the images but that would be it. I'm NOT going to add 'precise' collision checking because that would be extremely slow and would not run realtime due to GML limitations, neither should you even be using the built in precise collision checking. Use collision rectangles instead, they are way faster and in most cases really easily controllable.
 

my alternate method is to create a surface from the draw_image on each draw, then make it a sprite with precise collision checking.

You really should reconsider how you do collisions, precise collisions are extremely slow and inefficent. There is really no point using them unless you don't know how to use proper fast collision boxes.

 

I strongly suggest not using precise collision checking.
 
https://www.yoyogames.com/tech_blog/40


  • 0

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#44 cookieboy

cookieboy

    Seabass (The Human)

  • GMC Member
  • 747 posts
  • Version:GM:Studio

Posted 07 January 2016 - 03:46 PM

@Shamanovitch

I am using an external mod system that uses this image framework. You can add sprites with sprite_add() and use them purely as collision masks. Game Maker will operate with these just fine and it doesn't require precise collision. That is what I recommend you do if you refuse to do it internally.


  • 0

Vnc5NxB.jpg

Support a fellow GMC member? <3

http://store.steampo...com//app/357650


#45 Shamanovitch

Shamanovitch

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM:Studio

Posted 07 January 2016 - 05:22 PM

Okay thanks for your answers everybody.

 

Actually, my game works with rectangle collision boxes (it's an old school fighting game, so doing anything else would be blasphemy)

I just used precise collision checking for specific graphic things, like this :

 

sRFEeKp.png

 

The spotlights (an instance in every spotlight) turn off when they collide with the npcs heads, without this I couldn't have them in front of lights but affected by it too.

So I'll use precise for those small things, not for the whole game.

Anyway, having collision boxes on the images is awesome :D I thought you wouldn't do anything about collisions !

 

Cookieboy, wouldn't that take twice the memory, like having one strip for the graphic sprite (image), another one for the collision mask sprite (sprite) ?

I think every real collisions will be handled with pure code checking that triggers collision events in objects. That's the lightest in my opinion. But for the precise things, I have no choice but to rely on external sprite add.


  • 1

#46 Shamanovitch

Shamanovitch

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM:Studio

Posted 08 January 2016 - 01:00 AM

Hello I'm back !

Now I've converted almost every big asset from my game into strips and included it in texturepages from groups.

The main problem now is that ... It takes a LOT more memory than the normal system. Where the whole assets loaded via GM were making a ~300MB Runner.exe, this one takes 700 !

I'm deleting caches after usage, I'm freeing groups (I can see it dropping to 100MB when I destroy every group)

Why is it taking that much ? I have one group with only one texturepage (4096x4096), but it takes around 180MB for being created. About 10 sprites are added and split on this page.

Maybe it is because GM originally compresses texturepages in memory ?

 

I've did a test, found that :

- creating a 4096x4096 sprite in built-in system says it takes 64MB in GM but actually takes around 32MB in runner.exe

- creating an empty group with a 4096x4096 page with your framework takes around 128MB in runner.exe

 

Do you think you can do something about this ? My game is already too heavy without any new graphics added ! Haha


Edited by Shamanovitch, 08 January 2016 - 01:05 AM.

  • 0

#47 cookieboy

cookieboy

    Seabass (The Human)

  • GMC Member
  • 747 posts
  • Version:GM:Studio

Posted 08 January 2016 - 01:28 AM

You can always clear out memory. For example, load the assets for a particular scene, unload them, and repeat.


  • 0

Vnc5NxB.jpg

Support a fellow GMC member? <3

http://store.steampo...com//app/357650


#48 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 08 January 2016 - 07:43 AM

I've did a test, found that :

- creating a 4096x4096 sprite in built-in system says it takes 64MB in GM but actually takes around 32MB in runner.exe

- creating an empty group with a 4096x4096 page with your framework takes around 128MB in runner.exe

 

Do you think you can do something about this ? My game is already too heavy without any new graphics added ! Haha

Don't use task manager to see how much memory something takes. Use the built in debugger.

 

The texture pages are stored in backgrounds, if you create an empty background with the size 4096x4096 then it will also take 128mb.

There's nothing that I can do about this really.


  • 0

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt


#49 Shamanovitch

Shamanovitch

    GMC Member

  • GMC Member
  • 24 posts
  • Version:GM:Studio

Posted 08 January 2016 - 09:20 AM

You can always clear out memory. For example, load the assets for a particular scene, unload them, and repeat.

Thanks for your answer, that's the whole point of using this set of script and I'm already doing this. But that doesn't change the fact that external resources take twice as memory (RAM) as uncompressed internal ressources, which take twice as memory as compressed internal ressources. That means using the script, I can only use 4 times less graphics at the same time before hitting the ram limit for the application.

 

 

 

snip

Don't use task manager to see how much memory something takes. Use the built in debugger.

 

The texture pages are stored in backgrounds, if you create an empty background with the size 4096x4096 then it will also take 128mb.

There's nothing that I can do about this really.

 

Creating an empty background for this size takes 64MB as uncompressed (it will take 64MB in VRAM) but only around 32MB in RAM, because GM is compressing it's own made texturepages in memory. BUT doing a background_add for a 4096x4096 png takes 128MB (4times more, 2times more than the uncompressed file. WTF).

 

I've made some researches (lol) and it seems using surface could be cool. It would need an extra loading time to create the surface again each time it is destroyed because of it's volatile aspect (when switching to fullscreen for example), but a 4096x4096 surface takes 64MB, so it's halfway between the light, compressed GM texturepages and the oversized external loaded files. I'll try to mod your scripts to get that working.


  • 0

#50 Braffolk

Braffolk

    Lumenus Team

  • GMC Member
  • 1010 posts
  • Version:GM:Studio

Posted 08 January 2016 - 09:43 AM

I've made some researches (lol) and it seems using surface could be cool. It would need an extra loading time to create the surface again each time it is destroyed because of it's volatile aspect (when switching to fullscreen for example), but a 4096x4096 surface takes 64MB, so it's halfway between the light, compressed GM texturepages and the oversized external loaded files. I'll try to mod your scripts to get that working.

 

Surfaces are extremely slow to draw compared to backgrounds and you are simply wasting processing time recreating and reloading all of the assets every time the user changes the window size, switches the window, goes to fullscreen, etc.

 

I do not see how a single scene would take up a texturepage larger than 4096x4096, sprites should not be used for movie clips or anything similar. If it is, you are doing something very wrong.


Edited by Braffolk, 08 January 2016 - 09:45 AM.

  • 2

xOVkpik.png

Custom sprite framework(GML): http://gmc.yoyogames...howtopic=669935

My main project ^o^ 2Volution GMC | GameJolt