-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
Draft
ryanhcode
wants to merge
2
commits into
Engine-Room:1.21.1/dev
Choose a base branch
from
ryanhcode:1.21.1/lighting-scenes
base: 1.21.1/dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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. | ||
|
2 changes: 1 addition & 1 deletion
2
common/src/lib/resources/assets/flywheel/flywheel/light/flat.glsl
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
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); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
common/src/lib/resources/assets/flywheel/flywheel/light/smooth.glsl
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
2 changes: 1 addition & 1 deletion
2
common/src/lib/resources/assets/flywheel/flywheel/light/smooth_when_embedded.glsl
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
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
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.
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