Fix flat lighting

This commit is contained in:
ah-OOG-ah committed 2025-10-06 15:29:42 -04:00
1 parent 3096601ab9
commit 5fef1b7f6b
3 files changed
+14 -18

No files matched your search

@@ -71,9 +71,9 @@ public class ModelISBRH implements ISimpleBlockRenderingHandler {
color = block.colorMultiplier(world, x, y, z);
}
final int r = color & 255;
final int g = color >> 8 & 255;
final int b = color >> 16 & 255;
final float r = (color & 255) / 255f;
final float g = (color >> 8 & 255) / 255f;
final float b = (color >> 16 & 255) / 255f;
final int lx = x + dir.offsetX;
final int ly = y + dir.offsetY;
@@ -4,6 +4,7 @@ import static java.lang.Math.max;
import static java.lang.Math.min;
import static org.joml.Math.fma;
import com.google.common.base.Objects;
import com.gtnewhorizon.gtnhlib.client.model.BakeData;
import com.gtnewhorizon.gtnhlib.client.model.BakedModel;
import com.gtnewhorizon.gtnhlib.client.model.UnbakedModel;
@@ -42,6 +43,8 @@ public class JSONModel implements UnbakedModel {
private final Map<String, String> textures;
private List<ModelElement> elements;
private static final Vector4f DEFAULT_UV = new Vector4f(0, 0, 16, 16);
public JSONModel(@Nullable ResourceLoc.ModelLoc parentId, boolean useAO,
Map<ModelDisplay.Position, ModelDisplay> display, @NotNull Map<String, String> textures,
List<ModelElement> elements) {
@@ -127,18 +130,11 @@ public class JSONModel implements UnbakedModel {
// Set UV
// TODO: UV locking
final Vector4f uv = f.getUv();
if (uv != null) {
setUV(quad,0, uv.x, uv.y);
setUV(quad,1, uv.x, uv.w);
setUV(quad,2, uv.z, uv.w);
setUV(quad,3, uv.z, uv.y);
} else {
// Not sure if this is correct, but it seems to fix things
flags |= QuadBuilder.BAKE_LOCK_UV;
}
final Vector4f uv = Objects.firstNonNull(f.getUv(), DEFAULT_UV);
setUV(quad,0, uv.x, uv.y);
setUV(quad,1, uv.x, uv.w);
setUV(quad,2, uv.z, uv.w);
setUV(quad,3, uv.z, uv.y);
// Set the sprite
bakeSprite(quad, this.textures.get(f.getTexture()), flags);
@@ -167,8 +163,8 @@ public class JSONModel implements UnbakedModel {
final float dV = icon.getMaxV() - minV;
for (int i = 0; i < 4; ++i) {
quad.setTexU(i, fma(dU, quad.getTexU(i), minU));
quad.setTexV(i, fma(dV, quad.getTexV(i), minV));
quad.setTexU(i, fma(dU, quad.getTexU(i) / 16, minU));
quad.setTexV(i, fma(dV, quad.getTexV(i) / 16, minV));
}
}