Skip to content

Commit

Permalink
The Trimming
Browse files Browse the repository at this point in the history
  • Loading branch information
IMS212 committed Aug 4, 2023
1 parent 3ebef6f commit f94b6c6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.coderbot.iris.mixin.entity_render_context;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
import net.coderbot.iris.uniforms.CapturedRenderingState;
Expand All @@ -9,6 +10,7 @@
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
import net.minecraft.client.renderer.entity.layers.RenderLayer;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -43,15 +45,15 @@ private void changeId(PoseStack pHumanoidArmorLayer0, MultiBufferSource pMultiBu
private int backupValue = 0;

@Inject(method = "renderTrim", at = @At(value = "HEAD"), locals = LocalCapture.CAPTURE_FAILHARD)
private void changeTrimTemp(ArmorMaterial pHumanoidArmorLayer0, PoseStack pPoseStack1, MultiBufferSource pMultiBufferSource2, int pInt3, ArmorTrim pArmorTrim4, A pHumanoidModel5, boolean pBoolean6, CallbackInfo ci) {
private void changeTrimTemp(ArmorMaterial pHumanoidArmorLayer0, PoseStack pPoseStack1, MultiBufferSource pMultiBufferSource2, int pInt3, ArmorTrim pArmorTrim4, boolean pBoolean5, A pHumanoidModel6, boolean pBoolean7, float pFloat8, float pFloat9, float pFloat10, CallbackInfo ci) {
if (BlockRenderingSettings.INSTANCE.getItemIds() == null) return;

backupValue = CapturedRenderingState.INSTANCE.getCurrentRenderedItem();
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(BlockRenderingSettings.INSTANCE.getItemIds().applyAsInt(new NamespacedId("minecraft", "trim_" + pArmorTrim4.material().value().assetName())));
}

@Inject(method = "renderTrim", at = @At(value = "TAIL"), locals = LocalCapture.CAPTURE_FAILHARD)
private void changeTrimTemp2(ArmorMaterial pHumanoidArmorLayer0, PoseStack pPoseStack1, MultiBufferSource pMultiBufferSource2, int pInt3, ArmorTrim pArmorTrim4, A pHumanoidModel5, boolean pBoolean6, CallbackInfo ci) {
private void changeTrimTemp2(ArmorMaterial pHumanoidArmorLayer0, PoseStack pPoseStack1, MultiBufferSource pMultiBufferSource2, int pInt3, ArmorTrim pArmorTrim4, boolean pBoolean5, A pHumanoidModel6, boolean pBoolean7, float pFloat8, float pFloat9, float pFloat10, CallbackInfo ci, TextureAtlasSprite lvTextureAtlasSprite12, VertexConsumer lvVertexConsumer13) {
if (BlockRenderingSettings.INSTANCE.getItemIds() == null) return;
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(backupValue);
backupValue = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.jellysquid.mods.sodium.client.render.vertex.VertexFormatDescription;
import me.jellysquid.mods.sodium.common.util.MatrixHelper;
import net.coderbot.iris.vertices.IrisVertexFormats;
import net.coderbot.iris.vertices.NormI8;
import net.coderbot.iris.vertices.NormalHelper;
import org.joml.Matrix4f;
import org.joml.Vector3f;
Expand Down Expand Up @@ -35,7 +36,7 @@ public static void write(long ptr, Matrix4f matrix, float x, float y, float z, i
quad.setup(ptr, STRIDE);

NormalHelper.computeFaceNormal(saveNormal, quad);
int normal = NormalHelper.packNormal(saveNormal, 0.0F);
int normal = NormI8.pack(saveNormal);

for (long vertex = 0; vertex < 4; vertex++) {
MemoryUtil.memPutInt(ptr + 16L - STRIDE * vertex, normal);
Expand All @@ -56,7 +57,7 @@ public static void write(long ptr, float x, float y, float z, int color) {
quad.setup(ptr, STRIDE);

NormalHelper.computeFaceNormal(saveNormal, quad);
int normal = NormalHelper.packNormal(saveNormal, 0.0F);
int normal = NormI8.pack(saveNormal);

for (long vertex = 0; vertex < 4; vertex++) {
MemoryUtil.memPutInt(ptr + 16L - STRIDE * vertex, normal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import me.jellysquid.mods.sodium.client.util.Norm3b;
import net.coderbot.iris.uniforms.CapturedRenderingState;
import net.coderbot.iris.vertices.IrisVertexFormats;
import net.coderbot.iris.vertices.NormI8;
import net.coderbot.iris.vertices.NormalHelper;
import net.minecraft.client.renderer.texture.OverlayTexture;
import org.joml.Matrix3f;
Expand Down Expand Up @@ -83,7 +84,7 @@ private static void endQuad(long ptr) {
normalX = saveNormal.x;
normalY = saveNormal.y;
normalZ = saveNormal.z;
int normal = NormalHelper.packNormal(saveNormal, 0.0F);
int normal = NormI8.pack(saveNormal);

int tangent = NormalHelper.computeTangent(normalX, normalY, normalZ, quad);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import me.jellysquid.mods.sodium.client.render.vertex.type.ChunkVertexEncoder;
import net.coderbot.iris.compat.sodium.impl.block_context.BlockContextHolder;
import net.coderbot.iris.compat.sodium.impl.block_context.ContextAwareVertexWriter;
import net.coderbot.iris.vertices.NormI8;
import org.joml.Vector3f;
import net.coderbot.iris.vertices.ExtendedDataHelper;
import net.coderbot.iris.vertices.NormalHelper;
Expand Down Expand Up @@ -140,7 +141,7 @@ public long write(long ptr,
} else {
NormalHelper.computeFaceNormal(normal, quad);
}
int packedNormal = NormalHelper.packNormal(normal, 0.0f);
int packedNormal = NormI8.pack(normal);



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import me.jellysquid.mods.sodium.client.util.color.ColorABGR;
import net.coderbot.iris.compat.sodium.impl.vertex_format.entity_xhfp.EntityVertex;
import net.coderbot.iris.vertices.ImmediateState;
import net.coderbot.iris.vertices.NormI8;
import net.coderbot.iris.vertices.NormalHelper;
import net.irisshaders.iris.api.v0.IrisApi;
import net.minecraft.client.model.geom.ModelPart;
Expand Down Expand Up @@ -181,6 +182,6 @@ private int getTangent(int normal, float x0, float y0, float z0, float u0, float
tangentW = 1.0F;
}

return NormalHelper.packNormal(tangentx, tangenty, tangentz, tangentW);
return NormI8.pack(tangentx, tangenty, tangentz, tangentW);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import me.jellysquid.mods.sodium.common.util.MatrixHelper;
import net.coderbot.iris.compat.sodium.impl.vertex_format.entity_xhfp.EntityVertex;
import net.coderbot.iris.vertices.ImmediateState;
import net.coderbot.iris.vertices.NormI8;
import net.coderbot.iris.vertices.NormalHelper;
import net.irisshaders.iris.api.v0.IrisApi;
import net.minecraft.client.renderer.LightTexture;
Expand Down Expand Up @@ -188,7 +189,7 @@ private static int getTangent(int normal, float x0, float y0, float z0, float u0
tangentW = 1.0F;
}

return NormalHelper.packNormal(tangentx, tangenty, tangentz, tangentW);
return NormI8.pack(tangentx, tangenty, tangentz, tangentW);
}

private static float rsqrt(float value) {
Expand Down

0 comments on commit f94b6c6

Please sign in to comment.