mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-26 04:47:59 +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;
|
import net.minecraft.core.SectionPos;
|
||||||
|
|
||||||
// Massive kudos to RogueLogix for figuring out this LUT scheme.
|
// Massive kudos to RogueLogix for figuring out this LUT scheme.
|
||||||
|
// First layer is Y, then X, then Z.
|
||||||
public final class LightLut {
|
public final class LightLut {
|
||||||
private final Layer<Layer<IntLayer>> indices = new Layer<>();
|
private final Layer<Layer<IntLayer>> indices = new Layer<>();
|
||||||
|
|
||||||
|
@ -17,8 +18,8 @@ public final class LightLut {
|
||||||
final var y = SectionPos.y(position);
|
final var y = SectionPos.y(position);
|
||||||
final var z = SectionPos.z(position);
|
final var z = SectionPos.z(position);
|
||||||
|
|
||||||
indices.computeIfAbsent(x, Layer::new)
|
indices.computeIfAbsent(y, Layer::new)
|
||||||
.computeIfAbsent(y, IntLayer::new)
|
.computeIfAbsent(x, IntLayer::new)
|
||||||
.set(z, index + 1);
|
.set(z, index + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,13 +28,13 @@ public final class LightLut {
|
||||||
final var y = SectionPos.y(section);
|
final var y = SectionPos.y(section);
|
||||||
final var z = SectionPos.z(section);
|
final var z = SectionPos.z(section);
|
||||||
|
|
||||||
var first = indices.get(x);
|
var first = indices.get(y);
|
||||||
|
|
||||||
if (first == null) {
|
if (first == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var second = first.get(y);
|
var second = first.get(x);
|
||||||
|
|
||||||
if (second == null) {
|
if (second == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -43,18 +43,18 @@ bool _flw_nextLut(uint base, int coord, out uint next) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _flw_chunkCoordToSectionIndex(ivec3 sectionPos, out uint index) {
|
bool _flw_chunkCoordToSectionIndex(ivec3 sectionPos, out uint index) {
|
||||||
uint y;
|
uint first;
|
||||||
if (_flw_nextLut(0, sectionPos.x, y) || y == 0) {
|
if (_flw_nextLut(0, sectionPos.y, first) || first == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint z;
|
uint second;
|
||||||
if (_flw_nextLut(y, sectionPos.y, z) || z == 0) {
|
if (_flw_nextLut(first, sectionPos.x, second) || second == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint sectionIndex;
|
uint sectionIndex;
|
||||||
if (_flw_nextLut(z, sectionPos.z, sectionIndex) || sectionIndex == 0) {
|
if (_flw_nextLut(second, sectionPos.z, sectionIndex) || sectionIndex == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue