alexh Posted October 30, 2014 Share Posted October 30, 2014 Hello, I'm wondering how to erase something from a rendertexture. I don't want to clear the whole thing and it might not necessarily be a rectangle. (for rectangles I found http://www.html5gamedevs.com/topic/9031-trying-to-build-a-paint-application-with-pixi/#entry54977) Usually I would try to disable all blendmodes and draw transparent stuff onto the rendertexture, but blendModes.NORMAL still does alpha blending, so it doesn't change anything to the texture.Is there a way of doing this? EDIT:For the WebGL renderer I discovered that this works:renderer.renderSession.gl.disable(renderer.renderSession.gl.BLEND);//draw with alpha 0renderer.renderSession.gl.enable(renderer.renderSession.gl.BLEND);How would you do it with the Canvas renderer? Thanks Quote Link to comment Share on other sites More sharing options...
agamemnus Posted November 1, 2014 Share Posted November 1, 2014 You can make a mask with canvas paths and the clip function , then use a globalCompositeOperation: https://developer.mozilla.org/samples/canvas-tutorial/6_1_canvas_composite.html Quote Link to comment Share on other sites More sharing options...
omnivibe Posted January 4, 2015 Share Posted January 4, 2015 Alex- I tried your solution and it works, but the drawing just erases a square, even if the drawn object is non-square (i.e. with alpha channel) Any way around that? Quote Link to comment Share on other sites More sharing options...
msha Posted January 5, 2015 Share Posted January 5, 2015 What is behind the rendertexture, does it have a static background, or there are things moving behind it? If it has a static texture as a background, then instead of erasing, you can draw that bg texture on the rendertexture, masked with the brush sprite. Quote Link to comment Share on other sites More sharing options...
omnivibe Posted January 5, 2015 Share Posted January 5, 2015 Interesting... I'll try that! Quote Link to comment Share on other sites More sharing options...
omnivibe Posted January 5, 2015 Share Posted January 5, 2015 Wait, no ultimately that won't work since the user needs to be able to swap out the background too... any suggestions for true erasing? (in WebGL mode) Quote Link to comment Share on other sites More sharing options...
msha Posted January 5, 2015 Share Posted January 5, 2015 No idea, sorry. Are you sure canvas is too slow for this? Quote Link to comment Share on other sites More sharing options...
omnivibe Posted January 5, 2015 Share Posted January 5, 2015 Need to target mobile, so yeah I think so :\ Quote Link to comment Share on other sites More sharing options...
msha Posted January 6, 2015 Share Posted January 6, 2015 BTW, there is a big thread about painting - http://www.html5gamedevs.com/topic/11091-what-is-the-fastest-way-to-paint/ omnivibe 1 Quote Link to comment Share on other sites More sharing options...
omnivibe Posted January 7, 2015 Share Posted January 7, 2015 Cool, I moved the discussion over there and provided a fully working starting point... hopefully that will get some more eyes on it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.