What is the simplest way to utilise a depth buffer with MSAA? #1668
-
Hi there, Thanks very much for all the great work on this project, it's amazing! I have a quick question that I'm hoping has a wgpu-specific answer (because I don't mean to waste your time ingorantly asking for explanations of general computer graphics concepts!)- is there a simple way to utilise a depth buffer while also using MSAA? I have MSAA working perfectly without depth buffering, and I have depth buffering working perfectly without MSAA, so it seems very tempting to assume there is a final little step to take to combine the two- the problem I'm facing when I naively try to drop both of them in is that I can't have attachments with different sample counts (MSAA > 1, depth buffer = 1) in the same render pipeline. My render process is very simple:
However, as I mentioned, the above configuration doesn't work because of the differing sample counts. Any help would be greatly appreciated- apologies again if this question concerns a broader concept than just a wgpu implementation, if that's the case then I'll look elsewhere for hints. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Thanks for the kind words! The solution is pretty simple, you just need to create a multi-sampled depth buffer. It will then do depth tests on every single sample not just every pixel. You can make a multisampled depth buffer the same was as a normal texture by making its sample count != 1. |
Beta Was this translation helpful? Give feedback.
Thanks for the kind words! The solution is pretty simple, you just need to create a multi-sampled depth buffer. It will then do depth tests on every single sample not just every pixel. You can make a multisampled depth buffer the same was as a normal texture by making its sample count != 1.