HarsimranVirk Posted July 21, 2020 Share Posted July 21, 2020 Hey, I want to ask if there's a way to create render textures of displayObjects which aren't rendered/shown on screen? For example, let's say I have a container which has the sprites of normal maps, I want to create a render texture of this container which I could then maybe use in a shader. Now, I obviously wouldn't want this container to be visible at all, if I make it invisible, the renderTexture is going to be empty as well. So, the use case is that I have a container which is just used to create textures that could be used in a shader, and I dont want this container to be visible in the scene. Is there a way to achieve this? Quote Link to comment Share on other sites More sharing options...
Jammy Posted July 21, 2020 Share Posted July 21, 2020 (edited) Yes, I do this by setting them offscreen -1000,-1000 alternatively have a hidden pixi instance and use that. Other may have more suggestions tho. edit; Also, im pretty sure you can just add what you want to a container and use renderTexture and never add the container to the stage or another container? Edited July 21, 2020 by Jammy Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 21, 2020 Share Posted July 21, 2020 > For example, let's say I have a container which has the sprites of normal maps, I want to create a render texture of this container which I could then maybe use in a shader. just use container that is not added to stage. Just in case, here is basic lighting example: https://pixijs.io/examples/#/plugin-layers/lighting.js , it uses pixi-layers "useRenderTexture" feature, basically same as you want to do by hands - render container into texture, use somewhere else Quote Link to comment Share on other sites More sharing options...
HarsimranVirk Posted July 21, 2020 Author Share Posted July 21, 2020 (edited) 3 hours ago, ivan.popelyshev said: just use container that is not added to stage. Thanks for the reply @ivan.popelyshev Also, I found my exact problem I guess. I was adding app.renderer.render(container, renderTexture) inside the default ticker of PIXI.Application, and I think the result of this is cleared because the default ticker finally calls app.renderer.render(app.stage) which clears the screen? Is this correct? If it is correct, then I guess this shouldn't be a problem in a custom game loop if handled correctly, right? Thank you ? Edited July 21, 2020 by HarsimranVirk Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted July 21, 2020 Share Posted July 21, 2020 if you dont want to clear it - there's third param, "false". As for application, every time its mentioned i tell people to study https://github.com/pixijs/pixi.js/wiki/v5-Custom-Application-GameLoop and make their own application class instead of using default pixi. 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.