Sets the current depth test. The depth test controls how overlapping objects are rendered.
|compareMode||CompareMode||nil||The new depth test. Use |
|write||boolean||true||Whether pixels will have their z value updated when rendered to.|
The depth test is an advanced technique to control how 3D objects overlap each other when they are rendered. It works as follows:
- Each pixel keeps track of its z value as well as its color.
writeis enabled when something is drawn, then any pixels that are drawn will have their z values updated.
- Additionally, anything drawn will first compare the existing z value of a pixel with the new z
compareModesetting determines how this comparison is performed. If the comparison succeeds, the new pixel will overwrite the previous one, otherwise that pixel won't be rendered to.
Smaller z values are closer to the camera.
The default compare mode is
lequal, which usually gives good results for normal 3D rendering.