From 5bf0a546867790ee3a477720f485949ac8fe4643 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Fri, 9 Feb 2024 23:52:41 +1000 Subject: [PATCH] Began work on a "permanent/proper" fix for determining what pixels are tinted and what arnt and by how much --- .../voxy/client/core/model/ModelTextureBakery.java | 6 ++++-- .../cortex/voxy/client/saver/SaveSelectionSystem.java | 10 ++++++++++ .../assets/voxy/shaders/bakery/position_tex.vsh | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/core/model/ModelTextureBakery.java b/src/main/java/me/cortex/voxy/client/core/model/ModelTextureBakery.java index 1e782ed8..3d740438 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/ModelTextureBakery.java +++ b/src/main/java/me/cortex/voxy/client/core/model/ModelTextureBakery.java @@ -190,7 +190,7 @@ public class ModelTextureBakery { private ColourDepthTextureData captureView(BlockState state, BakedModel model, MatrixStack stack, long randomValue, int face, boolean renderFluid) { var vc = Tessellator.getInstance().getBuffer(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - vc.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE); + vc.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE); if (!renderFluid) { renderQuads(vc, state, model, new MatrixStack(), randomValue); @@ -281,7 +281,9 @@ public class ModelTextureBakery { for (Direction direction : new Direction[]{Direction.DOWN, Direction.UP, Direction.NORTH, Direction.SOUTH, Direction.WEST, Direction.EAST, null}) { var quads = model.getQuads(state, direction, new LocalRandom(randomValue)); for (var quad : quads) { - builder.quad(stack.peek(), quad, 0, 0, 0, 0, 0); + //TODO: mark pixels that have + int meta = quad.hasColor()?1:0; + builder.quad(stack.peek(), quad, (meta>>16)&0xff, (meta>>8)&0xff, meta&0xff, 0, 0); } } } diff --git a/src/main/java/me/cortex/voxy/client/saver/SaveSelectionSystem.java b/src/main/java/me/cortex/voxy/client/saver/SaveSelectionSystem.java index 86dd3443..5ad61937 100644 --- a/src/main/java/me/cortex/voxy/client/saver/SaveSelectionSystem.java +++ b/src/main/java/me/cortex/voxy/client/saver/SaveSelectionSystem.java @@ -22,6 +22,16 @@ public class SaveSelectionSystem { } public WorldEngine createWorldEngine() { + //TODO: have basicly a recursive config tree for StorageBackend + // with a .build() method + // also have a way for the config to specify and create a config "screen" + + // e.g. CompressionStorageAdaptorConfig(StorageCompressorConfig, StorageBackendConfig) + // FragmentedStorageBackendAdaptorConfig(File) + // RocksDBStorageBackendConfig(File) + // RedisStorageBackendConfig(String, int, String) + + var storage = new CompressionStorageAdaptor(new ZSTDCompressor(VoxyConfig.CONFIG.savingCompressionLevel), new FragmentedStorageBackendAdaptor(new File(VoxyConfig.CONFIG.storagePath))); return new WorldEngine(storage, VoxyConfig.CONFIG.ingestThreads, VoxyConfig.CONFIG.savingThreads, 5); } diff --git a/src/main/resources/assets/voxy/shaders/bakery/position_tex.vsh b/src/main/resources/assets/voxy/shaders/bakery/position_tex.vsh index 5429d546..104e2f87 100644 --- a/src/main/resources/assets/voxy/shaders/bakery/position_tex.vsh +++ b/src/main/resources/assets/voxy/shaders/bakery/position_tex.vsh @@ -1,12 +1,16 @@ #version 430 in vec3 pos; +in vec4 _metadata; in vec2 uv; layout(location=1) uniform mat4 transform; out vec2 texCoord; void main() { + uvec4 metadata = uvec4(_metadata*255); + uint metadata = (metadata.r<<16)|(metadata.g<<8)|(metadata.b); + gl_Position = transform * vec4(pos, 1.0); texCoord = uv; }