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

How to combine Render Command Encoders that use a different shader in Metal

I'm writing a graphics engine in Metal and I'm using the stencil buffer to mask the volumes covered by the Spherical Harmonic lights in the scene. I use two shaders for that, and I need 3 draw calls per light: one for the back faces, another for the…
endavid
  • 1,781
  • 17
  • 42
2
votes
1 answer

Problem using stencil mask on 3d object in arcore

I am using a stencil mask on a 3d object using the hello ar java demo however i am running into some unexpected behaviour. My stencil mask correctly occludes the plane renderer but the 3d object (andy) does not seem to react expectedly. Instead he…
smp007
  • 31
  • 1
  • 4
2
votes
1 answer

OperGL stencil buffer not acting how I expect

I have a simple UI widget system and I'm using the stencil buffer to act as a clipper so that children of a widget can't be drawn outside the widget. Basically, the stencil value for everything is inside the bounds for this widget is incremented.…
Alex
  • 14,973
  • 13
  • 59
  • 94
2
votes
0 answers

How to read the stencil buffer in Vulkan?

I have a combined depth/stencil image with the VK_FORMAT_D32_SFLOAT_S8_UINT format. I am trying to create 2 image views for it, so that I can use them to sample the depth and the stencil values in a shader. I set the image aspect flags to…
bishopp
  • 113
  • 8
2
votes
1 answer

Stencil test does not clip Texture

I'm trying to clip a texture using a Stencil Test. The idea is to create a surface (in this example a simple rectangle) to select a region of the texture to be shown (as the image bellow) I created a simple code to do so, where I first perform an…
Pedro H. Forli
  • 332
  • 2
  • 14
2
votes
1 answer

Shadow volumes - final stage

I continue to work on shadow volumes in OpenGL, after finishing with volume itself, i need to draw a shadow using stencil buffer, and thats where i'm stuck :) I rendered this scene: http://prntscr.com/17lyr As you see, sphere represents light…
Anton
  • 3,006
  • 3
  • 26
  • 37
2
votes
1 answer

OpenGL Stenciling, separating ref from value written?

The following code sets up the stencil test to see if ref is greater than the stored value in the stencil buffer, and if it is, it'll write ref to the stencil buffer unsigned int ref = 42; glStencilFunc(GL_GREATER, ref, 0xFF); glStencilOp(GL_KEEP,…
Anne Quinn
  • 12,609
  • 8
  • 54
  • 101
2
votes
1 answer

What exactly does glStencilMask() do?

I'm a beginner at OpenGL and while learning about stenciling this one function has been troubling me (glStencilMask). I've been told that it can be used to enable or disable stenciling, how is this? Why are hexadecimal values passed into this…
Barkin MAD
  • 127
  • 1
  • 10
2
votes
1 answer

Check a stencil bit, and write to another bit

I'm rendering reflective surfaces in my 3D engine. I need to perform two stencil operations. First, I draw out the reflective surface with depth testing to find visible areas of the surface. I then need to draw out models into a G-Buffer, which is…
Jagoly
  • 939
  • 1
  • 8
  • 32
2
votes
1 answer

android opengl 2.0 stencil buffer not working

I'm facing very strange behaviour on my android device when I am trying to use stencil buffer feature. (GLES20.glEnable(GLES20.GL_STENCIL_TEST);) here is my code: GLES20.glEnable(GLES20.GL_STENCIL_TEST); GLES20.glStencilFunc(GLES20.GL_GEQUAL, 1,…
esmeralda2
  • 169
  • 10
2
votes
1 answer

OpenGL: Clear the Stencil buffer, except for certain bits?

I'm using the stencil buffer for two jobs. The first is to allow masking to happen, and the second is to write masks for objects that can be 'seen' through. In this particular case, the reserved bit is 0x80, the very last bit in the byte, with the…
Anne Quinn
  • 12,609
  • 8
  • 54
  • 101
2
votes
2 answers

Occlusion queries with stencil test only

Do occlusion queries still work if I disable depth testing altogether when the obstacle set is known a priori to be strictly in-between the camera and the object to be tested? This is an attempt to improve performance, as, logically, I don't need…
user2464424
  • 1,536
  • 1
  • 14
  • 28
2
votes
1 answer

opengl stencils seem to have no effect

I am attempting to create slightly-rounded rectangles - the idea is that these would be platforms in a game - by creating a solid white rectangle, outlining it with black rectangles, and putting circles in the corners. To keep things simple, my…
Eric Dubé
  • 472
  • 1
  • 4
  • 12
2
votes
1 answer

How to use stenciling to create a 2d clipping mask in webgl?

I've been investigating a way to create a clipping mask similar to this one (done in SVG). Based on my findings I chose to achieve this through stenciling. My implementation however is grossly incorrect. I'm not entirely sure how gl.stencilOp and…
jonobr1
  • 1,013
  • 2
  • 11
  • 22
2
votes
1 answer

WebGL stencil buffer is working only in Firefox

I have a semi-working usage of a stencil buffer in WebGL. This works fine in Firefox, but fails in Chrome (and Internet Explorer as well.) The rest of the application continues to function without error, except that the stencil is ignored. Here…
Jacob Brunson
  • 1,482
  • 4
  • 23
  • 37