From 1f357b4e872619099a7c20869b7cac199366b6eb Mon Sep 17 00:00:00 2001 From: Szymon Nowakowski Date: Thu, 24 Sep 2026 20:25:29 +0200 Subject: [PATCH] Minor fixes and refactors --- castle | 2 +- src/Chunk.zig | 12 ++++++------ src/Game.zig | 17 +++++++++-------- src/engine/Gui.zig | 6 +++--- src/shaders.zig | 13 ++----------- 5 files changed, 21 insertions(+), 29 deletions(-) diff --git a/castle b/castle index af5f035..99b8cf1 160000 --- a/castle +++ b/castle @@ -1 +1 @@ -Subproject commit af5f035830394d083fab9c6da4445e048bbc7808 +Subproject commit 99b8cf1d8e75c788b88463d4c1df3f1415162324 diff --git a/src/Chunk.zig b/src/Chunk.zig index 02e36fc..7514438 100644 --- a/src/Chunk.zig +++ b/src/Chunk.zig @@ -123,13 +123,13 @@ pub fn refresh(self: *Chunk, blocks: *const Blocks, neighbors: Neighbors) !void if (wall.material != .empty and self.getOpposite(side, ix, iy, iz, blocks, neighbors) == .empty) { const matrix = getMatrix(side, origin); try uniforms.append(allocator_frame, .{ - .matrixOStoWS_i = matrix.getIVersor().dropW(), - .matrixOStoWS_j = matrix.getJVersor().dropW(), - .matrixOStoWS_k = matrix.getKVersor().dropW(), - .matrixOStoWS_t = matrix.getTranslationVector().dropW(), - + .matrixOStoWS = .{ + matrix.getIVersor().dropW(), + matrix.getJVersor().dropW(), + matrix.getKVersor().dropW(), + matrix.getTranslationVector().dropW(), + }, .texCoordTransform = wall.transform.getMatrix(), - .material = wall.material, }); } diff --git a/src/Game.zig b/src/Game.zig index df1d1fc..3bd28fa 100644 --- a/src/Game.zig +++ b/src/Game.zig @@ -86,9 +86,9 @@ pub fn init() !Game { .mag_filter = .linear, .min_filter = .linear, .mipmap_mode = .linear, - .address_mode_u = .repeat, - .address_mode_v = .repeat, - .address_mode_w = .repeat, + .address_mode_u = .clamp_to_edge, + .address_mode_v = .clamp_to_edge, + .address_mode_w = .clamp_to_edge, .mip_lod_bias = 0, .anisotropy_enable = .false, .max_anisotropy = 0, @@ -909,11 +909,12 @@ fn render(self: *Game) !void { const ambient_light = vm.Vector3.init(0.01, 0.01, 0.01); self.global_uniforms_staging_ptr.* = .{ - .matrixWStoVS_i = matrix_ws_to_vs.getIVersor().dropW(), - .matrixWStoVS_j = matrix_ws_to_vs.getJVersor().dropW(), - .matrixWStoVS_k = matrix_ws_to_vs.getKVersor().dropW(), - .matrixWStoVS_t = matrix_ws_to_vs.getTranslationVector().dropW(), - + .matrixWStoVS = .{ + matrix_ws_to_vs.getIVersor().dropW(), + matrix_ws_to_vs.getJVersor().dropW(), + matrix_ws_to_vs.getKVersor().dropW(), + matrix_ws_to_vs.getTranslationVector().dropW(), + }, .matrixVStoCS = matrix_vs_to_cs, .matrixSSPXtoCS = matrix_sspx_to_cs, diff --git a/src/engine/Gui.zig b/src/engine/Gui.zig index 42b1d88..d4b77e7 100644 --- a/src/engine/Gui.zig +++ b/src/engine/Gui.zig @@ -133,9 +133,9 @@ pub fn init() !*Gui { .mag_filter = .linear, .min_filter = .linear, .mipmap_mode = .linear, - .address_mode_u = .repeat, - .address_mode_v = .repeat, - .address_mode_w = .repeat, + .address_mode_u = .clamp_to_edge, + .address_mode_v = .clamp_to_edge, + .address_mode_w = .clamp_to_edge, .mip_lod_bias = 0, .anisotropy_enable = .false, .max_anisotropy = 0, diff --git a/src/shaders.zig b/src/shaders.zig index 5c0fdab..eca698b 100644 --- a/src/shaders.zig +++ b/src/shaders.zig @@ -44,11 +44,7 @@ pub const Vertex = extern struct { pub const Index = u16; pub const GlobalUniforms = extern struct { - matrixWStoVS_i: vm.Vector3, - matrixWStoVS_j: vm.Vector3, - matrixWStoVS_k: vm.Vector3, - matrixWStoVS_t: vm.Vector3, - + matrixWStoVS: [4]vm.Vector3, matrixVStoCS: vm.Matrix4x4, matrixSSPXtoCS: vm.Matrix3x2, @@ -98,13 +94,8 @@ pub const Material = extern struct { pub const ObjectUniforms = extern struct { // Limited to a composition of translation and rotation - matrixOStoWS_i: vm.Vector3, - matrixOStoWS_j: vm.Vector3, - matrixOStoWS_k: vm.Vector3, - matrixOStoWS_t: vm.Vector3, - + matrixOStoWS: [4]vm.Vector3, texCoordTransform: vm.Matrix3x2, - material: Materials.Id, };