Overv / VulkanTutorial

Tutorial for the Vulkan graphics and compute API
https://vulkan-tutorial.com
Creative Commons Attribution Share Alike 4.0 International
3.08k stars 513 forks source link

Depth buffering: Note regarding transparent objects #203

Closed maltekliemann closed 3 years ago

maltekliemann commented 3 years ago

In chapter Depth buffering, section Depth and stencil state (emphasis is mine):

The depthWriteEnable field specifies if the new depth of fragments that pass the depth test should actually be written to the depth buffer. This is useful for drawing transparent objects. They should be compared to the previously rendered opaque objects, but not cause further away transparent objects to not be drawn.

The bold transparent is not required, right?

Also, maybe transparent should be replaced by fully transparent to emphasize that the alpha channel must be strictly zero. A partially transparent object (a tinted window, for example) should most likely not be ignored in depth testing.

I'm really confused about this paragraph. I don't understand what rendering technique you're describing. If I had to guess, I'd say that you want to render opaque objects first, then render (partially) transparent objects over them in arbitrary order. Not writing to the depth buffer prevents near transparent objects from occluding far transparent objects. But depending on the order in which the transparent objects are rendered, I think you need different blending operations, so you have to keep track of the order one way or another.

Overv commented 3 years ago

Yeah, looking at it again now, it doesn't make any sense since it implies that you'd render near transparent objects before farther ones. I'll remove that section.

Fixed in 661eb797673de173a986063b3c452309365ccf2a