Improve a buuuunch of textures and some reworks
This commit is contained in:
@@ -5,7 +5,7 @@ import { get_sprite_region } from "$/client/sprites.ts";
|
||||
import type { ItemEntity } from "$/client/entity/item_entity.ts";
|
||||
import type { ItemStack } from "$/common/inventory.ts";
|
||||
import { push_vertex, Texture } from "$/client/renderer/mod.ts";
|
||||
import { block_item_texture, cube_face_texture } from "$/common/block_models.ts";
|
||||
import { block_item_texture, cube_face_texture, cube_face_tint } from "$/common/block_models.ts";
|
||||
import { item_model } from "./item_model.ts";
|
||||
|
||||
// how big items on the ground are drawn, minecraft's ground transform
|
||||
@@ -82,7 +82,8 @@ export function push_item(atlas: Texture, item: ItemStack, transform: ItemTransf
|
||||
for (const face of CUBE_FACES) {
|
||||
const region = get_sprite_region(cube_face_texture(block, face.texture));
|
||||
const corners = face.corners.map(([cx, cy, cz]) => transform(cx - 0.5, cy, cz - 0.5));
|
||||
push_textured_quad(atlas, region, corners, face.shade);
|
||||
const [r, g, b] = cube_face_tint(block, face.texture);
|
||||
push_textured_quad(atlas, region, corners, [face.shade * r, face.shade * g, face.shade * b]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -100,7 +101,7 @@ export function push_item(atlas: Texture, item: ItemStack, transform: ItemTransf
|
||||
}
|
||||
}
|
||||
|
||||
function push_textured_quad(atlas: Texture, region: { x: number; y: number }, corners: number[][], shade: number) {
|
||||
function push_textured_quad(atlas: Texture, region: { x: number; y: number }, corners: number[][], color: number[]) {
|
||||
const u0 = (region.x * TEXTURE_SIZE + UV_PAD) / atlas.width;
|
||||
const v0 = (region.y * TEXTURE_SIZE + UV_PAD) / atlas.height;
|
||||
const u1 = ((region.x + 1) * TEXTURE_SIZE - UV_PAD) / atlas.width;
|
||||
@@ -109,7 +110,7 @@ function push_textured_quad(atlas: Texture, region: { x: number; y: number }, co
|
||||
for (const i of [0, 1, 2, 0, 2, 3]) {
|
||||
const [px, py, pz] = corners[i];
|
||||
const [cu, cv] = CORNER_UVS[i];
|
||||
push_vertex(px, py, pz, cu ? u1 : u0, cv ? v1 : v0, shade, shade, shade, 1);
|
||||
push_vertex(px, py, pz, cu ? u1 : u0, cv ? v1 : v0, color[0], color[1], color[2], 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { get_sprite_region } from "$/client/sprites.ts";
|
||||
import { BlockRegistry, EverythingRegistry, ItemRegistry } from "$/common/everything_registry.ts";
|
||||
import { AssetManager } from "$/client/assets.ts";
|
||||
import { ItemStack } from "$/common/inventory.ts";
|
||||
import { block_item_texture, cube_face_texture } from "$/common/block_models.ts";
|
||||
import { block_item_texture, cube_face_texture, cube_face_tint } from "$/common/block_models.ts";
|
||||
import { draw_text, draw_texture_region, draw_texture_region_skewed, Texture } from "$/client/renderer/mod.ts";
|
||||
|
||||
// the corners keep their size (times scale), the edges stretch along and the middle fills the rest, like minecraft's
|
||||
@@ -146,6 +146,7 @@ function draw_item_block(block_info: BlockRegistry, x: number, y: number) {
|
||||
{ x: cx, y: cy + half_h },
|
||||
{ x: cx - half_w, y: cy },
|
||||
],
|
||||
...cube_face_tint(block_info, "top"),
|
||||
);
|
||||
draw_texture_region_skewed(
|
||||
atlas,
|
||||
@@ -159,6 +160,7 @@ function draw_item_block(block_info: BlockRegistry, x: number, y: number) {
|
||||
{ x: cx, y: cy + half_h + height },
|
||||
{ x: cx - half_w, y: cy + height },
|
||||
],
|
||||
...cube_face_tint(block_info, "side"),
|
||||
);
|
||||
draw_texture_region_skewed(
|
||||
atlas,
|
||||
@@ -172,5 +174,6 @@ function draw_item_block(block_info: BlockRegistry, x: number, y: number) {
|
||||
{ x: cx, y: cy + half_h + height },
|
||||
{ x: cx + half_w, y: cy + height },
|
||||
],
|
||||
...cube_face_tint(block_info, "front"),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user