From 5a0d3a073de15a82551d6f39e572697848ab8f53 Mon Sep 17 00:00:00 2001 From: Sollace Date: Sat, 19 Aug 2023 22:42:35 +0100 Subject: [PATCH] Fixed glitchy magic glows with vulkan mod --- .../com/minelittlepony/client/render/MagicGlow.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/minelittlepony/client/render/MagicGlow.java b/src/main/java/com/minelittlepony/client/render/MagicGlow.java index 11009f55..4c868829 100644 --- a/src/main/java/com/minelittlepony/client/render/MagicGlow.java +++ b/src/main/java/com/minelittlepony/client/render/MagicGlow.java @@ -1,5 +1,6 @@ package com.minelittlepony.client.render; +import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.RenderPhase; import net.minecraft.client.render.VertexFormat; @@ -8,16 +9,21 @@ import net.minecraft.util.Identifier; import net.minecraft.util.Util; import com.mojang.blaze3d.systems.RenderSystem; +import com.google.common.base.Suppliers; import com.minelittlepony.common.util.Color; import java.util.function.BiFunction; +import java.util.function.Supplier; public abstract class MagicGlow extends RenderPhase { private MagicGlow(String name, Runnable beginAction, Runnable endAction) { super(name, beginAction, endAction); } - private static final RenderLayer MAGIC = RenderLayer.of("mlp_magic_glow", VertexFormats.POSITION_COLOR_LIGHT, VertexFormat.DrawMode.QUADS, 256, RenderLayer.MultiPhaseParameters.builder() + private static final Supplier MAGIC = Suppliers.memoize(() -> { + return RenderLayer.of("mlp_magic_glow", + FabricLoader.getInstance().isModLoaded("vulkanmod") ? VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL : VertexFormats.POSITION_COLOR_LIGHT, + VertexFormat.DrawMode.QUADS, 256, RenderLayer.MultiPhaseParameters.builder() .program(EYES_PROGRAM) .writeMaskState(COLOR_MASK) .depthTest(LEQUAL_DEPTH_TEST) @@ -25,6 +31,7 @@ public abstract class MagicGlow extends RenderPhase { .lightmap(DISABLE_LIGHTMAP) .cull(DISABLE_CULLING) .build(false)); + }); private static final BiFunction TINTED_LAYER = Util.memoize((texture, color) -> { return RenderLayer.of("mlp_tint_layer", VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, VertexFormat.DrawMode.QUADS, 256, true, true, RenderLayer.MultiPhaseParameters.builder() @@ -39,7 +46,7 @@ public abstract class MagicGlow extends RenderPhase { }); public static RenderLayer getRenderLayer() { - return MAGIC; + return MAGIC.get(); } public static RenderLayer getColoured(Identifier texture, int color) {