Repository navigation
Lighting: warn on Canvas only when a normal-mapped sprite goes unlit - #1771
Merged
Merged
Conversation
The Canvas renderer warned that normal-map lighting needs a GPU backend as soon as any Light2d existed. A light only reaches a sprite with a normal map, on WebGL and WebGPU alike, so a lit game without normal maps loses nothing on Canvas and was warned for nothing. Canvas now counts the lights it is given and warns once, when it draws a sprite with a normal map under them. Also puts setLightUniforms' doc comment back on it: inserting setFog had left it orphaned above setFog's own doc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SeWCkETjW35ZbXDRswV1hx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On the Canvas renderer, "Light2d normal-map lighting requires a GPU backend…" fired as soon as any
Light2dexisted (since 20.3.0). That was a false alarm for most games.A light only reaches a sprite with a normal map: WebGL and WebGPU switch to the lit pipeline only when there are active lights and the sprite being drawn has a
normalMap. A sprite without one is drawn unlit on every renderer. So a lit game without normal maps loses nothing on Canvas, yet it was warned.The fix
setLightUniforms(which only Canvas uses) now just counts the lights it's given, asactiveLightCount, like the GPU renderers do.CanvasRenderer.drawImagewarns once when it draws a sprite with a normal map while lights are active.Also:
setLightUniforms' doc comment had been orphaned, sitting abovesetFog's doc sincesetFogwas inserted. It's back on its method, and updated (it still said "WebGPU once it lands").Testing
tests/lights.spec.js), which replace the old pair that pinned the false alarm:Light2dwarns.Set.sizeshortcut it removed was redundant, so the shortcut was dropped.pnpm lintpasses.🤖 Generated with Claude Code
https://claude.ai/code/session_01SeWCkETjW35ZbXDRswV1hx