diff --git a/build.gradle.kts b/build.gradle.kts index fc4d081369..342f0dacb9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ val MINECRAFT_VERSION by extra { "1.21" } val NEOFORGE_VERSION by extra { "21.0.57-beta" } val FABRIC_LOADER_VERSION by extra { "0.15.11" } val FABRIC_API_VERSION by extra { "0.100.1+1.21" } -val SODIUM_FILE by extra { "sodium-fabric-0.6.0-alpha.2.jar" } +val SODIUM_FILE by extra { "sodium-fabric-0.6.0-snapshot+mc1.21-local.jar" } // https://semver.org/ val MOD_VERSION by extra { "1.8.0" } diff --git a/common/src/sodiumCompatibility/java/net/irisshaders/iris/compat/sodium/mixin/copyEntity/CuboidMixin.java b/common/src/sodiumCompatibility/java/net/irisshaders/iris/compat/sodium/mixin/copyEntity/CuboidMixin.java deleted file mode 100644 index f280b02e21..0000000000 --- a/common/src/sodiumCompatibility/java/net/irisshaders/iris/compat/sodium/mixin/copyEntity/CuboidMixin.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.irisshaders.iris.compat.sodium.mixin.copyEntity; - -import net.caffeinemc.mods.sodium.client.model.ModelCuboidAccessor; -import net.caffeinemc.mods.sodium.client.render.immediate.model.ModelCuboid; -import net.minecraft.client.model.geom.ModelPart; -import net.minecraft.core.Direction; -import org.objectweb.asm.Opcodes; -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.CallbackInfo; - -import java.util.Set; - -@Mixin(ModelPart.Cube.class) -public class CuboidMixin implements ModelCuboidAccessor { - @Unique - private ModelCuboid sodium$cuboid; - - // Inject at the start of the function, so we don't capture modified locals - @Inject(method = "", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lnet/minecraft/client/model/geom/ModelPart$Cube;polygons:[Lnet/minecraft/client/model/geom/ModelPart$Polygon;", ordinal = 0)) - private void onInit(int u, int v, float x, float y, float z, float sizeX, float sizeY, float sizeZ, float extraX, float extraY, float extraZ, boolean mirror, float textureWidth, float textureHeight, Set renderDirections, CallbackInfo ci) { - this.sodium$cuboid = new ModelCuboid(u, v, x, y, z, sizeX, sizeY, sizeZ, extraX, extraY, extraZ, mirror, textureWidth, textureHeight, renderDirections); - } - - @Override - public ModelCuboid sodium$copy() { - return this.sodium$cuboid; - } -} diff --git a/common/src/sodiumCompatibility/java/net/irisshaders/iris/compat/sodium/mixin/copyEntity/ModelPartMixin.java b/common/src/sodiumCompatibility/java/net/irisshaders/iris/compat/sodium/mixin/copyEntity/ModelPartMixin.java deleted file mode 100644 index c9e19af525..0000000000 --- a/common/src/sodiumCompatibility/java/net/irisshaders/iris/compat/sodium/mixin/copyEntity/ModelPartMixin.java +++ /dev/null @@ -1,142 +0,0 @@ -package net.irisshaders.iris.compat.sodium.mixin.copyEntity; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import net.caffeinemc.mods.sodium.client.model.ModelCuboidAccessor; -import net.caffeinemc.mods.sodium.client.render.immediate.model.EntityRenderer; -import net.caffeinemc.mods.sodium.client.render.immediate.model.ModelCuboid; -import net.caffeinemc.mods.sodium.client.render.immediate.model.ModelPartData; -import net.caffeinemc.mods.sodium.client.render.vertex.VertexConsumerUtils; -import net.caffeinemc.mods.sodium.api.math.MatrixHelper; -import net.caffeinemc.mods.sodium.api.util.ColorABGR; -import net.caffeinemc.mods.sodium.api.util.ColorARGB; -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.minecraft.client.model.geom.ModelPart; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Mutable; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -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.CallbackInfo; - -import java.util.Collections; -import java.util.List; -import java.util.Map; - -@Mixin(ModelPart.class) -public class ModelPartMixin implements ModelPartData { - @Shadow - public float x; - @Shadow - public float y; - @Shadow - public float z; - - @Shadow - public float xScale; - @Shadow - public float yScale; - @Shadow - public float zScale; - - @Shadow - public float yRot; - @Shadow - public float xRot; - @Shadow - public float zRot; - - @Shadow - public boolean visible; - @Shadow - public boolean skipDraw; - - @Mutable - @Shadow - @Final - private List cubes; - - @Mutable - @Shadow - @Final - private Map children; - - @Unique - private ModelPart[] sodium$children; - - @Unique - private ModelCuboid[] sodium$cuboids; - - @Inject(method = "", at = @At("RETURN")) - private void onInit(List cuboids, Map children, CallbackInfo ci) { - var copies = new ModelCuboid[cuboids.size()]; - - for (int i = 0; i < cuboids.size(); i++) { - var accessor = (ModelCuboidAccessor) cuboids.get(i); - copies[i] = accessor.sodium$copy(); - } - - this.sodium$cuboids = copies; - this.sodium$children = children.values() - .toArray(ModelPart[]::new); - - // Try to catch errors caused by mods touching the collections after we've copied everything. - this.cubes = Collections.unmodifiableList(this.cubes); - this.children = Collections.unmodifiableMap(this.children); - } - - @Inject(method = "render(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;III)V", at = @At("HEAD"), cancellable = true) - private void onRender(PoseStack matrices, VertexConsumer vertices, int light, int overlay, int color, CallbackInfo ci) { - VertexBufferWriter writer = VertexConsumerUtils.convertOrLog(vertices); - - if (writer == null) { - return; - } - - ci.cancel(); - - EntityRenderer.render(matrices, writer, (ModelPart) (Object) this, light, overlay, ColorARGB.toABGR(color)); - } - - /** - * @author JellySquid - * @reason Apply transform more quickly - */ - @Overwrite - public void translateAndRotate(PoseStack matrixStack) { - if (this.x != 0.0F || this.y != 0.0F || this.z != 0.0F) { - matrixStack.translate(this.x * (1.0f / 16.0f), this.y * (1.0f / 16.0f), this.z * (1.0f / 16.0f)); - } - - if (this.xRot != 0.0F || this.yRot != 0.0F || this.zRot != 0.0F) { - MatrixHelper.rotateZYX(matrixStack.last(), this.zRot, this.yRot, this.xRot); - } - - if (this.xScale != 1.0F || this.yScale != 1.0F || this.zScale != 1.0F) { - matrixStack.scale(this.xScale, this.yScale, this.zScale); - } - } - - @Override - public ModelCuboid[] getCuboids() { - return this.sodium$cuboids; - } - - @Override - public boolean isVisible() { - return this.visible; - } - - @Override - public boolean isHidden() { - return this.skipDraw; - } - - @Override - public ModelPart[] getChildren() { - return this.sodium$children; - } -} diff --git a/common/src/sodiumCompatibility/java/net/irisshaders/iris/compat/sodium/mixin/copyEntity/cull/EntityRendererMixin.java b/common/src/sodiumCompatibility/java/net/irisshaders/iris/compat/sodium/mixin/copyEntity/cull/EntityRendererMixin.java deleted file mode 100644 index dbe32c534a..0000000000 --- a/common/src/sodiumCompatibility/java/net/irisshaders/iris/compat/sodium/mixin/copyEntity/cull/EntityRendererMixin.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.irisshaders.iris.compat.sodium.mixin.copyEntity.cull; - -import net.caffeinemc.mods.sodium.client.render.SodiumWorldRenderer; -import net.minecraft.client.renderer.culling.Frustum; -import net.minecraft.client.renderer.entity.EntityRenderer; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.phys.AABB; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(EntityRenderer.class) -public abstract class EntityRendererMixin { - @Redirect( - method = "shouldRender", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/culling/Frustum;isVisible(Lnet/minecraft/world/phys/AABB;)Z", - ordinal = 0 - ) - ) - private boolean preShouldRender(Frustum instance, AABB box, Entity entity) { - SodiumWorldRenderer renderer = SodiumWorldRenderer.instanceNullable(); - if (renderer == null) { - return instance.isVisible(box); - } else { - return instance.isVisible(box) && renderer.isEntityVisible(entity); - } - } -} diff --git a/common/src/sodiumCompatibility/java/net/irisshaders/iris/compat/sodium/mixin/copyEntity/shadows/EntityRenderDispatcherMixin.java b/common/src/sodiumCompatibility/java/net/irisshaders/iris/compat/sodium/mixin/copyEntity/shadows/EntityRenderDispatcherMixin.java deleted file mode 100644 index 3c808fef7f..0000000000 --- a/common/src/sodiumCompatibility/java/net/irisshaders/iris/compat/sodium/mixin/copyEntity/shadows/EntityRenderDispatcherMixin.java +++ /dev/null @@ -1,134 +0,0 @@ -package net.irisshaders.iris.compat.sodium.mixin.copyEntity.shadows; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import net.caffeinemc.mods.sodium.client.render.vertex.VertexConsumerUtils; -import net.caffeinemc.mods.sodium.api.math.MatrixHelper; -import net.caffeinemc.mods.sodium.api.util.ColorABGR; -import net.caffeinemc.mods.sodium.api.vertex.buffer.VertexBufferWriter; -import net.caffeinemc.mods.sodium.api.vertex.format.common.ModelVertex; -import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.entity.EntityRenderDispatcher; -import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.world.level.LevelReader; -import net.minecraft.world.level.block.RenderShape; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.phys.AABB; -import net.minecraft.world.phys.shapes.VoxelShape; -import org.joml.Matrix4f; -import org.lwjgl.system.MemoryStack; -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.CallbackInfo; - -@Mixin(EntityRenderDispatcher.class) -public class EntityRenderDispatcherMixin { - @Unique - private static final int SHADOW_COLOR = ColorABGR.pack(1.0f, 1.0f, 1.0f); - - /** - * @author JellySquid - * @reason Reduce vertex assembly overhead for shadow rendering - */ - @Inject(method = "renderBlockShadow", at = @At("HEAD"), cancellable = true) - private static void renderShadowPartFast(PoseStack.Pose entry, VertexConsumer vertices, ChunkAccess chunk, LevelReader world, BlockPos pos, double x, double y, double z, float radius, float opacity, CallbackInfo ci) { - var writer = VertexConsumerUtils.convertOrLog(vertices); - - if (writer == null) { - return; - } - - ci.cancel(); - - BlockPos blockPos = pos.below(); - BlockState blockState = world.getBlockState(blockPos); - - if (blockState.getRenderShape() == RenderShape.INVISIBLE || !blockState.isCollisionShapeFullBlock(world, blockPos)) { - return; - } - - var light = world.getMaxLocalRawBrightness(pos); - - if (light <= 3) { - return; - } - - VoxelShape voxelShape = blockState.getShape(world, blockPos); - - if (voxelShape.isEmpty()) { - return; - } - - float brightness = LightTexture.getBrightness(world.dimensionType(), light); - float alpha = (float) (((double) opacity - ((y - (double) pos.getY()) / 2.0)) * 0.5 * (double) brightness); - - if (alpha >= 0.0F) { - if (alpha > 1.0F) { - alpha = 1.0F; - } - - AABB box = voxelShape.bounds(); - - float minX = (float) ((pos.getX() + box.minX) - x); - float maxX = (float) ((pos.getX() + box.maxX) - x); - - float minY = (float) ((pos.getY() + box.minY) - y); - - float minZ = (float) ((pos.getZ() + box.minZ) - z); - float maxZ = (float) ((pos.getZ() + box.maxZ) - z); - - renderShadowPart(entry, writer, radius, alpha, minX, maxX, minY, minZ, maxZ); - } - } - - @Unique - private static void renderShadowPart(PoseStack.Pose matrices, VertexBufferWriter writer, float radius, float alpha, float minX, float maxX, float minY, float minZ, float maxZ) { - float size = 0.5F * (1.0F / radius); - - float u1 = (-minX * size) + 0.5F; - float u2 = (-maxX * size) + 0.5F; - - float v1 = (-minZ * size) + 0.5F; - float v2 = (-maxZ * size) + 0.5F; - - var matNormal = matrices.normal(); - var matPosition = matrices.pose(); - - var color = ColorABGR.withAlpha(SHADOW_COLOR, alpha); - var normal = MatrixHelper.transformNormal(matNormal, matrices.trustedNormals, Direction.UP); - - try (MemoryStack stack = MemoryStack.stackPush()) { - long buffer = stack.nmalloc(4 * ModelVertex.STRIDE); - long ptr = buffer; - - writeShadowVertex(ptr, matPosition, minX, minY, minZ, u1, v1, color, normal); - ptr += ModelVertex.STRIDE; - - writeShadowVertex(ptr, matPosition, minX, minY, maxZ, u1, v2, color, normal); - ptr += ModelVertex.STRIDE; - - writeShadowVertex(ptr, matPosition, maxX, minY, maxZ, u2, v2, color, normal); - ptr += ModelVertex.STRIDE; - - writeShadowVertex(ptr, matPosition, maxX, minY, minZ, u2, v1, color, normal); - ptr += ModelVertex.STRIDE; - - writer.push(stack, buffer, 4, ModelVertex.FORMAT); - } - } - - @Unique - private static void writeShadowVertex(long ptr, Matrix4f matPosition, float x, float y, float z, float u, float v, int color, int normal) { - // 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); - - ModelVertex.write(ptr, xt, yt, zt, color, u, v, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, normal); - } -} diff --git a/common/src/sodiumCompatibility/resources/mixins.iris.compat.sodium.json b/common/src/sodiumCompatibility/resources/mixins.iris.compat.sodium.json index 953bf5da65..899477979c 100644 --- a/common/src/sodiumCompatibility/resources/mixins.iris.compat.sodium.json +++ b/common/src/sodiumCompatibility/resources/mixins.iris.compat.sodium.json @@ -16,10 +16,6 @@ "block_id.MixinChunkRenderRebuildTask", "block_id.MixinChunkVertexBufferBuilder", "clouds.MixinCloudRenderer", - "copyEntity.CuboidMixin", - "copyEntity.ModelPartMixin", - "copyEntity.cull.EntityRendererMixin", - "copyEntity.shadows.EntityRenderDispatcherMixin", "directional_shading.MixinFlatLightPipeline", "directional_shading.MixinSmoothLightPipeline", "font.MixinGlyphRenderer", diff --git a/fabric/src/main/java/net/irisshaders/iris/mixin/fabric/MixinDHCrashFix.java b/fabric/src/main/java/net/irisshaders/iris/mixin/fabric/MixinDHCrashFix.java index 0d23877c39..5dfb68a57a 100644 --- a/fabric/src/main/java/net/irisshaders/iris/mixin/fabric/MixinDHCrashFix.java +++ b/fabric/src/main/java/net/irisshaders/iris/mixin/fabric/MixinDHCrashFix.java @@ -29,7 +29,7 @@ public class MixinDHCrashFix { * @author IMS * @reason see above */ - @Overwrite + @Overwrite(remap = false) public HashSet getNormalRenderedChunks() { SodiumWorldRenderer renderer = SodiumWorldRenderer.instance(); LevelHeightAccessor height = Minecraft.getInstance().level; @@ -38,7 +38,7 @@ public HashSet getNormalRenderedChunks() { }).collect(Collectors.toCollection(HashSet::new)); } - @Overwrite + @Overwrite(remap = false) public void setFogOcclusion(boolean b) { SodiumClientMod.options().performance.useFogOcclusion = b; } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 893a5e56d6..30dfbb2d97 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -60,7 +60,6 @@ "custom": { "sodium:options": { "mixin.features.render.world.sky": false, - "mixin.features.render.entity": false, "mixin.features.render.gui.font": false }, "mc-publish": {