Shadow

gfx.shadow.set_directional_atlas_size

Client

Sets the size and depth precision of the directional shadow atlas

Syntax

local status = gfx.shadow.set_directional_atlas_size(
    size,
    is_16bits = nil
)

A larger atlas gives sharper directional shadows at a memory cost.

  • Shared — used by every directional light with shadows, and split between each light's cascades.
  • Cost — memory and GPU cost grow with the square of the size, so 8192 uses four times as much as 4096.
  • Default — 4096 with a 16-bit depth buffer.

Parameters

TypeNameDescription
intsizeAtlas size in pixels
Must be between 256 and 16384, values that are not a power of two are rounded up to the next one
An error is raised if the value is out of range
boolis_16bitsDetermines the depth precision of the atlas:
• When true - uses a 16-bit depth buffer, lower memory usage and faster
• When false - uses a 32-bit depth buffer, higher precision at double the memory cost
• When omitted - keeps the current setting

Returns

TypeNameDescription
boolstatustrue on successful execution, false otherwise

Examples

Set an 8192 directional atlas
gfx.shadow.set_directional_atlas_size(8192)
Set a 4096 directional atlas with 32-bit depth
gfx.shadow.set_directional_atlas_size(4096, false)
Switch to 16-bit depth, keeping the current size
gfx.shadow.set_directional_atlas_size(gfx.shadow.get_directional_atlas_size(), true)

On this page