Sign in to follow this  
jmp909

double buffered renderTexture trail never reaches 0 alpha

Recommended Posts

Hi,

 

I have 2 render textures swapping to create a trail, a bit similar to this concept http://phaser.io/examples/v2/display/pixi-render-texture

 

does anybody know why my trail never fades out.. I guess it's because the value never actually reaches 0? you can see there is grey residue of the sprite everywhere

http://phaser.io/sandbox/VWOOYqpU/play

 

I've adjusted the second image in photoshop to show the trails as they're not always easy to see on a monitor, but that can depend on the colour used

 

thanks

J

post-16536-0-72162400-1444088747.png

post-16536-0-30232200-1444093145.jpg

Share this post


Link to post
Share on other sites

I presume this occurs in http://phaser.io/sandbox/VWOOYqpU/play after you comment out "activeSnapshot.clear()" from the Update code?

It could be an issue with the iterating never reaching 0, but another thought is maybe alpha cutoff/testing is simply not drawing darker pixels when the textures are swapped. For I also notice it occurs in one browser but not in another.

Share this post


Link to post
Share on other sites

I presume this occurs in http://phaser.io/sandbox/VWOOYqpU/play after you comment out "activeSnapshot.clear()" from the Update code?

It could be an issue with the iterating never reaching 0, but another thought is maybe alpha cutoff/testing is simply not drawing darker pixels when the textures are swapped. For I also notice it occurs in one browser but not in another.

 

i didn't realise the sandbox auto-saved, i've taken that out.

thanks

 

PS Corona has the same issue https://forums.coronalabs.com/topic/42077-snapshot-painting-trails-never-quite-fade-out/

 

(Note In flash you can apply filters like BlurFilter & ColorMatrix to bitmap data to achieve similar, not sure that's a possibility with Phaser http://code.tutsplus.com/tutorials/quick-tip-add-a-blurry-trail-effect-to-your-bullets--active-11064)

Share this post


Link to post
Share on other sites

When the alpha channel of one of the textures gets to a small enough value like 4, it will not get any smaller due to the fixed precision of the 1 byte used for the alpha channel

Math.round((230/255)*4) = 4; // where 230/255 is our alpha value of .9 expressed as fraction of our 8bit alpha channel

Share this post


Link to post
Share on other sites

thanks...so there's no solution here?

Numerically? Fading by more than 50% per swap (alpha less than .5) should get to zero

Programmatically? I'm sure there are various tricks to apply eg. you could use WebGL's alpha test to effectively truncate low alpha values like 4/255 or 5/255 to 0 (by not rendering these pixels in the render texture to the canvas)

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.