Commit dc5d3a7
committed
Add per-player shadow direction override via set_lighting
Add an optional shadow.direction field to the lighting struct, allowing
server mods to override the shadow light direction on a per-player basis.
This is needed for games that use custom skyboxes where the sun/moon
position in the skybox texture does not correspond to the engine's
internal time-of-day cycle.
When shadow_direction is set, Game::updateShadows() uses it directly
instead of computing direction from getSunDirection()/getMoonDirection(),
and applies shadow_intensity unconditionally (bypassing the sun/moon
visibility check that would otherwise zero out shadows).
Lua API:
player:set_lighting({shadows = {direction = vector.new(0.3, 0.9, 0.3)}})
player:set_lighting({shadows = {direction = vector.zero()}}) -- clear
A zero vector is treated as "unset" throughout: Lua API, network
protocol, and client all use the same convention. The shadow direction
is always sent as a v3f on the wire (no flag byte), with {0,0,0}
meaning "use default sun/moon-based direction".
Removed dead code: the timeoftheday fmod computation in updateShadows()
was unused even before this change, and is now removed. The remaining
timeoftheday variable is scoped to the else branch where it is needed.
Updated TOCLIENT_SET_LIGHTING packet documentation in networkprotocol.h
to reflect all fields actually sent and parsed, plus the new shadow
direction.
Network compatibility: the new field is appended to the end of the
packet. Old clients ignore the extra bytes. New clients handle missing
bytes via the existing hasRemainingBytes() pattern, falling back to
sun/moon-based shadows when the server does not send a direction.
Bump LATEST_PROTOCOL_VERSION to 52 so servers can tell older clients
to disable shadows, or an alternative skybox, or no skybox, otherwise
things will look really weird for those players. Also bump unittests'
list of core versions.1 parent 3b67e73 commit dc5d3a7
File tree
9 files changed
+43
-7
lines changed- builtin/game
- doc
- src
- client
- network
- script/lua_api
9 files changed
+43
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9147 | 9147 | | |
9148 | 9148 | | |
9149 | 9149 | | |
| 9150 | + | |
| 9151 | + | |
| 9152 | + | |
| 9153 | + | |
| 9154 | + | |
9150 | 9155 | | |
9151 | 9156 | | |
9152 | 9157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3591 | 3591 | | |
3592 | 3592 | | |
3593 | 3593 | | |
3594 | | - | |
3595 | | - | |
3596 | | - | |
3597 | 3594 | | |
3598 | | - | |
3599 | 3595 | | |
3600 | 3596 | | |
3601 | | - | |
3602 | 3597 | | |
3603 | 3598 | | |
3604 | | - | |
| 3599 | + | |
| 3600 | + | |
| 3601 | + | |
| 3602 | + | |
| 3603 | + | |
| 3604 | + | |
| 3605 | + | |
| 3606 | + | |
| 3607 | + | |
| 3608 | + | |
| 3609 | + | |
| 3610 | + | |
3605 | 3611 | | |
3606 | 3612 | | |
3607 | 3613 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| 55 | + | |
54 | 56 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1875 | 1875 | | |
1876 | 1876 | | |
1877 | 1877 | | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
1878 | 1883 | | |
1879 | 1884 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
692 | 692 | | |
693 | 693 | | |
694 | 694 | | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
695 | 702 | | |
696 | 703 | | |
697 | 704 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2691 | 2691 | | |
2692 | 2692 | | |
2693 | 2693 | | |
| 2694 | + | |
| 2695 | + | |
| 2696 | + | |
| 2697 | + | |
2694 | 2698 | | |
2695 | 2699 | | |
2696 | 2700 | | |
| |||
2744 | 2748 | | |
2745 | 2749 | | |
2746 | 2750 | | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
| 2754 | + | |
2747 | 2755 | | |
2748 | 2756 | | |
2749 | 2757 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2024 | 2024 | | |
2025 | 2025 | | |
2026 | 2026 | | |
| 2027 | + | |
| 2028 | + | |
2027 | 2029 | | |
2028 | 2030 | | |
2029 | 2031 | | |
| |||
0 commit comments