Quick answer: Godot 4 canvas item shader rendering as if all lights enabled despite light_mask filtering? Mask changes invalidate the shader's lighting state - call queue_redraw on affected items.

Toggling a light's enabled state doesn't visually update shaded sprites for one frame.

Force redraw on mask change

Iterate affected CanvasItems; call queue_redraw(). Forces shader pass; lighting updates.

Or animate light energy

Tween light energy to zero instead of toggling enabled. Avoids the mask change; lighting updates per frame.

Verify per frame in profiler

Profile_canvas_lights = 1. Lighting calls per frame visible; missing calls = the bug.

“Canvas lighting is cached per item. Cache invalidation requires explicit triggers.”

For day/night cycles, lerp light energy rather than toggling lights. Smoother visually; avoids invalidation bugs.

Related reading