Swap chunk-scan direction for future stuff :)

This commit is contained in:
Lukas Rieger (Blue) 2024-02-25 18:12:27 +01:00
parent c9a8c83d6e
commit 2899646adc
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6
3 changed files with 30 additions and 22 deletions

View File

@ -78,7 +78,7 @@ public class HiresModelRenderer {
minY = Math.max(min.getY(), chunk.getMinY(x, z));
maxY = Math.min(max.getY(), chunk.getMaxY(x, z));
for (y = minY; y <= maxY; y++) {
for (y = maxY; y >= minY; y--) {
block.set(x, y, z);
if (!block.isInsideRenderBounds()) continue;
@ -87,17 +87,7 @@ public class HiresModelRenderer {
modelFactory.render(block, blockModel, blockColor);
//update topBlockLight
if (
y >= renderSettings.getRemoveCavesBelowY() ||
(renderSettings.isCaveDetectionUsesBlockLight() ? block.getBlockLightLevel() : block.getSunLightLevel()) > 0
) {
if (blockColor.a > 0) {
topBlockLight = Math.floor(topBlockLight * (1 - blockColor.a));
}
topBlockLight = Math.max(topBlockLight, block.getBlockLightLevel());
} else {
topBlockLight = 0;
}
topBlockLight = Math.max(topBlockLight, block.getBlockLightLevel() * (1 - columnColor.a));
// skip empty blocks
if (blockModel.getSize() <= 0) continue;
@ -107,9 +97,11 @@ public class HiresModelRenderer {
//update color and height (only if not 100% translucent)
if (blockColor.a > 0) {
maxHeight = y;
columnColor.overlay(blockColor.premultiplied());
if (maxHeight < y) maxHeight = y;
columnColor.underlay(blockColor.premultiplied());
}
//if (blockColor.a > 0.999 && block.getProperties().isCulling()) break;
}
}

View File

@ -193,7 +193,17 @@ public class ResourceModelBuilder {
(renderSettings.isCaveDetectionUsesBlockLight() ? Math.max(blockLight, sunLight) : sunLight) == 0
) return;
// calculate faceRotationVector
faceRotationVector.set(
faceDirVector.getX(),
faceDirVector.getY(),
faceDirVector.getZ()
);
faceRotationVector.rotateAndScale(element.getRotation().getMatrix());
makeRotationRelative(faceRotationVector);
// face culling
//if (faceRotationVector.y < 0.01) return;
if (face.getCullface() != null) {
ExtendedBlock<?> b = getRotationRelativeBlock(face.getCullface());
BlockProperties p = b.getProperties();
@ -315,14 +325,6 @@ public class ResourceModelBuilder {
tileModel.setAOs(face2, ao0, ao2, ao3);
//if is top face set model-color
faceRotationVector.set(
faceDirVector.getX(),
faceDirVector.getY(),
faceDirVector.getZ()
);
faceRotationVector.rotateAndScale(element.getRotation().getMatrix());
makeRotationRelative(faceRotationVector);
float a = faceRotationVector.y;
if (a > 0.01 && texturePath != null) {
Texture texture = texturePath.getResource(resourcePack::getTexture);

View File

@ -125,6 +125,20 @@ public class Color {
return this;
}
public Color underlay(Color color) {
if (color.a < 1f && !color.premultiplied) throw new IllegalArgumentException("Can only underlay premultiplied colors with alpha!");
premultiplied();
float p = 1 - a;
this.a = p * color.a + this.a;
this.r = p * color.r + this.r;
this.g = p * color.g + this.g;
this.b = p * color.b + this.b;
return this;
}
public Color flatten() {
if (this.a == 1f) return this;