# Turning Depth Buffer into a PGraphics element

**URL:** https://discourse.processing.org/t/turning-depth-buffer-into-a-pgraphics-element/14184
**Category:** Coding Questions
**Created:** [September 24, 2019, 9:32pm UTC](https://discourse.processing.org/t/turning-depth-buffer-into-a-pgraphics-element/14184 "2019-09-24T21:32:59Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [September 25, 2019, 10:39pm UTC](https://discourse.processing.org/t/turning-depth-buffer-into-a-pgraphics-element/14184/8 "2019-09-25T22:39:26Z")

</div>

You may also be interested in this recent thread on stencil shaders.

> [@Using stencils in P2D / P3D](https://discourse.processing.org/t/using-stencils-in-p2d-p3d/13207):
>
> I asked Andres Colubri if he could help me out with getting stencils to work in processing. Here it is, and it’s freaking awesome. // Adapted from https://learnopengl.com/Advanced-OpenGL/Stencil-testing void setup() { size(600, 600, P3D); noStroke(); } void draw() { PGL pgl = beginPGL(); pgl.enable(PGL.STENCIL\_TEST); pgl.stencilOp(PGL.KEEP, PGL.KEEP, PGL.REPLACE); background(100); lights(); pgl.stencilMask(0); fill(128); drawFloor(); flush(); pgl.stenc…

 ![](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/7/7ece26a7a95c1d53de5a6f7cd7d6fd6760d8872b.png)

---

_[View the full topic](https://discourse.processing.org/t/turning-depth-buffer-into-a-pgraphics-element/14184)._
