implement shading

This commit is contained in:
LabyStudio
2022-01-31 21:32:35 +01:00
parent c63bf36bca
commit 00af52a66a
3 changed files with 38 additions and 2 deletions
@@ -43,13 +43,18 @@ window.BlockRenderer = class {
let textureIndex = typeId;
let minU = (textureIndex % 16) / 16.0;
let maxU = minU + (16 / 256);
let minV = parseInt(textureIndex / 16); // TODO Math.round
let minV = Math.round(textureIndex / 16);
let maxV = minV + (16 / 256);
// Flip V
minV = 1 - minV;
maxV = 1 - maxV;
// Classic lightning
let brightness = 0.9 / 15.0 * 15 + 0.1;
let color = brightness * face.getShading();
this.tessellator.setColor(color, color, color);
if (face === EnumBlockFace.BOTTOM) {
this.addBlockCorner(world, face, minX, minY, maxZ, minU, maxV);
this.addBlockCorner(world, face, minX, minY, minZ, minU, minV);