Buran Posted July 15, 2021 Share Posted July 15, 2021 I have a few images, which i need to combine and then store the result. As i understood, RenderTexture is just what i need. let provinceTexture = resources["province"].texture; let baseProvinceSprite = new PIXI.Sprite(provinceTexture); baseProvinceSprite.x = 0; baseProvinceSprite.y = 0; baseProvinceSprite.width = w; baseProvinceSprite.height = h; let terrainTexture = resources["grass"].texture; let terrainSprite = new PIXI.TilingSprite(terrainTexture, w, h); terrainSprite.mask = baseProvinceSprite; terrainSprite.x = 0; terrainSprite.y = 0; terrainSprite.width = w; terrainSprite.height = h; let renderTexture = PIXI.RenderTexture.create({ width: w, height: h }); app.renderer.render(terrainSprite, { renderTexture: renderTexture }); "renderTexture" stores what i need. But i also want to remove sprites and textures i used to make this rendertexture. If i just destroy them right after .render call, rendertexture is rendered as black texture on screen. It works, only if i destroy them after 1sec timeout, but it doesnt look like a good decision. I guess, i can destroy them only when rendertexture was rendered on screen, which happens later in the code. So, how do i make this properly? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 15, 2021 Share Posted July 15, 2021 Its rendered exactly when you call `renderer.render({renderTexture})`. If the result is different, please make complete reproduction demo so I can debug what is wrong there. Quote Link to comment Share on other sites More sharing options...
Buran Posted July 15, 2021 Author Share Posted July 15, 2021 Nevermind, it was just a coincidence. For some reason textures are rendered black half the time inside of loader.load callback method. 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.