Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stencil Additions #242

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Conversation

EriKWDev
Copy link
Contributor

@EriKWDev EriKWDev commented Jan 5, 2025

Motivation

We want to use stencil tests to optimize part of our planar reflection rendering

Added Texture Formats

  • Depth32FloatStencil8Uint
  • Stencil8Uint

API Additions

Added set_stencil_reference(&mut self, reference: u32) to RenderEncoder trait
Both metal, gles and vulkan support setting it for front and back faces individually, but from what I could find metal only supports setting them both at the same time.

I decided to simply set front and back to same value for now. Could be solved by requiring both be specified as a front_reference: u32 and back_reference: u32. Skipped for now

Metal

Noticed that metal wasn't doing anything with the stencil load/clear ops so implemented those while peeking at wpgu-hal implementation

Testing

Tested and inspected in vulkan. Gles compiles on linux. Macos compiles and runs.

@EriKWDev
Copy link
Contributor Author

EriKWDev commented Jan 6, 2025

The results using stencil test for planar reflection show performance gain, especially on our weaker laptop targets for the game :)

@EriKWDev
Copy link
Contributor Author

EriKWDev commented Jan 7, 2025

One thing that caught me was that the TextureColor became a little unintuitive when I wanted to clear the depth and stencils to 1.0 and 0.

OpaqueBlack needed a few extra brain cells for me to associate xD But makes sense once you rule out the other options of what it could mean

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.

1 participant