[libgdx] [solved] Allowing sprites to "bypass" lighting

My world is rendered in two frame buffers. First, there’s a world buffer where all the blocks and entities are rendered to. Then there’s a lighting buffer where all the lights and shadows are rendered two. The world buffer is rendered first, and then the lighting buffer is masked on top of the world buffer. My question is how do I allow some sprites to “bypass” the lighting buffer, that is to always remain at full brightness? I don’t really know how to start and thus I don’t really know what to google for or ask.

If you know Minecraft, the spiders’ and endermens’ eyes always seem bright even in dark places.

Thanks!

  • Render world buffer minus bypassing sprites
  • Render light buffer on top
  • Render bypassing sprites on top

I’m guessing that the Minecraft examples are actually due to per-vertex info or similar though. Is your system 2D or 3D?

The thing is it’s not a set of particular sprites I want not lit, it’s for things like a block with a secondary “electric” texture that seems to “glow” even at night, or a monster where the eyes always are lit (like a cat’s eyes). If possible I want to render all my stuff during the world buffer phase without having to hackily put things outside of it.

If this really isn’t possible without too much of a performance hit or whatnot I’ll probably go with your idea. Thanks anyway :slight_smile:

EDIT:
I just saw your edit. My system is 2D.

EDIT deux:
I was thinking of having a separate “world glow” buffer where it would be overlaid over the lighting buffer. If an object were to render a bypassed sprite it could call some method in my rendering class and switch to that buffer (almost like a batch begin/end sequence of sorts). I might go with this method but I was wondering if there was a more effective way of doing this.

You could also use the depth test or stencil buffer so that the light buffer doesn’t get rendered in places where you didn’t want it.

I quickly read up on the depth test and stencil buffer using mattdesl’s guide (here) but all the cases he used it for only used ShapeRenderer to render primitive shapes. Is it limited to just primitives or could you potentially draw a sprite and have it work with the depth test?

I ended up using a separate buffer to put all the bypassed sprites in. It was a bit easier than trying to put in a depth buffer and I made batching methods. Probably will lose some performance but that’s not to be bothered with right now.