jmp909 Posted October 5, 2015 Share Posted October 5, 2015 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 everywherehttp://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 thanksJ Link to comment Share on other sites More sharing options...
chg Posted October 6, 2015 Share Posted October 6, 2015 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. Link to comment Share on other sites More sharing options...
jmp909 Posted October 6, 2015 Author Share Posted October 6, 2015 if i rotate my viewSprite slightly the residue fades to a single small cluster of pixels in the middle, but you can just about see it's still grey , if you open it up in photoshop and adjust the exposure you can see this example: http://phaser.io/sandbox/UGaLncwl/play Link to comment Share on other sites More sharing options...
jmp909 Posted October 6, 2015 Author Share Posted October 6, 2015 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) Link to comment Share on other sites More sharing options...
chg Posted October 6, 2015 Share Posted October 6, 2015 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 Link to comment Share on other sites More sharing options...
jmp909 Posted October 6, 2015 Author Share Posted October 6, 2015 thanks...so there's no solution here? Link to comment Share on other sites More sharing options...
chg Posted October 6, 2015 Share Posted October 6, 2015 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) Link to comment Share on other sites More sharing options...
jmp909 Posted October 6, 2015 Author Share Posted October 6, 2015 * numerically... those fade out the trails too fast though * programatically.. but what would i be doing an alpha test on? it's a double buffered renderTexture that captures one faded screen snapshot on top of another thanksj Link to comment Share on other sites More sharing options...
Recommended Posts