Fixed glitchy magic glows with vulkan mod

This commit is contained in:
Sollace 2023-08-19 22:42:35 +01:00
parent db75aa1600
commit 5a0d3a073d
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB

View file

@ -1,5 +1,6 @@
package com.minelittlepony.client.render; package com.minelittlepony.client.render;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.render.RenderLayer; import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderPhase; import net.minecraft.client.render.RenderPhase;
import net.minecraft.client.render.VertexFormat; import net.minecraft.client.render.VertexFormat;
@ -8,16 +9,21 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.Util; import net.minecraft.util.Util;
import com.mojang.blaze3d.systems.RenderSystem; import com.mojang.blaze3d.systems.RenderSystem;
import com.google.common.base.Suppliers;
import com.minelittlepony.common.util.Color; import com.minelittlepony.common.util.Color;
import java.util.function.BiFunction; import java.util.function.BiFunction;
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(String name, Runnable beginAction, Runnable endAction) {
super(name, beginAction, 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<RenderLayer> 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) .program(EYES_PROGRAM)
.writeMaskState(COLOR_MASK) .writeMaskState(COLOR_MASK)
.depthTest(LEQUAL_DEPTH_TEST) .depthTest(LEQUAL_DEPTH_TEST)
@ -25,6 +31,7 @@ public abstract class MagicGlow extends RenderPhase {
.lightmap(DISABLE_LIGHTMAP) .lightmap(DISABLE_LIGHTMAP)
.cull(DISABLE_CULLING) .cull(DISABLE_CULLING)
.build(false)); .build(false));
});
private static final BiFunction<Identifier, Integer, RenderLayer> TINTED_LAYER = Util.memoize((texture, color) -> { private static final BiFunction<Identifier, Integer, RenderLayer> 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() 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() { public static RenderLayer getRenderLayer() {
return MAGIC; return MAGIC.get();
} }
public static RenderLayer getColoured(Identifier texture, int color) { public static RenderLayer getColoured(Identifier texture, int color) {