4

I'm implementing texture masking using framebuffer's depth buffer following this example:

https://github.com/mattdesl/lwjgl-basics/wiki/LibGDX-Masking#masking-with-depth-buffer

I got it working with ShapeRenderer altering depth buffer, but now I want to alter depth buffer with a Pixmap. I need all non-opaque pxiels from pixmap to be written to depth buffer as 1.0 depth value, and all opaque ones as 0.0 depth value.

I see a solution in writing individual pixels from Pixmap with ShapeRenderer. But that seems rather inefficient. Is there a more appropriate and efficient way?

gvlasov
  • 18,638
  • 21
  • 74
  • 110
  • 1
    Seems pretty straight-forward. Clear the depth buffer to 1.0, draw a fullscreen quad that applies your pixmap as a texture at depth 0.0 (near plane in other words) and then apply an alpha test: EQUAL 1.0. If this is modern GL, you will have to do this with a fragment shader, so something like `if (tex.a != 1.0) discard;`. – Andon M. Coleman Nov 08 '13 at 03:46

1 Answers1

0

Texture myTex = new Texture(Pixmap pixmap);

Should be pretty trivial to draw a texture to a FrameBuffer, no?

SpacePrez
  • 1,086
  • 7
  • 15