natiny.surface.get_depth

Lua
natiny.surface.get_depth(surf) -> texture

The surface's depth buffer, as a texture handle - for a shader that wants to know how far away each pixel was, rather than only what colour it ended up.

Returns 0 for a surface created without depth.

Parameters

Name Type Description
surf number Surface handle

Returns

Type Description
number Texture handle, or 0 when the surface has no depth buffer

Example

Lua
local depth = natiny.surface.get_depth(scene)

Notes

  • The returned texture is owned by the surface and uses a sampleable 32-bit float depth format. It is sampled without filtering.
  • Only slot 0's depth buffer takes part in a pass; a surface bound to another slot contributes colour alone.
  • Invalid surfaces and surfaces created without depth return 0.