b2dDrawImageQuadDepth

Category: 2D Overlay

Syntax:

b2dDrawImageQuadDepth:Void(image:Int, x1:Int, y1:Int, z1:Double, x2:Int, y2:Int, z2:Double, x3:Int, y3:Int, z3:Double, x4:Int, y4:Int, z4:Double)


Parameters

Returns

Void



Summary

b2dDrawImageQuad with a depth at every corner. The whole image is mapped onto the four corners in the same way, and the quad is depth-tested per pixel, so textured faces hide each other correctly whatever order you draw them in — no sorting and no backface culling.

Returns nothing.

It uses the same depth buffer as b2dDrawQuadDepth and b2dSetDepth, so textured faces and solid primitives hide one another too. That is what lets two objects pass through each other and cut cleanly where they meet, which no draw order can do.

The one rule: the depths must be perspective-correct. Exactly as for b2dDrawQuadDepth, depth is interpolated linearly across the screen, so pass projective values of the form a + b/z, not raw view-space z, or a flat face creases along its diagonal:

dep = (FARZ * (z - NEARZ)) / (z * (FARZ - NEARZ))

Depths outside 0..1 are clamped. Colour tints the image and alpha fades it; the image handle, scale and rotation do not apply.

Where there is no depth buffer it draws flat, in call order, like b2dDrawImageQuad: that is inside a render target (b2dSetRenderTarget), and everything drawn while a screen shader is applied. Palette-cycling (indexed) images are not supported and draw nothing. To give each corner its own point in the image, use b2dDrawImageQuadDepthUV.

View detailed documentation online



Example
; one textured face of a 3D model, each corner with its own depth
dA = (FARZ * (tzA - NEARZ)) / (tzA * (FARZ - NEARZ))
dB = (FARZ * (tzB - NEARZ)) / (tzB * (FARZ - NEARZ))
dC = (FARZ * (tzC - NEARZ)) / (tzC * (FARZ - NEARZ))
dD = (FARZ * (tzD - NEARZ)) / (tzD * (FARZ - NEARZ))

b2dDrawImageQuadDepth(crate, sxA,syA,dA, sxB,syB,dB, sxC,syC,dC, sxD,syD,dD)

See examples/Runtime/29 - Image Quads/ImageQuadDepth.bam — all six faces of a spinning crate, unsorted, with a slab passing through it.


BambooBasic © 2026 Michael Denathorn