jpvaillancourt Posted September 2, 2018 Share Posted September 2, 2018 I have a very simple graphics with a custom filter that creates a Noise + basic sin calculation to create a wave displacement map. I need to get the result of only one channel and I'm currently using : renderer.extract.pixels() But it is VERY slow. Is there a way to get the data output directly from the shader instead? I'm not sure if I'm explaining well enough... In other words, I would like to have the gl_FragColor of each pixels directly after the filter calculation. I'm pretty sure it should be possible instead of waiting for the Renderer to calculate the exact same result based on the position of the graphics, and then extracting it. I have search for several hours everywhere... Here's what I have at the moment (in Typescript), but the pixel() consume 49% of the tick duration. private createTextureDeformer() : void { this._pixiApp = new PIXI.Application(this.textureResolution + 1, this.textureResolution + 1, { transparent : <any> "notMultiplied", }); var uniforms : any = {}; uniforms.u_time = { type : 'f', value : 0 }; uniforms.u_size = { type : 'i', value : this.textureResolution }; this._textureFilter = new PIXI.Filter(null, this.getTextureDeformerShader(), uniforms); var graphics : PIXI.Graphics = new PIXI.Graphics(); graphics.drawRect(0, 0, this.textureResolution, this.textureResolution); graphics.filters = [this._textureFilter]; this._pixiApp.stage.addChild(graphics); if(this.debug) { document.body.appendChild(this._pixiApp.view); this._pixiApp.view.id = 'pixi-canvas'; } this.renderTextureDeformer(0); } private renderTextureDeformer(delta : number) : void { this._textureFilter.uniforms.u_time += delta / 1000; this._texturePixels = this._pixiApp.renderer.extract.pixels() as Uint8Array; } Quote Link to comment Share on other sites More sharing options...
xerver Posted September 3, 2018 Share Posted September 3, 2018 If you don't need the pixel data on the CPU then don't extract it, just write it to a framebuffer and use it in a different shader. If you do need the pixels on the CPU (becuase you need to write them to disk or some such) then this is the only way. 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.