From 48cfbc5c20f1f5e51cf8b3619cfa2a39b394212a Mon Sep 17 00:00:00 2001 From: IntegratedQuantum Date: Tue, 6 Dec 2022 19:19:17 +0100 Subject: [PATCH] Finish the log/log-top texturing, and add stone and soil textures. --- assets/cubyz/block_materials/oak_wood.json | 12 -------- assets/cubyz/block_materials/oak_wood1.json | 28 +++++++++++++++++ assets/cubyz/block_materials/oak_wood2.json | 28 +++++++++++++++++ assets/cubyz/block_materials/soil.json | 24 +++++++++++++++ assets/cubyz/block_materials/stone.json | 26 ++++++++++++++++ assets/cubyz/blocks/oak_log.json | 6 ++-- assets/cubyz/blocks/oak_top.json | 10 +++--- assets/cubyz/blocks/soil.json | 4 ++- assets/cubyz/blocks/stone.json | 4 ++- src/main.zig | 2 +- src/models.zig | 34 +++++++++++++++++++-- 11 files changed, 153 insertions(+), 25 deletions(-) delete mode 100644 assets/cubyz/block_materials/oak_wood.json create mode 100644 assets/cubyz/block_materials/oak_wood1.json create mode 100644 assets/cubyz/block_materials/oak_wood2.json create mode 100644 assets/cubyz/block_materials/soil.json create mode 100644 assets/cubyz/block_materials/stone.json diff --git a/assets/cubyz/block_materials/oak_wood.json b/assets/cubyz/block_materials/oak_wood.json deleted file mode 100644 index 2095e719..00000000 --- a/assets/cubyz/block_materials/oak_wood.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "colors": [ - {"diffuse" : 0xeac174}, - {"diffuse" : 0xe4b466}, - {"diffuse" : 0xdea958}, - {"diffuse" : 0xdaa34d}, - {"diffuse" : 0xcc994a}, - {"diffuse" : 0xbf8d3f}, - {"diffuse" : 0xb98a41}, - {"diffuse" : 0xaf7d31} - ], -} \ No newline at end of file diff --git a/assets/cubyz/block_materials/oak_wood1.json b/assets/cubyz/block_materials/oak_wood1.json new file mode 100644 index 00000000..ac743c3c --- /dev/null +++ b/assets/cubyz/block_materials/oak_wood1.json @@ -0,0 +1,28 @@ +{ + "colors": [ + {"diffuse" : 0xeac174}, + {"diffuse" : 0xe4b466}, + {"diffuse" : 0xdea958}, + {"diffuse" : 0xdaa34d}, + {"diffuse" : 0xcc994a}, + {"diffuse" : 0xbf8d3f}, + {"diffuse" : 0xb98a41}, + {"diffuse" : 0xaf7d31} + ], + + + "simplex1Wavelength": [8.0, 8.0, 8.0], + "simplex1Weight": 0.0, + + "simplex2Wavelength": [4.0, 16.0, 4.0], + "simplex2DomainWarp": [0.05, 0.05, 0.05], + "simplex2Weight": 1.0, + + "simplex3Wavelength": [2.0, 8.0, 2.0], + "simplex3DomainWarp": [0.1, 0.1, 0.1], + "simplex3Weight": 0.5, + + "brightnessOffset": 0.0, + + "randomness": 0.1, +} \ No newline at end of file diff --git a/assets/cubyz/block_materials/oak_wood2.json b/assets/cubyz/block_materials/oak_wood2.json new file mode 100644 index 00000000..be55f876 --- /dev/null +++ b/assets/cubyz/block_materials/oak_wood2.json @@ -0,0 +1,28 @@ +{ + "colors": [ + {"diffuse" : 0xeac174}, + {"diffuse" : 0xe4b466}, + {"diffuse" : 0xdea958}, + {"diffuse" : 0xdaa34d}, + {"diffuse" : 0xcc994a}, + {"diffuse" : 0xbf8d3f}, + {"diffuse" : 0xb98a41}, + {"diffuse" : 0xaf7d31} + ], + + + "simplex1Wavelength": [8.0, 8.0, 8.0], + "simplex1Weight": 0.0, + + "simplex2Wavelength": [4.0, 16.0, 4.0], + "simplex2DomainWarp": [0.05, 0.05, 0.05], + "simplex2Weight": 1.0, + + "simplex3Wavelength": [2.0, 8.0, 2.0], + "simplex3DomainWarp": [0.1, 0.1, 0.1], + "simplex3Weight": 0.5, + + "brightnessOffset": 1.5, + + "randomness": 0.1, +} \ No newline at end of file diff --git a/assets/cubyz/block_materials/soil.json b/assets/cubyz/block_materials/soil.json new file mode 100644 index 00000000..7e5dca6e --- /dev/null +++ b/assets/cubyz/block_materials/soil.json @@ -0,0 +1,24 @@ +{ + "colors": [ + {"diffuse" : 0x3c2e20}, + {"diffuse" : 0x3a2c1f}, + {"diffuse" : 0x382a1e}, + {"diffuse" : 0x35271c}, + {"diffuse" : 0x34251c} + ], + + + + "simplex1Wavelength": [4.0, 4.0, 4.0], + "simplex1Weight": 2.0, + + "simplex2Wavelength": [2.0, 2.0, 2.0], + "simplex2Weight": 1.0, + + "simplex3Wavelength": [1.0, 1.0, 1.0], + "simplex3Weight": 0.5, + + "brightnessOffset": -0.5, + + "randomness": 0.5, +} \ No newline at end of file diff --git a/assets/cubyz/block_materials/stone.json b/assets/cubyz/block_materials/stone.json new file mode 100644 index 00000000..c9b1caea --- /dev/null +++ b/assets/cubyz/block_materials/stone.json @@ -0,0 +1,26 @@ +{ + "colors": [ + {"diffuse" : 0x6b6964}, + {"diffuse" : 0x62605a}, + {"diffuse" : 0x595854}, + {"diffuse" : 0x575551}, + {"diffuse" : 0x54504d}, + {"diffuse" : 0x4f4b48} + ], + + + + "simplex1Wavelength": [20000.0, 4000.0, 20000.0], + "simplex1Weight": 0.0, + + "simplex2Wavelength": [0.0, 0.0, 0.0], + "simplex2DomainWarp": [250, 250, 250], + "simplex2Weight": 2.5, + + "simplex3Wavelength": [3.0, 8.0, 6.0], + "simplex3Weight": 1.0, + + "brightnessOffset": 0.0, + + "randomness": 0.0, +} \ No newline at end of file diff --git a/assets/cubyz/blocks/oak_log.json b/assets/cubyz/blocks/oak_log.json index 0ca813fd..8d82df8d 100644 --- a/assets/cubyz/blocks/oak_log.json +++ b/assets/cubyz/blocks/oak_log.json @@ -7,10 +7,8 @@ "rotation" : "cubyz:log", "model" : "log", "palette" : [ - "cubyz:oak_wood", + "cubyz:oak_wood1", + "cubyz:oak_wood2", "cubyz:oak_bark" ], - "texture" : "cubyz:oak_log_side", - "//texture_top" : "cubyz:oak_log_rings_top", - "//texture_bottom" : "cubyz:oak_log_rings_bottom" } diff --git a/assets/cubyz/blocks/oak_top.json b/assets/cubyz/blocks/oak_top.json index 6dfc4513..31550893 100644 --- a/assets/cubyz/blocks/oak_top.json +++ b/assets/cubyz/blocks/oak_top.json @@ -5,8 +5,10 @@ "auto" ], "rotation" : "cubyz:log", - "model" : "cube", - "texture" : "cubyz:oak_log_side", - "texture_top" : "cubyz:oak_log_top", - "texture_bottom" : "cubyz:oak_log_rings_bottom", + "model" : "logTop", + "palette" : [ + "cubyz:oak_wood1", + "cubyz:oak_wood2", + "cubyz:oak_bark" + ], } diff --git a/assets/cubyz/blocks/soil.json b/assets/cubyz/blocks/soil.json index 2b3aa4b6..c07aef9b 100644 --- a/assets/cubyz/blocks/soil.json +++ b/assets/cubyz/blocks/soil.json @@ -5,5 +5,7 @@ "auto" ], "model" : "cube", - "texture" : "cubyz:soil" + "palette" : [ + "cubyz:soil" + ] } diff --git a/assets/cubyz/blocks/stone.json b/assets/cubyz/blocks/stone.json index 839d3e3f..4d5846e1 100644 --- a/assets/cubyz/blocks/stone.json +++ b/assets/cubyz/blocks/stone.json @@ -6,5 +6,7 @@ "cubyz:cobblestone" ], "model" : "cube", - "texture" : "cubyz:stone" + "palette" : [ + "cubyz:stone" + ] } diff --git a/src/main.zig b/src/main.zig index 85f3aaec..da017b10 100644 --- a/src/main.zig +++ b/src/main.zig @@ -178,7 +178,7 @@ pub const Window = struct { if(c.gladLoadGL() == 0) { return error.GLADFailed; } - c.glfwSwapInterval(1); + c.glfwSwapInterval(0); if(@import("builtin").mode == .Debug) { c.glEnable(c.GL_DEBUG_OUTPUT); diff --git a/src/models.zig b/src/models.zig index 4a47d0d6..0ee839de 100644 --- a/src/models.zig +++ b/src/models.zig @@ -120,8 +120,35 @@ fn log(_x: u16, _y: u16, _z: u16) ?u4 { var y = @intToFloat(f32, _y) - 7.5; var z = @intToFloat(f32, _z) - 7.5; _ = y; - if(x*x + z*z < 5.5*5.5) return 0; - if(x*x + z*z < 6.5*6.5) return 1; + const radius = x*x + z*z; + if(radius < 0.9*0.9) return 0; + if(radius < 1.9*1.9) return 1; + if(radius < 2.9*2.9) return 0; + if(radius < 3.9*3.9) return 1; + if(radius < 4.9*4.9) return 0; + if(radius < 5.9*5.9) return 1; + if(radius < 6.9*6.9) return 0; + if(radius < 8.0*8.0) return 2; + return null; +} + +fn logTop(_x: u16, _y: u16, _z: u16) ?u4 { + var x = @intToFloat(f32, _x) - 7.5; + var y = @intToFloat(f32, _y) - 7.5; + var z = @intToFloat(f32, _z) - 7.5; + const radius = if(y >= 0) ( + x*x + y*y + z*z + ) else ( + x*x + z*z + ); + if(radius < 0.9*0.9) return 0; + if(radius < 1.9*1.9) return 1; + if(radius < 2.9*2.9) return 0; + if(radius < 3.9*3.9) return 1; + if(radius < 4.9*4.9) return 0; + if(radius < 5.9*5.9) return 1; + if(radius < 6.9*6.9) return 0; + if(radius < 8.0*8.0) return 2; return null; } @@ -166,6 +193,9 @@ pub fn init() !void { try nameToIndex.put("log", @intCast(u16, voxelModels.items.len)); (try voxelModels.addOne()).init(log); + try nameToIndex.put("logTop", @intCast(u16, voxelModels.items.len)); + (try voxelModels.addOne()).init(logTop); + try nameToIndex.put("fence", @intCast(u16, voxelModels.items.len)); (try voxelModels.addOne()).init(fence);