Skip to content

Add a 2D light playground - #1129

Open
4ian wants to merge 3 commits into
mainfrom
claude/kind-lamport-y7aci1
Open

4ian wants to merge 3 commits into
mainfrom
claude/kind-lamport-y7aci1

Conversation

@4ian

@4ian 4ian commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

What's added

examples/2d-light-playground: three scenes to try the 2D lights and light obstacles (press 1, 2 or 3 to switch):

  • Dungeon: brick walls (each brick an obstacle) lit by torches and a turning flashlight.
  • Moving Lights and Obstacles: coloured lights going around, crates and doors turning, pillars sliding, candles next to the doors.
  • Crowded Room: 320 crates, 9 lights, one following the mouse.

Tests

  • A gameplay test checking the lights move as expected.
  • A rendering test with 6 screenshots (each scene at the start and after things moved), with the expected images in rendering-screenshots/2d-light-playground.

Note

The expected images are drawn with 4ian/GDevelop#9401 (merged), where the turning doors cast shadows (moving-lights-and-obstacles-later.png). The rendering check will pass once the GDevelop build published for master includes it.

Three scenes to try the 2D lights and light obstacles: a dungeon of brick
walls lit by torches and a turning flashlight, lights and obstacles moving
(crates and doors turning, pillars sliding), and a room crowded with
hundreds of crates lit by many lights, one following the mouse.

Its rendering tests take screenshots of each scene, at the start and after
the lights and obstacles moved.
@github-actions

Copy link
Copy Markdown
Contributor

Preview the game(s) changed or added in this Pull Request


This is an automatic message displaying links to the games in this PR - double check the JSON in case of doubt.

4ian added a commit to 4ian/GDevelop that referenced this pull request Nov 21, 2026
## Problem

On Apple GPUs (Chrome, Metal), 2D lights with a texture showed dotted
lines coming out of the light, darker inside the lit area and faintly
lit outside it (visible in the [2D light
playground](GDevelopApp/GDevelop-examples#1129)).

## Why

The GPU chooses a texture's mipmap level for each 2x2 block of pixels.
On Apple GPUs, once a pixel of the block is discarded, the level chosen
for the others is wrong. Light meshes are made of very thin triangles
(most are thinner than 0.1 px), so almost every block had a pixel
discarded before the texture was sampled.

This was already the case before #9401: the light meshes are the same.

## Fix

The texture is sampled before any pixel is discarded. Plain GLSL ES 1.0,
no extension: it works wherever the light shader works today.

## Tests

- On an M2 Pro, with the meshes of the playground: 8% of the pixels were
wrong before, none after.
- 0 differing pixels on the 12 rendering screenshots (playground,
`lights` and `raycast-debug-view` examples) with SwiftShader. The
lighting tests pass.

---
_Generated by [Claude Code](https://claude.ai/code)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants