Jump to content

Caching output of sprite with filter applied


Saltallica
 Share

Recommended Posts

Hey Guys,

Running in to a scenario where I'm using an expensive shader applied to a large background sprite. The background doesn't get updated once the shader is applied, and it would be great if I could just get a copy of the sprite as it looks with the shader applied, without it having to re apply the shader every frame. 

My failed attempts so far:

  • The most straight forward approach was to attempt using cacheAsBitmap, but it simply makes the entire contents of the container disappear.
     
  • I also tried rendering the sprite (with filter) to a renderTexture, then outputting that to a sprite. The sprite shows up, but the affects of the filter do not show up.

 

Does anyone have any tricks up their sleeves?

Thanks!

Link to comment
Share on other sites

>I also tried rendering the sprite (with filter) to a renderTexture, then outputting that to a sprite. The sprite shows up, but the affects of the filter do not show up.

Put that sprite into container, and cache container. Sometimes filters dont work directly..

 

\Are you using v4 or v5? v5-alpha.3 has a problem with filters in renderTexture

Link to comment
Share on other sites

Ivan,

Thanks for the quick reply! I'm using v4 (4.6.2).

Wrapping the sprite into a container, and applying the filter to either the sprite or the container, with the container.cacheAsBitmap = true causes it to disappear completely. 

Also tried playing with render.generateTexture and also getting the same results - as in nothing displays.

Only other thing I can think to do at this point is extract the image, and re add it as a new texture, but not sure if that'll work either.

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...