Pixel rounding

0 favourites
  • 5 posts
From the Asset Store
Per Pixel Destruction like in "Worms" (perfect performance, no third party plugins)
  • Well not really a bug, but I didn't know where to post it and I want this to catch someone's attention badly, so Ashley :)

    I did some experiments with mobile exports as you may know already and it came to me, that doing pixel rounding the way it's done in the runtime by Math.round(x) is the slowest way available to round a number.

    Done some research and it seems that you can achieve double the speed by rounding using something called a Hack rounding with bitwise or:

    rounded = (0.5 + somenum) | 0;

    tested it by changing every instance of

    if (this.runtime.pixel_rounding) ... Math.round

    to the above code and i could actually see a little performance boost in more complex creations.

    so... any chance this would be implemented in next c2 version pretty please? :)

    cheers!

  • How much of a performance boost could you measure?

    I'd have thought it was negligable, since doing something like drawing a sprite probably takes 1000 times longer than the call to Round().

  • around 2 fps gain. not much but still... :)

  • OK, well every little helps on mobile, so I've used the (x + 0.5) | 0 form in the next build. It won't be changelogged though since it's a really small change.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • well no problem for me it's not changelogged :) thanks and cheers!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)