hecrj / wgpu_glyph

A fast text renderer for wgpu (https://github.com/gfx-rs/wgpu)
https://docs.rs/wgpu_glyph
MIT License
443 stars 77 forks source link

Support for depth testing? #11

Closed paulkernfeld closed 4 years ago

paulkernfeld commented 4 years ago

In certain cases, it might be nice to be able to render text that is behind objects that have already been rendered, i.e. by using depth testing.

I'm not 100% clear on how wgpu_glyph's rendering pipeline should interact with the user's rendering pipeline, but I think it might be possible to have the user pass in a DepthStencilStateDescriptor and a RenderPassDepthStencilAttachmentDescriptor.

hecrj commented 4 years ago

Absolutely. This feature is missing.

The challenge here is to offer a safe API. The issue is that if we create a pipeline with a DepthStencilStateDescriptor, then it should be mandatory for the user to provide a depth attachment to draw_queued.

I think we can easily achieve this with a phantom type D in GlyphBrush. Let me give it a shot.

hecrj commented 4 years ago

I have been able to get a draft implementation with a depth example in #13! I still have to think about some changes a bit, but let me know what you think!

paulkernfeld commented 4 years ago

Overall this does exactly what I was hoping for; thanks so much!