GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2010-06-06 23:35:51

xantier
Member
Registered: 2010-06-06
Posts: 3

Is it possible to optimize ?

http://www.gmlscripts.com/script/sprite … olor_blend

This code is what i exactly search : colorize partial code.. But it is really laggy. The other sprite_replace_color replaces only one type color. Will it be optimized by someone ? There is no other way for it ?

Edit : i wonder how colorize partial works that fast in sprite editor..

Last edited by xantier (2010-06-07 00:31:37)

Offline

#2 2010-06-07 09:03:08

xot
Administrator
Registered: 2007-08-18
Posts: 1,240

Re: Is it possible to optimize ?

The sprite editor's "colorize partial" tool works that fast because it is natively compiled code and it can directly access the memory the sprite is stored into. GML has neither of those advantages.

It might be possible to make a script to replace multiple colors with blending using the raster tricks that sprite_replace_color uses, along with some  of the similar work that brac37 has done with HSV conversion, but there are certain limitations to what can be accomplished due to the imprecision problems inherent to those methods. The complexity of the resulting script would probably slow it down to the point that it would be impractical for real-time use.

If it's suitable for your project, I'd highly recommend splitting your sprite into parts. You can recolor any of these parts extremely quickly using the color blending features of image_blend or the extended sprite drawing functions.


Abusing forum power since 1986.

Offline

#3 2010-06-07 10:07:12

xantier
Member
Registered: 2010-06-06
Posts: 3

Re: Is it possible to optimize ?

Can i see what brac37 did ? And why are these functions removed at gm5 ? And im not able to split 115 images per sprite.. I'm ripping RA1 sprites so my work is hard.. I recoded the replace_color_blend using surfaces (surface_getpixel, set target on surface etc.), it became only a "bit" faster.. Is it possible to do it with DLLs, without lag ?

Offline

#4 2010-06-07 10:23:23

xot
Administrator
Registered: 2007-08-18
Posts: 1,240

Re: Is it possible to optimize ?

GM5 uses a completely different graphics API. Many things had to be changed when hardware acceleration was added to later versions of Game Maker.

If your sprites are files, you could certainly make a recoloring DLL that would be much faster, but you wouldn't be able to recolor sprites quickly enough to do at 30 FPS if that's what you are thinking.

Here are brac37's scripts:
http://gmc.yoyogames.com/index.php?showtopic=377844

Now think about this: If the slow script works for you, can't you modify it to automatically extract the parts you are recoloring into separate sprites which could then be saved to disk for fast loading at game time?


Abusing forum power since 1986.

Offline

#5 2010-06-08 16:44:42

xantier
Member
Registered: 2010-06-06
Posts: 3

Re: Is it possible to optimize ?

I think i will have to recode my gm8 game for gm5. Actually I dont want to spend my time on complicated things DLLs, surfaces etc. much more.. The functions i needed are already in gm5. I hope advanced functions like these will be added in gm9 (if there will be..). Until that, i will probably use gm5..

Offline

Board footer

Powered by FluxBB