mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-22 10:35:16 +01:00
Fix lowres lighting and color calculation issues
This commit is contained in:
parent
b06ef68d99
commit
34d89ae0fe
@ -43,8 +43,8 @@
|
||||
import de.bluecolored.bluemap.core.util.math.VectorM2f;
|
||||
import de.bluecolored.bluemap.core.util.math.VectorM3f;
|
||||
import de.bluecolored.bluemap.core.world.BlockNeighborhood;
|
||||
import de.bluecolored.bluemap.core.world.LightData;
|
||||
import de.bluecolored.bluemap.core.world.ExtendedBlock;
|
||||
import de.bluecolored.bluemap.core.world.LightData;
|
||||
|
||||
/**
|
||||
* This model builder creates a BlockStateModel using the information from parsed resource-pack json files.
|
||||
@ -65,6 +65,7 @@ public class ResourceModelBuilder {
|
||||
private TransformedBlockModelResource blockModelResource;
|
||||
private BlockModelView blockModel;
|
||||
private Color blockColor;
|
||||
private float blockColorOpacity;
|
||||
|
||||
public ResourceModelBuilder(ResourcePack resourcePack, RenderSettings renderSettings) {
|
||||
this.blockColorCalculator = resourcePack.getBlockColorCalculatorFactory().createCalculator();
|
||||
@ -79,6 +80,7 @@ public void build(BlockNeighborhood<?> block, TransformedBlockModelResource bmr,
|
||||
this.block = block;
|
||||
this.blockModel = blockModel;
|
||||
this.blockColor = color;
|
||||
this.blockColorOpacity = 0f;
|
||||
this.blockModelResource = bmr;
|
||||
|
||||
this.tintColor.set(0, 0, 0, -1, true);
|
||||
@ -86,10 +88,15 @@ public void build(BlockNeighborhood<?> block, TransformedBlockModelResource bmr,
|
||||
// render model
|
||||
int modelStart = blockModel.getStart();
|
||||
|
||||
for (BlockModelResource.Element element : blockModelResource.getModel().getElements()){
|
||||
for (BlockModelResource.Element element : blockModelResource.getModel().getElements()) {
|
||||
buildModelElementResource(element, blockModel.initialize());
|
||||
}
|
||||
|
||||
if (color.a > 0) {
|
||||
color.flatten();
|
||||
color.a = blockColorOpacity;
|
||||
}
|
||||
|
||||
blockModel.initialize(modelStart);
|
||||
|
||||
// apply model-rotation
|
||||
@ -311,11 +318,14 @@ private void createElementFace(BlockModelResource.Element element, Direction fac
|
||||
|
||||
// apply light
|
||||
float combinedLight = Math.max(sunLight / 15f, blockLight / 15f);
|
||||
combinedLight = (renderSettings.getAmbientLight() + combinedLight) / (renderSettings.getAmbientLight() + 1f);
|
||||
combinedLight = (1 - renderSettings.getAmbientLight()) * combinedLight + renderSettings.getAmbientLight();
|
||||
mapColor.r *= combinedLight;
|
||||
mapColor.g *= combinedLight;
|
||||
mapColor.b *= combinedLight;
|
||||
|
||||
if (mapColor.a > blockColorOpacity)
|
||||
blockColorOpacity = mapColor.a;
|
||||
|
||||
blockColor.add(mapColor);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user