Jump to content

RenderTexture of a Container not rendered/shown on screen


HarsimranVirk
 Share

Recommended Posts

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? 

Link to comment
Share on other sites

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 by Jammy
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by HarsimranVirk
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...