-
-
Couldn't load subscription status.
- Fork 69
Add lighting scene IDs to lighting system #295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.21.1/dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,9 +44,14 @@ bool _flw_nextLut(uint base, int coord, out uint next) { | |
| return false; | ||
| } | ||
|
|
||
| bool _flw_chunkCoordToSectionIndex(ivec3 sectionPos, out uint index) { | ||
| bool _flw_chunkCoordToSectionIndex(uint sceneId, ivec3 sectionPos, out uint index) { | ||
| uint scene; | ||
| if (_flw_nextLut(0u, int(sceneId), scene) || scene == 0u) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The cast to int here is a little spooky since the data really is a uint, but we'll realistically run out of memory before this causes issues. Still, it could be good to have a copy of _flw_nextLut that takes a uint index |
||
| return true; | ||
| } | ||
|
|
||
| uint first; | ||
| if (_flw_nextLut(0u, sectionPos.y, first) || first == 0u) { | ||
| if (_flw_nextLut(scene, sectionPos.y, first) || first == 0u) { | ||
| return true; | ||
| } | ||
|
|
||
|
|
@@ -90,9 +95,9 @@ bool _flw_isSolid(uint sectionOffset, uvec3 blockInSectionPos) { | |
| return (word & (1u << bitInWordOffset)) != 0u; | ||
| } | ||
|
|
||
| bool flw_lightFetch(ivec3 blockPos, out vec2 lightCoord) { | ||
| bool flw_lightFetch(uint scene, ivec3 blockPos, out vec2 lightCoord) { | ||
| uint lightSectionIndex; | ||
| if (_flw_chunkCoordToSectionIndex(blockPos >> 4, lightSectionIndex)) { | ||
| if (_flw_chunkCoordToSectionIndex(scene, blockPos >> 4, lightSectionIndex)) { | ||
| return false; | ||
| } | ||
| // The offset of the section in the light buffer. | ||
|
|
@@ -307,14 +312,14 @@ vec3 _flw_lightForDirection(uint[27] lights, vec3 interpolant, uint c00, uint c0 | |
| return light; | ||
| } | ||
|
|
||
| bool flw_light(vec3 worldPos, vec3 normal, out FlwLightAo light) { | ||
| bool flw_light(uint scene, vec3 worldPos, vec3 normal, out FlwLightAo light) { | ||
| // Always use the section of the block we are contained in to ensure accuracy. | ||
| // We don't want to interpolate between sections, but also we might not be able | ||
| // to rely on the existence neighboring sections, so don't do any extra rounding here. | ||
| ivec3 blockPos = ivec3(floor(worldPos)) + flw_renderOrigin; | ||
|
|
||
| uint lightSectionIndex; | ||
| if (_flw_chunkCoordToSectionIndex(blockPos >> 4, lightSectionIndex)) { | ||
| if (_flw_chunkCoordToSectionIndex(scene, blockPos >> 4, lightSectionIndex)) { | ||
| return false; | ||
| } | ||
| // The offset of the section in the light buffer. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| void flw_shaderLight() { | ||
| vec2 embeddedLight; | ||
| if (flw_lightFetch(ivec3(floor(flw_vertexPos.xyz)) + flw_renderOrigin, embeddedLight)) { | ||
| if (flw_lightFetch(0, ivec3(floor(flw_vertexPos.xyz)) + flw_renderOrigin, embeddedLight)) { | ||
| flw_fragLight = max(flw_fragLight, embeddedLight); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably need to expose the scene ID/embedding ID here