You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add normal map support for 2D lit sprites (#4)
* feat: add normal map support for 2D lit sprites
Add per-pixel normal mapping to the 2D lighting pipeline using a
two-shader approach: one shader for standard lit sprites and one with
the normal map always sampled. The renderer switches between them via
BeginShaderMode, the correct raylib pattern for shader state changes.
Key changes:
- SpriteState gains a NormalMap field (Texture2D voption)
- LightContext2D manages two shader programs with independent location
caches and uploads uniforms to both
- LitShader exports a normal-map fragment variant using Half-Lambert
lighting (NdotL = max(1.0 + dot(normal.xy, L), 0)) for correct 2D
behavior
- Renderer2D selects the shader variant per-sprite based on NormalMap
- New LightDraw.litAnimatedSprite helper for animated sprites
- SpriteState moved to top-level type for ergonomic use
* fix: address PR #4 review feedback
- Remove dead normal map code from standard shader (unused uniforms, getNormal)
- Mark LitSprite signature change as breaking in CHANGELOG
- Add FlipY handling to litAnimatedSprite
Copy file name to clipboardExpand all lines: CHANGELOG.md
+13-2Lines changed: 13 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,19 @@
1
1
# Changelog
2
2
3
-
[Unreleased]
3
+
## [Unreleased]
4
4
5
-
## [1.0.0] - 2026-05-30
5
+
### Added
6
+
7
+
- 2D normal map support: `SpriteState.NormalMap` field for per-pixel lighting on lit sprites. `LightContext2D` manages two shader variants (standard and normal-mapped) and switches between them via `BeginShaderMode`. The normal-map shader uses a 2D-compatible Half-Lambert lighting model (`NdotL = max(1.0 + dot(normal.xy, L), 0)`) for correct visual results with 2D light directions.
8
+
-`LightDraw.litAnimatedSprite` helper for animated sprites with automatic flip handling.
9
+
-`SpriteState` promoted to top-level type with builder DSL (`create`, `withNormalMap`, `withLayer`, etc.).
10
+
11
+
### Changed
12
+
13
+
-**Breaking:**`LitSprite` command signature changed — now carries `LightContext2D * SpriteState` instead of 8 individual fields. Consumers must update pattern matches and `LightDraw.litSprite` call sites to use the new `SpriteState` type.
14
+
-`SpriteState` moved from `Command2D` module to top-level `Mibo.Elmish.Graphics2D` namespace.
0 commit comments