mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-24 11:57:54 +01:00
Swizzle
- Switch to Y X Z ordering - In theory this will be more coherent since the first lut step on the GPU will have a more constrained range of values in the worst case
This commit is contained in:
parent
bedb92c73c
commit
671d47a136
2 changed files with 10 additions and 9 deletions
|
@ -9,6 +9,7 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
|
|||
import net.minecraft.core.SectionPos;
|
||||
|
||||
// Massive kudos to RogueLogix for figuring out this LUT scheme.
|
||||
// First layer is Y, then X, then Z.
|
||||
public final class LightLut {
|
||||
private final Layer<Layer<IntLayer>> indices = new Layer<>();
|
||||
|
||||
|
@ -17,8 +18,8 @@ public final class LightLut {
|
|||
final var y = SectionPos.y(position);
|
||||
final var z = SectionPos.z(position);
|
||||
|
||||
indices.computeIfAbsent(x, Layer::new)
|
||||
.computeIfAbsent(y, IntLayer::new)
|
||||
indices.computeIfAbsent(y, Layer::new)
|
||||
.computeIfAbsent(x, IntLayer::new)
|
||||
.set(z, index + 1);
|
||||
}
|
||||
|
||||
|
@ -27,13 +28,13 @@ public final class LightLut {
|
|||
final var y = SectionPos.y(section);
|
||||
final var z = SectionPos.z(section);
|
||||
|
||||
var first = indices.get(x);
|
||||
var first = indices.get(y);
|
||||
|
||||
if (first == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var second = first.get(y);
|
||||
var second = first.get(x);
|
||||
|
||||
if (second == null) {
|
||||
return;
|
||||
|
|
|
@ -43,18 +43,18 @@ bool _flw_nextLut(uint base, int coord, out uint next) {
|
|||
}
|
||||
|
||||
bool _flw_chunkCoordToSectionIndex(ivec3 sectionPos, out uint index) {
|
||||
uint y;
|
||||
if (_flw_nextLut(0, sectionPos.x, y) || y == 0) {
|
||||
uint first;
|
||||
if (_flw_nextLut(0, sectionPos.y, first) || first == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint z;
|
||||
if (_flw_nextLut(y, sectionPos.y, z) || z == 0) {
|
||||
uint second;
|
||||
if (_flw_nextLut(first, sectionPos.x, second) || second == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint sectionIndex;
|
||||
if (_flw_nextLut(z, sectionPos.z, sectionIndex) || sectionIndex == 0) {
|
||||
if (_flw_nextLut(second, sectionPos.z, sectionIndex) || sectionIndex == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue