#Repeat 1 px or use one big sprite?

1 messages · Page 1 of 1 (latest)

gray panther
#

Hey folks!
This is a question about performance/good practices:
Is it better to scale up a 1px black sprite or to have a , lets says, 100x100px black square that is also scaled to different sizes? (This is being used to block out areas between walls in a level).
I understand there isn't probably a huge performance difference (if any), but I would like to know what's your preferred approach.

Im thinking of using the 1 px sprite as it works for any size rectangle, but perhaps repeating a 1px texture is actually more intensive?.

On a separate but similar question: if I made an object out of it, would the collision mask work properly?

Cheers

scenic pollen
#

You might want to do some performance testing and see which variant draws faster. Though since you already plan to upscale 1px square, you might be better off using draw_rectangle(...) in the first place.

#

(or at least, I imagine drawing a solid colour rectangle will be faster than running upscaling on a solid colour 1px)

gray panther
#

Mh thats a good point, I was thinking it would repeat the texture but actually its upscaling it (thinking about it as black squares confused me somehow). Probably the process of upscaling is equally intensive between 2 sprites of different sizes (or more intensive in the bigger sprite since it has more pixels)

agile onyx
#

(or at least, I imagine drawing a solid colour rectangle will be faster than running upscaling on a solid colour 1px)
you'd be surprised

scenic pollen
#

I vaguely recall that upscaling is less expensive than downscaling, but not sure if it converts to "more upscaling is less expensive than less upscaling" or not. ^^'

agile onyx
#

in any case, stretching a monochromatic sprite is going to be basically the same cost no matter what the starting/ending scale is

#

to be honest, this sort of question is best answered with a "try it and find out" as Alice says

gray panther
#

Im very new to programming so I imagined there was some Code of Honor on how to do these things 😅
How would you go on to test it? make a room with x amount of scaled up sprites in debug mode?

scenic pollen
#

Yeah, might even make multiple overlapping instances.

tough holly
#

drawing a 1px upscaled is much faster that draw_rectangle

#

i remeber doing the tests

scenic pollen
#

What's the point of draw_rectangle, then?

agile onyx
#

to distract and amuse

tough holly
#

and drawing a 1px like a line is faster than draw_line

#

lol

scenic pollen
#

Ah, I already knew that draw_rectangle is faster than draw_line, so drawing 1px (which is faster than draw_rectangle) should logically be faster than draw_line as well (transitivity and stuff).

#

The one thing draw_line has going for it is that it can connect two arbitrary points, not only along the rectangle. Though I'm not sure if 1px draw_sprite_ext with some angle wouldn't achieve close enough effect faster, now that it all comes to light. ^^'