Allow armor to render with translucency

This commit is contained in:
Sollace 2023-09-27 12:11:20 +01:00
parent 24a8afc508
commit ca728ded81
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 39 additions and 7 deletions

View file

@ -0,0 +1,33 @@
package com.minelittlepony.client.render;
import net.minecraft.client.render.*;
import net.minecraft.client.render.RenderLayer.MultiPhaseParameters;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import java.util.function.BiFunction;
public class ArmorRenderLayers extends RenderPhase {
private ArmorRenderLayers() {
super(null, null, null);
}
private static final BiFunction<Identifier, Boolean, RenderLayer> ARMOR_TRANSLUCENT_NO_CULL = Util.memoize((texture, decal) -> {
return RenderLayer.of(decal ? "armor_decal_translucent_no_cull" : "armor_translucent_no_cull",
VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, VertexFormat.DrawMode.QUADS, 256, true, false, MultiPhaseParameters.builder()
.program(ARMOR_CUTOUT_NO_CULL_PROGRAM)
.texture(new RenderPhase.Texture(texture, false, false))
.transparency(TRANSLUCENT_TRANSPARENCY)
.cull(DISABLE_CULLING)
.lightmap(ENABLE_LIGHTMAP)
.overlay(ENABLE_OVERLAY_COLOR)
.layering(VIEW_OFFSET_Z_LAYERING)
.depthTest(decal ? EQUAL_DEPTH_TEST : LEQUAL_DEPTH_TEST)
.build(true)
);
});
public static RenderLayer getArmorTranslucentNoCull(Identifier texture, boolean decal) {
return ARMOR_TRANSLUCENT_NO_CULL.apply(texture, decal);
}
}

View file

@ -16,8 +16,8 @@ import java.util.function.BiFunction;
import java.util.function.Supplier; import java.util.function.Supplier;
public abstract class MagicGlow extends RenderPhase { public abstract class MagicGlow extends RenderPhase {
private MagicGlow(String name, Runnable beginAction, Runnable endAction) { private MagicGlow() {
super(name, beginAction, endAction); super(null, null, null);
} }
private static final Supplier<RenderLayer> MAGIC = Suppliers.memoize(() -> { private static final Supplier<RenderLayer> MAGIC = Suppliers.memoize(() -> {
@ -54,7 +54,6 @@ public abstract class MagicGlow extends RenderPhase {
} }
private static class Colored extends Texture { private static class Colored extends Texture {
private final float red; private final float red;
private final float green; private final float green;
private final float blue; private final float blue;

View file

@ -3,6 +3,7 @@ package com.minelittlepony.client.render.entity.feature;
import com.minelittlepony.api.model.ModelWrapper; import com.minelittlepony.api.model.ModelWrapper;
import com.minelittlepony.api.model.PonyModel; import com.minelittlepony.api.model.PonyModel;
import com.minelittlepony.client.model.armour.*; import com.minelittlepony.client.model.armour.*;
import com.minelittlepony.client.render.ArmorRenderLayers;
import com.minelittlepony.client.render.PonyRenderContext; import com.minelittlepony.client.render.PonyRenderContext;
import com.minelittlepony.common.util.Color; import com.minelittlepony.common.util.Color;
@ -95,7 +96,7 @@ public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & Po
} }
private static VertexConsumer getArmorConsumer(VertexConsumerProvider provider, Identifier texture, boolean glint) { private static VertexConsumer getArmorConsumer(VertexConsumerProvider provider, Identifier texture, boolean glint) {
return ItemRenderer.getArmorGlintConsumer(provider, RenderLayer.getArmorCutoutNoCull(texture), false, glint); return ItemRenderer.getArmorGlintConsumer(provider, ArmorRenderLayers.getArmorTranslucentNoCull(texture, false), false, glint);
} }
private static VertexConsumer getTrimConsumer(VertexConsumerProvider provider, ArmorMaterial material, ArmorTrim trim, ArmourLayer layer, boolean glint) { private static VertexConsumer getTrimConsumer(VertexConsumerProvider provider, ArmorMaterial material, ArmorTrim trim, ArmourLayer layer, boolean glint) {
@ -103,9 +104,8 @@ public class ArmourFeature<T extends LivingEntity, M extends EntityModel<T> & Po
Sprite sprite = armorTrimsAtlas.getSprite( Sprite sprite = armorTrimsAtlas.getSprite(
layer == ArmourLayer.INNER ? trim.getLeggingsModelId(material) : trim.getGenericModelId(material) layer == ArmourLayer.INNER ? trim.getLeggingsModelId(material) : trim.getGenericModelId(material)
); );
RenderLayer renderLayer = ArmorRenderLayers.getArmorTranslucentNoCull(TexturedRenderLayers.ARMOR_TRIMS_ATLAS_TEXTURE, trim.getPattern().value().decal());
return sprite.getTextureSpecificVertexConsumer( return sprite.getTextureSpecificVertexConsumer(ItemRenderer.getDirectItemGlintConsumer(provider, renderLayer, true, glint));
ItemRenderer.getDirectItemGlintConsumer(provider, TexturedRenderLayers.getArmorTrims(trim.getPattern().value().decal()), true, glint)
);
} }
} }