Questions tagged [stencil-buffer]

The stencil buffer is a concept implemented in various 3D graphics APIs used for performing "stencil" operations, used to minimize rasterization of hidden pixels or to implement various effects.

Resources:

202 questions
0
votes
1 answer

OpenGL ES: Stencilbuffers and culling

I am new to OpenGL and i am trying out few experiments especially with the stencil buffers. In my code, I have set the front and back stencil buffers separately using glStencilFuncSeparate to 0x5 and 0xC respectively(GL_ALWAYS as parameter to the…
user45620
  • 3
  • 1
0
votes
0 answers

Read stencil texture in shader in WebGL2

I have a draw call which is updating the stencil buffer as a DEPTH24_STENCIL8 texture, which I bound to my FBO as a depth-stencil attachment; this works fine. Now I wish to read back the final stencil values in another pass to do something with…
Seawaves32
  • 103
  • 6
0
votes
2 answers

What the equivalent of OpenGL glStencilFunc in Metal?

How to translate to Metal the following OpenGL instruction: glStencilFunc(Func, Ref, Mask);
zeus
  • 12,173
  • 9
  • 63
  • 184
0
votes
1 answer

I want to know the original stencil value of a pixel/fragment., zero or one? If possible to get what specific action modify the stencil value?

I am confused many things about stencil buffer in OpenGL. I read the opengl tutorials here, https://learnopengl.com/Advanced-OpenGL/Stencil-testing. I simply add one line code glStencilFunc(GL_EQUAL, 1, 0xFF); and then nothing will be rendered. if…
Mengyu Chen
  • 137
  • 6
0
votes
1 answer

Create "Union" of two masking images in OpenGL

for a current 2D project I am rendering different objects on a scene. On top of this I render images which have a cut out part, for example a transparent circle on a black image. When moving the cut-out circle, this creates the effect that of course…
florianbaethge
  • 2,520
  • 3
  • 22
  • 29
0
votes
1 answer

Rendering a mesh only if behind another mesh

I'm trying to render a mesh ("content mesh") (with depth testing) only when it is behind another mesh ("window mesh"). The first solution would be to use a stencil buffer to only write where the "window mesh" has been written. My issue is that the…
Kiord
  • 79
  • 7
0
votes
2 answers

Why stencil test does not discard fragments?

I want to run stencil test to outline cubes. It is from learnopengl https://learnopengl.com/Advanced-OpenGL/Stencil-testing. A cubes that do outlining should have discarded fragments that are on a textured cubes. It does not happen, the outlining…
Shout
  • 338
  • 5
  • 14
0
votes
1 answer

Mixing GL_ALWAYS with GL_LESS in OpenGl

I have: a set of dots a set of meshes I need the meshes to be drawn in the correct z order, based on depth. For this I used glDepthFunc(GL_LESS) or glDepthFunc(GL_LEQUAL), or glEnable(GL_DEPTH_TEST) the dots to be rendered in the order of…
Cristi Stoica
  • 169
  • 2
  • 7
0
votes
1 answer

Is there a way in WebGL to quickly invert the stencil buffer?

I'm using WebGL 1.0. I drew a circle to the stencil buffer, and now I want to use this stencil buffer multiple times without clearing it. The first time I use it, I enable stencil testing with: gl.enable(GL.STENCIL_TEST); Then, I perform my drawing…
jwir3
  • 6,019
  • 5
  • 47
  • 92
0
votes
0 answers

Drawing Concave Polygons Using Stencil Test

I am attempting to draw concave polygons using the stencil buffer trick outlined in the OpenGL redbook but I can't seem to get it working correctly. Per the redbook, I clear the stencil buffer first prior to enabling the stencil test. Next, I then…
JDBones
  • 495
  • 1
  • 7
  • 18
0
votes
0 answers

how to extract ROI using stencil buffer

What I want to do is that extracting where main avatar is using stencil buffer. I'm using planeshift which is opensource of 3D MMORPG game and this game uses crystalspace as rendering engine. What I want to get is as below : =====in stencil…
John
  • 17
  • 1
  • 5
0
votes
1 answer

Python, Pyglet draw shape pixels inside stencil mask

I'm facing this trouble that I tried to solve in so many ways that I found on the internet, but everything I tried didn't any visual difference. I want to draw a shape discarding all pixels that are outside of the circle mask, in the example code…
0
votes
1 answer

How to use depth texture with stencil, OpenGL ES 3.0

I have an application where I want to render depth to a texture using stencil mask. I try GL_DEPTH_STENCIL_OES: Creating texture: glGenFramebuffers(1, fbo); glBindFramebuffer(GL_FRAMEBUFFER, *fbo); glGenTextures(1,…
Zheden
  • 583
  • 2
  • 11
  • 36
0
votes
1 answer

How to find valid OpenGL framebuffer configuration/documentation

I'm using an early 2011 MacBook Pro with macOS Sierra 10.12.4 and Intel HD Graphics 3000 512 MB, and I'm using JOGL. According to OS X 10.9 Core Profile OpenGL Information (unfortunately they don't have info for newer versions yet), my system…
Andy
  • 7,885
  • 5
  • 55
  • 61
0
votes
1 answer

Why sometimes we use specific bits to do stencil test?

I am not clear why sometimes choose some specific bits of the stencil buffer to do stencil test. I cannot find examples like only test 1,3,5 bits of one stencil buffer.
james
  • 335
  • 1
  • 5
  • 18