3

I'm making a splitscreen coop 2D from-the-top game with LWJGL. I'm currently trying to figure a smart way of merging two field of vision with the stencil buffer. The whole point is that you are able to see what the other player is able to see.

A picture is better than word.

Stencil buffer

Keep in mind I can only draw white square and black shadow.

I don't want anything to be drawn inside the black area, hence the stencil buffer.

Drawing the world while filling the stencil buffer with "1" is easy. Drawing the field of view for a player is easy. Figuring out where only one of the player can see isn't easy.

To me It seems like a OR operation between the 2 last pictures. However there is only one stencil buffer. Because of the relative lack of documentation about stencil buffer I'm also not sure about how it really work.

I would also like to avoid having complicated stuff like FBO. I'm pretty sure there is a simple way to do it with the stencil buffer.

Does anyone have an idea about this ?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Klems
  • 183
  • 1
  • 2
  • 8

0 Answers0