Sign in to follow this  
qdrj

Draw to BitmapData

Recommended Posts

Hello everyone,

 

In my game I have big scrolling back(960x640) with parallax which consists of 8 parts.

 

I was thinking to replace it with one bitmapData. I'm going to draw all parts into this bmd and then use it as texture for only one image.

 

It will definetely reduce canvas draw calls but there any shortcomings for this method which i'm missing in theory?

 

I have been done this many times in Flash and it was good for performance.

 

Share this post


Link to post
Share on other sites

I doubt this will improve performance; in fact it's likely to reduce performance. BitmapData internally is just another canvas, so any compositing you do to this incurs the same performance hits as doing draw calls to the main screen canvas - except in addition once you've done your compositing on the BitmapData, it must then be drawn to the main canvas as well!

 

WebGL I believe would be even worse, because you'd be uploading the new texture to the GPU each frame, rather than allowing the GPU to composite the scrolling layers itself (which it can do very quickly compared to any code-based way).

 

Your best bet for increasing performance is to reduce overdraw. Avoid at all costs having 8 full-size parts all scrolling over the top of each other (even if they have totally transparent pixels, these still get drawn!) - reduce the parts down to rectangular sections that define only what can be seen, as in the attached diagram:

post-7918-0-19649500-1404215278.gif

Share this post


Link to post
Share on other sites

I doubt this will improve performance; in fact it's likely to reduce performance. BitmapData internally is just another canvas, so any compositing you do to this incurs the same performance hits as doing draw calls to the main screen canvas - except in addition once you've done your compositing on the BitmapData, it must then be drawn to the main canvas as well!

 

WebGL I believe would be even worse, because you'd be uploading the new texture to the GPU each frame, rather than allowing the GPU to composite the scrolling layers itself (which it can do very quickly compared to any code-based way).

 

Your best bet for increasing performance is to reduce overdraw. Avoid at all costs having 8 full-size parts all scrolling over the top of each other (even if they have totally transparent pixels, these still get drawn!) - reduce the parts down to rectangular sections that define only what can be seen, as in the attached diagram:

I didn't know about internals of BitmapData in Phaser. But now I find this on docs :)

 

And thanks for overdraw tip. I will try this very soon and write here about results.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.