© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
D. IlettBuilding Quality Shaders for Unity®https://doi.org/10.1007/978-1-4842-8652-4_7

7. The Depth Buffer

Daniel Ilett1  
(1)
Coventry, UK
 

How do you make sure objects get rendered in the correct order if they overlap in the viewport? What if an object is only partially obscured by another one? When attempting to render a given pixel, we need a system in place that allows us to check whether a pixel has already been drawn at the same position and determine whether it is in front of or behind the one we are currently drawing. This requires us to store additional data every time we draw a pixel. We can’t just store the color of the pixel; we also need to store ...

Get Building Quality Shaders for Unity®: Using Shader Graphs and HLSL Shaders now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.