jfred1979 Posted October 28, 2017 Share Posted October 28, 2017 I am trying to do the following: draw some shapes to a Graphics object render those shapes to a RenderTexture without clearing it first, so that the shapes are "painted onto the texture" apply a filter (a blur, for example) to the RenderTexture without ever clearing it so the current blur is processing an already blurred texture from the previous frame render to the screen repeat, never clearing the previously rendered display This is basically continuously blurring the display so that the longer something has been displayed, the more blurred it gets. Here is where I am at so far: class Project { constructor() { this.renderer = new PIXI.WebGLRenderer(window.innerWidth, window.innerHeight, { antialias: true }); this.renderTexture = PIXI.RenderTexture.create(this.renderer.width, this.renderer.height); document.body.appendChild(this.renderer.view); this.stage = new PIXI.Container(); this.canvas = new PIXI.Graphics(); this.sprite = new PIXI.Sprite(this.renderTexture); this.blurFilter = new PIXI.filters.BlurFilter(); this.stage.addChild(this.sprite); this.draw(); } draw() { var mousePosition = this.renderer.plugins.interaction.mouse.global; this.canvas.clear(); this.canvas.lineStyle(0); this.canvas.beginFill(0x666666); this.canvas.drawCircle(mousePosition.x, mousePosition.y, 50); // Somehow apply a blur to this.renderTexture without clearing it so the next line renders the // canvas on top of already blurred elements. This display will be fed into the next render // cycle without being cleared so that the blurs are "additive". this.renderer.render(this.canvas, this.renderTexture, false); this.renderer.render(this.stage); requestAnimationFrame(this.draw.bind(this)); } } Does this make sense? Am I on the right track? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted October 29, 2017 Share Posted October 29, 2017 You dont have to refill `canvas` every time, just change its position. Draw circle at (0,0) one time and use `canvas.position.copy(mousePosition)` You can apply filter to it, but filters of root element does not appear in renderTexture, you need to create one more container, add your graphics there, put filters in graphics, and render the container. Please explain whether you want to blur whole image or blur that graphics mask. If you want that, you have to use that graphics as a mask for a sprtie with your renderTexture. There will be also a problem with "rendering texture over itself" so its possible that you need two render textures. I'm very busy, I can help you with the code later if you try to use this advice jfred1979 1 Quote Link to comment Share on other sites More sharing options...
jfred1979 Posted November 1, 2017 Author Share Posted November 1, 2017 Thanks, makes sense. I will give it a go and respond if I get stuck! ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted November 1, 2017 Share Posted November 1, 2017 Btw, Flash had the same approach, properties of root container weren't used at all. Its pure technical thing, you can understand it only if you try to write stage tree yourself, so just take it as granted for now 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.