-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Feature: Extraction LightMerger usage in post-ready step. #4502
Conversation
When I try to start a new game with just Core gameplay it crashes with:
|
🚀 The chunks indeed load faster, but ... |
Freeze happened, Shadowy chunks. |
Oh. when chunk loads - VoxelSystem getAll blocks from chunk.. But VoxelSystems requests block every block position... Suggestion:
especially now, when chunks delivering faster. |
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.
I'm not really the best reviewer for this, I guess (peeking at @4Denthusiast 🙄 ), but I found at least one little bug with iterating over BlockRegion
.
Please have a look at the comments 🤓
/** | ||
* @deprecated Use {@link org.terasology.world.chunks.pipeline.stages.ChunkTask} instead | ||
*/ | ||
@Deprecated |
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.
So we reverted the deprecation? Was the other ChunkTask
recently introduced, or has it been around for some time but was never put to "special" use (justifying this deprecation)?
* System which will process light merging after chunk is ready. | ||
*/ | ||
@RegisterSystem | ||
public class ChunkLightMergingSystem extends BaseComponentSystem { |
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.
Oh, we don't even hook that up to the magic chunk generation off-thread process, but it is just a regular system 🤓 neat!
engine/src/main/java/org/terasology/world/chunks/ChunkLightMergingSystem.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/world/chunks/ChunkLightMergingSystem.java
Show resolved
Hide resolved
engine/src/main/java/org/terasology/world/chunks/ChunkLightMergingSystem.java
Show resolved
Hide resolved
engine/src/main/java/org/terasology/world/chunks/CoreChunk.java
Outdated
Show resolved
Hide resolved
engine/src/main/java/org/terasology/world/chunks/internal/ChunkImpl.java
Outdated
Show resolved
Hide resolved
* Creates ChunkLightMergingSystem which process light merging after chunk is ready for light merging * Remove LightMerging from ChunkProcessingPipeline
* ChunkProcessingPipeline have only one-to-one steps.
* RelativeSystem should sort chunks to loads itself.
…osition, if processing for ChunkProcessingPipeline.
…eline's methods. * ChunkProcessingPipeline use Function and Consumer for stage now.
…EGA ViewDistance's volume
…unk generation now.
…ocks to `boolean[]`
cb6bbf2
to
72c4129
Compare
Co-authored-by: Tobias Nett <skaldarnar@googlemail.com>
…kImpl.java Co-authored-by: Tobias Nett <skaldarnar@googlemail.com>
Co-authored-by: Tobias Nett <skaldarnar@googlemail.com>
…gingSystem.java Co-authored-by: Tobias Nett <skaldarnar@googlemail.com>
…gingSystem.java Co-authored-by: Tobias Nett <skaldarnar@googlemail.com>
Tried this out and the chunks seemed to load very slowly... it took quite a while and then a bunch of them popped up... usually it felt like they pop up one by one 🤔 |
every chunk ready is faster, because lightmerger(a huge time eater) take a lot of time. (also internal chunkprocessing sorting was eliminated and compilcated wait logic was removed too) other profit in tests. tests with chunks works faster(and take less memory) now |
@DarkWeird testing this a bit but sometimes restarting the world makes the whole world black. |
@pollend |
Some of the chunks are loading in this way and the other half are fine. |
No. It is not about some of the chunks. |
* strange, hashset not determinate that two Vector3i has same hashcode, if this vectors not same...
…postready' into feature/extract-light-merger-to-postready
9c99f00
to
8c837a1
Compare
…mpletableFuture with simple function Composition. * function composition seems work faster.
Just wait. Idk why this works so bad. ChunkLightMergingSystem checks around chunks on every chunk loading for possible to start light merging... |
} | ||
chunks[index++] = chunkProvider.getChunk(position); | ||
} | ||
threadManager.submitTask("Chunk Light Merging", () -> new LightMerger().merge(chunks)); |
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.
This doesn't look thread safe. It's changing the light values for a chunk that's already accessible elsewhere, so another system could be updating the lighting at the same time. Also, it looks like you don't mark the chunk dirty anywhere after light merging happens, so it may never be re-meshed (depending on the order of operations).
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.
Yeah it not thread safe, but it costs low price if error happens there.
About dirting chunks. It marks implicitly.(somewhere during merging)
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.
The changes to the world collision systems seems pretty irrelevant, and it's annoying to have that mixed into the same PR. I can't find any obvious problems that would cause the mostly unlit chunks shown in the screenshots. Internal light merging is clearly still happening, otherwise there wouldn't be that light at the bottom of the chunks, but somehow it's starting off dark, rather than starting off lit at the top like it should be.
I haven't had a look at everything yet. In particular, I haven't read through all of the changes to ChunkProcessingPipeline
. @DarkWeird Could you summarise what those changes are meant to do (except directly removing the light merging step)? It looks like a lot has been removed. Does that reduce the functionality of it? If it removes the ability to have steps that require multiple chunks at once, I would expect it could be simplified much more than this.
|
About unlit. Mostly lightning data at all - LightMerger. Unlit border happens because lightmerger is not processed those chunks. But it cannot process them, because not enough chunks (next chunks is lod chunk already) |
What are the main issues that make lighting inefficient. just shuffling things around does not resolve the problem does it :?. I see large spikes now with the lighting being moved to the main thread. this should be a parallelizable problem since lighting is local to its chunk. the only thing that would matter is the locations of the active light source and a border similar to how facets work. I also don't see why we can't cache out the lighting to the filesystem to avoid having to recalculate it every time. |
@pollend Hmm. I suspect that internalLightProcesdor works incorrect. Also.. provide facet data to game can helps make lightning better... Quality change |
one thing I would like is to have a dynamic light facet for sunlight and just move the light column up the chain until it hits an unloaded chunk and then move the up the next visible block. so we don't have areas underground that are lit because a chunk was momentarily exposed to the sky. |
The issue that this PR fixes is that you need to load all the chunks around a chunk before it can become visible. That's sort of an efficiency thing in that it reduces the amount of woth necessary before a given amount of chunks become visible. |
I'm not happy with just merging this with the concurrency issues left in. Although I agree that the issues would be mostly minor, and probably rare, they would also likely be really confusing. Others who have actually tested this PR have commented that it causes the game to have noticable lag spikes, and fixing the concurrency issue would make that even worse. Possibly that could be improved by improving the efficiency of the lighting calculations (which Michael thinks is very possible), but I think overall this change may just not be worth making, so I suggest just closing the PR unmerged. |
Contains
How to test
2.1. fly on
hspeed
, check how fast chunk loadings.3.1. fly on
hspeed
, check how fast chunk loadings.