From 78689d4c78647aa73ac2f5c9b4e8cccda36d52c3 Mon Sep 17 00:00:00 2001 From: Decencies Date: Sat, 28 Dec 2024 05:28:37 +0000 Subject: [PATCH] A lot of refactoring --- .../frapi/api/renderer/v1/Renderer.java | 16 -- .../api/renderer/v1/material/BlendMode.java | 14 -- .../renderer/v1/material/MaterialFinder.java | 5 - .../renderer/v1/material/RenderMaterial.java | 43 ---- .../frapi/api/renderer/v1/mesh/Mesh.java | 56 ----- .../api/renderer/v1/mesh/MutableMesh.java | 66 ------ .../api/renderer/v1/mesh/MutableQuadView.java | 11 +- .../api/renderer/v1/mesh/QuadEmitter.java | 96 --------- .../api/renderer/v1/mesh/QuadTransform.java | 26 --- .../frapi/api/renderer/v1/mesh/QuadView.java | 71 ------- .../renderer/v1/model/FabricBakedModel.java | 104 ---------- .../api/renderer/v1/model/ModelHelper.java | 41 ---- .../api/renderer/v1/model/SpriteFinder.java | 53 ----- .../impl/renderer/VanillaModelEncoder.java | 21 +- .../renderer/client/BakedModelMixin.java | 30 --- .../api/vertex/buffer/VertexBufferWriter.java | 103 --------- .../model/color/ColorProviderRegistry.java | 26 ++- .../client/render/SodiumWorldRenderer.java | 12 +- .../buffers/BakedChunkModelBuilder.java | 10 - .../compile/buffers/ChunkModelBuilder.java | 17 -- .../compile/buffers/ChunkVertexConsumer.java | 195 ------------------ .../compile/pipeline/BlockRenderCache.java | 4 +- .../compile/pipeline/BlockRenderContext.java | 88 -------- .../chunk/compile/pipeline/BlockRenderer.java | 62 +++--- .../pipeline/DefaultFluidRenderer.java | 21 +- .../terrain/DefaultTerrainRenderPasses.java | 8 +- .../terrain/material/DefaultMaterials.java | 2 +- .../client/render/frapi/SodiumRenderer.java | 14 +- .../frapi/material/MaterialFinderImpl.java | 6 - .../client/render/frapi/mesh/MeshImpl.java | 105 ---------- .../render/frapi/mesh/MutableMeshImpl.java | 93 --------- .../frapi/mesh/MutableQuadViewImpl.java | 94 +-------- .../render/frapi/mesh/QuadViewImpl.java | 86 -------- .../render/AbstractBlockRenderContext.java | 33 +-- .../render/NonTerrainBlockRenderContext.java | 132 ------------ .../render/frapi/render/QuadEncoder.java | 140 ------------- .../immediate/model/BakedModelEncoder.java | 130 ------------ .../immediate/model/EntityRenderer.java | 175 ---------------- .../render/immediate/model/ModelCuboid.java | 100 --------- .../render/texture/SpriteFinderCache.java | 3 +- .../client/render/util/RenderAsserts.java | 16 -- .../render/vertex/VertexConsumerTracker.java | 20 -- .../render/vertex/VertexConsumerUtils.java | 22 -- .../vertex/VertexFormatRegistryImpl.java | 46 ----- .../vertex/buffer/BufferBuilderExtension.java | 7 - .../viewport/frustum/SimpleFrustum.java | 2 +- .../client/services/FluidRendererFactory.java | 27 --- .../client/services/PlatformBlockAccess.java | 94 --------- .../client/services/PlatformLevelAccess.java | 31 --- .../services/PlatformLevelRenderHooks.java | 50 ----- .../services/PlatformMixinOverrides.java | 2 +- .../client/services/PlatformModelAccess.java | 76 ------- .../services/PlatformRuntimeInformation.java | 23 --- .../client/services/SodiumModelData.java | 8 - .../services/SodiumModelDataContainer.java | 27 --- .../mods/sodium/client/world/LevelSlice.java | 11 +- .../world/SodiumAuxiliaryLightManager.java | 7 - .../world/cloned/ChunkRenderContext.java | 2 +- .../world/cloned/ClonedChunkSection.java | 54 ----- .../mods/sodium/mixin/SodiumMixinPlugin.java | 6 - .../mixin/core/access/CameraAccessor.java | 16 -- .../frustum/CullingCameraViewMixin.java | 28 --- .../consumer/BufferBuilderMixin.java | 81 -------- .../core/render/world/LevelRendererMixin.java | 18 +- .../entity/cull/EntityRendererMixin.java | 16 -- .../render/frapi/BakedModelMixin.java | 28 --- .../render/frapi/ModelBlockRendererMixin.java | 52 ----- .../intrinsics/BufferBuilderMixin.java | 47 ----- .../main/resources/radium-frapi.mixins.json | 1 - .../resources/sodium-common.accesswidener | 1 + .../main/resources/sodium-common.mixins.json | 7 - .../fabric/FabricRuntimeInformation.java | 20 -- .../fabric/block/FabricBlockAccess.java | 63 ------ .../fabric/level/FabricLevelAccess.java | 20 -- .../fabric/level/FabricLevelRenderHooks.java | 32 --- .../fabric/model/FabricModelAccess.java | 51 ----- .../fabric/render/FabricColorProviders.java | 26 --- .../fabric/render/FluidRendererImpl.java | 127 ------------ .../model/block/ModelBlockRendererMixin.java | 126 ----------- ...odium.client.services.FluidRendererFactory | 1 - ...sodium.client.services.PlatformBlockAccess | 1 - ...sodium.client.services.PlatformLevelAccess | 1 - ...m.client.services.PlatformLevelRenderHooks | 1 - ...sodium.client.services.PlatformModelAccess | 1 - .../resources/sodium-fabric.accesswidener | 1 + .../main/resources/sodium-fabric.mixins.json | 2 +- 86 files changed, 84 insertions(+), 3527 deletions(-) delete mode 100644 common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/Mesh.java delete mode 100644 common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/MutableMesh.java delete mode 100644 common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/QuadTransform.java delete mode 100644 common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/model/FabricBakedModel.java delete mode 100644 common/src/api/java/dev/vexor/radium/frapi/mixin/renderer/client/BakedModelMixin.java delete mode 100644 common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/buffers/ChunkVertexConsumer.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/MeshImpl.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/MutableMeshImpl.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/NonTerrainBlockRenderContext.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/QuadEncoder.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/model/BakedModelEncoder.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/model/EntityRenderer.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/model/ModelCuboid.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/util/RenderAsserts.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexConsumerTracker.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexConsumerUtils.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexFormatRegistryImpl.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/buffer/BufferBuilderExtension.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/services/FluidRendererFactory.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformBlockAccess.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformLevelAccess.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformLevelRenderHooks.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformModelAccess.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/services/SodiumModelData.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/services/SodiumModelDataContainer.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/client/world/SodiumAuxiliaryLightManager.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/access/CameraAccessor.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/frustum/CullingCameraViewMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/immediate/consumer/BufferBuilderMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/entity/cull/EntityRendererMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/frapi/BakedModelMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/frapi/ModelBlockRendererMixin.java delete mode 100644 common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/immediate/buffer_builder/intrinsics/BufferBuilderMixin.java delete mode 100644 fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/block/FabricBlockAccess.java delete mode 100644 fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/level/FabricLevelAccess.java delete mode 100644 fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/level/FabricLevelRenderHooks.java delete mode 100644 fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/model/FabricModelAccess.java delete mode 100644 fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java delete mode 100644 fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FluidRendererImpl.java delete mode 100644 fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/block/ModelBlockRendererMixin.java delete mode 100644 fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.FluidRendererFactory delete mode 100644 fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformBlockAccess delete mode 100644 fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformLevelAccess delete mode 100644 fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformLevelRenderHooks delete mode 100644 fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformModelAccess diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/Renderer.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/Renderer.java index 7081a1b37..8508af7b9 100644 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/Renderer.java +++ b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/Renderer.java @@ -22,7 +22,6 @@ import dev.vexor.radium.frapi.api.renderer.v1.material.MaterialFinder; import dev.vexor.radium.frapi.api.renderer.v1.material.RenderMaterial; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.MutableMesh; import dev.vexor.radium.frapi.impl.renderer.RendererManager; /** @@ -50,15 +49,6 @@ static void register(Renderer renderer) { RendererManager.registerRenderer(renderer); } - /** - * Obtain a new {@link MutableMesh} instance to build optimized meshes and create baked models - * with enhanced features. - * - *

Renderer does not retain a reference to returned instances, so they should be re-used - * when possible to avoid memory allocation overhead. - */ - MutableMesh mutableMesh(); - /** * Obtain a new {@link MaterialFinder} instance to retrieve standard {@link RenderMaterial} * instances. @@ -68,12 +58,6 @@ static void register(Renderer renderer) { */ MaterialFinder materialFinder(); - /** - * Return a material previously registered via {@link #registerMaterial(Identifier, RenderMaterial)}. - * Will return null if no material was found matching the given identifier. - */ - @Nullable - RenderMaterial materialById(Identifier id); /** * Register a material for re-use by other mods or models within a mod. diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/material/BlendMode.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/material/BlendMode.java index 7376cd973..0211fb88b 100644 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/material/BlendMode.java +++ b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/material/BlendMode.java @@ -59,18 +59,4 @@ public enum BlendMode { BlendMode(@Nullable RenderLayer blockRenderLayer) { this.blockRenderLayer = blockRenderLayer; } - - public static BlendMode fromRenderLayer(@Nullable RenderLayer renderLayer) { - if (renderLayer == RenderLayer.SOLID) { - return SOLID; - } else if (renderLayer == RenderLayer.CUTOUT_MIPPED) { - return CUTOUT_MIPPED; - } else if (renderLayer == RenderLayer.CUTOUT) { - return CUTOUT; - } else if (renderLayer == RenderLayer.TRANSLUCENT) { - return TRANSLUCENT; - } else { - return DEFAULT; - } - } } diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/material/MaterialFinder.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/material/MaterialFinder.java index 7bbcd8ffa..1016b2b6e 100644 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/material/MaterialFinder.java +++ b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/material/MaterialFinder.java @@ -93,11 +93,6 @@ public interface MaterialFinder extends MaterialView { */ MaterialFinder shadeMode(ShadeMode mode); - /** - * Copies all properties from the given {@link MaterialView} to this material finder. - */ - MaterialFinder copyFrom(MaterialView material); - /** * Resets this instance to default values. Values will match those in effect when an instance is newly obtained via * {@link Renderer#materialFinder()}. diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/material/RenderMaterial.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/material/RenderMaterial.java index 90d1f978c..7334a2694 100644 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/material/RenderMaterial.java +++ b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/material/RenderMaterial.java @@ -19,49 +19,6 @@ import net.minecraft.block.Block; import net.minecraft.util.Identifier; -import dev.vexor.radium.frapi.api.renderer.v1.Renderer; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.MutableMesh; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.MutableQuadView; - -/** - * All model quads have an associated render material governing - * how the quad will be rendered. - * - *

A material instance is always immutable and thread-safe. References to a material - * remain valid until the end of the current game session. - * - *

Materials can be registered and shared between mods using {@link Renderer#registerMaterial(Identifier, RenderMaterial)}. - * The registering mod is responsible for creating each registered material at startup. - * - *

Materials are not required to know their registration identity, and two materials - * with the same attributes may or may not satisfy equality and identity tests. Model - * implementations should never attempt to analyze materials or implement control logic based on them. - * They are only tokens for communicating quad attributes to the ModelRenderer. - * - *

There are three classes of materials... - * - *

STANDARD MATERIALS - * - *

Standard materials have "normal" rendering with control over lighting, - * color, and texture blending. In the default renderer, "normal" rendering - * emulates unmodified Minecraft. Other renderers may offer a different aesthetic. - * - *

The number of standard materials is finite, but not necessarily small. - * To find a standard material, use {@link Renderer#materialFinder()}. - * - *

All renderer implementations should support standard materials. - * - *

SPECIAL MATERIALS - * - *

Special materials are implemented directly by the Renderer implementation, typically - * with the aim of providing advanced/extended features. Such materials may offer additional - * vertex attributes via extensions to {@link MutableMesh} and {@link MutableQuadView}. - * - *

Special materials can be obtained using {@link Renderer#materialById(Identifier)} - * with a known identifier. Renderers may provide other means of access. Popular - * special materials could be implemented by multiple renderers, however there is - * no requirement that special materials be cross-compatible. - */ public interface RenderMaterial extends MaterialView { /** * This will be identical to the material that would be obtained by calling {@link MaterialFinder#find()} on a new, diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/Mesh.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/Mesh.java deleted file mode 100644 index 8a288f9d1..000000000 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/Mesh.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dev.vexor.radium.frapi.api.renderer.v1.mesh; - -import java.util.function.Consumer; - -import org.jetbrains.annotations.Range; - -import net.minecraft.client.render.model.BakedModel; - -/** - * A bundle of {@link QuadView} instances encoded by the renderer, typically - * via {@link MutableMesh#immutableCopy()}. - * - *

Similar in purpose to the {@code List} instances returned by - * {@link BakedModel#getQuads()}, but allows the - * renderer to optimize the format for performance and memory allocation. - * - *

All declared methods in this interface are thread-safe and can be used - * concurrently. - * - *

Only the renderer should implement or extend this interface. - */ -public interface Mesh { - /** - * Returns the number of quads encoded in this mesh. - */ - @Range(from = 0, to = Integer.MAX_VALUE) - int size(); - - /** - * Use to access all the quads encoded in this mesh. The quad instance sent - * to the consumer should never be retained outside the current call to the - * consumer. - */ - void forEach(Consumer action); - - /** - * Outputs all quads in this mesh to the given quad emitter. - */ - void outputTo(QuadEmitter emitter); -} diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/MutableMesh.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/MutableMesh.java deleted file mode 100644 index c880923d1..000000000 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/MutableMesh.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dev.vexor.radium.frapi.api.renderer.v1.mesh; - -import java.util.function.Consumer; - -/** - * A bundle of {@link MutableQuadView} instances encoded by the renderer that - * can have more quads added to it. Typically used to build optimized, - * immutable {@link Mesh}es via {@link #emitter()}, {@link #immutableCopy()}, - * and {@link #clear()}. Encoded quads can also be inspected, modified, and - * outputted directly to allow for advanced use cases where creating an - * immutable {@link Mesh} is not desirable. - * - *

All declared methods in this interface are not thread-safe and - * should not be used concurrently. Inherited methods from {@link Mesh} are - * still thread-safe when used in isolation. - * - *

Only the renderer should implement or extend this interface. - */ -public interface MutableMesh extends Mesh { - /** - * Returns the {@link QuadEmitter} used to append quads to this mesh. - * Calling this method a second time invalidates any prior result. - * Do not retain references outside the context of this mesh. - */ - QuadEmitter emitter(); - - /** - * Use to access all the quads encoded in this mesh and modify them as - * necessary. The quad instance sent to the consumer should never be - * retained outside the current call to the consumer. - */ - void forEachMutable(Consumer action); - - /** - * Returns a new, optimized, immutable {@link Mesh} instance containing all - * quads currently encoded in {@code this} mesh. This operation does not - * change the state of {@code this} mesh; if you need to build another - * immutable mesh, call {@link #clear()} first. - * - *

If quad data has been added to the {@link #emitter()} but has - * not yet been emitted, calling this method will not affect it. - */ - Mesh immutableCopy(); - - /** - * Resets this mesh to an empty state with zero quads, effectively clearing - * all existing quads. - */ - void clear(); -} diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/MutableQuadView.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/MutableQuadView.java index 9b37d8fd9..72e953fd9 100644 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/MutableQuadView.java +++ b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/MutableQuadView.java @@ -269,13 +269,6 @@ default MutableQuadView normal(int vertexIndex, Vector3fc normal) { */ MutableQuadView tag(int tag); - /** - * Copies all quad properties from the given {@link QuadView} to this quad. - * - *

Calling this method does not emit the quad. - */ - MutableQuadView copyFrom(QuadView quad); - /** * Enables bulk vertex data transfer using the standard Minecraft vertex formats. * Only the {@link BakedQuad#getVertexData() quad vertex data} is copied. @@ -292,12 +285,12 @@ default MutableQuadView normal(int vertexIndex, Vector3fc normal) { * Enables bulk vertex data transfer using the standard Minecraft quad format. * *

The material applied to this quad view might be slightly different from the {@code material} parameter - * regarding diffuse shading. If either the baked quad {@link BakedQuad#hasShade() does not have shade} or the + * regarding diffuse shading. If either the baked quad {@link BakedQuad#hasColor() does not have shade} or the * material {@link MaterialFinder#disableDiffuse(boolean) does not have shade}, diffuse shading will be disabled for * this quad view. This is reflected in the quad view's {@link #material()}, but the {@code material} parameter is * unchanged (it is immutable anyway). * - *

The {@linkplain BakedQuad#getLightEmission() baked quad's light emission} will be applied to the lightmap + *

The {@linkplain BakedQuad#getColorIndex() baked quad's light emission} will be applied to the lightmap * values from the vertex data after copying. * *

Calling this method does not emit the quad. diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/QuadEmitter.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/QuadEmitter.java index c87f2b498..3fcc74aea 100644 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/QuadEmitter.java +++ b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/QuadEmitter.java @@ -80,14 +80,6 @@ default QuadEmitter uv(int vertexIndex, Vector2fc uv) { @Override QuadEmitter spriteBake(Sprite sprite, int bakeFlags); - default QuadEmitter uvUnitSquare() { - uv(0, 0, 0); - uv(1, 0, 1); - uv(2, 1, 1); - uv(3, 1, 0); - return this; - } - @Override QuadEmitter lightmap(int vertexIndex, int lightmap); @@ -127,100 +119,12 @@ default QuadEmitter normal(int vertexIndex, Vector3fc normal) { @Override QuadEmitter tag(int tag); - QuadEmitter copyFrom(QuadView quad); - @Override QuadEmitter fromVanilla(int[] quadData, int startIndex); @Override QuadEmitter fromVanilla(BakedQuad quad, RenderMaterial material, @Nullable Direction cullFace); - /** - * Tolerance for determining if the depth parameter to {@link #square(Direction, float, float, float, float, float)} - * is effectively zero - meaning the face is a cull face. - */ - float CULL_FACE_EPSILON = 0.00001f; - - /** - * Helper method to assign vertex coordinates for a square aligned with the given face. - * Ensures that vertex order is consistent with vanilla convention. (Incorrect order can - * lead to bad AO lighting unless enhanced lighting logic is available/enabled.) - * - *

Square will be parallel to the given face and coplanar with the face (and culled if the - * face is occluded) if the depth parameter is approximately zero. See {@link #CULL_FACE_EPSILON}. - * - *

All coordinates should be normalized (0-1). - */ - default QuadEmitter square(Direction nominalFace, float left, float bottom, float right, float top, float depth) { - if (Math.abs(depth) < CULL_FACE_EPSILON) { - cullFace(nominalFace); - depth = 0; // avoid any inconsistency for face quads - } else { - cullFace(null); - } - - nominalFace(nominalFace); - switch (nominalFace) { - case UP: - depth = 1 - depth; - top = 1 - top; - bottom = 1 - bottom; - - case DOWN: - pos(0, left, depth, top); - pos(1, left, depth, bottom); - pos(2, right, depth, bottom); - pos(3, right, depth, top); - break; - - case EAST: - depth = 1 - depth; - left = 1 - left; - right = 1 - right; - - case WEST: - pos(0, depth, top, left); - pos(1, depth, bottom, left); - pos(2, depth, bottom, right); - pos(3, depth, top, right); - break; - - case SOUTH: - depth = 1 - depth; - left = 1 - left; - right = 1 - right; - - case NORTH: - pos(0, 1 - left, top, depth); - pos(1, 1 - left, bottom, depth); - pos(2, 1 - right, bottom, depth); - pos(3, 1 - right, top, depth); - break; - } - - return this; - } - - /** - * Pushed transforms will be applied immediately after every call to {@link #emit()} and before the quad data is - * delivered to its destination. If any transform returns {@code false}, the emitted quad will be discarded and will - * not be delivered to its destination. - * - *

You MUST call {@link #popTransform()} once you are done using this emitter in the current scope. - * - *

More than one transformer can be pushed. Transformers are applied in reverse order. (Last pushed is applied - * first.) - * - *

Using {@code this} emitter from inside the pushed quad transform is not supported. - */ - void pushTransform(QuadTransform transform); - - /** - * Removes the transformer added by the last call to {@link #pushTransform(QuadTransform)}. MUST be called once you - * are done using this emitter in the current scope. - */ - void popTransform(); - /** * In static mesh building, causes quad to be appended to the mesh being built. In a dynamic render context, create * a new quad to be output to rendering. In both cases, current instance is reset to default values. diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/QuadTransform.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/QuadTransform.java deleted file mode 100644 index 6bd4a4639..000000000 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/QuadTransform.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dev.vexor.radium.frapi.api.renderer.v1.mesh; - -@FunctionalInterface -public interface QuadTransform { - /** - * Return false to filter out quads from rendering. When more than one transform - * is in effect, returning false means unapplied transforms will not receive the quad. - */ - boolean transform(MutableQuadView quad); -} diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/QuadView.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/QuadView.java index a8f3abbcc..296606e8e 100644 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/QuadView.java +++ b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/mesh/QuadView.java @@ -29,13 +29,6 @@ import dev.vexor.radium.frapi.api.renderer.v1.material.RenderMaterial; -/** - * Interface for reading quad data encoded in {@link Mesh}es. - * Enables models to do analysis, re-texturing or translation without knowing the - * renderer's vertex formats and without retaining redundant information. - * - *

Only the renderer should implement or extend this interface. - */ public interface QuadView { /** Count of integers in a conventional (un-modded) block or item vertex. */ int VANILLA_VERTEX_STRIDE = VertexFormats.POSITION_TEXTURE_COLOR_NORMAL.getVertexSize() / 4; @@ -63,12 +56,6 @@ public interface QuadView { */ float posByIndex(int vertexIndex, int coordinateIndex); - /** - * Pass a non-null target to avoid allocation - will be returned with values. - * Otherwise returns a new instance. - */ - Vector3f copyPos(int vertexIndex, @Nullable Vector3f target); - /** * Retrieve vertex color in ARGB format (0xAARRGGBB). */ @@ -84,12 +71,6 @@ public interface QuadView { */ float v(int vertexIndex); - /** - * Pass a non-null target to avoid allocation - will be returned with values. - * Otherwise returns a new instance. - */ - Vector2f copyUv(int vertexIndex, @Nullable Vector2f target); - /** * Minimum block brightness. Zero if not set. */ @@ -101,28 +82,6 @@ public interface QuadView { */ boolean hasNormal(int vertexIndex); - /** - * Will return {@link Float#NaN} if normal not present. - */ - float normalX(int vertexIndex); - - /** - * Will return {@link Float#NaN} if normal not present. - */ - float normalY(int vertexIndex); - - /** - * Will return {@link Float#NaN} if normal not present. - */ - float normalZ(int vertexIndex); - - /** - * Pass a non-null target to avoid allocation - will be returned with values. - * Otherwise returns a new instance. Returns null if normal not present. - */ - @Nullable - Vector3f copyNormal(int vertexIndex, @Nullable Vector3f target); - /** * If non-null, quad should not be rendered in-world if the * opposite face of a neighbor block occludes it. @@ -171,34 +130,4 @@ public interface QuadView { * Will return zero if no tag was set. For use by models. */ int tag(); - - /** - * Reads baked vertex data and outputs standard {@link BakedQuad#getVertexData() baked quad vertex data} - * in the given array and location. - * - * @param target Target array for the baked quad data. - * - * @param targetIndex Starting position in target array - array must have - * at least {@link #VANILLA_QUAD_STRIDE} elements available at this index. - */ - void toVanilla(int[] target, int targetIndex); - - /** - * Generates a new BakedQuad instance with texture - * coordinates and colors from the given sprite. - * - * @param sprite {@link QuadView} does not serialize sprites - * so the sprite must be provided by the caller. - * - * @return A new baked quad instance with the closest-available appearance - * supported by vanilla features. Will retain emissive light maps, for example, - * but the standard Minecraft renderer will not use them. - */ - default BakedQuad toBakedQuad(Sprite sprite) { - int[] vertexData = new int[VANILLA_QUAD_STRIDE]; - toVanilla(vertexData, 0); - - - return new BakedQuad(vertexData, tintIndex(), lightFace()); - } } diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/model/FabricBakedModel.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/model/FabricBakedModel.java deleted file mode 100644 index c77b3e00e..000000000 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/model/FabricBakedModel.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dev.vexor.radium.frapi.api.renderer.v1.model; - -import java.util.function.Predicate; -import java.util.function.Supplier; - -import dev.vexor.radium.compat.mojang.minecraft.random.RandomSource; -import net.minecraft.client.render.BufferBuilder; -import net.minecraft.world.BlockView; -import org.jetbrains.annotations.Nullable; - -import net.minecraft.block.BlockState; -import net.minecraft.client.render.block.BlockModelRenderer; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; - -import dev.vexor.radium.frapi.api.renderer.v1.mesh.MutableQuadView; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.QuadEmitter; -import dev.vexor.radium.frapi.impl.renderer.VanillaModelEncoder; - -/** - * Interface for baked models that output meshes with enhanced rendering features. - * Can also be used to generate or customize outputs based on world state instead of - * or in addition to block state when render chunks are rebuilt. - * - *

Implementors should have a look at {@link ModelHelper} as it contains many useful functions. - * - *

Note: This interface is automatically implemented on all baked models via Mixin and interface injection. - */ -public interface FabricBakedModel { - /** - * When true, signals renderer this producer is implemented through - * {@link BakedModel#getQuads()}. - * Also means the model does not rely on any non-vanilla features. - * Allows the renderer to optimize or route vanilla models through the unmodified vanilla pipeline if desired. - * - *

Vanilla baked models will return true. - * Enhanced models that use this API should return false, - * otherwise the API will not recognize the model. - */ - default boolean isVanillaAdapter() { - return true; - } - - /** - * This method will be called during chunk rebuilds to generate both the static and - * dynamic portions of a block model when the model implements this interface and - * {@link #isVanillaAdapter()} returns false. - * - *

During chunk rebuild, this method will always be called exactly one time per block - * position, irrespective of which or how many faces or block render layers are included - * in the model. Models must output all quads in a single pass. - * - *

Also called to render block models outside of chunk rebuild or block entity rendering. - * Typically, this happens when the block is being rendered as an entity, not as a block placed in the world. - * Currently, this happens for falling blocks and blocks being pushed by a piston, but renderers - * should invoke this for all calls to - * {@link BlockModelRenderer#render(BlockView, BakedModel, BlockState, BlockPos, BufferBuilder, boolean)} - * that occur outside of chunk rebuilds to allow for features added by mods, unless {@link #isVanillaAdapter()} - * returns true. - * - *

Outside of chunk rebuilds, this method will be called every frame. Model implementations should - * rely on pre-baked meshes as much as possible and keep transformation to a minimum. The provided - * block position may be the nearest block position and not actual. For this reason, neighbor - * state lookups are best avoided or will require special handling. Block entity lookups are - * likely to fail and/or give meaningless results. - * - *

Note: with {@link BakedModel#getQuads()}, the random - * parameter is normally initialized with the same seed prior to each face layer. - * Model authors should note this method is called only once per block, and call the provided - * Random supplier multiple times if re-seeding is necessary. - * - * @param emitter Accepts model output. - * @param blockView Access to world state. - * @param state Block state for model being rendered. - * @param pos Position of block for model being rendered. - * @param randomSupplier Random object seeded per vanilla conventions. Call multiple times to re-seed. - * Will not be thread-safe. Do not cache or retain a reference. - * @param cullTest A test that returns {@code true} for faces which will be culled and {@code false} for faces which - * may or may not be culled. Meant to be used to cull groups of quads or expensive dynamic quads - * early for performance. Early culled quads will likely not be added the emitter, so callers of - * this method must account for this. In general, prefer using - * {@link MutableQuadView#cullFace(Direction)} instead of this test. - */ - default void emitBlockQuads(QuadEmitter emitter, BlockView blockView, BlockState state, BlockPos pos, Supplier randomSupplier, Predicate<@Nullable Direction> cullTest) { - VanillaModelEncoder.emitBlockQuads(emitter, (BakedModel) this, state, randomSupplier, cullTest); - } -} diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/model/ModelHelper.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/model/ModelHelper.java index c76009dca..794bee712 100644 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/model/ModelHelper.java +++ b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/model/ModelHelper.java @@ -17,17 +17,11 @@ package dev.vexor.radium.frapi.api.renderer.v1.model; import java.util.Arrays; -import java.util.List; -import com.google.common.collect.ImmutableList; import org.jetbrains.annotations.Nullable; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.model.BakedQuad; import net.minecraft.util.math.Direction; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.Mesh; - /** * Collection of utilities for model implementations. */ @@ -60,39 +54,4 @@ public static Direction faceFromIndex(int faceIndex) { /** @see #faceFromIndex(int) */ private static final Direction[] FACES = Arrays.copyOf(Direction.values(), 7); - - /** - * Converts a mesh into an array of lists of vanilla baked quads. - * Useful for creating vanilla baked models when required for compatibility. - * The array indexes correspond to {@link Direction#getId()} with the - * addition of {@link #NULL_FACE_ID}. - * - *

Retrieves sprites from the block texture atlas via {@link SpriteFinder}. - */ - public static List[] toQuadLists(Mesh mesh) { - SpriteFinder finder = SpriteFinder.get(MinecraftClient.getInstance().getSpriteAtlasTexture()); - - @SuppressWarnings("unchecked") - final ImmutableList.Builder[] builders = new ImmutableList.Builder[7]; - - for (int i = 0; i < 7; i++) { - builders[i] = ImmutableList.builder(); - } - - if (mesh != null) { - mesh.forEach(q -> { - Direction cullFace = q.cullFace(); - builders[cullFace == null ? NULL_FACE_ID : cullFace.getId()].add(q.toBakedQuad(finder.find(q))); - }); - } - - @SuppressWarnings("unchecked") - List[] result = new List[7]; - - for (int i = 0; i < 7; i++) { - result[i] = builders[i].build(); - } - - return result; - } } diff --git a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/model/SpriteFinder.java b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/model/SpriteFinder.java index 8b22641cb..a735e3b09 100644 --- a/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/model/SpriteFinder.java +++ b/common/src/api/java/dev/vexor/radium/frapi/api/renderer/v1/model/SpriteFinder.java @@ -16,64 +16,11 @@ package dev.vexor.radium.frapi.api.renderer.v1.model; -import org.jetbrains.annotations.ApiStatus; - import net.minecraft.client.texture.Sprite; -import net.minecraft.client.texture.SpriteAtlasTexture; - -import dev.vexor.radium.frapi.api.renderer.v1.mesh.Mesh; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.MutableQuadView; import dev.vexor.radium.frapi.api.renderer.v1.mesh.QuadView; -import dev.vexor.radium.frapi.impl.renderer.SpriteFinderImpl; -/** - * Indexes a texture atlas to allow fast lookup of Sprites from - * baked vertex coordinates. Main use is for {@link Mesh}-based models - * to generate vanilla quads on demand without tracking and retaining - * the sprites that were baked into the mesh. In other words, this class - * supplies the sprite parameter for {@link QuadView#toBakedQuad(Sprite)}. - */ -@ApiStatus.NonExtendable public interface SpriteFinder { - /** - * Retrieves or creates the finder for the given atlas. - * Instances should not be retained as fields, or they must be - * refreshed whenever there is a resource reload or other event - * that causes atlas textures to be re-stitched. - */ - static SpriteFinder get(SpriteAtlasTexture atlas) { - return SpriteFinderImpl.get(atlas); - } - - /** - * Finds the atlas sprite containing the vertex centroid of the quad. - * Vertex centroid is essentially the mean u,v coordinate - the intent being - * to find a point that is unambiguously inside the sprite (vs on an edge.) - * - *

Should be reliable for any convex quad or triangle. May fail for non-convex quads. - * Note that all the above refers to u,v coordinates. Geometric vertex does not matter, - * except to the extent it was used to determine u,v. - */ Sprite find(QuadView quad); - /** - * Alternative to {@link #find(QuadView, int)} when vertex centroid is already - * known or unsuitable. Expects normalized (0-1) coordinates on the atlas texture, - * which should already be the case for u,v values in vanilla baked quads and in - * {@link QuadView} after calling {@link MutableQuadView#spriteBake(Sprite, int)}. - * - *

Coordinates must be in the sprite interior for reliable results. Generally will - * be easier to use {@link #find(QuadView, int)} unless you know the vertex - * centroid will somehow not be in the quad interior. This method will be slightly - * faster if you already have the centroid or another appropriate value. - */ Sprite find(float u, float v); - - /** - * @deprecated Use {@link #find(QuadView)} instead. - */ - @Deprecated - default Sprite find(QuadView quad, int textureIndex) { - return find(quad); - } } diff --git a/common/src/api/java/dev/vexor/radium/frapi/impl/renderer/VanillaModelEncoder.java b/common/src/api/java/dev/vexor/radium/frapi/impl/renderer/VanillaModelEncoder.java index 611dc7504..582f2ca07 100644 --- a/common/src/api/java/dev/vexor/radium/frapi/impl/renderer/VanillaModelEncoder.java +++ b/common/src/api/java/dev/vexor/radium/frapi/impl/renderer/VanillaModelEncoder.java @@ -42,7 +42,7 @@ public class VanillaModelEncoder { private static final RenderMaterial STANDARD_MATERIAL = Renderer.get().materialFinder().shadeMode(ShadeMode.VANILLA).find(); private static final RenderMaterial NO_AO_MATERIAL = Renderer.get().materialFinder().shadeMode(ShadeMode.VANILLA).ambientOcclusion(TriState.FALSE).find(); - public static void emitBlockQuads(QuadEmitter emitter, BakedModel model, @Nullable BlockState state, Supplier randomSupplier, Predicate<@Nullable Direction> cullTest) { + public static void emitBlockQuads(QuadEmitter emitter, BakedModel model, @Nullable BlockState state, Predicate<@Nullable Direction> cullTest) { final RenderMaterial defaultMaterial = model.useAmbientOcclusion() ? STANDARD_MATERIAL : NO_AO_MATERIAL; for (int i = 0; i <= ModelHelper.NULL_FACE_ID; i++) { @@ -67,23 +67,4 @@ public static void emitBlockQuads(QuadEmitter emitter, BakedModel model, @Nullab } } } - - public static void emitItemQuads(QuadEmitter emitter, BakedModel model, @Nullable BlockState state, Supplier randomSupplier) { - for (int i = 0; i <= ModelHelper.NULL_FACE_ID; i++) { - final Direction cullFace = ModelHelper.faceFromIndex(i); - - final List quads; - - if (cullFace != null) { - quads = model.getByDirection(cullFace); - } else { - quads = model.getQuads(); - } - - for (final BakedQuad quad : quads) { - emitter.fromVanilla(quad, STANDARD_MATERIAL, cullFace); - emitter.emit(); - } - } - } } diff --git a/common/src/api/java/dev/vexor/radium/frapi/mixin/renderer/client/BakedModelMixin.java b/common/src/api/java/dev/vexor/radium/frapi/mixin/renderer/client/BakedModelMixin.java deleted file mode 100644 index 25f705025..000000000 --- a/common/src/api/java/dev/vexor/radium/frapi/mixin/renderer/client/BakedModelMixin.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package dev.vexor.radium.frapi.mixin.renderer.client; - -import org.spongepowered.asm.mixin.Mixin; - -import net.minecraft.client.render.model.BakedModel; - -import dev.vexor.radium.frapi.api.renderer.v1.model.FabricBakedModel; - -/** - * Avoids instanceof checks and enables consistent code path for all baked models. - */ -@Mixin(BakedModel.class) -public interface BakedModelMixin extends FabricBakedModel { -} diff --git a/common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter.java b/common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter.java deleted file mode 100644 index 51afa44e9..000000000 --- a/common/src/api/java/net/caffeinemc/mods/sodium/api/vertex/buffer/VertexBufferWriter.java +++ /dev/null @@ -1,103 +0,0 @@ -package net.caffeinemc.mods.sodium.api.vertex.buffer; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; -import net.caffeinemc.mods.sodium.api.memory.MemoryIntrinsics; -import net.minecraft.client.render.VertexFormat; -import org.jetbrains.annotations.Nullable; -import org.lwjgl.system.MemoryStack; - -public interface VertexBufferWriter { - /** - * Converts a {@link VertexConsumer} into a {@link VertexBufferWriter}. - * - * @param consumer The vertex consumer to create a writer for - * @return An implementation of {@link VertexBufferWriter} which will write vertices into {@param consumer} - * @throws IllegalArgumentException If the vertex consumer does not implement the necessary interface - */ - static VertexBufferWriter of(VertexConsumer consumer) { - if (consumer instanceof VertexBufferWriter) { - VertexBufferWriter writer = (VertexBufferWriter) consumer; - if (writer.canUseIntrinsics()) { - return writer; - } - } - - throw createUnsupportedVertexConsumerThrowable(consumer); - } - - /** - * Converts a {@link VertexConsumer} into a {@link VertexBufferWriter} if possible. - * - * @param consumer The vertex consumer to create a writer for - * @return An implementation of {@link VertexBufferWriter} which will write vertices into {@param consumer}, or null - * if the vertex consumer does not implement the necessary interface - */ - @Nullable - static VertexBufferWriter tryOf(VertexConsumer consumer) { - if (consumer instanceof VertexBufferWriter writer) { - if (writer.canUseIntrinsics()) { - return writer; - } - } - - return null; - } - - static RuntimeException createUnsupportedVertexConsumerThrowable(VertexConsumer consumer) { - Class clazz = consumer.getClass(); - String name = clazz.getName(); - - return new IllegalArgumentException(String.format("The class %s does not implement interface VertexBufferWriter, " + - "which is required for compatibility with Radium", name)); - } - - /** - * Copy the vertices from the source buffer and pushes them into this vertex buffer. The vertex buffer - * is advanced by {@param count} vertices. If the vertex format differs from the target format of the - * vertex buffer, a conversion will be performed. - *

- * After calling this function, the contents of {@param ptr} are undefined. - *

- * If {@param stack} is used by the caller, the stack frame will not be pushed/popped. This function should - * only be called in a try-with-resources block with the provided stack, otherwise it could leak memory. - * - * @param stack The memory stack which can be used as scratch memory - * @param ptr The pointer to read vertices from - * @param count The number of vertices to copy - * @param format The format of the vertices - */ - void push(MemoryStack stack, long ptr, int count, VertexFormat format); - - /** - * If this {@link VertexBufferWriter} passes through data to nested {@link VertexConsumer} implementations, - * this method should be implemented to check that the nested implementations also support use of VertexBufferWriter - * methods. - * @return true if the inner consumer is also a valid {@link VertexBufferWriter} that can use intrinsics - */ - default boolean canUseIntrinsics() { - return true; - } - - /** - * Creates a copy of the source data and pushes it into the specified {@param writer}. This is useful for when - * you need to use to re-use the source data after the call, and do not want the {@param writer} to modify - * the original data. - * - * @param writer The buffer to push the vertices into - * @param stack The memory stack which can be used to create temporary allocations - * @param ptr The pointer to read vertices from - * @param count The number of vertices to push - * @param format The format of the vertices - */ - static void copyInto(VertexBufferWriter writer, - MemoryStack stack, long ptr, int count, - VertexFormat format) - { - int length = count * format.getVertexSize(); - long copy = stack.nmalloc(length); - - MemoryIntrinsics.copyMemory(ptr, copy, length); - - writer.push(stack, copy, count, format); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/model/color/ColorProviderRegistry.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/model/color/ColorProviderRegistry.java index ae69e7f99..16c7848d6 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/model/color/ColorProviderRegistry.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/model/color/ColorProviderRegistry.java @@ -5,17 +5,34 @@ import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; import it.unimi.dsi.fastutil.objects.ReferenceSet; import net.caffeinemc.mods.sodium.client.model.color.interop.BlockColorsExtension; -import net.caffeinemc.mods.sodium.client.services.FluidRendererFactory; +import net.caffeinemc.mods.sodium.client.model.quad.blender.BlendedColorProvider; +import net.caffeinemc.mods.sodium.client.world.LevelSlice; import net.minecraft.block.AbstractFluidBlock; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.client.color.world.BiomeColors; +import net.minecraft.util.math.BlockPos; // TODO: Make the registry a global somewhere that is only initialized once after content load public class ColorProviderRegistry { private final Reference2ReferenceMap> blocks = new Reference2ReferenceOpenHashMap<>(); private final Reference2ReferenceMap> fluids = new Reference2ReferenceOpenHashMap<>(); + class WaterColors extends BlendedColorProvider { + @Override + protected int getColor(LevelSlice slice, BlockState state, BlockPos pos) { + return BiomeColors.getWaterColor(slice, pos) | 0xFF000000; + } + } + + class WaterBlockColors extends BlendedColorProvider { + @Override + protected int getColor(LevelSlice slice, BlockState state, BlockPos pos) { + return BiomeColors.getWaterColor(slice, pos) | 0xFF000000; + } + } + private final ReferenceSet overridenBlocks; public ColorProviderRegistry(BlockColors blockColors) { @@ -38,11 +55,8 @@ private void installOverrides() { this.registerBlocks(DefaultColorProviders.FoliageColorProvider.BLOCKS, Blocks.LEAVES, Blocks.LEAVES2, Blocks.VINE); - this.registerBlocks(FluidRendererFactory.getInstance().getWaterBlockColorProvider(), - Blocks.WATER); - - this.registerFluids(FluidRendererFactory.getInstance().getWaterColorProvider(), - Blocks.WATER, Blocks.FLOWING_WATER); + this.registerBlocks(new WaterBlockColors(), Blocks.WATER); + this.registerFluids(new WaterColors(), Blocks.WATER, Blocks.FLOWING_WATER); } private void registerBlocks(ColorProvider provider, Block... blocks) { diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/SodiumWorldRenderer.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/SodiumWorldRenderer.java index 7b0d5c607..a98300ebd 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/SodiumWorldRenderer.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/SodiumWorldRenderer.java @@ -1,5 +1,6 @@ package net.caffeinemc.mods.sodium.client.render; +import com.mojang.blaze3d.platform.GlStateManager; import dev.vexor.radium.compat.mojang.minecraft.render.FogHelper; import net.caffeinemc.mods.sodium.client.SodiumClientMod; import net.caffeinemc.mods.sodium.client.gl.device.CommandList; @@ -275,7 +276,7 @@ private void initRenderer(CommandList commandList) { public void renderBlockEntities(Map blockBreakingProgressions, float tickDelta) { - Vec3d cameraPos = Camera.getPosition(); + var cameraPos = lastCameraPos;//Camera.getPosition(); double x = cameraPos.x; double y = cameraPos.y; double z = cameraPos.z; @@ -359,17 +360,16 @@ private static void renderBlockEntity(Map blockBreak ClientPlayerEntity player) { BlockPos pos = entity.getPos(); - GL11.glPushMatrix(); - GL11.glTranslated((double) pos.getX() - x, (double) pos.getY() - y, (double) pos.getZ() - z); + //GlStateManager.pushMatrix(); + //GlStateManager.translate(pos.getX() - x, pos.getY() - y, pos.getZ() - z); int destroyProgress = blockBreakingProgressions.values().stream().filter(info -> - info.getPos().equals(pos)).map((info) -> info.getStage()).findFirst().orElse(-1); + info.getPos().equals(pos)).map(BlockBreakingInfo::getStage).findFirst().orElse(-1); dispatcher.renderEntity(entity, tickDelta, destroyProgress); - - GL11.glPopMatrix(); + //GlStateManager.popMatrix(); } public void iterateVisibleBlockEntities(Consumer blockEntityConsumer) { diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/buffers/BakedChunkModelBuilder.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/buffers/BakedChunkModelBuilder.java index 97695a7d7..fb31d84ec 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/buffers/BakedChunkModelBuilder.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/buffers/BakedChunkModelBuilder.java @@ -1,16 +1,12 @@ package net.caffeinemc.mods.sodium.client.render.chunk.compile.buffers; -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; import net.caffeinemc.mods.sodium.client.model.quad.properties.ModelQuadFacing; import net.caffeinemc.mods.sodium.client.render.chunk.data.BuiltSectionInfo; -import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.Material; -import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.TranslucentGeometryCollector; import net.caffeinemc.mods.sodium.client.render.chunk.vertex.builder.ChunkMeshBufferBuilder; import net.minecraft.client.texture.Sprite; public class BakedChunkModelBuilder implements ChunkModelBuilder { private final ChunkMeshBufferBuilder[] vertexBuffers; - private final ChunkVertexConsumer fallbackVertexConsumer = new ChunkVertexConsumer(this); private BuiltSectionInfo.Builder renderData; @@ -28,12 +24,6 @@ public void addSprite(Sprite sprite) { this.renderData.addSprite(sprite); } - @Override - public VertexConsumer asFallbackVertexConsumer(Material material, TranslucentGeometryCollector collector) { - fallbackVertexConsumer.setData(material, collector); - return fallbackVertexConsumer; - } - public void destroy() { for (ChunkMeshBufferBuilder builder : this.vertexBuffers) { builder.destroy(); diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/buffers/ChunkModelBuilder.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/buffers/ChunkModelBuilder.java index 740c96c80..506e8e99d 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/buffers/ChunkModelBuilder.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/buffers/ChunkModelBuilder.java @@ -1,9 +1,6 @@ package net.caffeinemc.mods.sodium.client.render.chunk.compile.buffers; -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; import net.caffeinemc.mods.sodium.client.model.quad.properties.ModelQuadFacing; -import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.Material; -import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.TranslucentGeometryCollector; import net.caffeinemc.mods.sodium.client.render.chunk.vertex.builder.ChunkMeshBufferBuilder; import net.minecraft.client.texture.Sprite; @@ -11,18 +8,4 @@ public interface ChunkModelBuilder { ChunkMeshBufferBuilder getVertexBuffer(ModelQuadFacing facing); void addSprite(Sprite sprite); - - /** - * This method should not be used unless absolutely necessary! It exists only for compatibility purposes. - * Prefer using the other methods in this class instead as they are more efficient. - * - *

Returns a {@link VertexConsumer} which adds geometry to this model builder using the given {@link Material}. - * The returned vertex consumer expects quads and requires the position, color, texture, light, and normal - * attributes to be provided for each vertex. The returned vertex consumer may be a reused object, so it must not be - * stored or cached in any way by the caller. - * - * @param material the material that should be used for geometry pushed to the vertex consumer - * @return the fallback vertex consumer which adds geometry to this model builder - */ - VertexConsumer asFallbackVertexConsumer(Material material, TranslucentGeometryCollector collector); } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/buffers/ChunkVertexConsumer.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/buffers/ChunkVertexConsumer.java deleted file mode 100644 index e34691c73..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/buffers/ChunkVertexConsumer.java +++ /dev/null @@ -1,195 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.chunk.compile.buffers; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; -import net.caffeinemc.mods.sodium.api.util.ColorABGR; -import net.caffeinemc.mods.sodium.api.util.ColorARGB; -import net.caffeinemc.mods.sodium.api.util.NormI8; -import net.caffeinemc.mods.sodium.client.model.quad.properties.ModelQuadFacing; -import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.Material; -import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.TranslucentGeometryCollector; -import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexEncoder; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteFinderCache; -import net.minecraft.client.texture.Sprite; -import org.jetbrains.annotations.NotNull; - -public class ChunkVertexConsumer implements VertexConsumer { - private static final int ATTRIBUTE_POSITION_BIT = 1 << 0; - private static final int ATTRIBUTE_COLOR_BIT = 1 << 1; - private static final int ATTRIBUTE_TEXTURE_BIT = 1 << 2; - private static final int ATTRIBUTE_LIGHT_BIT = 1 << 3; - private static final int ATTRIBUTE_NORMAL_BIT = 1 << 4; - private static final int REQUIRED_ATTRIBUTES = (1 << 5) - 1; - - private final ChunkModelBuilder modelBuilder; - private final ChunkVertexEncoder.Vertex[] vertices = ChunkVertexEncoder.Vertex.uninitializedQuad(); - - private Material material; - private int vertexIndex; - private int writtenAttributes; - private TranslucentGeometryCollector collector; - - public ChunkVertexConsumer(ChunkModelBuilder modelBuilder) { - this.modelBuilder = modelBuilder; - } - - public void setData(Material material, TranslucentGeometryCollector collector) { - this.material = material; - this.collector = collector; - } - - @Override - public @NotNull VertexConsumer addVertex(float x, float y, float z) { - ChunkVertexEncoder.Vertex vertex = this.vertices[this.vertexIndex]; - vertex.x = x; - vertex.y = y; - vertex.z = z; - vertex.ao = 1.0f; - this.writtenAttributes |= ATTRIBUTE_POSITION_BIT; - return potentiallyEndVertex(); - } - - // Writing color ignores alpha since alpha is used as a color multiplier by Sodium. - @Override - public @NotNull VertexConsumer setColor(int red, int green, int blue, int alpha) { - ChunkVertexEncoder.Vertex vertex = this.vertices[this.vertexIndex]; - vertex.color = ColorABGR.pack(red, green, blue, alpha); - this.writtenAttributes |= ATTRIBUTE_COLOR_BIT; - return potentiallyEndVertex(); - } - - @Override - public @NotNull VertexConsumer setColor(float red, float green, float blue, float alpha) { - ChunkVertexEncoder.Vertex vertex = this.vertices[this.vertexIndex]; - vertex.color = ColorABGR.pack(red, green, blue, alpha); - this.writtenAttributes |= ATTRIBUTE_COLOR_BIT; - return potentiallyEndVertex(); - } - - @Override - public @NotNull VertexConsumer setColor(int argb) { - ChunkVertexEncoder.Vertex vertex = this.vertices[this.vertexIndex]; - vertex.color = ColorARGB.toABGR(argb); - this.writtenAttributes |= ATTRIBUTE_COLOR_BIT; - return potentiallyEndVertex(); - } - - @Override - public @NotNull VertexConsumer setUv(float u, float v) { - ChunkVertexEncoder.Vertex vertex = this.vertices[this.vertexIndex]; - vertex.u = u; - vertex.v = v; - this.writtenAttributes |= ATTRIBUTE_TEXTURE_BIT; - return potentiallyEndVertex(); - } - - // Overlay is ignored for chunk geometry. - @Override - public @NotNull VertexConsumer setUv1(int u, int v) { - return potentiallyEndVertex(); - } - - @Override - public @NotNull VertexConsumer setOverlay(int uv) { - return potentiallyEndVertex(); - } - - @Override - public @NotNull VertexConsumer setUv2(int u, int v) { - ChunkVertexEncoder.Vertex vertex = this.vertices[this.vertexIndex]; - vertex.light = ((v & 0xFFFF) << 16) | (u & 0xFFFF); - this.writtenAttributes |= ATTRIBUTE_LIGHT_BIT; - return potentiallyEndVertex(); - } - - @Override - public @NotNull VertexConsumer setLight(int uv) { - ChunkVertexEncoder.Vertex vertex = this.vertices[this.vertexIndex]; - vertex.light = uv; - this.writtenAttributes |= ATTRIBUTE_LIGHT_BIT; - return potentiallyEndVertex(); - } - - @Override - public @NotNull VertexConsumer setNormal(float x, float y, float z) { - this.writtenAttributes |= ATTRIBUTE_NORMAL_BIT; - return potentiallyEndVertex(); - } - - public VertexConsumer potentiallyEndVertex() { - if (this.writtenAttributes != REQUIRED_ATTRIBUTES) { - return this; - } - - this.vertexIndex++; - this.writtenAttributes = 0; - - if (this.vertexIndex == 4) { - int normal = calculateNormal(); - - ModelQuadFacing cullFace = ModelQuadFacing.fromPackedNormal(normal); - - if (this.material.isTranslucent() && this.collector != null) { - this.collector.appendQuad(normal, this.vertices, cullFace); - } - - this.modelBuilder.getVertexBuffer(cullFace).push(this.vertices, this.material); - - float u = 0; - float v = 0; - - for (ChunkVertexEncoder.Vertex vertex : this.vertices) { - u += vertex.u; - v += vertex.v; - } - - Sprite sprite = SpriteFinderCache.forBlockAtlas().find(u * 0.25f, v * 0.25f); - - if (sprite != null) { - this.modelBuilder.addSprite(sprite); - } - - this.vertexIndex = 0; - } - - return this; - } - - private int calculateNormal() { - final float x0 = this.vertices[0].x; - final float y0 = this.vertices[0].y; - final float z0 = this.vertices[0].z; - - final float x1 = this.vertices[1].x; - final float y1 = this.vertices[1].y; - final float z1 = this.vertices[1].z; - - final float x2 = this.vertices[2].x; - final float y2 = this.vertices[2].y; - final float z2 = this.vertices[2].z; - - final float x3 = this.vertices[3].x; - final float y3 = this.vertices[3].y; - final float z3 = this.vertices[3].z; - - final float dx0 = x2 - x0; - final float dy0 = y2 - y0; - final float dz0 = z2 - z0; - final float dx1 = x3 - x1; - final float dy1 = y3 - y1; - final float dz1 = z3 - z1; - - float normX = dy0 * dz1 - dz0 * dy1; - float normY = dz0 * dx1 - dx0 * dz1; - float normZ = dx0 * dy1 - dy0 * dx1; - - // normalize by length for the packed normal - float length = (float) Math.sqrt(normX * normX + normY * normY + normZ * normZ); - if (length != 0.0 && length != 1.0) { - normX /= length; - normY /= length; - normZ /= length; - } - - return NormI8.pack(normX, normY, normZ); - } -} \ No newline at end of file diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderCache.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderCache.java index 40f3fa770..06ac62481 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderCache.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderCache.java @@ -4,7 +4,7 @@ import net.caffeinemc.mods.sodium.client.model.color.ColorProviderRegistry; import net.caffeinemc.mods.sodium.client.model.light.LightPipelineProvider; import net.caffeinemc.mods.sodium.client.model.light.data.ArrayLightDataCache; -import net.caffeinemc.mods.sodium.client.services.FluidRendererFactory; +import net.caffeinemc.mods.sodium.client.render.FluidRendererImpl; import net.caffeinemc.mods.sodium.client.world.LevelSlice; import net.caffeinemc.mods.sodium.client.world.cloned.ChunkRenderContext; import net.minecraft.client.MinecraftClient; @@ -29,7 +29,7 @@ public BlockRenderCache(MinecraftClient minecraft, ClientWorld level) { var colorRegistry = new ColorProviderRegistry(BlockColors.INSTANCE); this.blockRenderer = new BlockRenderer(colorRegistry, lightPipelineProvider); - this.fluidRenderer = FluidRendererFactory.getInstance().createPlatformFluidRenderer(colorRegistry, lightPipelineProvider); + this.fluidRenderer = new FluidRendererImpl(colorRegistry, lightPipelineProvider); this.blockModels = minecraft.getBlockRenderManager().getModels(); } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java deleted file mode 100644 index 586286f73..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderContext.java +++ /dev/null @@ -1,88 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline; - -import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.TranslucentGeometryCollector; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.util.math.BlockPos; -import org.joml.Vector3f; -import org.joml.Vector3fc; - -public class BlockRenderContext { - private final LevelSlice slice; - public final TranslucentGeometryCollector collector; - - private final BlockPos.Mutable pos = new BlockPos.Mutable(); - - private final Vector3f origin = new Vector3f(); - - private BlockState state; - private BakedModel model; - - private long seed; - - - public BlockRenderContext(LevelSlice slice, TranslucentGeometryCollector collector) { - this.slice = slice; - this.collector = collector; - } - - public void update(BlockPos pos, BlockPos origin, BlockState state, BakedModel model, long seed) { - this.pos.setPosition(pos.getX(), pos.getY(), pos.getZ()); - this.origin.set(origin.getX(), origin.getY(), origin.getZ()); - - this.state = state; - this.model = model; - - this.seed = seed; - } - - /** - * @return The collector for translucent geometry sorting - */ - public TranslucentGeometryCollector collector() { - return this.collector; - } - - /** - * @return The position (in block space) of the block being rendered - */ - public BlockPos pos() { - return this.pos; - } - - /** - * @return The level which the block is being rendered from - */ - public LevelSlice slice() { - return this.slice; - } - - /** - * @return The state of the block being rendered - */ - public BlockState state() { - return this.state; - } - - /** - * @return The model used for this block - */ - public BakedModel model() { - return this.model; - } - - /** - * @return The origin of the block within the model - */ - public Vector3fc origin() { - return this.origin; - } - - /** - * @return The PRNG seed for rendering this block - */ - public long seed() { - return this.seed; - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java index 1101f4329..d891b63f3 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/BlockRenderer.java @@ -1,7 +1,9 @@ package net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline; import dev.vexor.radium.compat.mojang.minecraft.random.SingleThreadedRandomSource; +import dev.vexor.radium.frapi.impl.renderer.VanillaModelEncoder; import net.caffeinemc.mods.sodium.api.util.ColorABGR; +import net.caffeinemc.mods.sodium.api.util.ColorARGB; import net.caffeinemc.mods.sodium.api.util.ColorMixer; import net.caffeinemc.mods.sodium.client.model.color.ColorProvider; import net.caffeinemc.mods.sodium.client.model.color.ColorProviderRegistry; @@ -19,12 +21,10 @@ import net.caffeinemc.mods.sodium.client.render.frapi.mesh.MutableQuadViewImpl; import net.caffeinemc.mods.sodium.client.render.frapi.render.AbstractBlockRenderContext; import net.caffeinemc.mods.sodium.client.render.texture.SpriteFinderCache; -import net.caffeinemc.mods.sodium.client.services.SodiumModelData; import net.caffeinemc.mods.sodium.client.world.LevelSlice; import dev.vexor.radium.frapi.api.renderer.v1.material.BlendMode; import dev.vexor.radium.frapi.api.renderer.v1.material.RenderMaterial; import dev.vexor.radium.frapi.api.renderer.v1.material.ShadeMode; -import dev.vexor.radium.frapi.api.renderer.v1.model.FabricBakedModel; import net.legacyfabric.fabric.api.util.TriState; import net.minecraft.block.Block; import net.minecraft.block.BlockState; @@ -75,25 +75,25 @@ public void renderModel(BakedModel model, BlockState state, BlockPos pos, BlockP this.posOffset.set(origin.getX(), origin.getY(), origin.getZ()); - Block.OffsetType offsetType = state.getBlock().getOffsetType(); - - if (offsetType != Block.OffsetType.NONE) { - int x = origin.getX(); - int z = origin.getZ(); - // Taken from MathHelper.hashCode() - long i = (x * 3129871L) ^ z * 116129781L; - i = i * i * 42317861L + i * 11L; - - double fx = (((i >> 16 & 15L) / 15.0F) - 0.5f) * 0.5f; - double fz = (((i >> 24 & 15L) / 15.0F) - 0.5f) * 0.5f; - double fy = 0; - - if (offsetType == Block.OffsetType.XYZ) { - fy += (((i >> 20 & 15L) / 15.0F) - 1.0f) * 0.2f; - } - - posOffset.add((float) fx, (float) fy, (float) fz); - } + //Block.OffsetType offsetType = state.getBlock().getOffsetType(); +// + //if (offsetType != Block.OffsetType.NONE) { + // int x = origin.getX(); + // int z = origin.getZ(); + // // Taken from MathHelper.hashCode() + // long i = (x * 3129871L) ^ z * 116129781L; + // i = i * i * 42317861L + i * 11L; +// + // double fx = (((i >> 16 & 15L) / 15.0F) - 0.5f) * 0.5f; + // double fz = (((i >> 24 & 15L) / 15.0F) - 0.5f) * 0.5f; + // double fy = 0; +// + // if (offsetType == Block.OffsetType.XYZ) { + // fy += (((i >> 20 & 15L) / 15.0F) - 1.0f) * 0.2f; + // } +// + // posOffset.add((float) fx, (float) fy, (float) fz); + //} this.colorProvider = this.colorProviderRegistry.getColorProvider(state.getBlock()); @@ -102,13 +102,10 @@ public void renderModel(BakedModel model, BlockState state, BlockPos pos, BlockP this.prepareCulling(true); this.prepareAoInfo(model.useAmbientOcclusion()); - modelData = null; - this.type = state.getBlock().getRenderLayerType(); - ((FabricBakedModel) model).emitBlockQuads(getEmitter(), this.level, state, pos, this.randomSupplier, this::isFaceCulled); + VanillaModelEncoder.emitBlockQuads(getEmitter(), model, state, this::isFaceCulled); type = null; - modelData = SodiumModelData.EMPTY; } /** @@ -172,24 +169,17 @@ private void bufferQuad(MutableQuadViewImpl quad, float[] brightnesses, Material out.y = quad.y(srcIndex) + offset.y; out.z = quad.z(srcIndex) + offset.z; - int color; - - if (state.getBlock().isTranslucent()) { - color = ColorABGR.mulRGB(quad.color(srcIndex), 1.0f); - } else { - color = ColorABGR.mulRGB(quad.color(srcIndex), brightnesses[srcIndex]); - } - out.color = color; + out.color = ColorARGB.fromABGR(quad.color(srcIndex)); out.ao = brightnesses[srcIndex]; out.u = quad.u(srcIndex); out.v = quad.v(srcIndex); - out.light = quad.lightmap(srcIndex); + out.light = 15;//quad.lightmap(srcIndex); } - var atlasSprite = quad.sprite(SpriteFinderCache.forBlockAtlas()); + //var atlasSprite = quad.sprite(SpriteFinderCache.forBlockAtlas()); var materialBits = material.bits(); ModelQuadFacing normalFace = quad.normalFace(); @@ -205,6 +195,6 @@ private void bufferQuad(MutableQuadViewImpl quad, float[] brightnesses, Material ChunkMeshBufferBuilder vertexBuffer = builder.getVertexBuffer(normalFace); vertexBuffer.push(vertices, materialBits); - builder.addSprite(atlasSprite); + //builder.addSprite(atlasSprite); } } \ No newline at end of file diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/DefaultFluidRenderer.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/DefaultFluidRenderer.java index 31881bb28..930ed4081 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/DefaultFluidRenderer.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/pipeline/DefaultFluidRenderer.java @@ -19,7 +19,6 @@ import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.Material; import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.TranslucentGeometryCollector; import net.caffeinemc.mods.sodium.client.render.chunk.vertex.format.ChunkVertexEncoder; -import net.caffeinemc.mods.sodium.client.services.PlatformBlockAccess; import net.caffeinemc.mods.sodium.client.util.DirectionUtil; import net.caffeinemc.mods.sodium.client.world.LevelSlice; import net.minecraft.block.AbstractFluidBlock; @@ -109,7 +108,7 @@ public void render(LevelSlice level, BlockState fluidState, BlockPos blockPos, B int posZ = blockPos.getZ(); AbstractFluidBlock fluid = (AbstractFluidBlock) fluidState.getBlock(); - + boolean cullUp = this.isFluidOccluded(level, blockPos, Direction.UP, fluid); boolean cullDown = this.isFluidOccluded(level, blockPos, Direction.DOWN, fluid) || !this.isSideExposed(level, posX, posY, posZ, Direction.DOWN, 0.8888889F); @@ -333,18 +332,6 @@ && isAlignedEquals(southEastHeight, southWestHeight) Sprite sprite = sprites[1]; - boolean isOverlay = false; - - if (sprites.length > 2 && sprites[2] != null) { - BlockPos adjPos = this.scratchPos.setPosition(adjX, adjY, adjZ); - BlockState adjBlock = level.getBlockState(adjPos); - - if (PlatformBlockAccess.getInstance().shouldShowFluidOverlay(adjBlock, level, adjPos, fluidState)) { - sprite = sprites[2]; - isOverlay = true; - } - } - float u1 = sprite.getFrameU(0.0F); float u2 = sprite.getFrameU(0.5F); float v1 = sprite.getFrameV((1.0F - c1) * 0.5F); @@ -364,11 +351,7 @@ && isAlignedEquals(southEastHeight, southWestHeight) this.updateQuad(quad, level, blockPos, lighter, dir, facing, br, colorProvider, fluidState); this.writeQuad(meshBuilder, collector, material, offset, quad, facing, false); - - if (!isOverlay) { - this.writeQuad(meshBuilder, collector, material, offset, quad, facing.getOpposite(), true); - } - + this.writeQuad(meshBuilder, collector, material, offset, quad, facing.getOpposite(), true); } } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/DefaultTerrainRenderPasses.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/DefaultTerrainRenderPasses.java index 6f775832e..5e8669328 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/DefaultTerrainRenderPasses.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/DefaultTerrainRenderPasses.java @@ -4,15 +4,17 @@ public class DefaultTerrainRenderPasses { public static final TerrainRenderPass SOLID = new TerrainRenderPass(RenderLayer.SOLID, false, false); - public static final TerrainRenderPass CUTOUT = new TerrainRenderPass(RenderLayer.CUTOUT_MIPPED, false, true); + public static final TerrainRenderPass CUTOUT = new TerrainRenderPass(RenderLayer.CUTOUT, false, true); + public static final TerrainRenderPass CUTOUT_MIPPED = new TerrainRenderPass(RenderLayer.CUTOUT_MIPPED, false, true); public static final TerrainRenderPass TRANSLUCENT = new TerrainRenderPass(RenderLayer.TRANSLUCENT, true, false); - public static final TerrainRenderPass[] ALL = new TerrainRenderPass[] { SOLID, CUTOUT, TRANSLUCENT }; + public static final TerrainRenderPass[] ALL = new TerrainRenderPass[] { SOLID, CUTOUT, CUTOUT_MIPPED, TRANSLUCENT }; public static TerrainRenderPass fromLayer(RenderLayer layer) { return switch (layer) { case SOLID -> SOLID; - case CUTOUT, CUTOUT_MIPPED -> CUTOUT; + case CUTOUT -> CUTOUT; + case CUTOUT_MIPPED -> CUTOUT_MIPPED; case TRANSLUCENT -> TRANSLUCENT; }; } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/material/DefaultMaterials.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/material/DefaultMaterials.java index b465b4815..f331d7602 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/material/DefaultMaterials.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/terrain/material/DefaultMaterials.java @@ -8,7 +8,7 @@ public class DefaultMaterials { public static final Material SOLID = new Material(DefaultTerrainRenderPasses.SOLID, AlphaCutoffParameter.ZERO, true); public static final Material CUTOUT = new Material(DefaultTerrainRenderPasses.CUTOUT, AlphaCutoffParameter.ONE_TENTH, false); - public static final Material CUTOUT_MIPPED = new Material(DefaultTerrainRenderPasses.CUTOUT, AlphaCutoffParameter.HALF, true); + public static final Material CUTOUT_MIPPED = new Material(DefaultTerrainRenderPasses.CUTOUT_MIPPED, AlphaCutoffParameter.HALF, true); public static final Material TRANSLUCENT = new Material(DefaultTerrainRenderPasses.TRANSLUCENT, AlphaCutoffParameter.ZERO, true); public static Material forBlockState(BlockState state) { diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/SodiumRenderer.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/SodiumRenderer.java index adcc7f9f7..78aa08d85 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/SodiumRenderer.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/SodiumRenderer.java @@ -17,12 +17,9 @@ package net.caffeinemc.mods.sodium.client.render.frapi; import net.caffeinemc.mods.sodium.client.render.frapi.material.MaterialFinderImpl; -import net.caffeinemc.mods.sodium.client.render.frapi.material.RenderMaterialImpl; -import net.caffeinemc.mods.sodium.client.render.frapi.mesh.MutableMeshImpl; import dev.vexor.radium.frapi.api.renderer.v1.Renderer; import dev.vexor.radium.frapi.api.renderer.v1.material.MaterialFinder; import dev.vexor.radium.frapi.api.renderer.v1.material.RenderMaterial; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.MutableMesh; import net.minecraft.util.Identifier; import java.util.HashMap; @@ -43,27 +40,18 @@ public class SodiumRenderer implements Renderer { private SodiumRenderer() { } - @Override - public MutableMesh mutableMesh() { - return new MutableMeshImpl(); - } @Override public MaterialFinder materialFinder() { return new MaterialFinderImpl(); } - @Override - public RenderMaterial materialById(Identifier id) { - return materialMap.get(id); - } - @Override public boolean registerMaterial(Identifier id, RenderMaterial material) { if (materialMap.containsKey(id)) return false; // cast to prevent acceptance of impostor implementations - materialMap.put(id, (RenderMaterialImpl) material); + materialMap.put(id, material); return true; } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/material/MaterialFinderImpl.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/material/MaterialFinderImpl.java index 94121051d..7bb497f14 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/material/MaterialFinderImpl.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/material/MaterialFinderImpl.java @@ -75,12 +75,6 @@ public MaterialFinder shadeMode(ShadeMode mode) { return this; } - @Override - public MaterialFinder copyFrom(MaterialView material) { - bits = ((MaterialViewImpl) material).bits; - return this; - } - @Override public MaterialFinder clear() { bits = defaultBits; diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/MeshImpl.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/MeshImpl.java deleted file mode 100644 index 1367ba50a..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/MeshImpl.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.caffeinemc.mods.sodium.client.render.frapi.mesh; - -import it.unimi.dsi.fastutil.objects.ObjectArrayList; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.Mesh; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.QuadEmitter; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.QuadView; -import org.jetbrains.annotations.Range; - -import java.util.function.Consumer; - -/** - * Implementation of {@link Mesh}. - * The way we encode meshes makes it very simple. - */ -public class MeshImpl implements Mesh { - /** Used to satisfy external calls to {@link #forEach(Consumer)}. */ - private static final ThreadLocal> CURSOR_POOLS = ThreadLocal.withInitial(ObjectArrayList::new); - - int[] data; - int limit; - - MeshImpl(int[] data) { - this.data = data; - limit = data.length; - } - - MeshImpl() {} - - @Override - @Range(from = 0, to = Integer.MAX_VALUE) - public int size() { - return limit / EncodingFormat.TOTAL_STRIDE; - } - - @Override - public void forEach(Consumer action) { - ObjectArrayList pool = CURSOR_POOLS.get(); - QuadViewImpl cursor; - - if (pool.isEmpty()) { - cursor = new QuadViewImpl(); - } else { - cursor = pool.pop(); - } - - forEach(action, cursor); - - pool.push(cursor); - } - - /** - * The renderer can call this with its own cursor - * to avoid the performance hit of a thread-local lookup. - * Also means renderer can hold final references to quad buffers. - */ - void forEach(Consumer action, C cursor) { - final int limit = this.limit; - int index = 0; - cursor.data = this.data; - - while (index < limit) { - cursor.baseIndex = index; - cursor.load(); - action.accept(cursor); - index += EncodingFormat.TOTAL_STRIDE; - } - - cursor.data = null; - } - - // TODO: This could be optimized by checking if the emitter is that of a MutableMeshImpl and if - // it has no transforms, in which case the entire data array can be copied in bulk. - @Override - public void outputTo(QuadEmitter emitter) { - MutableQuadViewImpl e = (MutableQuadViewImpl) emitter; - final int[] data = this.data; - final int limit = this.limit; - int index = 0; - - while (index < limit) { - System.arraycopy(data, index, e.data, e.baseIndex, EncodingFormat.TOTAL_STRIDE); - e.load(); - e.transformAndEmit(); - index += EncodingFormat.TOTAL_STRIDE; - } - - e.clear(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/MutableMeshImpl.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/MutableMeshImpl.java deleted file mode 100644 index 2672ba0de..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/MutableMeshImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.caffeinemc.mods.sodium.client.render.frapi.mesh; - -import dev.vexor.radium.frapi.api.renderer.v1.mesh.Mesh; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.MutableMesh; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.MutableQuadView; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.QuadEmitter; - -import java.util.function.Consumer; - -/** - * Our implementation of {@link MutableMesh}, used for static mesh creation and baking. - * Not much to it - mainly it just needs to grow the int[] array as quads are appended - * and maintain/provide a properly-configured {@link MutableQuadView} instance. - * All the encoding and other work is handled in the quad base classes. - * The one interesting bit is in {@link MutableQuadViewImpl#emitDirectly()}. - */ -public class MutableMeshImpl extends MeshImpl implements MutableMesh { - private final MutableQuadViewImpl emitter = new MutableQuadViewImpl() { - @Override - protected void emitDirectly() { - // Necessary because the validity of geometry is not encoded; reading mesh data always - // uses QuadViewImpl#load(), which assumes valid geometry. Built immutable meshes - // should also have valid geometry for better performance. - computeGeometry(); - limit += EncodingFormat.TOTAL_STRIDE; - ensureCapacity(); - baseIndex = limit; - } -}; - - public MutableMeshImpl() { - data = new int[8 * EncodingFormat.TOTAL_STRIDE]; - limit = 0; - - ensureCapacity(); - emitter.data = data; - emitter.baseIndex = limit; - emitter.clear(); - } - - private void ensureCapacity() { - if (EncodingFormat.TOTAL_STRIDE > data.length - limit) { - final int[] bigger = new int[data.length * 2]; - System.arraycopy(data, 0, bigger, 0, limit); - data = bigger; - emitter.data = data; - } - } - - @Override - public QuadEmitter emitter() { - emitter.clear(); - return emitter; - } - - @Override - public void forEachMutable(Consumer action) { - // emitDirectly will not be called by forEach, so just reuse the main emitter. - forEach(action, emitter); - emitter.data = data; - emitter.baseIndex = limit; - } - - @Override - public Mesh immutableCopy() { - final int[] packed = new int[limit]; - System.arraycopy(data, 0, packed, 0, limit); - return new MeshImpl(packed); - } - - @Override - public void clear() { - limit = 0; - emitter.baseIndex = limit; - emitter.clear(); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/MutableQuadViewImpl.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/MutableQuadViewImpl.java index 6bdca973a..cc3076a89 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/MutableQuadViewImpl.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/MutableQuadViewImpl.java @@ -16,7 +16,6 @@ package net.caffeinemc.mods.sodium.client.render.frapi.mesh; -import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.caffeinemc.mods.sodium.api.util.NormI8; import net.caffeinemc.mods.sodium.client.model.quad.BakedQuadView; import net.caffeinemc.mods.sodium.client.render.frapi.SodiumRenderer; @@ -25,7 +24,6 @@ import net.caffeinemc.mods.sodium.client.render.frapi.material.RenderMaterialImpl; import dev.vexor.radium.frapi.api.renderer.v1.material.RenderMaterial; import dev.vexor.radium.frapi.api.renderer.v1.mesh.QuadEmitter; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.QuadTransform; import dev.vexor.radium.frapi.api.renderer.v1.mesh.QuadView; import dev.vexor.radium.frapi.api.renderer.v1.model.SpriteFinder; import net.legacyfabric.fabric.api.util.TriState; @@ -50,22 +48,6 @@ public abstract class MutableQuadViewImpl extends QuadViewImpl implements QuadEm @Nullable private Sprite cachedSprite; - protected static final QuadTransform NO_TRANSFORM = q -> true; - - protected QuadTransform activeTransform = NO_TRANSFORM; - private final ObjectArrayList transformStack = new ObjectArrayList<>(); - private final QuadTransform stackTransform = q -> { - int i = transformStack.size() - 1; - - while (i >= 0) { - if (!transformStack.get(i--).transform(q)) { - return false; - } - } - - return true; - }; - /** Used for quick clearing of quad buffers. Implicitly has invalid geometry. */ static final int[] DEFAULT = EMPTY.clone(); @@ -86,11 +68,6 @@ protected void emitDirectly() { quad.tintIndex(-1); } - @Nullable - public Sprite cachedSprite() { - return cachedSprite; - } - public void cachedSprite(@Nullable Sprite sprite) { cachedSprite = sprite; } @@ -167,51 +144,6 @@ public MutableQuadViewImpl normal(int vertexIndex, float x, float y, float z) { return this; } - @Override - public void pushTransform(QuadTransform transform) { - if (transform == null) { - throw new NullPointerException("QuadTransform cannot be null!"); - } - - transformStack.push(transform); - - if (transformStack.size() == 1) { - activeTransform = transform; - } else if (transformStack.size() == 2) { - activeTransform = stackTransform; - } - } - - @Override - public void popTransform() { - transformStack.pop(); - - if (transformStack.isEmpty()) { - activeTransform = NO_TRANSFORM; - } else if (transformStack.size() == 1) { - activeTransform = transformStack.stream().findFirst().get(); - } - } - - /** - * Internal helper method. Copies face normals to vertex normals lacking one. - */ - public final void populateMissingNormals() { - final int normalFlags = this.normalFlags(); - - if (normalFlags == 0b1111) return; - - final int packedFaceNormal = packedFaceNormal(); - - for (int v = 0; v < 4; v++) { - if ((normalFlags & (1 << v)) == 0) { - data[baseIndex + v * VERTEX_STRIDE + VERTEX_NORMAL] = packedFaceNormal; - } - } - - normalFlags(0b1111); - } - @Override public final MutableQuadViewImpl cullFace(@Nullable Direction face) { data[baseIndex + HEADER_BITS] = EncodingFormat.cullFace(data[baseIndex + HEADER_BITS], face); @@ -243,28 +175,6 @@ public final MutableQuadViewImpl tag(int tag) { return this; } - @Override - public MutableQuadViewImpl copyFrom(QuadView quad) { - final QuadViewImpl q = (QuadViewImpl) quad; - - System.arraycopy(q.data, q.baseIndex, data, baseIndex, EncodingFormat.TOTAL_STRIDE); - nominalFace = q.nominalFace; - - isGeometryInvalid = q.isGeometryInvalid; - - if (!isGeometryInvalid) { - faceNormal.set(q.faceNormal); - } - - if (quad instanceof MutableQuadViewImpl mutableQuad) { - cachedSprite(mutableQuad.cachedSprite()); - } else { - cachedSprite(null); - } - - return this; - } - /** * Does the same work as {@link #fromVanilla(int[], int)}, but does not mark the geometry as invalid * and does not clear the cached sprite. @@ -330,9 +240,7 @@ public final MutableQuadViewImpl fromVanilla(BakedQuad quad, RenderMaterial mate * Apply transforms and then if transforms return true, emit the quad without clearing the underlying data. */ public final void transformAndEmit() { - if (activeTransform.transform(this)) { - emitDirectly(); - } + emitDirectly(); } @Override diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/QuadViewImpl.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/QuadViewImpl.java index 8bf6e9037..57cbbb4e7 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/QuadViewImpl.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/mesh/QuadViewImpl.java @@ -30,7 +30,6 @@ import net.minecraft.util.math.Direction; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.joml.Vector2f; import org.joml.Vector3f; import static net.caffeinemc.mods.sodium.client.render.frapi.mesh.EncodingFormat.*; @@ -112,17 +111,6 @@ public float posByIndex(int vertexIndex, int coordinateIndex) { return Float.intBitsToFloat(data[baseIndex + vertexIndex * VERTEX_STRIDE + VERTEX_X + coordinateIndex]); } - @Override - public Vector3f copyPos(int vertexIndex, @Nullable Vector3f target) { - if (target == null) { - target = new Vector3f(); - } - - final int index = baseIndex + vertexIndex * VERTEX_STRIDE + VERTEX_X; - target.set(Float.intBitsToFloat(data[index]), Float.intBitsToFloat(data[index + 1]), Float.intBitsToFloat(data[index + 2])); - return target; - } - @Override public int color(int vertexIndex) { return data[baseIndex + vertexIndex * VERTEX_STRIDE + VERTEX_COLOR]; @@ -138,17 +126,6 @@ public float v(int vertexIndex) { return Float.intBitsToFloat(data[baseIndex + vertexIndex * VERTEX_STRIDE + VERTEX_V]); } - @Override - public Vector2f copyUv(int vertexIndex, @Nullable Vector2f target) { - if (target == null) { - target = new Vector2f(); - } - - final int index = baseIndex + vertexIndex * VERTEX_STRIDE + VERTEX_U; - target.set(Float.intBitsToFloat(data[index]), Float.intBitsToFloat(data[index + 1])); - return target; - } - @Override public int lightmap(int vertexIndex) { return data[baseIndex + vertexIndex * VERTEX_STRIDE + VERTEX_LIGHTMAP]; @@ -163,58 +140,10 @@ public boolean hasNormal(int vertexIndex) { return (normalFlags() & (1 << vertexIndex)) != 0; } - /** True if any vertex normal has been set. */ - public boolean hasVertexNormals() { - return normalFlags() != 0; - } - - /** True if all vertex normals have been set. */ - public boolean hasAllVertexNormals() { - return (normalFlags() & 0b1111) == 0b1111; - } - protected final int normalIndex(int vertexIndex) { return baseIndex + vertexIndex * VERTEX_STRIDE + VERTEX_NORMAL; } - /** - * This method will only return a meaningful value if {@link #hasNormal} returns {@code true} for the same vertex index. - */ - public int packedNormal(int vertexIndex) { - return data[normalIndex(vertexIndex)]; - } - - @Override - public float normalX(int vertexIndex) { - return hasNormal(vertexIndex) ? NormI8.unpackX(data[normalIndex(vertexIndex)]) : Float.NaN; - } - - @Override - public float normalY(int vertexIndex) { - return hasNormal(vertexIndex) ? NormI8.unpackY(data[normalIndex(vertexIndex)]) : Float.NaN; - } - - @Override - public float normalZ(int vertexIndex) { - return hasNormal(vertexIndex) ? NormI8.unpackZ(data[normalIndex(vertexIndex)]) : Float.NaN; - } - - @Override - @Nullable - public Vector3f copyNormal(int vertexIndex, @Nullable Vector3f target) { - if (hasNormal(vertexIndex)) { - if (target == null) { - target = new Vector3f(); - } - - final int normal = data[normalIndex(vertexIndex)]; - NormI8.unpack(normal, target); - return target; - } else { - return null; - } - } - @Override @Nullable public final Direction cullFace() { @@ -265,21 +194,6 @@ public final int tag() { return data[baseIndex + HEADER_TAG]; } - @Override - public final void toVanilla(int[] target, int targetIndex) { - System.arraycopy(data, baseIndex + HEADER_STRIDE, target, targetIndex, QUAD_STRIDE); - - // The color is the fourth integer in each vertex. - // EncodingFormat.VERTEX_COLOR is not used because it also - // contains the header size; vanilla quads do not have a header. - int colorIndex = targetIndex + 3; - - for (int i = 0; i < 4; i++) { - target[colorIndex] = ColorHelper.toVanillaColor(target[colorIndex]); - colorIndex += QuadView.VANILLA_VERTEX_STRIDE; - } - } - // ModelQuadView method implementations below @Override diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/AbstractBlockRenderContext.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/AbstractBlockRenderContext.java index b64887f15..136b0feee 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/AbstractBlockRenderContext.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/AbstractBlockRenderContext.java @@ -9,9 +9,6 @@ import net.caffeinemc.mods.sodium.client.render.frapi.SodiumRenderer; import net.caffeinemc.mods.sodium.client.render.frapi.mesh.EncodingFormat; import net.caffeinemc.mods.sodium.client.render.frapi.mesh.MutableQuadViewImpl; -import net.caffeinemc.mods.sodium.client.services.PlatformBlockAccess; -import net.caffeinemc.mods.sodium.client.services.PlatformModelAccess; -import net.caffeinemc.mods.sodium.client.services.SodiumModelData; import net.caffeinemc.mods.sodium.client.world.LevelSlice; import dev.vexor.radium.frapi.api.renderer.v1.material.BlendMode; import dev.vexor.radium.frapi.api.renderer.v1.material.RenderMaterial; @@ -29,7 +26,6 @@ import net.minecraft.world.BlockView; import org.jetbrains.annotations.Nullable; -import java.util.List; import java.util.function.Predicate; import java.util.function.Supplier; @@ -102,10 +98,6 @@ public void emitDirectly() { */ protected RenderLayer type; - /** - * The current model's model data. - */ - protected SodiumModelData modelData; private final BlockOcclusionCache occlusionCache = new BlockOcclusionCache(); private boolean enableCulling = true; @@ -115,10 +107,6 @@ public void emitDirectly() { protected RandomSource random; protected long randomSeed; - protected final Supplier randomSupplier = () -> { - random.setSeed(randomSeed); - return random; - }; /** * Must be set by the subclass constructor. @@ -181,8 +169,9 @@ protected void prepareCulling(boolean enableCulling) { protected void prepareAoInfo(boolean modelAo) { this.useAmbientOcclusion = MinecraftClient.isAmbientOcclusionEnabled(); - // Ignore the incorrect IDEA warning here. - this.defaultLightMode = this.useAmbientOcclusion && modelAo && PlatformBlockAccess.getInstance().getLightEmission(state, level, pos) == 0 ? LightMode.SMOOTH : LightMode.FLAT; + // was .getLightLevel + var emission = state.getBlock().getBrightness(level, pos); + this.defaultLightMode = this.useAmbientOcclusion && modelAo && emission == 0 ? LightMode.SMOOTH : LightMode.FLAT; } protected void shadeQuad(MutableQuadViewImpl quad, LightMode lightMode, boolean emissive, ShadeMode shadeMode) { @@ -205,29 +194,19 @@ public void bufferDefaultModel(BakedModel model, @Nullable BlockState state, Pre continue; } - RandomSource random = this.randomSupplier.get(); - AmbientOcclusionMode ao = PlatformBlockAccess.getInstance().usesAmbientOcclusion(model, state, modelData, type, slice, pos); + var ao = MinecraftClient.isAmbientOcclusionEnabled() ? AmbientOcclusionMode.ENABLED : AmbientOcclusionMode.DISABLED; - final List quads = PlatformModelAccess.getInstance().getQuads(level, pos, model, state, cullFace, random, type, modelData); - final int count = quads.size(); + final var quads = cullFace == null ? model.getQuads() : model.getByDirection(cullFace); for (final BakedQuad q : quads) { editorQuad.fromVanilla(q, (type == RenderLayer.TRANSLUCENT) ? TRANSLUCENT_MATERIAL : STANDARD_MATERIALS[ao.ordinal()], cullFace); // Call processQuad instead of emit for efficiency // (avoid unnecessarily clearing data, trying to apply transforms, and performing cull check again) - editorQuad.transformAndEmit(); + this.processQuad(editorQuad); } } editorQuad.clear(); } - - public SodiumModelData getModelData() { - return modelData; - } - - public RenderLayer getRenderType() { - return type; - } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/NonTerrainBlockRenderContext.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/NonTerrainBlockRenderContext.java deleted file mode 100644 index b127b3237..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/NonTerrainBlockRenderContext.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.caffeinemc.mods.sodium.client.render.frapi.render; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.PoseStack; -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; -import dev.vexor.radium.compat.mojang.minecraft.BlockColors; -import dev.vexor.radium.compat.mojang.minecraft.random.RandomSource; -import net.caffeinemc.mods.sodium.api.util.ColorARGB; -import net.caffeinemc.mods.sodium.api.util.ColorMixer; -import net.caffeinemc.mods.sodium.client.model.light.LightMode; -import net.caffeinemc.mods.sodium.client.model.light.LightPipelineProvider; -import net.caffeinemc.mods.sodium.client.model.light.data.SingleBlockLightDataCache; -import net.caffeinemc.mods.sodium.client.render.frapi.mesh.MutableQuadViewImpl; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteFinderCache; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; -import net.caffeinemc.mods.sodium.client.services.SodiumModelData; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import dev.vexor.radium.frapi.api.renderer.v1.material.RenderMaterial; -import dev.vexor.radium.frapi.api.renderer.v1.material.ShadeMode; -import dev.vexor.radium.frapi.api.renderer.v1.model.FabricBakedModel; -import net.legacyfabric.fabric.api.util.TriState; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; -import org.joml.Matrix3f; -import org.joml.Matrix4f; - -public class NonTerrainBlockRenderContext extends AbstractBlockRenderContext { - private final BlockColors colorMap; - private final SingleBlockLightDataCache lightDataCache = new SingleBlockLightDataCache(); - - private VertexConsumer vertexConsumer; - private Matrix4f matPosition; - private boolean trustedNormals; - private Matrix3f matNormal; - private int overlay; - - public NonTerrainBlockRenderContext(BlockColors colorMap) { - this.colorMap = colorMap; - this.lighters = new LightPipelineProvider(this.lightDataCache); - } - - public void renderModel(BlockView blockView, BakedModel model, BlockState state, BlockPos pos, PoseStack poseStack, VertexConsumer buffer, boolean cull, RandomSource random, long seed, int overlay) { - this.level = blockView; - this.state = state; - this.pos = pos; - - this.random = random; - this.randomSeed = seed; - - this.vertexConsumer = buffer; - this.matPosition = poseStack.last().pose(); - this.trustedNormals = poseStack.last().trustedNormals; - this.matNormal = poseStack.last().normal(); - this.overlay = overlay; - this.type = state.getBlock().getRenderLayerType(); - this.modelData = SodiumModelData.EMPTY; - - this.lightDataCache.reset(pos, (LevelSlice) blockView); - this.prepareCulling(cull); - this.prepareAoInfo(model.useAmbientOcclusion()); - - ((FabricBakedModel) model).emitBlockQuads(getEmitter(), blockView, state, pos, this.randomSupplier, this::isFaceCulled); - - this.level = null; - this.type = null; - this.modelData = null; - this.lightDataCache.release(); - this.random = null; - this.vertexConsumer = null; - } - - @Override - protected void processQuad(MutableQuadViewImpl quad) { - final RenderMaterial mat = quad.material(); - final TriState aoMode = mat.ambientOcclusion(); - final ShadeMode shadeMode = mat.shadeMode(); - final LightMode lightMode; - if (aoMode == TriState.DEFAULT) { - lightMode = this.defaultLightMode; - } else { - lightMode = this.useAmbientOcclusion && aoMode.get() ? LightMode.SMOOTH : LightMode.FLAT; - } - final boolean emissive = mat.emissive(); - - tintQuad(quad); - shadeQuad(quad, lightMode, emissive, shadeMode); - bufferQuad(quad); - } - - private void tintQuad(MutableQuadViewImpl quad) { - if (quad.tintIndex() != -1) { - final int blockColor = this.colorMap.getColor(this.state); - - for (int i = 0; i < 4; i++) { - quad.color(i, ColorMixer.mulComponentWise(blockColor, quad.color(i))); - } - } - } - - @Override - protected void shadeQuad(MutableQuadViewImpl quad, LightMode lightMode, boolean emissive, ShadeMode shadeMode) { - super.shadeQuad(quad, lightMode, emissive, shadeMode); - - float[] brightnesses = this.quadLightData.br; - - for (int i = 0; i < 4; i++) { - quad.color(i, ColorARGB.mulRGB(quad.color(i), brightnesses[i])); - } - } - - private void bufferQuad(MutableQuadViewImpl quad) { - QuadEncoder.writeQuadVertices(quad, vertexConsumer, overlay, matPosition, trustedNormals, matNormal); - SpriteUtil.markSpriteActive(quad.sprite(SpriteFinderCache.forBlockAtlas())); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/QuadEncoder.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/QuadEncoder.java deleted file mode 100644 index bd9b6abd5..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/frapi/render/QuadEncoder.java +++ /dev/null @@ -1,140 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.frapi.render; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; -import net.caffeinemc.mods.sodium.client.render.frapi.mesh.MutableQuadViewImpl; -import net.caffeinemc.mods.sodium.client.render.vertex.VertexConsumerUtils; -import net.caffeinemc.mods.sodium.api.math.MatrixHelper; -import net.caffeinemc.mods.sodium.api.util.ColorARGB; -import net.caffeinemc.mods.sodium.api.util.NormI8; -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.caffeinemc.mods.sodium.api.vertex.format.common.EntityVertex; -import org.joml.Math; -import org.joml.Matrix3f; -import org.joml.Matrix4f; -import org.joml.Vector3f; -import org.lwjgl.system.MemoryStack; - -public class QuadEncoder { - public static void writeQuadVertices(MutableQuadViewImpl quad, VertexConsumer vertexConsumer, int overlay, Matrix4f matPosition, boolean trustedNormals, Matrix3f matNormal) { - VertexBufferWriter writer = VertexConsumerUtils.convertOrLog(vertexConsumer); - - if (writer != null) { - writeQuadVertices(quad, writer, overlay, matPosition, trustedNormals, matNormal); - } else { - writeQuadVerticesSlow(quad, vertexConsumer, overlay, matPosition, trustedNormals, matNormal); - } - } - - public static void writeQuadVertices(MutableQuadViewImpl quad, VertexBufferWriter writer, int overlay, Matrix4f matPosition, boolean trustedNormals, Matrix3f matNormal) { - try (MemoryStack stack = MemoryStack.stackPush()) { - long buffer = stack.nmalloc(4 * EntityVertex.STRIDE); - long ptr = buffer; - - final boolean useNormals = quad.hasVertexNormals(); - - // The packed transformed normal vector - int normal = 0; - - if (useNormals) { - quad.populateMissingNormals(); - } else { - normal = MatrixHelper.transformNormal(matNormal, trustedNormals, quad.packedFaceNormal()); - } - - for (int i = 0; i < 4; i++) { - // The position vector - float x = quad.x(i); - float y = quad.y(i); - float z = quad.z(i); - - // The transformed position vector - float xt = MatrixHelper.transformPositionX(matPosition, x, y, z); - float yt = MatrixHelper.transformPositionY(matPosition, x, y, z); - float zt = MatrixHelper.transformPositionZ(matPosition, x, y, z); - - if (useNormals) { - normal = MatrixHelper.transformNormal(matNormal, trustedNormals, quad.packedNormal(i)); - } - - EntityVertex.write(ptr, xt, yt, zt, ColorARGB.toABGR(quad.color(i)), quad.u(i), quad.v(i), overlay, quad.lightmap(i), normal); - ptr += EntityVertex.STRIDE; - } - - writer.push(stack, buffer, 4, EntityVertex.FORMAT); - } - } - - private static void writeQuadVerticesSlow(MutableQuadViewImpl quad, VertexConsumer vertexConsumer, int overlay, Matrix4f matPosition, boolean trustedNormals, Matrix3f matNormal) { - final boolean useNormals = quad.hasVertexNormals(); - - // The transformed normal vector - float nxt = 0; - float nyt = 0; - float nzt = 0; - - if (useNormals) { - quad.populateMissingNormals(); - } else { - Vector3f faceNormal = quad.faceNormal(); - - // The normal vector - float nx = faceNormal.x; - float ny = faceNormal.y; - float nz = faceNormal.z; - - nxt = MatrixHelper.transformNormalX(matNormal, nx, ny, nz); - nyt = MatrixHelper.transformNormalY(matNormal, nx, ny, nz); - nzt = MatrixHelper.transformNormalZ(matNormal, nx, ny, nz); - - if (!trustedNormals) { - float scalar = Math.invsqrt(Math.fma(nxt, nxt, Math.fma(nyt, nyt, nzt * nzt))); - - nxt *= scalar; - nyt *= scalar; - nzt *= scalar; - } - } - - for (int i = 0; i < 4; i++) { - // The position vector - float x = quad.x(i); - float y = quad.y(i); - float z = quad.z(i); - - // The transformed position vector - float xt = MatrixHelper.transformPositionX(matPosition, x, y, z); - float yt = MatrixHelper.transformPositionY(matPosition, x, y, z); - float zt = MatrixHelper.transformPositionZ(matPosition, x, y, z); - - vertexConsumer.addVertex(xt, yt, zt); - - vertexConsumer.setColor(quad.color(i)); - vertexConsumer.setUv(quad.u(i), quad.v(i)); - vertexConsumer.setOverlay(overlay); - vertexConsumer.setLight(quad.lightmap(i)); - - if (useNormals) { - int packedNormal = quad.packedNormal(i); - - // The normal vector - float nx = NormI8.unpackX(packedNormal); - float ny = NormI8.unpackY(packedNormal); - float nz = NormI8.unpackZ(packedNormal); - - nxt = MatrixHelper.transformNormalX(matNormal, nx, ny, nz); - nyt = MatrixHelper.transformNormalY(matNormal, nx, ny, nz); - nzt = MatrixHelper.transformNormalZ(matNormal, nx, ny, nz); - - if (!trustedNormals) { - float scalar = Math.invsqrt(Math.fma(nxt, nxt, Math.fma(nyt, nyt, nzt * nzt))); - - nxt *= scalar; - nyt *= scalar; - nzt *= scalar; - } - } - - vertexConsumer.setNormal(nxt, nyt, nzt); - } - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/model/BakedModelEncoder.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/model/BakedModelEncoder.java deleted file mode 100644 index dce2395f0..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/model/BakedModelEncoder.java +++ /dev/null @@ -1,130 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.immediate.model; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.PoseStack; -import net.caffeinemc.mods.sodium.api.util.ColorMixer; -import net.caffeinemc.mods.sodium.client.model.quad.ModelQuadView; -import net.caffeinemc.mods.sodium.api.math.MatrixHelper; -import net.caffeinemc.mods.sodium.api.util.ColorABGR; -import net.caffeinemc.mods.sodium.api.util.ColorU8; -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.caffeinemc.mods.sodium.api.vertex.format.common.EntityVertex; -import net.caffeinemc.mods.sodium.client.services.PlatformRuntimeInformation; -import org.joml.Matrix3f; -import org.joml.Matrix4f; -import org.lwjgl.system.MemoryStack; - -public class BakedModelEncoder { - private static int mergeLighting(int stored, int calculated) { - if (stored == 0) return calculated; - - int blockLight = Math.max(stored & 0xFFFF, calculated & 0xFFFF); - int skyLight = Math.max((stored >> 16) & 0xFFFF, (calculated >> 16) & 0xFFFF); - return blockLight | (skyLight << 16); - } - - private static final boolean MULTIPLY_ALPHA = PlatformRuntimeInformation.getInstance().usesAlphaMultiplication(); - - public static void writeQuadVertices(VertexBufferWriter writer, PoseStack.Pose matrices, ModelQuadView quad, int color, int light, int overlay, boolean colorize) { - Matrix3f matNormal = matrices.normal(); - Matrix4f matPosition = matrices.pose(); - - try (MemoryStack stack = MemoryStack.stackPush()) { - long buffer = stack.nmalloc(4 * EntityVertex.STRIDE); - long ptr = buffer; - - for (int i = 0; i < 4; i++) { - // The position vector - float x = quad.getX(i); - float y = quad.getY(i); - float z = quad.getZ(i); - - int newLight = mergeLighting(quad.getMaxLightQuad(i), light); - - int newColor = color; - - if (colorize) { - newColor = ColorMixer.mulComponentWise(newColor, quad.getColor(i)); - } - - // The packed transformed normal vector - int normal = MatrixHelper.transformNormal(matNormal, matrices.trustedNormals, quad.getAccurateNormal(i)); - - // The transformed position vector - float xt = MatrixHelper.transformPositionX(matPosition, x, y, z); - float yt = MatrixHelper.transformPositionY(matPosition, x, y, z); - float zt = MatrixHelper.transformPositionZ(matPosition, x, y, z); - - EntityVertex.write(ptr, xt, yt, zt, newColor, quad.getTexU(i), quad.getTexV(i), overlay, newLight, normal); - ptr += EntityVertex.STRIDE; - } - - writer.push(stack, buffer, 4, EntityVertex.FORMAT); - } - } - - public static void writeQuadVertices(VertexBufferWriter writer, PoseStack.Pose matrices, ModelQuadView quad, float r, float g, float b, float a, float[] brightnessTable, boolean colorize, int[] light, int overlay) { - Matrix3f matNormal = matrices.normal(); - Matrix4f matPosition = matrices.pose(); - - try (MemoryStack stack = MemoryStack.stackPush()) { - long buffer = stack.nmalloc(4 * EntityVertex.STRIDE); - long ptr = buffer; - - for (int i = 0; i < 4; i++) { - // The position vector - float x = quad.getX(i); - float y = quad.getY(i); - float z = quad.getZ(i); - - // The transformed position vector - float xt = MatrixHelper.transformPositionX(matPosition, x, y, z); - float yt = MatrixHelper.transformPositionY(matPosition, x, y, z); - float zt = MatrixHelper.transformPositionZ(matPosition, x, y, z); - - float fR; - float fG; - float fB; - float fA; - - var normal = MatrixHelper.transformNormal(matNormal, matrices.trustedNormals, quad.getAccurateNormal(i)); - - float brightness = brightnessTable[i]; - - if (colorize) { - int color = quad.getColor(i); - - float oR = ColorU8.byteToNormalizedFloat(ColorABGR.unpackRed(color)); - float oG = ColorU8.byteToNormalizedFloat(ColorABGR.unpackGreen(color)); - float oB = ColorU8.byteToNormalizedFloat(ColorABGR.unpackBlue(color)); - - fR = oR * brightness * r; - fG = oG * brightness * g; - fB = oB * brightness * b; - - if (MULTIPLY_ALPHA) { - float oA = ColorU8.byteToNormalizedFloat(ColorABGR.unpackAlpha(color)); - fA = oA * a; - } else { - fA = a; - } - } else { - fR = brightness * r; - fG = brightness * g; - fB = brightness * b; - fA = a; - } - - int color = ColorABGR.pack(fR, fG, fB, fA); - - EntityVertex.write(ptr, xt, yt, zt, color, quad.getTexU(i), quad.getTexV(i), overlay, light[i], normal); - ptr += EntityVertex.STRIDE; - } - - writer.push(stack, buffer, 4, EntityVertex.FORMAT); - } - } - - public static boolean shouldMultiplyAlpha() { - return MULTIPLY_ALPHA; - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/model/EntityRenderer.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/model/EntityRenderer.java deleted file mode 100644 index 0c8840b63..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/model/EntityRenderer.java +++ /dev/null @@ -1,175 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.immediate.model; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.PoseStack; -import net.caffeinemc.mods.sodium.api.math.MatrixHelper; -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.caffeinemc.mods.sodium.api.vertex.format.common.EntityVertex; -import net.minecraft.util.math.Direction; -import org.joml.Matrix3f; -import org.joml.Matrix4f; -import org.joml.Vector2f; -import org.joml.Vector3f; -import org.lwjgl.system.MemoryStack; - -import static net.caffeinemc.mods.sodium.client.render.immediate.model.ModelCuboid.*; - -public class EntityRenderer { - private static final int NUM_CUBE_VERTICES = 8; - private static final int NUM_CUBE_FACES = 6; - private static final int NUM_FACE_VERTICES = 4; - - private static final int - VERTEX_X1_Y1_Z1 = 0, - VERTEX_X2_Y1_Z1 = 1, - VERTEX_X2_Y2_Z1 = 2, - VERTEX_X1_Y2_Z1 = 3, - VERTEX_X1_Y1_Z2 = 4, - VERTEX_X2_Y1_Z2 = 5, - VERTEX_X2_Y2_Z2 = 6, - VERTEX_X1_Y2_Z2 = 7; - - private static final Matrix3f lastMatrix = new Matrix3f(); - - private static final int VERTEX_BUFFER_BYTES = NUM_CUBE_FACES * NUM_FACE_VERTICES * EntityVertex.STRIDE; - - private static final Vector3f[] CUBE_CORNERS = new Vector3f[NUM_CUBE_VERTICES]; - private static final int[][] CUBE_VERTICES = new int[NUM_CUBE_FACES][]; - - private static final Vector3f[][] VERTEX_POSITIONS = new Vector3f[NUM_CUBE_FACES][NUM_FACE_VERTICES]; - private static final Vector3f[][] VERTEX_POSITIONS_MIRRORED = new Vector3f[NUM_CUBE_FACES][NUM_FACE_VERTICES]; - - private static final Vector2f[][] VERTEX_TEXTURES = new Vector2f[NUM_CUBE_FACES][NUM_FACE_VERTICES]; - private static final Vector2f[][] VERTEX_TEXTURES_MIRRORED = new Vector2f[NUM_CUBE_FACES][NUM_FACE_VERTICES]; - - private static final int[] CUBE_NORMALS = new int[NUM_CUBE_FACES]; - private static final int[] CUBE_NORMALS_MIRRORED = new int[NUM_CUBE_FACES]; - - static { - CUBE_VERTICES[FACE_NEG_Y] = new int[] { VERTEX_X2_Y1_Z2, VERTEX_X1_Y1_Z2, VERTEX_X1_Y1_Z1, VERTEX_X2_Y1_Z1 }; - CUBE_VERTICES[FACE_POS_Y] = new int[] { VERTEX_X2_Y2_Z1, VERTEX_X1_Y2_Z1, VERTEX_X1_Y2_Z2, VERTEX_X2_Y2_Z2 }; - CUBE_VERTICES[FACE_NEG_Z] = new int[] { VERTEX_X2_Y1_Z1, VERTEX_X1_Y1_Z1, VERTEX_X1_Y2_Z1, VERTEX_X2_Y2_Z1 }; - CUBE_VERTICES[FACE_POS_Z] = new int[] { VERTEX_X1_Y1_Z2, VERTEX_X2_Y1_Z2, VERTEX_X2_Y2_Z2, VERTEX_X1_Y2_Z2 }; - CUBE_VERTICES[FACE_NEG_X] = new int[] { VERTEX_X2_Y1_Z2, VERTEX_X2_Y1_Z1, VERTEX_X2_Y2_Z1, VERTEX_X2_Y2_Z2 }; - CUBE_VERTICES[FACE_POS_X] = new int[] { VERTEX_X1_Y1_Z1, VERTEX_X1_Y1_Z2, VERTEX_X1_Y2_Z2, VERTEX_X1_Y2_Z1 }; - - for (int cornerIndex = 0; cornerIndex < NUM_CUBE_VERTICES; cornerIndex++) { - CUBE_CORNERS[cornerIndex] = new Vector3f(); - } - - for (int quadIndex = 0; quadIndex < NUM_CUBE_FACES; quadIndex++) { - for (int vertexIndex = 0; vertexIndex < NUM_FACE_VERTICES; vertexIndex++) { - VERTEX_TEXTURES[quadIndex][vertexIndex] = new Vector2f(); - VERTEX_POSITIONS[quadIndex][vertexIndex] = CUBE_CORNERS[CUBE_VERTICES[quadIndex][vertexIndex]]; - } - } - - for (int quadIndex = 0; quadIndex < NUM_CUBE_FACES; quadIndex++) { - for (int vertexIndex = 0; vertexIndex < NUM_FACE_VERTICES; vertexIndex++) { - VERTEX_TEXTURES_MIRRORED[quadIndex][vertexIndex] = VERTEX_TEXTURES[quadIndex][3 - vertexIndex]; - VERTEX_POSITIONS_MIRRORED[quadIndex][vertexIndex] = VERTEX_POSITIONS[quadIndex][3 - vertexIndex]; - } - } - } - - public static void renderCuboid(PoseStack.Pose matrices, VertexBufferWriter writer, ModelCuboid cuboid, int light, int overlay, int color) { - prepareNormalsIfChanged(matrices); - prepareVertices(matrices, cuboid); - - try (MemoryStack stack = MemoryStack.stackPush()) { - final var vertexBuffer = stack.nmalloc(16, VERTEX_BUFFER_BYTES); - final var vertexCount = emitQuads(vertexBuffer, cuboid, color, overlay, light); - - if (vertexCount > 0) { - writer.push(stack, vertexBuffer, vertexCount, EntityVertex.FORMAT); - } - } - } - - private static int emitQuads(final long buffer, ModelCuboid cuboid, int color, int overlay, int light) { - final var positions = cuboid.mirror ? VERTEX_POSITIONS_MIRRORED : VERTEX_POSITIONS; - final var textures = cuboid.mirror ? VERTEX_TEXTURES_MIRRORED : VERTEX_TEXTURES; - final var normals = cuboid.mirror ? CUBE_NORMALS_MIRRORED : CUBE_NORMALS; - - var vertexCount = 0; - - long ptr = buffer; - - for (int quadIndex = 0; quadIndex < NUM_CUBE_FACES; quadIndex++) { - if (!cuboid.shouldDrawFace(quadIndex)) { - continue; - } - - emitVertex(ptr, positions[quadIndex][0], color, textures[quadIndex][0], overlay, light, normals[quadIndex]); - ptr += EntityVertex.STRIDE; - - emitVertex(ptr, positions[quadIndex][1], color, textures[quadIndex][1], overlay, light, normals[quadIndex]); - ptr += EntityVertex.STRIDE; - - emitVertex(ptr, positions[quadIndex][2], color, textures[quadIndex][2], overlay, light, normals[quadIndex]); - ptr += EntityVertex.STRIDE; - - emitVertex(ptr, positions[quadIndex][3], color, textures[quadIndex][3], overlay, light, normals[quadIndex]); - ptr += EntityVertex.STRIDE; - - vertexCount += 4; - } - - return vertexCount; - } - - private static void emitVertex(long ptr, Vector3f pos, int color, Vector2f tex, int overlay, int light, int normal) { - EntityVertex.write(ptr, pos.x, pos.y, pos.z, color, tex.x, tex.y, overlay, light, normal); - } - - private static void prepareVertices(PoseStack.Pose matrices, ModelCuboid cuboid) { - buildVertexPosition(CUBE_CORNERS[VERTEX_X1_Y1_Z1], cuboid.x1, cuboid.y1, cuboid.z1, matrices.pose()); - buildVertexPosition(CUBE_CORNERS[VERTEX_X2_Y1_Z1], cuboid.x2, cuboid.y1, cuboid.z1, matrices.pose()); - buildVertexPosition(CUBE_CORNERS[VERTEX_X2_Y2_Z1], cuboid.x2, cuboid.y2, cuboid.z1, matrices.pose()); - buildVertexPosition(CUBE_CORNERS[VERTEX_X1_Y2_Z1], cuboid.x1, cuboid.y2, cuboid.z1, matrices.pose()); - buildVertexPosition(CUBE_CORNERS[VERTEX_X1_Y1_Z2], cuboid.x1, cuboid.y1, cuboid.z2, matrices.pose()); - buildVertexPosition(CUBE_CORNERS[VERTEX_X2_Y1_Z2], cuboid.x2, cuboid.y1, cuboid.z2, matrices.pose()); - buildVertexPosition(CUBE_CORNERS[VERTEX_X2_Y2_Z2], cuboid.x2, cuboid.y2, cuboid.z2, matrices.pose()); - buildVertexPosition(CUBE_CORNERS[VERTEX_X1_Y2_Z2], cuboid.x1, cuboid.y2, cuboid.z2, matrices.pose()); - - buildVertexTexCoord(VERTEX_TEXTURES[FACE_NEG_Y], cuboid.u1, cuboid.v0, cuboid.u2, cuboid.v1); - buildVertexTexCoord(VERTEX_TEXTURES[FACE_POS_Y], cuboid.u2, cuboid.v1, cuboid.u3, cuboid.v0); - buildVertexTexCoord(VERTEX_TEXTURES[FACE_NEG_Z], cuboid.u1, cuboid.v1, cuboid.u2, cuboid.v2); - buildVertexTexCoord(VERTEX_TEXTURES[FACE_POS_Z], cuboid.u4, cuboid.v1, cuboid.u5, cuboid.v2); - buildVertexTexCoord(VERTEX_TEXTURES[FACE_NEG_X], cuboid.u2, cuboid.v1, cuboid.u4, cuboid.v2); - buildVertexTexCoord(VERTEX_TEXTURES[FACE_POS_X], cuboid.u0, cuboid.v1, cuboid.u1, cuboid.v2); - } - - public static void prepareNormalsIfChanged(PoseStack.Pose matrices) { - if (!matrices.normal().equals(lastMatrix)) { - lastMatrix.set(matrices.normal()); - - CUBE_NORMALS[FACE_NEG_Y] = MatrixHelper.transformNormal(matrices.normal(), matrices.trustedNormals, Direction.DOWN); - CUBE_NORMALS[FACE_POS_Y] = MatrixHelper.transformNormal(matrices.normal(), matrices.trustedNormals, Direction.UP); - CUBE_NORMALS[FACE_NEG_Z] = MatrixHelper.transformNormal(matrices.normal(), matrices.trustedNormals, Direction.NORTH); - CUBE_NORMALS[FACE_POS_Z] = MatrixHelper.transformNormal(matrices.normal(), matrices.trustedNormals, Direction.SOUTH); - CUBE_NORMALS[FACE_POS_X] = MatrixHelper.transformNormal(matrices.normal(), matrices.trustedNormals, Direction.WEST); - CUBE_NORMALS[FACE_NEG_X] = MatrixHelper.transformNormal(matrices.normal(), matrices.trustedNormals, Direction.EAST); - - // When mirroring is used, the normals for EAST and WEST are swapped. - CUBE_NORMALS_MIRRORED[FACE_NEG_Y] = CUBE_NORMALS[FACE_NEG_Y]; - CUBE_NORMALS_MIRRORED[FACE_POS_Y] = CUBE_NORMALS[FACE_POS_Y]; - CUBE_NORMALS_MIRRORED[FACE_NEG_Z] = CUBE_NORMALS[FACE_NEG_Z]; - CUBE_NORMALS_MIRRORED[FACE_POS_Z] = CUBE_NORMALS[FACE_POS_Z]; - CUBE_NORMALS_MIRRORED[FACE_POS_X] = CUBE_NORMALS[FACE_NEG_X]; // mirrored - CUBE_NORMALS_MIRRORED[FACE_NEG_X] = CUBE_NORMALS[FACE_POS_X]; // mirrored - } - } - - private static void buildVertexPosition(Vector3f vector, float x, float y, float z, Matrix4f matrix) { - vector.x = MatrixHelper.transformPositionX(matrix, x, y, z); - vector.y = MatrixHelper.transformPositionY(matrix, x, y, z); - vector.z = MatrixHelper.transformPositionZ(matrix, x, y, z); - } - - private static void buildVertexTexCoord(Vector2f[] uvs, float u1, float v1, float u2, float v2) { - uvs[0].set(u2, v1); - uvs[1].set(u1, v1); - uvs[2].set(u1, v2); - uvs[3].set(u2, v2); - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/model/ModelCuboid.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/model/ModelCuboid.java deleted file mode 100644 index 2336a842e..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/immediate/model/ModelCuboid.java +++ /dev/null @@ -1,100 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.immediate.model; - -import java.util.Set; -import net.minecraft.util.math.Direction; -import org.jetbrains.annotations.NotNull; - -public class ModelCuboid { - // The ordering needs to be the same as Minecraft, otherwise some core shader replacements - // will be unable to identify the facing. - public static final int - FACE_NEG_Y = 0, // DOWN - FACE_POS_Y = 1, // UP - FACE_NEG_X = 2, // WEST - FACE_NEG_Z = 3, // NORTH - FACE_POS_X = 4, // EAST - FACE_POS_Z = 5; // SOUTH - - public final float x1, y1, z1; - public final float x2, y2, z2; - - public final float u0, u1, u2, u3, u4, u5; - public final float v0, v1, v2; - - private final int cullBitmask; - - public final boolean mirror; - - public ModelCuboid(int u, int v, - float x1, float y1, float z1, - float sizeX, float sizeY, float sizeZ, - float extraX, float extraY, float extraZ, - boolean mirror, - float textureWidth, float textureHeight, - Set renderDirections) { - float x2 = x1 + sizeX; - float y2 = y1 + sizeY; - float z2 = z1 + sizeZ; - - x1 -= extraX; - y1 -= extraY; - z1 -= extraZ; - - x2 += extraX; - y2 += extraY; - z2 += extraZ; - - if (mirror) { - float tmp = x2; - x2 = x1; - x1 = tmp; - } - - this.x1 = x1 / 16.0f; - this.y1 = y1 / 16.0f; - this.z1 = z1 / 16.0f; - - this.x2 = x2 / 16.0f; - this.y2 = y2 / 16.0f; - this.z2 = z2 / 16.0f; - - var scaleU = 1.0f / textureWidth; - var scaleV = 1.0f / textureHeight; - - this.u0 = scaleU * (u); - this.u1 = scaleU * (u + sizeZ); - this.u2 = scaleU * (u + sizeZ + sizeX); - this.u3 = scaleU * (u + sizeZ + sizeX + sizeX); - this.u4 = scaleU * (u + sizeZ + sizeX + sizeZ); - this.u5 = scaleU * (u + sizeZ + sizeX + sizeZ + sizeX); - - this.v0 = scaleV * (v); - this.v1 = scaleV * (v + sizeZ); - this.v2 = scaleV * (v + sizeZ + sizeY); - - this.mirror = mirror; - - int cullBitmask = 0; - - for (var direction : renderDirections) { - cullBitmask |= 1 << getFaceIndex(direction); - } - - this.cullBitmask = cullBitmask; - } - - public boolean shouldDrawFace(int faceIndex) { - return (this.cullBitmask & (1 << faceIndex)) != 0; - } - - public static int getFaceIndex(@NotNull Direction dir) { - return switch (dir) { - case DOWN -> FACE_NEG_Y; - case UP -> FACE_POS_Y; - case NORTH -> FACE_NEG_Z; - case SOUTH -> FACE_POS_Z; - case WEST -> FACE_NEG_X; - case EAST -> FACE_POS_X; - }; - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteFinderCache.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteFinderCache.java index 05df48ce8..f143b17f5 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteFinderCache.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/texture/SpriteFinderCache.java @@ -1,6 +1,7 @@ package net.caffeinemc.mods.sodium.client.render.texture; import dev.vexor.radium.frapi.api.renderer.v1.model.SpriteFinder; +import dev.vexor.radium.frapi.impl.renderer.SpriteFinderImpl; import net.minecraft.client.MinecraftClient; /** @@ -13,7 +14,7 @@ public class SpriteFinderCache { public static SpriteFinder forBlockAtlas() { if (blockAtlasSpriteFinder == null) { - blockAtlasSpriteFinder = SpriteFinder.get(MinecraftClient.getInstance().getSpriteAtlasTexture()); + blockAtlasSpriteFinder = SpriteFinderImpl.get(MinecraftClient.getInstance().getSpriteAtlasTexture()); } return blockAtlasSpriteFinder; diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/util/RenderAsserts.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/util/RenderAsserts.java deleted file mode 100644 index 428f76640..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/util/RenderAsserts.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.util; - -public class RenderAsserts { - /** - * Checks that the thread calling this function is the main render thread. This is useful for ensuring that OpenGL - * APIs are not accessed from off-thread incorrectly, which is known to cause severe issues. - * - * @throws IllegalStateException If the current thread is not the main render thread - * @return Always true, since an exception is thrown otherwise - */ - public static boolean validateCurrentThread() { - // Minecraft 1.8.9 doesn't have multi threading, so there is nothing to validate. - - return true; - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexConsumerTracker.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexConsumerTracker.java deleted file mode 100644 index 2934d8a26..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexConsumerTracker.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.vertex; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; -import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; -import it.unimi.dsi.fastutil.objects.ReferenceSet; -import it.unimi.dsi.fastutil.objects.ReferenceSets; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -public class VertexConsumerTracker { - private static final Logger LOGGER = LogManager.getLogger("Sodium-VertexConsumerTracker"); - private static final ReferenceSet> BAD_CONSUMERS = ReferenceSets.synchronize(new ReferenceOpenHashSet<>()); - - public static void logBadConsumer(VertexConsumer consumer) { - if (BAD_CONSUMERS.add(consumer.getClass())) { - LOGGER.warn("Class {} does not support optimized vertex writing code paths, which may cause reduced rendering performance", - consumer.getClass().getName()); - } - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexConsumerUtils.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexConsumerUtils.java deleted file mode 100644 index df41819d2..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexConsumerUtils.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.vertex; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; - -public class VertexConsumerUtils { - /** - * Attempt to convert a {@link VertexConsumer} into a {@link VertexBufferWriter}. If this fails, return null - * and log a message. - * @param consumer the consumer to convert - * @return a {@link VertexBufferWriter}, or null if the consumer does not support this - */ - public static VertexBufferWriter convertOrLog(VertexConsumer consumer) { - VertexBufferWriter writer = VertexBufferWriter.tryOf(consumer); - - if (writer == null) { - VertexConsumerTracker.logBadConsumer(consumer); - } - - return writer; - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexFormatRegistryImpl.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexFormatRegistryImpl.java deleted file mode 100644 index dc8f18366..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/VertexFormatRegistryImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.vertex; - -import net.minecraft.client.render.VertexFormat; -import it.unimi.dsi.fastutil.objects.Reference2IntMap; -import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; -import net.caffeinemc.mods.sodium.api.vertex.format.VertexFormatRegistry; - -import java.util.concurrent.locks.StampedLock; - -public class VertexFormatRegistryImpl implements VertexFormatRegistry { - private static final int ABSENT_INDEX = -1; - - private final Reference2IntMap descriptions = new Reference2IntOpenHashMap<>(); - private final StampedLock lock = new StampedLock(); - - public VertexFormatRegistryImpl() { - this.descriptions.defaultReturnValue(ABSENT_INDEX); - } - - @Override - public int allocateGlobalId(VertexFormat format) { - int id; - - { - var stamp = this.lock.readLock(); - - try { - id = this.descriptions.getInt(format); - } finally { - this.lock.unlockRead(stamp); - } - } - - if (id == ABSENT_INDEX) { - var stamp = this.lock.writeLock(); - - try { - this.descriptions.put(format, id = this.descriptions.size()); - } finally { - this.lock.unlockWrite(stamp); - } - } - - return id; - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/buffer/BufferBuilderExtension.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/buffer/BufferBuilderExtension.java deleted file mode 100644 index 40af81b01..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/vertex/buffer/BufferBuilderExtension.java +++ /dev/null @@ -1,7 +0,0 @@ -package net.caffeinemc.mods.sodium.client.render.vertex.buffer; - -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; - -public interface BufferBuilderExtension extends VertexBufferWriter { - void sodium$duplicateVertex(); -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/viewport/frustum/SimpleFrustum.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/viewport/frustum/SimpleFrustum.java index ff75adf84..0dd1b3d22 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/viewport/frustum/SimpleFrustum.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/viewport/frustum/SimpleFrustum.java @@ -11,6 +11,6 @@ public SimpleFrustum(CullingCameraView frustumIntersection) { @Override public boolean testAab(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) { - return true; + return frustum.isBoxInFrustum(minX, minY, minZ, maxX, maxY, maxZ); } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/FluidRendererFactory.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/services/FluidRendererFactory.java deleted file mode 100644 index 0bc87d2af..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/FluidRendererFactory.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.caffeinemc.mods.sodium.client.services; - -import net.caffeinemc.mods.sodium.client.model.color.ColorProviderRegistry; -import net.caffeinemc.mods.sodium.client.model.light.LightPipelineProvider; -import net.caffeinemc.mods.sodium.client.model.quad.blender.BlendedColorProvider; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.FluidRenderer; -import net.minecraft.block.BlockState; - -public interface FluidRendererFactory { - FluidRendererFactory INSTANCE = Services.load(FluidRendererFactory.class); - - static FluidRendererFactory getInstance() { - return INSTANCE; - } - - /** - * Creates a new platform dependent fluid renderer. - * @param colorRegistry The current color registry. - * @param lightPipelineProvider The current {@code LightPipelineProvider}. - * @return A new fluid renderer. - */ - FluidRenderer createPlatformFluidRenderer(ColorProviderRegistry colorRegistry, LightPipelineProvider lightPipelineProvider); - - BlendedColorProvider getWaterColorProvider(); - - BlendedColorProvider getWaterBlockColorProvider(); -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformBlockAccess.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformBlockAccess.java deleted file mode 100644 index d8d44e957..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformBlockAccess.java +++ /dev/null @@ -1,94 +0,0 @@ -package net.caffeinemc.mods.sodium.client.services; - -import net.caffeinemc.mods.sodium.client.model.quad.ModelQuadView; -import net.caffeinemc.mods.sodium.client.render.frapi.render.AmbientOcclusionMode; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import net.minecraft.block.BlockState; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.entity.player.ClientPlayerEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.BlockView; - -public interface PlatformBlockAccess { - PlatformBlockAccess INSTANCE = Services.load(PlatformBlockAccess.class); - - static PlatformBlockAccess getInstance() { - return INSTANCE; - } - - /** - * Gets the light emission of the current block. - * @param state The current block - * @param level The current level slice - * @param pos The block position - * @return The light emission of the current block (default 0) - */ - int getLightEmission(BlockState state, BlockView level, BlockPos pos); - - /** - * Checks if the block should stop drawing a specific side based on the adjacent block. - * @param level The level slice. - * @param selfState The block currently being drawn. - * @param otherState The adjacent block. - * @param selfPos The current block position. - * @param otherPos The other block position. - * @param facing The direction between the two blocks. - * @return If the block's face should be skipped. - */ - boolean shouldSkipRender(BlockView level, BlockState selfState, BlockState otherState, BlockPos selfPos, BlockPos otherPos, Direction facing); - - /** - * Returns if the fluid should render fluid overlays if a block is adjacent to it. - * @param block The block adjacent to the fluid being rendered - * @param level The level slice - * @param pos The position of the adjacent block - * @param fluidState The fluid - * @return True if the fluid should render an overlay. - */ - boolean shouldShowFluidOverlay(BlockState block, BlockView level, BlockPos pos, BlockState fluidState); - - /** - * @return If the platform can return block entity data - */ - boolean platformHasBlockData(); - - /** - * Gets the block shade. - * @param quad The quad being rendered. - * @param level The level. - * @param shade If directional lighting should be added. - * @return the block shade - */ - float getNormalVectorShade(ModelQuadView quad, LevelSlice level, boolean shade); - - /** - * If the block contains forced ambient occlusion. - * @param model The model being rendered - * @param state The current block - * @param data Any model data - * @param renderType The current render type being drawn - * @param level The level slice - * @param pos The current position - * @return If ambient occlusion is forced, or {@code DEFAULT} - */ - AmbientOcclusionMode usesAmbientOcclusion(BakedModel model, BlockState state, SodiumModelData data, RenderLayer renderType, LevelSlice level, BlockPos pos); - - /** - * @param blockEntity The block entity to check. - * @param player The current player rendering. - * @return Whether this block entity should activate the outline shader. - */ - boolean shouldBlockEntityGlow(BlockEntity blockEntity, ClientPlayerEntity player); - - /** - * Determines if a fluid adjacent to the block on the given side should not be rendered. - * - * @param adjDirection the face of this block that the fluid is adjacent to - * @param fluid the fluid that is touching that face - * @return if this block should cause the fluid's face to not render - */ - boolean shouldOccludeFluid(Direction adjDirection, BlockState adjBlockState, BlockState fluid); -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformLevelAccess.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformLevelAccess.java deleted file mode 100644 index 3859cfd8a..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformLevelAccess.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.caffeinemc.mods.sodium.client.services; - -import net.caffeinemc.mods.sodium.client.world.SodiumAuxiliaryLightManager; -import dev.vexor.radium.compat.mojang.minecraft.math.SectionPos; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.world.chunk.Chunk; -import org.jetbrains.annotations.Nullable; - -public interface PlatformLevelAccess { - PlatformLevelAccess INSTANCE = Services.load(PlatformLevelAccess.class); - - static PlatformLevelAccess getInstance() { - return INSTANCE; - } - - /** - * Gets the specialized render data for this block entity. - * @param blockEntity The block entity to get the render data of. - * @return The specialized render data for this block entity. If the platform does not support it or there is no data, null. - */ - @Nullable - Object getBlockEntityData(BlockEntity blockEntity); - - /** - * Gets the current light manager for the chunk section. - * @param chunk The current chunk. - * @param pos The section within that chunk being drawn. - * @return The current light manager, or null - */ - @Nullable SodiumAuxiliaryLightManager getLightManager(Chunk chunk, SectionPos pos); -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformLevelRenderHooks.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformLevelRenderHooks.java deleted file mode 100644 index a5a91546e..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformLevelRenderHooks.java +++ /dev/null @@ -1,50 +0,0 @@ -package net.caffeinemc.mods.sodium.client.services; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import net.minecraft.client.render.Camera; -import net.minecraft.client.render.Frustum; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.WorldRenderer; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import org.joml.Matrix4f; - -import java.util.List; -import java.util.function.Function; - -public interface PlatformLevelRenderHooks { - PlatformLevelRenderHooks INSTANCE = Services.load(PlatformLevelRenderHooks.class); - - static PlatformLevelRenderHooks getInstance() { - return INSTANCE; - } - - /** - * Runs any events after drawing a chunk layer. - * @param renderLayer The current chunk layer that was drawn - * @param levelRenderer The level renderer - * @param modelMatrix The current modelview matrix - * @param projectionMatrix The current projection matrix - * @param ticks The current tick count - * @param mainCamera The current camera - * @param cullingFrustum The current frustum - */ - void runChunkLayerEvents(RenderLayer renderLayer, WorldRenderer levelRenderer, Matrix4f modelMatrix, Matrix4f projectionMatrix, int ticks, Camera mainCamera, Frustum cullingFrustum); - - /** - * Returns any NeoForge chunk renderers to run. This is not thread safe. - * @param level The current level - * @param origin The origin of the current chunk - * @return Any NeoForge chunk renderers to run - */ - List retrieveChunkMeshAppenders(World level, BlockPos origin); - - /** - * Runs any NeoForge chunk renderers. - * @param renderers The list of chunk renderers to run. - * @param typeToConsumer A consumer that converts render types to vertex consumers - * @param slice The current level slice - */ - void runChunkMeshAppenders(List renderers, Function typeToConsumer, LevelSlice slice); -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformMixinOverrides.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformMixinOverrides.java index c39175d37..2423cefe4 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformMixinOverrides.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformMixinOverrides.java @@ -12,7 +12,7 @@ static PlatformMixinOverrides getInstance() { List applyModOverrides(); - public final class MixinOverride { + final class MixinOverride { private final String modId; private final String option; private final boolean enabled; diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformModelAccess.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformModelAccess.java deleted file mode 100644 index 089ce2b64..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformModelAccess.java +++ /dev/null @@ -1,76 +0,0 @@ -package net.caffeinemc.mods.sodium.client.services; - -import dev.vexor.radium.compat.mojang.minecraft.math.SectionPos; -import dev.vexor.radium.compat.mojang.minecraft.random.RandomSource; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.BakedQuad; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; -import org.jetbrains.annotations.ApiStatus; - -import java.util.List; - -public interface PlatformModelAccess { - PlatformModelAccess INSTANCE = Services.load(PlatformModelAccess.class); - - static PlatformModelAccess getInstance() { - return INSTANCE; - } - - /** - * Returns all the render types used by this model. - * @param level The level slice. - * @param model The {@code BakedModel} currently being drawn. - * @param state The block state of the current block. - * @param pos The position of the block being rendered. - * @param random The random source used by the current block renderer. - * @param modelData The platform specific model data. - * @return A list of render types used by this model. - */ - Iterable getModelRenderTypes(BlockView level, BakedModel model, BlockState state, BlockPos pos, RandomSource random, SodiumModelData modelData); - - /** - * Returns a list of quads used by this model. - * @param level The level slice. - * @param pos The position of the block being rendered. - * @param model The {@code BakedModel} currently being drawn. - * @param state The block state of the current block. - * @param face The current face of the block being rendered, or null if rendering unassigned quads. - * @param random The random source used by the current block renderer. - * @param renderType The current render type being drawn. - * @param modelData The platform specific model data. - * @return The list of quads used by the model. - */ - List getQuads(BlockView level, BlockPos pos, BakedModel model, BlockState state, Direction face, RandomSource random, RenderLayer renderType, SodiumModelData modelData); - - /** - * Gets the container holding model data for this chunk. This operation is not thread safe. - * @param level The current vanilla Level. - * @param sectionPos The current chunk position. - * @return The model data container for this section - */ - SodiumModelDataContainer getModelDataContainer(World level, SectionPos sectionPos); - - /** - * Gets the true model data from the block data in the container. - * @param slice The current world slice. - * @param model The current model. - * @param state The current block. - * @param pos The current block position. - * @param originalData The model data, as retrieved by {@code getModelDataContainer()}. - * @return The true model data, to render with. - */ - SodiumModelData getModelData(LevelSlice slice, BakedModel model, BlockState state, BlockPos pos, SodiumModelData originalData); - - /** - * Should not use. Use {@code SodiumModelData.EMPTY} instead. - * @return The empty model data for this platform. - */ - @ApiStatus.Internal - SodiumModelData getEmptyModelData(); -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformRuntimeInformation.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformRuntimeInformation.java index cd54ccde5..359c17108 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformRuntimeInformation.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/services/PlatformRuntimeInformation.java @@ -1,8 +1,5 @@ package net.caffeinemc.mods.sodium.client.services; -import dev.vexor.radium.compat.mojang.blaze3d.vertex.PoseStack; -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; - import java.nio.file.Path; public interface PlatformRuntimeInformation { @@ -26,24 +23,4 @@ static PlatformRuntimeInformation getInstance() { * Returns the current configuration directory for the platform. */ Path getConfigDirectory(); - - /** - * Returns if the platform has a early loading screen. - */ - boolean platformHasEarlyLoadingScreen(); - - /** - * Returns if the platform uses refmaps. - */ - boolean platformUsesRefmap(); - - /** - * Returns if a mod is in the mods folder during loading. - */ - boolean isModInLoadingList(String modId); - - /** - * @return Whether {@link VertexConsumer#putBulkData(PoseStack.Pose, net.minecraft.client.render.model.BakedQuad, float[], float, float, float, float, int[], int, boolean)} should multiply the vertex alpha component. - */ - boolean usesAlphaMultiplication(); } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/SodiumModelData.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/services/SodiumModelData.java deleted file mode 100644 index aae9fa104..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/SodiumModelData.java +++ /dev/null @@ -1,8 +0,0 @@ -package net.caffeinemc.mods.sodium.client.services; - -/** - * Template class for the platform's model data. This is used to pass around Forge model data in a multiloader environment seamlessly. - */ -public interface SodiumModelData { - SodiumModelData EMPTY = PlatformModelAccess.getInstance().getEmptyModelData(); -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/SodiumModelDataContainer.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/services/SodiumModelDataContainer.java deleted file mode 100644 index 7619cc580..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/services/SodiumModelDataContainer.java +++ /dev/null @@ -1,27 +0,0 @@ -package net.caffeinemc.mods.sodium.client.services; - -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import net.minecraft.util.math.BlockPos; - -import java.util.Map; - -/** - * A container that holds the platform's model data. - */ -public class SodiumModelDataContainer { - private final Long2ObjectMap modelDataMap; - private final boolean isEmpty; - - public SodiumModelDataContainer(Long2ObjectMap modelDataMap) { - this.modelDataMap = modelDataMap; - this.isEmpty = modelDataMap.isEmpty(); - } - - public SodiumModelData getModelData(BlockPos pos) { - return modelDataMap.getOrDefault(pos.asLong(), SodiumModelData.EMPTY); - } - - public boolean isEmpty() { - return isEmpty; - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java index fe550232e..a013747c9 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/world/LevelSlice.java @@ -80,10 +80,6 @@ public final class LevelSlice implements BlockView { // (Local Section -> Block States) table. private final BlockState[][] blockArrays; - // (Local Section -> Light Manager) table. - @SuppressWarnings("MismatchedReadAndWriteOfArray") - private final SodiumAuxiliaryLightManager[] auxLightManager; - // (Local Section -> Light Arrays) table. private final @Nullable ChunkNibbleArray[][] lightArrays; @@ -134,9 +130,7 @@ public static ChunkRenderContext prepare(World level, SectionPos pos, ClonedChun } } - List renderers = PlatformLevelRenderHooks.getInstance().retrieveChunkMeshAppenders(level, pos.origin()); - - return new ChunkRenderContext(pos, sections, box, renderers); + return new ChunkRenderContext(pos, sections, box); } @SuppressWarnings("unchecked") @@ -147,7 +141,6 @@ public LevelSlice(ClientWorld level) { this.lightArrays = new ChunkNibbleArray[SECTION_ARRAY_SIZE][LIGHT_TYPES.length]; this.blockEntityArrays = new Int2ReferenceMap[SECTION_ARRAY_SIZE]; - this.auxLightManager = new SodiumAuxiliaryLightManager[SECTION_ARRAY_SIZE]; var biomeBlendRadius = SodiumClientMod.options().quality.biomeBlendRadius; @@ -189,7 +182,6 @@ private void copySectionData(ChunkRenderContext context, int sectionIndex) { this.lightArrays[sectionIndex][LightType.SKY.ordinal()] = section.getLightArray(LightType.SKY); this.blockEntityArrays[sectionIndex] = section.getBlockEntityMap(); - this.auxLightManager[sectionIndex] = section.getAuxLightManager(); } private void unpackBlockData(BlockState[] blockArray, ChunkRenderContext context, ClonedChunkSection section) { @@ -235,7 +227,6 @@ public void reset() { Arrays.fill(this.lightArrays[sectionIndex], null); this.blockEntityArrays[sectionIndex] = null; - this.auxLightManager[sectionIndex] = null; } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/world/SodiumAuxiliaryLightManager.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/world/SodiumAuxiliaryLightManager.java deleted file mode 100644 index cdf5ad9f1..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/world/SodiumAuxiliaryLightManager.java +++ /dev/null @@ -1,7 +0,0 @@ -package net.caffeinemc.mods.sodium.client.world; - -/** - * This interface is used to pass Forge's AuxiliaryLightManager around in a multiloader environment. - */ -public interface SodiumAuxiliaryLightManager { -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java index de21d3bbd..c61c15671 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/world/cloned/ChunkRenderContext.java @@ -5,5 +5,5 @@ import java.util.List; -public record ChunkRenderContext(SectionPos origin, ClonedChunkSection[] sections, Box volume, List renderers) { +public record ChunkRenderContext(SectionPos origin, ClonedChunkSection[] sections, Box volume) { } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/world/cloned/ClonedChunkSection.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/world/cloned/ClonedChunkSection.java index d34514b3c..410f04724 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/world/cloned/ClonedChunkSection.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/world/cloned/ClonedChunkSection.java @@ -1,11 +1,9 @@ package net.caffeinemc.mods.sodium.client.world.cloned; import it.unimi.dsi.fastutil.ints.Int2ReferenceMap; -import it.unimi.dsi.fastutil.ints.Int2ReferenceMaps; import it.unimi.dsi.fastutil.ints.Int2ReferenceOpenHashMap; import net.caffeinemc.mods.sodium.client.services.*; import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import net.caffeinemc.mods.sodium.client.world.SodiumAuxiliaryLightManager; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.entity.BlockEntity; @@ -31,16 +29,12 @@ public class ClonedChunkSection { private final SectionPos pos; private final @Nullable Int2ReferenceMap blockEntityMap; - private final @Nullable Int2ReferenceMap blockEntityRenderDataMap; private final @Nullable ChunkNibbleArray[] lightDataArrays; - private final @Nullable SodiumAuxiliaryLightManager auxLightManager; private final @Nullable char[] blockData; private final @Nullable Biome[] biomeData; - private final SodiumModelDataContainer modelMap; - private long lastUsedTimestamp = Long.MAX_VALUE; public ClonedChunkSection(World level, Chunk chunk, @Nullable ChunkSection section, SectionPos pos) { @@ -50,19 +44,12 @@ public ClonedChunkSection(World level, Chunk chunk, @Nullable ChunkSection secti Biome[] biomeData = null; Int2ReferenceMap blockEntityMap = null; - Int2ReferenceMap blockEntityRenderDataMap = null; - SodiumModelDataContainer modelMap = PlatformModelAccess.getInstance().getModelDataContainer(level, pos); - auxLightManager = PlatformLevelAccess.INSTANCE.getLightManager(chunk, pos); if (section != null) { if (!section.isEmpty()) { blockData = section.getBlockStates(); blockEntityMap = copyBlockEntities(chunk, pos); - - if (blockEntityMap != null && PlatformBlockAccess.getInstance().platformHasBlockData()) { - blockEntityRenderDataMap = copyBlockEntityRenderData(level, blockEntityMap); - } } biomeData = convertBiomeArray(chunk.getBiomeArray()); @@ -70,10 +57,8 @@ public ClonedChunkSection(World level, Chunk chunk, @Nullable ChunkSection secti this.blockData = blockData; this.biomeData = biomeData; - this.modelMap = modelMap; this.blockEntityMap = blockEntityMap; - this.blockEntityRenderDataMap = blockEntityRenderDataMap; this.lightDataArrays = copyLightData(level, section); } @@ -158,33 +143,6 @@ private static Int2ReferenceMap copyBlockEntities(Chunk chunk, Sect return blockEntities; } - @Nullable - private static Int2ReferenceMap copyBlockEntityRenderData(World level, Int2ReferenceMap blockEntities) { - Int2ReferenceOpenHashMap blockEntityRenderDataMap = null; - - // Retrieve any render data after we have copied all block entities, as this will call into the code of - // other mods. This could potentially result in the chunk being modified, which would cause problems if we - // were iterating over any data in that chunk. - // See https://github.com/CaffeineMC/sodium/issues/942 for more info. - for (var entry : Int2ReferenceMaps.fastIterable(blockEntities)) { - Object data = PlatformLevelAccess.getInstance().getBlockEntityData(entry.getValue()); - - if (data != null) { - if (blockEntityRenderDataMap == null) { - blockEntityRenderDataMap = new Int2ReferenceOpenHashMap<>(); - } - - blockEntityRenderDataMap.put(entry.getIntKey(), data); - } - } - - if (blockEntityRenderDataMap != null) { - blockEntityRenderDataMap.trim(); - } - - return blockEntityRenderDataMap; - } - public SectionPos getPosition() { return this.pos; } @@ -209,14 +167,6 @@ public SectionPos getPosition() { return this.blockEntityMap; } - public @Nullable Int2ReferenceMap getBlockEntityRenderDataMap() { - return this.blockEntityRenderDataMap; - } - - public SodiumModelDataContainer getModelMap() { - return modelMap; - } - public @Nullable ChunkNibbleArray getLightArray(LightType lightType) { return this.lightDataArrays[lightType.ordinal()]; } @@ -228,8 +178,4 @@ public long getLastUsedTimestamp() { public void setLastUsedTimestamp(long timestamp) { this.lastUsedTimestamp = timestamp; } - - public SodiumAuxiliaryLightManager getAuxLightManager() { - return auxLightManager; - } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/SodiumMixinPlugin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/SodiumMixinPlugin.java index dc80d92b6..b31115de7 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/SodiumMixinPlugin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/SodiumMixinPlugin.java @@ -28,12 +28,6 @@ public void onLoad(String mixinPackage) { throw new RuntimeException("Could not load configuration file for Radium", e); } - this.dependencyResolutionFailed = PlatformRuntimeInformation.getInstance().isModInLoadingList("embeddium"); - - if (dependencyResolutionFailed) { - this.logger.error("Not applying any Radium mixins; dependency resolution has failed."); - } - this.logger.info("Loaded configuration file for Radium: {} options available, {} override(s) found", this.config.getOptionCount(), this.config.getOptionOverrideCount()); } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/access/CameraAccessor.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/access/CameraAccessor.java deleted file mode 100644 index 6e183e6ba..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/access/CameraAccessor.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.core.access; - -import net.minecraft.client.render.Camera; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -import java.nio.FloatBuffer; - -@Mixin(Camera.class) -public interface CameraAccessor { - @Accessor("PROJECTION_MATRIX") - public static FloatBuffer getProjectionMatrix() { throw new AssertionError(); } - - @Accessor("MODEL_MATRIX") - public static FloatBuffer getModelMatrix() { throw new AssertionError(); } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/frustum/CullingCameraViewMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/frustum/CullingCameraViewMixin.java deleted file mode 100644 index 13dbff7e0..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/frustum/CullingCameraViewMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.core.render.frustum; - -import net.caffeinemc.mods.sodium.client.render.viewport.frustum.SimpleFrustum; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.CullingCameraView; -import net.caffeinemc.mods.sodium.client.render.viewport.Viewport; -import net.caffeinemc.mods.sodium.client.render.viewport.ViewportProvider; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.Box; -import net.minecraft.util.math.Vec3d; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -@Mixin(CullingCameraView.class) -public abstract class CullingCameraViewMixin implements ViewportProvider { - // @Override - // public Viewport sodium$createViewport(double tickDelta) { - // Entity cameraEntity = MinecraftClient.getInstance().getCameraEntity(); -// - // double x = cameraEntity.prevTickX + (cameraEntity.x - cameraEntity.prevTickX) * tickDelta; - // double y = cameraEntity.prevTickY + (cameraEntity.y - cameraEntity.prevTickY) * tickDelta;// + (double) cameraEntity.getEyeHeight(); - // double z = cameraEntity.prevTickZ + (cameraEntity.z - cameraEntity.prevTickZ) * tickDelta; -// - // return new Viewport(new SimpleFrustum((CullingCameraView) (Object) this), new Vector3d(x, y, z)); - // } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/immediate/consumer/BufferBuilderMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/immediate/consumer/BufferBuilderMixin.java deleted file mode 100644 index b76efea6b..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/immediate/consumer/BufferBuilderMixin.java +++ /dev/null @@ -1,81 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.core.render.immediate.consumer; - -import org.lwjgl.system.MemoryStack; -import org.lwjgl.system.MemoryUtil; -import net.caffeinemc.mods.sodium.client.render.vertex.buffer.BufferBuilderExtension; -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.minecraft.client.render.BufferBuilder; -import net.minecraft.client.render.VertexFormat; -import org.spongepowered.asm.mixin.*; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; - -@Mixin(BufferBuilder.class) -public abstract class BufferBuilderMixin implements VertexBufferWriter, BufferBuilderExtension { - @Shadow - private int vertexCount; - - @Shadow - @Mutable - private ByteBuffer buffer; - - @Unique - private VertexFormat format; - - @Inject( - method = "begin", - at = @At(value = "TAIL") - ) - private void onFormatChanged(int drawMode, VertexFormat format, CallbackInfo ci) { - this.format = format; - } - - @Override - public boolean canUseIntrinsics() { - return this.format != null; - } - - @Override - public void push(MemoryStack stack, long src, int count, VertexFormat format) { - int length = count * this.vertexCount; - - // Ensure buffer has enough capacity for the new data - reserveBuffer(length); - - if (format.equals(this.format)) { - // Layout is the same, perform direct memory copy - // Using JNI for memory copying between direct buffers - copyMemoryDirect(src, buffer, length); - } - } - - /** - * Ensures the buffer has enough capacity to accommodate the new data. - */ - @Unique - private void reserveBuffer(int requiredCapacity) { - if (buffer.remaining() < requiredCapacity) { - // Allocate a new larger buffer if necessary - int newCapacity = Math.max(buffer.capacity() * 2, buffer.capacity() + requiredCapacity); - ByteBuffer newBuffer = ByteBuffer.allocateDirect(newCapacity).order(ByteOrder.nativeOrder()); - buffer.flip(); // Prepare old buffer for reading - newBuffer.put(buffer); // Copy old data into the new buffer - buffer = newBuffer; - } - } - - /** - * Copies memory from the source address into the buffer using native memory operations. - */ - @Unique - private void copyMemoryDirect(long src, ByteBuffer dst, int length) { - // Assuming src is a pointer, direct buffer required to manipulate memory - for (int i = 0; i < length; i++) { - dst.put((byte) MemoryUtil.memGetByte(src + i)); // Mimic memory copy - } - } -} \ No newline at end of file diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/world/LevelRendererMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/world/LevelRendererMixin.java index bf0bee3f0..415db1156 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/world/LevelRendererMixin.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/core/render/world/LevelRendererMixin.java @@ -1,15 +1,11 @@ package net.caffeinemc.mods.sodium.mixin.core.render.world; -import com.mojang.blaze3d.platform.GLX; -import com.mojang.blaze3d.platform.GlStateManager; import net.caffeinemc.mods.sodium.client.gl.device.RenderDevice; import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer; import net.caffeinemc.mods.sodium.client.render.chunk.ChunkRenderMatrices; import net.caffeinemc.mods.sodium.client.render.viewport.Viewport; -import net.caffeinemc.mods.sodium.client.render.viewport.ViewportProvider; import net.caffeinemc.mods.sodium.client.render.viewport.frustum.SimpleFrustum; import net.caffeinemc.mods.sodium.client.world.LevelRendererExtension; -import net.caffeinemc.mods.sodium.mixin.core.access.CameraAccessor; import net.minecraft.client.MinecraftClient; import net.minecraft.client.option.GameOptions; import net.minecraft.client.render.*; @@ -21,8 +17,6 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import org.joml.Matrix4f; -import org.lwjgl.opengl.GL15; -import org.lwjgl.opengl.GL30; import org.spongepowered.asm.mixin.*; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -97,15 +91,8 @@ public int renderLayer(RenderLayer renderLayer, double tickDelta, int anaglyphFi double y = entity.prevTickY + (entity.y - entity.prevTickY) * tickDelta; double z = entity.prevTickZ + (entity.z - entity.prevTickZ) * tickDelta; - Matrix4f projectionMatrix = new Matrix4f(CameraAccessor.getProjectionMatrix()); - Matrix4f modelViewMatrix = new Matrix4f(CameraAccessor.getModelMatrix()); - - - // client.gameRenderer.enableLightmap(); - //GlStateManager.activeTexture(GLX.textureUnit); - //GlStateManager.bindTexture(this.client.getSpriteAtlasTexture().getGlId()); - //GlStateManager.enableTexture(); - + Matrix4f projectionMatrix = new Matrix4f(Camera.PROJECTION_MATRIX); + Matrix4f modelViewMatrix = new Matrix4f(Camera.MODEL_MATRIX); try { this.renderer.drawChunkLayer(renderLayer, new ChunkRenderMatrices(projectionMatrix, modelViewMatrix), x, y, z); @@ -114,7 +101,6 @@ public int renderLayer(RenderLayer renderLayer, double tickDelta, int anaglyphFi } return 0; - } /** diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/entity/cull/EntityRendererMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/entity/cull/EntityRendererMixin.java deleted file mode 100644 index d3874a699..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/entity/cull/EntityRendererMixin.java +++ /dev/null @@ -1,16 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.features.render.entity.cull; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer; -import net.minecraft.client.render.CameraView; -import net.minecraft.client.render.entity.EntityRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.util.math.Box; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; - -@Mixin(EntityRenderer.class) -public abstract class EntityRendererMixin { - -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/frapi/BakedModelMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/frapi/BakedModelMixin.java deleted file mode 100644 index 753bf0b42..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/frapi/BakedModelMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.features.render.frapi; - -import dev.vexor.radium.compat.mojang.minecraft.random.RandomSource; -import net.caffeinemc.mods.sodium.client.render.frapi.render.AbstractBlockRenderContext; -import dev.vexor.radium.frapi.api.renderer.v1.mesh.QuadEmitter; -import dev.vexor.radium.frapi.api.renderer.v1.model.FabricBakedModel; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.BlockView; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; - -import java.util.function.Predicate; -import java.util.function.Supplier; - -@Mixin(BakedModel.class) -public interface BakedModelMixin extends FabricBakedModel { - @Override - default void emitBlockQuads(QuadEmitter emitter, BlockView blockView, BlockState state, BlockPos pos, Supplier randomSupplier, Predicate<@Nullable Direction> cullTest) { - if (emitter instanceof AbstractBlockRenderContext.BlockEmitter) { - ((AbstractBlockRenderContext.BlockEmitter) emitter).bufferDefaultModel((BakedModel) this, state, cullTest); - } else { - FabricBakedModel.super.emitBlockQuads(emitter, blockView, state, pos, randomSupplier, cullTest); - } - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/frapi/ModelBlockRendererMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/frapi/ModelBlockRendererMixin.java deleted file mode 100644 index 6f9c106d4..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/frapi/ModelBlockRendererMixin.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 2018, 2019 FabricMC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.caffeinemc.mods.sodium.mixin.features.render.frapi; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.PoseStack; -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; -import dev.vexor.radium.compat.mojang.minecraft.BlockColors; -import dev.vexor.radium.compat.mojang.minecraft.random.SingleThreadedRandomSource; -import net.caffeinemc.mods.sodium.client.render.frapi.render.NonTerrainBlockRenderContext; -import dev.vexor.radium.frapi.api.renderer.v1.model.FabricBakedModel; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.BufferBuilder; -import net.minecraft.client.render.block.BlockModelRenderer; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.BlockView; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -/** - * Entrypoint of the FRAPI pipeline for non-terrain block rendering, for the baked models that require it. - */ -@Mixin(BlockModelRenderer.class) -public abstract class ModelBlockRendererMixin { - @Unique - private final ThreadLocal contexts = ThreadLocal.withInitial(() -> new NonTerrainBlockRenderContext(BlockColors.INSTANCE)); - - @Inject(method = "render(Lnet/minecraft/world/BlockView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/render/BufferBuilder;Z)Z", at = @At("HEAD"), cancellable = true) - private void onRender(BlockView world, BakedModel model, BlockState state, BlockPos pos, BufferBuilder buffer, boolean cull, CallbackInfoReturnable cir) { - if (!((FabricBakedModel) model).isVanillaAdapter()) { - contexts.get().renderModel(world, model, state, pos, new PoseStack(), (VertexConsumer) buffer, cull, new SingleThreadedRandomSource(42L), 0L, 0); - cir.cancel(); - } - } -} diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/immediate/buffer_builder/intrinsics/BufferBuilderMixin.java b/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/immediate/buffer_builder/intrinsics/BufferBuilderMixin.java deleted file mode 100644 index 82cf6775f..000000000 --- a/common/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/immediate/buffer_builder/intrinsics/BufferBuilderMixin.java +++ /dev/null @@ -1,47 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.features.render.immediate.buffer_builder.intrinsics; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.PoseStack; -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; -import net.caffeinemc.mods.sodium.client.model.quad.ModelQuadView; -import net.caffeinemc.mods.sodium.client.render.immediate.model.BakedModelEncoder; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; -import net.caffeinemc.mods.sodium.api.util.ColorABGR; -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.minecraft.client.render.BufferBuilder; -import net.minecraft.client.render.model.BakedQuad; -import org.spongepowered.asm.mixin.Mixin; - -@SuppressWarnings({ "SameParameterValue" }) -@Mixin(BufferBuilder.class) -public abstract class BufferBuilderMixin implements VertexConsumer { - @Override - public void putBulkData(PoseStack.Pose matrices, BakedQuad bakedQuad, float r, float g, float b, float a, int light, int overlay) { - if (bakedQuad.getVertexData().length < 32) { - return; // we do not accept quads with less than 4 properly sized vertices - } - - VertexBufferWriter writer = VertexBufferWriter.of(this); - - ModelQuadView quad = (ModelQuadView) bakedQuad; - - int color = ColorABGR.pack(r, g, b, a); - BakedModelEncoder.writeQuadVertices(writer, matrices, quad, color, light, overlay, false); - - SpriteUtil.markSpriteActive(quad.getSprite()); - } - - @Override - public void putBulkData(PoseStack.Pose matrices, BakedQuad bakedQuad, float[] brightnessTable, float r, float g, float b, float a, int[] light, int overlay, boolean colorize) { - if (bakedQuad.getVertexData().length < 32) { - return; // we do not accept quads with less than 4 properly sized vertices - } - - VertexBufferWriter writer = VertexBufferWriter.of(this); - - ModelQuadView quad = (ModelQuadView) bakedQuad; - - BakedModelEncoder.writeQuadVertices(writer, matrices, quad, r, g, b, a, brightnessTable, colorize, light, overlay); - - SpriteUtil.markSpriteActive(quad.getSprite()); - } -} diff --git a/common/src/main/resources/radium-frapi.mixins.json b/common/src/main/resources/radium-frapi.mixins.json index 4d9ff26be..961628d3f 100644 --- a/common/src/main/resources/radium-frapi.mixins.json +++ b/common/src/main/resources/radium-frapi.mixins.json @@ -9,7 +9,6 @@ "conformVisibility" : true }, "client" : [ - "renderer.client.BakedModelMixin", "renderer.client.debughud.DebugHudMixin", "renderer.client.SpriteAtlasTextureMixin" ] diff --git a/common/src/main/resources/sodium-common.accesswidener b/common/src/main/resources/sodium-common.accesswidener index e9ed6de21..279924132 100644 --- a/common/src/main/resources/sodium-common.accesswidener +++ b/common/src/main/resources/sodium-common.accesswidener @@ -8,6 +8,7 @@ accessible field com/mojang/blaze3d/platform/GlStateManager FOG Lcom/mojang/blaz accessible field net/minecraft/client/render/GameRenderer fogRed F accessible field net/minecraft/client/render/GameRenderer fogGreen F accessible field net/minecraft/client/render/GameRenderer fogBlue F +accessible field net/minecraft/client/render/Camera MODEL_MATRIX Ljava/nio/FloatBuffer; accessible field net/minecraft/client/render/Camera PROJECTION_MATRIX Ljava/nio/FloatBuffer; accessible field net/minecraft/client/color/world/FoliageColors colorMap [I accessible field net/minecraft/client/color/world/GrassColors colorMap [I diff --git a/common/src/main/resources/sodium-common.mixins.json b/common/src/main/resources/sodium-common.mixins.json index 1f5d3aff4..38f671964 100644 --- a/common/src/main/resources/sodium-common.mixins.json +++ b/common/src/main/resources/sodium-common.mixins.json @@ -11,10 +11,7 @@ }, "client" : [ "core.MinecraftMixin", - "core.access.CameraAccessor", "core.render.VertexFormatMixin", - "core.render.frustum.CullingCameraViewMixin", - "core.render.immediate.consumer.BufferBuilderMixin", "core.render.world.LevelRendererMixin", "core.world.biome.ClientLevelMixin", "core.world.map.ClientChunkCacheMixin", @@ -27,11 +24,7 @@ "features.options.overlays.GuiMixin", "features.options.render_layers.LeavesBlockMixin", "features.options.weather.LevelRendererMixin", - "features.render.entity.cull.EntityRendererMixin", - "features.render.frapi.BakedModelMixin", - "features.render.frapi.ModelBlockRendererMixin", "features.render.immediate.DirectionMixin", - "features.render.immediate.buffer_builder.intrinsics.BufferBuilderMixin", "features.textures.animations.tracking.SpriteContentsMixin", "features.textures.animations.tracking.TextureAtlasMixin" ], diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/FabricRuntimeInformation.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/FabricRuntimeInformation.java index 68fcae272..026f85272 100644 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/FabricRuntimeInformation.java +++ b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/FabricRuntimeInformation.java @@ -20,24 +20,4 @@ public Path getGameDirectory() { public Path getConfigDirectory() { return FabricLoader.getInstance().getConfigDir(); } - - @Override - public boolean platformHasEarlyLoadingScreen() { - return false; - } - - @Override - public boolean platformUsesRefmap() { - return true; - } - - @Override - public boolean isModInLoadingList(String modId) { - return FabricLoader.getInstance().isModLoaded(modId); - } - - @Override - public boolean usesAlphaMultiplication() { - return false; - } } diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/block/FabricBlockAccess.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/block/FabricBlockAccess.java deleted file mode 100644 index 96e95994a..000000000 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/block/FabricBlockAccess.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.caffeinemc.mods.sodium.fabric.block; - -import net.caffeinemc.mods.sodium.api.util.NormI8; -import net.caffeinemc.mods.sodium.client.model.quad.ModelQuadView; -import net.caffeinemc.mods.sodium.client.render.frapi.render.AmbientOcclusionMode; -import net.caffeinemc.mods.sodium.client.services.PlatformBlockAccess; -import net.caffeinemc.mods.sodium.client.services.SodiumModelData; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import net.minecraft.block.BlockState; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.entity.player.ClientPlayerEntity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.world.BlockView; - -public class FabricBlockAccess implements PlatformBlockAccess { - @Override - public int getLightEmission(BlockState state, BlockView level, BlockPos pos) { - return state.getBlock().getLightLevel(); - } - - @Override - public boolean shouldSkipRender(BlockView level, BlockState selfState, BlockState otherState, BlockPos selfPos, BlockPos otherPos, Direction facing) { - return false; - } - - @Override - public boolean shouldShowFluidOverlay(BlockState block, BlockView level, BlockPos pos, BlockState fluidState) { - return false; - } - - @Override - public boolean platformHasBlockData() { - return false; - } - - @Override - public float getNormalVectorShade(ModelQuadView quad, LevelSlice level, boolean shade) { - return level.getBrightness(quad.getLightFace(), shade); - } - - @Override - public AmbientOcclusionMode usesAmbientOcclusion(BakedModel model, BlockState state, SodiumModelData data, RenderLayer renderType, LevelSlice level, BlockPos pos) { - if (MinecraftClient.isAmbientOcclusionEnabled()) { - return AmbientOcclusionMode.ENABLED; - } - - return AmbientOcclusionMode.DISABLED; - } - - @Override - public boolean shouldBlockEntityGlow(BlockEntity blockEntity, ClientPlayerEntity player) { - return false; - } - - @Override - public boolean shouldOccludeFluid(Direction adjDirection, BlockState adjBlockState, BlockState fluid) { - return false; - } -} diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/level/FabricLevelAccess.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/level/FabricLevelAccess.java deleted file mode 100644 index a1f8c8bf9..000000000 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/level/FabricLevelAccess.java +++ /dev/null @@ -1,20 +0,0 @@ -package net.caffeinemc.mods.sodium.fabric.level; - -import net.caffeinemc.mods.sodium.client.services.PlatformLevelAccess; -import net.caffeinemc.mods.sodium.client.world.SodiumAuxiliaryLightManager; -import dev.vexor.radium.compat.mojang.minecraft.math.SectionPos; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.world.chunk.Chunk; -import org.jetbrains.annotations.Nullable; - -public class FabricLevelAccess implements PlatformLevelAccess { - @Override - public @Nullable Object getBlockEntityData(BlockEntity blockEntity) { - return blockEntity.getDataValue(); - } - - @Override - public @Nullable SodiumAuxiliaryLightManager getLightManager(Chunk chunk, SectionPos pos) { - return null; - } -} diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/level/FabricLevelRenderHooks.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/level/FabricLevelRenderHooks.java deleted file mode 100644 index 9b78bde9c..000000000 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/level/FabricLevelRenderHooks.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.caffeinemc.mods.sodium.fabric.level; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; -import net.caffeinemc.mods.sodium.client.services.PlatformLevelRenderHooks; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import net.minecraft.client.render.Frustum; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.WorldRenderer; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import org.joml.Matrix4f; - -import java.util.List; -import java.util.function.Function; - -public class FabricLevelRenderHooks implements PlatformLevelRenderHooks { - - @Override - public void runChunkLayerEvents(RenderLayer renderLayer, WorldRenderer levelRenderer, Matrix4f modelMatrix, Matrix4f projectionMatrix, int ticks, net.minecraft.client.render.Camera mainCamera, Frustum cullingFrustum) { - - } - - @Override - public List retrieveChunkMeshAppenders(World level, BlockPos origin) { - return List.of(); - } - - @Override - public void runChunkMeshAppenders(List renderers, Function typeToConsumer, LevelSlice slice) { - - } -} diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/model/FabricModelAccess.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/model/FabricModelAccess.java deleted file mode 100644 index 38e6f3d49..000000000 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/model/FabricModelAccess.java +++ /dev/null @@ -1,51 +0,0 @@ -package net.caffeinemc.mods.sodium.fabric.model; - -import dev.vexor.radium.compat.mojang.minecraft.random.RandomSource; -import it.unimi.dsi.fastutil.longs.Long2ObjectMaps; -import net.caffeinemc.mods.sodium.client.services.PlatformModelAccess; -import net.caffeinemc.mods.sodium.client.services.SodiumModelData; -import net.caffeinemc.mods.sodium.client.services.SodiumModelDataContainer; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.BakedQuad; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import dev.vexor.radium.compat.mojang.minecraft.math.SectionPos; -import net.minecraft.world.BlockView; -import net.minecraft.world.World; - -import java.util.ArrayList; -import java.util.List; - -public class FabricModelAccess implements PlatformModelAccess { - private static final SodiumModelDataContainer EMPTY_CONTAINER = new SodiumModelDataContainer(Long2ObjectMaps.emptyMap()); - - @Override - public Iterable getModelRenderTypes(BlockView level, BakedModel model, BlockState state, BlockPos pos, RandomSource random, SodiumModelData modelData) { - return List.of(state.getBlock().getRenderLayerType()); - } - - @Override - public List getQuads(BlockView level, BlockPos pos, BakedModel model, BlockState state, Direction face, RandomSource random, RenderLayer renderType, SodiumModelData modelData) { - if (face == null) return model.getQuads(); - - return model.getByDirection(face); - } - - @Override - public SodiumModelDataContainer getModelDataContainer(World level, SectionPos sectionPos) { - return EMPTY_CONTAINER; - } - - @Override - public SodiumModelData getModelData(LevelSlice slice, BakedModel model, BlockState state, BlockPos pos, SodiumModelData originalData) { - return SodiumModelData.EMPTY; - } - - @Override - public SodiumModelData getEmptyModelData() { - return SodiumModelData.EMPTY; - } -} diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java deleted file mode 100644 index 8ade3ece1..000000000 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FabricColorProviders.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.caffeinemc.mods.sodium.fabric.render; - -import net.caffeinemc.mods.sodium.client.model.color.ColorProvider; -import net.caffeinemc.mods.sodium.client.model.quad.ModelQuadView; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import net.minecraft.block.BlockState; -import net.minecraft.client.color.world.BiomeColors; -import net.minecraft.util.math.BlockPos; - -import java.util.Arrays; - -public class FabricColorProviders { - public static ColorProvider adapt() { - return new FabricFluidAdapter(); - } - - private static class FabricFluidAdapter implements ColorProvider { - public FabricFluidAdapter() { - } - - @Override - public void getColors(LevelSlice slice, BlockPos pos, BlockPos.Mutable scratchPos, BlockState state, ModelQuadView quad, int[] output) { - Arrays.fill(output, 0xFF000000 | BiomeColors.getWaterColor(slice, pos)); - } - } -} diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FluidRendererImpl.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FluidRendererImpl.java deleted file mode 100644 index 0adcc775b..000000000 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/fabric/render/FluidRendererImpl.java +++ /dev/null @@ -1,127 +0,0 @@ -package net.caffeinemc.mods.sodium.fabric.render; - -import dev.vexor.radium.compat.mojang.minecraft.WorldUtil; -import dev.vexor.radium.util.FluidSprites; -import net.caffeinemc.mods.sodium.client.model.color.ColorProvider; -import net.caffeinemc.mods.sodium.client.model.color.ColorProviderRegistry; -import net.caffeinemc.mods.sodium.client.model.light.LightPipelineProvider; -import net.caffeinemc.mods.sodium.client.model.quad.blender.BlendedColorProvider; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.ChunkBuildBuffers; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.buffers.ChunkModelBuilder; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.DefaultFluidRenderer; -import net.caffeinemc.mods.sodium.client.render.chunk.compile.pipeline.FluidRenderer; -import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.DefaultMaterials; -import net.caffeinemc.mods.sodium.client.render.chunk.terrain.material.Material; -import net.caffeinemc.mods.sodium.client.render.chunk.translucent_sorting.TranslucentGeometryCollector; -import net.caffeinemc.mods.sodium.client.services.FluidRendererFactory; -import net.caffeinemc.mods.sodium.client.world.LevelSlice; -import net.minecraft.block.AbstractFluidBlock; -import net.minecraft.block.BlockState; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.color.world.BiomeColors; -import net.minecraft.client.texture.Sprite; -import net.minecraft.client.texture.SpriteAtlasTexture; -import net.minecraft.util.math.BlockPos; - -public class FluidRendererImpl extends FluidRenderer { - private final ColorProviderRegistry colorProviderRegistry; - private final DefaultFluidRenderer defaultRenderer; - private final DefaultRenderContext defaultContext; - - private final FluidSprites sprites; - - public FluidRendererImpl(ColorProviderRegistry colorProviderRegistry, LightPipelineProvider lighters) { - this.colorProviderRegistry = colorProviderRegistry; - defaultRenderer = new DefaultFluidRenderer(lighters); - defaultContext = new DefaultRenderContext(); - sprites = FluidSprites.create(); - } - - public void render(LevelSlice level, BlockState blockState, BlockState fluidState, BlockPos blockPos, BlockPos offset, TranslucentGeometryCollector collector, ChunkBuildBuffers buffers) { - var material = DefaultMaterials.forFluidState(fluidState); - var meshBuilder = buffers.get(material); - var fluid = WorldUtil.getFluid(fluidState); - - defaultContext.setUp(this.colorProviderRegistry, this.defaultRenderer, level, blockState, fluidState, blockPos, offset, collector, meshBuilder, material, false); - - defaultRenderer.render(level, blockState, blockPos, offset, collector, meshBuilder, material, defaultContext.getColorProvider(fluid), sprites.forFluid(fluid)); - } - - private static class DefaultRenderContext { - private DefaultFluidRenderer renderer; - private LevelSlice level; - private BlockState blockState; - private BlockState fluidState; - private BlockPos blockPos; - private BlockPos offset; - private TranslucentGeometryCollector collector; - private ChunkModelBuilder meshBuilder; - private Material material; - private ColorProviderRegistry colorProviderRegistry; - private boolean hasModOverride; - - public void setUp(ColorProviderRegistry colorProviderRegistry, DefaultFluidRenderer renderer, LevelSlice level, BlockState blockState, BlockState fluidState, BlockPos blockPos, BlockPos offset, TranslucentGeometryCollector collector, ChunkModelBuilder meshBuilder, Material material, boolean hasModOverride) { - this.colorProviderRegistry = colorProviderRegistry; - this.renderer = renderer; - this.level = level; - this.blockState = blockState; - this.fluidState = fluidState; - this.blockPos = blockPos; - this.offset = offset; - this.collector = collector; - this.meshBuilder = meshBuilder; - this.material = material; - this.hasModOverride = hasModOverride; - } - - public void clear() { - this.renderer = null; - this.level = null; - this.blockState = null; - this.fluidState = null; - this.blockPos = null; - this.offset = null; - this.collector = null; - this.meshBuilder = null; - this.material = null; - this.hasModOverride = false; - } - - public ColorProvider getColorProvider(AbstractFluidBlock fluid) { - var override = this.colorProviderRegistry.getColorProvider(fluid); - - if (!hasModOverride && override != null) { - return override; - } - - return FabricColorProviders.adapt(); - } - } - - public static class FabricFactory implements FluidRendererFactory { - @Override - public FluidRenderer createPlatformFluidRenderer(ColorProviderRegistry colorRegistry, LightPipelineProvider lightPipelineProvider) { - return new FluidRendererImpl(colorRegistry, lightPipelineProvider); - } - - @Override - public BlendedColorProvider getWaterColorProvider() { - return new BlendedColorProvider<>() { - @Override - protected int getColor(LevelSlice slice, BlockState state, BlockPos pos) { - return BiomeColors.getWaterColor(slice, pos) | 0xFF000000; - } - }; - } - - @Override - public BlendedColorProvider getWaterBlockColorProvider() { - return new BlendedColorProvider<>() { - @Override - protected int getColor(LevelSlice slice, BlockState state, BlockPos pos) { - return BiomeColors.getWaterColor(slice, pos) | 0xFF000000; - } - }; - } - } -} diff --git a/fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/block/ModelBlockRendererMixin.java b/fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/block/ModelBlockRendererMixin.java deleted file mode 100644 index 73a589fc2..000000000 --- a/fabric/src/main/java/net/caffeinemc/mods/sodium/mixin/features/render/model/block/ModelBlockRendererMixin.java +++ /dev/null @@ -1,126 +0,0 @@ -package net.caffeinemc.mods.sodium.mixin.features.render.model.block; - -import dev.vexor.radium.compat.mojang.blaze3d.vertex.PoseStack; -import dev.vexor.radium.compat.mojang.blaze3d.vertex.VertexConsumer; -import dev.vexor.radium.compat.mojang.minecraft.random.RandomSource; -import dev.vexor.radium.compat.mojang.minecraft.random.SingleThreadedRandomSource; -import net.caffeinemc.mods.sodium.api.util.ColorABGR; -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.caffeinemc.mods.sodium.client.model.quad.BakedQuadView; -import net.caffeinemc.mods.sodium.client.render.immediate.model.BakedModelEncoder; -import net.caffeinemc.mods.sodium.client.render.texture.SpriteUtil; -import net.caffeinemc.mods.sodium.client.render.vertex.VertexConsumerUtils; -import net.caffeinemc.mods.sodium.client.util.DirectionUtil; -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.client.render.BufferBuilder; -import net.minecraft.client.render.GameRenderer; -import net.minecraft.client.render.block.BlockModelRenderer; -import net.minecraft.client.render.model.BakedModel; -import net.minecraft.client.render.model.BakedQuad; -import net.minecraft.client.texture.TextureUtil; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; -import net.minecraft.util.math.MathHelper; -import net.minecraft.world.BlockView; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.List; - -@Mixin(BlockModelRenderer.class) -public class ModelBlockRendererMixin { - @Unique - private final RandomSource random = new SingleThreadedRandomSource(42L); - - @Unique - @SuppressWarnings("ForLoopReplaceableByForEach") - private static void renderQuads(PoseStack.Pose matrices, VertexBufferWriter writer, int defaultColor, List quads, int light, int overlay) { - for (int i = 0; i < quads.size(); i++) { - BakedQuad bakedQuad = quads.get(i); - - if (bakedQuad.getVertexData().length < 32) { - continue; // ignore bad quads - } - - BakedQuadView quad = (BakedQuadView) bakedQuad; - - int color = quad.hasColor() ? defaultColor : 0xFFFFFFFF; - - BakedModelEncoder.writeQuadVertices(writer, matrices, quad, color, light, overlay, false); - - SpriteUtil.markSpriteActive(quad.getSprite()); - } - } - - /** - * @reason Use optimized vertex writer intrinsics, avoid allocations - * @author JellySquid - */ - @Inject(method = "render(Lnet/minecraft/world/BlockView;Lnet/minecraft/client/render/model/BakedModel;Lnet/minecraft/block/BlockState;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/client/render/BufferBuilder;Z)Z", at = @At("HEAD"), cancellable = true) - private void renderFast(BlockView world, BakedModel model, BlockState state, BlockPos pos, BufferBuilder buffer, boolean cull, CallbackInfoReturnable cir) { - var writer = VertexConsumerUtils.convertOrLog((VertexConsumer) buffer); - if (writer == null) { - return; - } - - double x = (double)pos.getX(); - double y = (double)pos.getY(); - double z = (double)pos.getZ(); - Block.OffsetType offsetType = state.getBlock().getOffsetType(); - if (offsetType != Block.OffsetType.NONE) { - long l = MathHelper.hashCode(pos); - x += ((double)((float)(l >> 16 & 15L) / 15.0F) - (double)0.5F) * (double)0.5F; - y += ((double)((float)(l >> 24 & 15L) / 15.0F) - (double)0.5F) * (double)0.5F; - if (offsetType == Block.OffsetType.XYZ) { - z += ((double)((float)(l >> 20 & 15L) / 15.0F) - (double)1.0F) * 0.2; - } - } - - cir.cancel(); - - int i = state.getBlock().getColor(state.getBlock().getRenderState(state)); - if (GameRenderer.anaglyphEnabled) { - i = TextureUtil.getAnaglyphColor(i); - } - - float red = (float)(i >> 16 & 255) / 255.0F; - float green = (float)(i >> 8 & 255) / 255.0F; - float blue = (float)(i & 255) / 255.0F; - - RandomSource random = this.random; - - // Clamp color ranges - red = MathHelper.clamp(red, 0.0F, 1.0F); - green = MathHelper.clamp(green, 0.0F, 1.0F); - blue = MathHelper.clamp(blue, 0.0F, 1.0F); - - int defaultColor = ColorABGR.pack(red, green, blue, 1.0F); - - PoseStack poseStack = new PoseStack(); - - poseStack.pushPose(); - poseStack.translate(x, y, z); - - for (Direction direction : DirectionUtil.ALL_DIRECTIONS) { - random.setSeed(42L); - List quads = model.getByDirection(direction); - - if (!quads.isEmpty()) { - renderQuads(poseStack.last(), writer, defaultColor, quads, 0, 0); - } - } - - random.setSeed(42L); - List quads = model.getQuads(); - - if (!quads.isEmpty()) { - renderQuads(poseStack.last(), writer, defaultColor, quads, 0, 0); - } - - poseStack.popPose(); - } -} diff --git a/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.FluidRendererFactory b/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.FluidRendererFactory deleted file mode 100644 index 995c122c1..000000000 --- a/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.FluidRendererFactory +++ /dev/null @@ -1 +0,0 @@ -net.caffeinemc.mods.sodium.fabric.render.FluidRendererImpl$FabricFactory \ No newline at end of file diff --git a/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformBlockAccess b/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformBlockAccess deleted file mode 100644 index d5c344c89..000000000 --- a/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformBlockAccess +++ /dev/null @@ -1 +0,0 @@ -net.caffeinemc.mods.sodium.fabric.block.FabricBlockAccess \ No newline at end of file diff --git a/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformLevelAccess b/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformLevelAccess deleted file mode 100644 index 194bf9fe8..000000000 --- a/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformLevelAccess +++ /dev/null @@ -1 +0,0 @@ -net.caffeinemc.mods.sodium.fabric.level.FabricLevelAccess \ No newline at end of file diff --git a/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformLevelRenderHooks b/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformLevelRenderHooks deleted file mode 100644 index 327c9c7b9..000000000 --- a/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformLevelRenderHooks +++ /dev/null @@ -1 +0,0 @@ -net.caffeinemc.mods.sodium.fabric.level.FabricLevelRenderHooks \ No newline at end of file diff --git a/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformModelAccess b/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformModelAccess deleted file mode 100644 index d19ccea5a..000000000 --- a/fabric/src/main/resources/META-INF/services/net.caffeinemc.mods.sodium.client.services.PlatformModelAccess +++ /dev/null @@ -1 +0,0 @@ -net.caffeinemc.mods.sodium.fabric.model.FabricModelAccess \ No newline at end of file diff --git a/fabric/src/main/resources/sodium-fabric.accesswidener b/fabric/src/main/resources/sodium-fabric.accesswidener index c0c38b35e..8a8675e21 100644 --- a/fabric/src/main/resources/sodium-fabric.accesswidener +++ b/fabric/src/main/resources/sodium-fabric.accesswidener @@ -9,6 +9,7 @@ accessible field com/mojang/blaze3d/platform/GlStateManager FOG Lcom/mojang/blaz accessible field net/minecraft/client/render/GameRenderer fogRed F accessible field net/minecraft/client/render/GameRenderer fogGreen F accessible field net/minecraft/client/render/GameRenderer fogBlue F +accessible field net/minecraft/client/render/Camera MODEL_MATRIX Ljava/nio/FloatBuffer; accessible field net/minecraft/client/render/Camera PROJECTION_MATRIX Ljava/nio/FloatBuffer; accessible field net/minecraft/client/color/world/FoliageColors colorMap [I accessible field net/minecraft/client/color/world/GrassColors colorMap [I diff --git a/fabric/src/main/resources/sodium-fabric.mixins.json b/fabric/src/main/resources/sodium-fabric.mixins.json index 40e4d7782..a0c63c00a 100644 --- a/fabric/src/main/resources/sodium-fabric.mixins.json +++ b/fabric/src/main/resources/sodium-fabric.mixins.json @@ -9,6 +9,6 @@ "conformVisibility": true }, "client": [ - "core.model.quad.BakedQuadMixin" + "core.model.quad.BakedQuadMixin" ] } \ No newline at end of file