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
1
vote
1 answer

How does gl_FragColor affect the stencil buffer?

I have set up my operations to draw to the stencil buffer, similar to the following: void onDisplay() { glClear(GL_DEPTH_BUFFER_BIT); glEnable(GL_STENCIL_TEST); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); glDepthMask(GL_FALSE); …
jwir3
  • 6,019
  • 5
  • 47
  • 92
1
vote
0 answers

Incorrect values written in stencil buffer

I am trying to pick objects on mouse click. For this I have followed this tutorial, and tried to use the stencil buffer for this purpose. Inside "game" loop I am trying to draw 10 (5 pairs) 'pick'able triangles as follows: ... glClearColor(red,…
Sayan Pal
  • 4,768
  • 5
  • 43
  • 82
1
vote
1 answer

Stencil buffer acts differently on different graphics cards

I'm rendering portals in my world in lwjgl/opengl. To increase performance and to make it possible for many portals to render behind each other, I try to user a stencil buffer for clipping the drawn scene to the place, where the portal will be. But…
Geosearchef
  • 600
  • 1
  • 5
  • 22
1
vote
1 answer

OpenGL - Stencil Test in a Rectangle

I am planning to draw a rectangle with a hole in its center. I am trying to use the stencil test on it but I can't make it work. You can see below for how I do it. glEnable(GL_STENCIL_TEST); glColorMask(GL_FALSE,GL_FALSE, GL_FALSE,…
zyneragetro
  • 139
  • 1
  • 2
  • 13
1
vote
1 answer

How do I use the stencil buffer to mask only the object pixels that are BEHIND another object?

I have two objects, we'll call them Mask and Masked. I want to use the shape of Mask to "cut a hole" in Masked. So far, I've been able to set up a very simple test, which renders as shown below: https://i.stack.imgur.com/Ct2ZR.png Unfortunately,…
Jarf
  • 11
  • 1
  • 3
1
vote
2 answers

OpenGl: Stencil buffer problem (Wall + Window)?

I want to create a wall with a window inside, using stencil buffer. My code looks like this: glEnable(GL_STENCIL_TEST); glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); glStencilMask(1); glStencilFunc(GL_ALWAYS, 1, 1); glStencilOp(GL_REPLACE,…
Lisa
  • 3,121
  • 15
  • 53
  • 85
1
vote
0 answers

Using stencil buffer to make windows

I would like to create windows in different walls and I want it to be dynamic so I do not want to change geometry of the wall because I want to be able to move the window. So I want to use stencil shader. I am new to shaders, but I have found some…
Dejvid Smith
  • 11
  • 1
  • 3
1
vote
1 answer

OpenGL ES 2.0 - GL_POINTS and Stencil Buffer

I am trying to draw a texture in OpenGL ES 2.0 using GL_POINTS by applying a stencil buffer. The stencil buffer should come from a texture. I am rendering the results to another texture and then presenting the texture to screen. Here is my code for…
Amendale
  • 317
  • 3
  • 19
1
vote
1 answer

libgdx open gles 2.0 stencil alpha masking

I'm looking for a solution to implement alpha masking with stencil buffer in libgdx with open gles 2.0. I have managed to implement simple alpha masking with stencil buffer and shaders, where if alpha channel of fragment is greater then some…
Veljko
  • 1,893
  • 6
  • 28
  • 58
1
vote
1 answer

libgdx decal not drawing into stencil buffer

I'm working on 3d app in libgdx engine. I just figured out that decalBatch isn't drawing into stencil buffer. I wanned to make stencil masks for 3d world, and it's not working at all. This is the code which works for sprite batch, but it's not…
Veljko
  • 1,893
  • 6
  • 28
  • 58
1
vote
1 answer

Considering the Stencil in depth

I'm using Orthographic projection to draw my objects. Each object items is being added to different buffers and being drawn in several cycles. Let's say that each object has an outline square and fill for the square (in different color). So i'm…
Raziza O
  • 1,560
  • 1
  • 17
  • 37
1
vote
1 answer

Stencil buffers seem to not work properly

I am writing an SDL2/modern OpenGL application that uses stencil buffers. I have written the following code in my renderer: glEnable(GL_STENCIL_FUNC); glClearStencil(0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |…
Taylee
  • 133
  • 6
1
vote
1 answer

Drawing Efficient Circles

I found 6 different ways to draw a basic circle in modern OpenGL (using the Qt framework). the discard statement of the fragment shader the stencil buffer the QPainter the triangle-fan primitve mapping a texture which contains an image of a circle…
Sharky Bamboozle
  • 1,066
  • 16
  • 28
1
vote
1 answer

webGL - How do I set up a stencil buffer alongside a frame buffer and use it?

Wandering if anyone could help me out. I am currently using webGL to render my content to a frame buffer so that it can be used as a texture for other parts of the project. This works like a champ. However I now need to make use of a stencil buffer…
Mat Groves
  • 113
  • 1
  • 5
1
vote
1 answer

How Stencil Buffer Operates in OpenGL

I'm trying to achieve the following effect in OpenGL as depicted in the given link http://commons.wikimedia.org/wiki/File:OpenGL_Tutorial_Stencil.png, code snippet is also below, this is the official openGL wikipedia tutorial. Although it has code…
Sonya Blade
  • 399
  • 7
  • 24