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
4
votes
1 answer

Android OpenGL ES 1.1: Read from Stencil Buffer

Using Android OpenGL ES 1.1 (HTC Desire)... The problem I have in general is this: I have various 3D objects rendered in a complex scene. I want to check if the user has clicked on a particular object. This object may be partially hidden and…
chris
  • 1,731
  • 4
  • 26
  • 33
4
votes
1 answer

Concave polygon drawing

For drawing complex concave polygons with OpenGL, is it better to tesselate it into triangles, or use the stencil buffer? I'm guessing the stencil buffer would be faster for a single frame, but triangulation would be better for multiple frames if…
Zifre
  • 26,504
  • 11
  • 85
  • 105
4
votes
1 answer

Unity shader warning when not adding _Stencil properties

I'm writing a custom shader for Unity 2019.3.13f1 that is just a simple UI gradient. This shader does not (need to) do anything with the stencil buffer, so I set the Stencil to always pass statically: Stencil { Ref 0 Comp Equal Pass…
Remy
  • 4,843
  • 5
  • 30
  • 60
4
votes
1 answer

Stencil buffer in WebGL

How I can use to stencil buffer for my easiest program? I have read many different themes about it, but I not found a detailed guide about it. I want to cut out for hole each side in a created tetrahedron. Please explain to me step by step use…
AnatoliyC
  • 57
  • 9
4
votes
1 answer

IOS Metal Stencil Buffer project crashes when Metal Validation Enabled

I am trying to learn how to implement Stencil Buffer in Metal IOS. For now It works fine without Metal Validation. But as soon as I turn on Metal Validations, project crashes. Here is my code:- Metal View:- import MetalKit class DrawingView:…
Nilupul Sandeepa
  • 748
  • 6
  • 20
4
votes
0 answers

OpenGL - Rendering a tunnel through a surface?

For a project of mine in OpenGL, I want to render a series of tunnels through a terrain mesh. The immediate problem is that the terrain still renders inside of the tunnel. At the moment I solve this through using the stencil buffer, preventing the…
leopardGeckos
  • 91
  • 2
  • 8
4
votes
1 answer

How to draw concave shape using Stencil test on Metal

This is the first time I'm trying to use Stencil Test but I have seen some examples using OpenGL and a few on Metal but focused on the Depth test instead. I understand the theory behind the Stencil test but I don't know how to set it up on Metal. I…
mvcs
  • 255
  • 2
  • 11
4
votes
1 answer

OpenGL using GL_STENCIL with a sphere

I'm working with OpenGL and I am trying to create a sphere that has a reflective surface. I have it reflecting but the reflection isn't correct. The object in the reflection should be bent and deformed according to the curve of the surface, instead…
ars265
  • 1,949
  • 3
  • 21
  • 37
4
votes
1 answer

Issue when updating stencil buffer in OpenGL

I'm having issues when drawing using the stencil test in OpenGL on mac. When I first draw the scene, the stencil works fine. I draw a semi-transparent black rectangle in the middle, with writing to the stencil buffer enabled, and then a larger blue…
KFox
  • 1,166
  • 3
  • 10
  • 35
4
votes
1 answer

How does mask affect stencil value according to stencil op?

The documentation in OpenGL reference pdf (both OpenGL 3.3 and 4.5 specs) is not much clear about what happens to the stored stencil value when a mask is applied. In example If I have the following mask: glStencilMask( 0x06); and stored in the…
CoffeDeveloper
  • 7,961
  • 3
  • 35
  • 69
4
votes
4 answers

Does OpenGL stencil test happen before or after fragment program runs?

When I set glStencilFunc( GL_NEVER, . . . ) effectively disabling all drawing, and then run my [shader-bound] program I get no performance increase over letting the fragment shader run. I thought the stencil test happened before the fragment…
david
  • 205
  • 1
  • 4
  • 9
4
votes
1 answer

Porting OpenGL stencil functionality to DirectX 11

I have some rendering code written in OpenGL. I use stencil buffer to implement clipping: //Let's assume this is done in render loop. if(!already_created()) { …
Mateusz Grzejek
  • 11,698
  • 3
  • 32
  • 49
4
votes
1 answer

glreadpixels stencil buffer always throws GL_INVALID_OPERATION

I'm trying to figure out stencils. Right now I am just drawing some boxes with stencil values, then reading the value. Every time I call glReadPixels with GL_STENCIL_INDEX, I get GL_INVALID_OPERATION. Here is the code in…
tmo7452
  • 43
  • 4
4
votes
1 answer

Early stencil culling

I'm trying to get early fragment culling to work, based on the stencil test. My scenario is the following: I have a fragment shader that does a lot of work, but needs to be run only on very few fragments when I render my scene. These fragments can…
Fred
  • 41
  • 1
  • 2
4
votes
1 answer

how to do customized stencil test in fragment shader

In my project, I used 'discard' call to perform customized stencil test, which tries to draw things only on a specified area defined by a stencil texture. Here is the code from fragment shader: //get the stencil value from a texture float…
Sunf71
  • 93
  • 2
  • 8
1
2
3
13 14