Jump to content

UI on top of full-screen filter (shader)


swemaniac
 Share

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...

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

Link to comment
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!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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