swemaniac

UI on top of full-screen filter (shader)

Recommended Posts

Hi everyone,

I'm doing some lightmapping and deferred lighting with a shader and a render texture on the whole screen to produce ambient light and illuminating with selected light sources. I apply the lightmap filter to the whole world like so:

this.game.world.filters = [lightmap];

This makes everything affected by the lightmap including the UI texts and stuff (obviously, since they attach to the stage like everything else I guess). My question is simply, is there a separate layer or such that I can use for UI stuff to exclude those things from the filter?

My solution for this right now I think would be:

  1. Render the UI component to a separate render texture
  2. Render the whole stage to a separate render texture
  3. Apply the lightmap filter to the render texture with the stage components in it
  4. Clear the stage and render both textures back to it

Would that be a viable solution? Or would it be a significant performance hit, rendering the stage multiple times...

Share this post


Link to post
Share on other sites

I can think of a couple of solutions: add anything you don't want filtered to the stage directly (via game.stage) and then remember to manage it on state transition since it won't be cleared like the world will. Or, you could create two top-level groups in the world: one which gets filtered and one which doesn't, and add children to the groups as you need.

Groups can have filters as well.

Share this post


Link to post
Share on other sites

That's really interesting, for whatever reason I never thought a group could have a filter, but why not indeed. Sounds like a good idea actually. I just need to pass the groups around and remember to add components there instead of to the stage.....

Thanks for the input!

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.