Skip to content

Stencil Texture Sampling#977

Merged
bjornbytes merged 1 commit into
devfrom
stencil-sampling
Jul 21, 2026
Merged

Stencil Texture Sampling#977
bjornbytes merged 1 commit into
devfrom
stencil-sampling

Conversation

@bjornbytes

@bjornbytes bjornbytes commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Allows sampling the stencil aspect of depth/stencil textures (d24s8 and d32fs8).

The data you get when sampling the texture depends on the type of the sampler variable:

  • Floating point texture (texture2D) will give you depth data.
  • Unsigned integer texture (utexture2D) will give you stencil data.

There's new validation to make sure the float/integerness of texture sampling is valid.

For some reason, I can't get glslang to accept overloads of getPixel that take usampler variables, so I left that out for now.

Fixes #869

(TODO: add s8 textures?)

Rejected idea: Add an aspect option to lovr.graphics.newTextureView where you can create different views of a texture to select between depth and stencil. It would be more explicit, but would require everyone to create a texture view just to sample the stencil data.

@bjornbytes
bjornbytes merged commit 5610911 into dev Jul 21, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reading Stencil Data in Shaders

1 participant