From 2eed94e4d7ae44a4043410897b7d669a640efad7 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sun, 19 Dec 2021 10:10:10 -0600 Subject: [PATCH] "lighting" --- src/chunk.onyx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/chunk.onyx b/src/chunk.onyx index 25c2eb4..f592b24 100644 --- a/src/chunk.onyx +++ b/src/chunk.onyx @@ -15,7 +15,7 @@ block_make :: (red, green, blue: f32, brightness: f32) -> Block { return ~~((i << 12) | (b << 8) | (g << 4) | r); } -Chunk_Size :: 16 +Chunk_Size :: 32 Chunk :: struct { blocks: [] Block; @@ -93,11 +93,18 @@ chunk_build_mesh :: (use chunk: ^Chunk) -> ^Mesh { nz := z + n.z; if chunk_get(chunk, nx, ny, nz) != Block_Empty do continue; + color := block; + if i != 4 { + color = cast(Block) (0xb000 | (0xfff & cast(u32) color)); + } + if i == 5 { + color = cast(Block) (0x9000 | (0xfff & cast(u32) color)); + } indicies := cast([] u32) block_indicies[i]; for j: 6 { v := block_verticies[indicies[j]]; - verticies << .{ ~~x+v.x, ~~y+v.y, ~~z+v.z, ~~block }; + verticies << .{ ~~x+v.x, ~~y+v.y, ~~z+v.z, ~~color }; } } }; -- 2.25.1