godotengine / godotengine/godot

Newly instantiated PointLight2D nodes set to Mix blend mode only render on sprites present in scene at spawn time.

Open
#96,445 0 comments 2 reactions 0 assignees View on GitHub
bug topic:2d topic:rendering
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in both versions I tried: 4.2.1 and 4.3stable.

### System information

Godot v4.3.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2080 (NVIDIA; 32.0.15.5599) - Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz (12 Threads)

### Issue description

A newly instantiated PointLight2D node using Mix blend mode will only render on CanvasItem textures that are present in the scene at the time of its spawn. Either instantiating a pre-saved scene with a point light or creating PointLight2D.new() both deliver similar results.

Changing the light blend mode to Add fixes the issue, PointLight2D's will now render on every sprite, but using Add blend mode piles up brightness in an undesirable way for my project.

I created a test project in both Godot 4.2 and 4.3 with the same result. I instantiate moving sprites one at a time with normal-mapped CanvasItem textures. After each sprite a new PointLight2D is created and tied to its position. (I've tried creating a single scene with both sprite and point light inside which causes the same issue.)

The first sprite to spawn will only render lights that have been created after it. It renders all future lights, while the last sprite will render only the single light created just after it.
![2dLightTest](https://github.com/user-attachments/assets/717a936c-5bc7-41b8-a151-8be67084d10a)

### Steps to reproduce

- Create a CanvasModulate node set to black.
- Instantiate one or more Sprite2Ds with a normal map set in its CanvasItem texture.
- Instantiate a new PointLight2D, add a texture and set blend mode to Mix.
- Instantiate one or more new Sprite2Ds.
- The second set of Sprite2Ds do not accept light from the PointLight2Ds created before them.

### Minimal reproduction project (MRP)

[LightTest.zip](https://github.com/user-attachments/files/16830492/LightTest.zip)

Contributor guide

Open the contributing guide

Research direction

Start by running the attached LightTest.zip reproduction and follow the listed steps with CanvasModulate, normal-mapped Sprite2D nodes, and PointLight2D nodes using Mix blend mode. Investigate the rendering path responsible for dynamically spawned 2D lights; done means newly spawned sprites receive lighting from previously created Mix-mode lights without requiring Add mode.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.