POM Support (#1927)

Co-authored-by: Jason Mitchell <[email protected]>
This commit is contained in:
Eclipse-SolandJason Mitchell authored and GitHub committed 2026-09-03 22:28:20 -07:00
1 parent 0dfffca88e
commit ffc324bab6
38 files changed
+1920 -166

No files matched your search

@@ -8,6 +8,7 @@ import com.gtnewhorizons.angelica.glsm.RenderSystem;
import com.gtnewhorizons.angelica.glsm.backend.BackendManager;
import com.gtnewhorizons.angelica.glsm.shader.GlslVulkanPreprocess;
import com.gtnewhorizons.angelica.glsm.shader.SpirvCompiler;
import com.gtnewhorizons.angelica.iris.ImmediateExtendedAttribs;
import com.gtnewhorizons.angelica.iris.IrisGLSMBridge;
import com.gtnewhorizons.angelica.proxy.ClientProxy;
import com.gtnewhorizons.angelica.rendering.StateAwareTessellator;
@@ -802,6 +803,9 @@ public class Iris {
// Load the new shaderpack
loadShaderpack();
// Drop the stale program probe and cached item geometry
ImmediateExtendedAttribs.onShaderPackChanged();
// Very important - we need to re-create the pipeline straight away.
// https://github.com/IrisShaders/Iris/issues/1330
if (Minecraft.getMinecraft().theWorld != null) {
@@ -5,6 +5,7 @@ package net.coderbot.iris.gl.shader;
import com.gtnewhorizons.angelica.glsm.GLDebug;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.RenderSystem;
import com.gtnewhorizons.angelica.glsm.hooks.ImmediateExtendedAttribHandler;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.opengl.GL11;
@@ -15,10 +16,10 @@ public class ProgramCreator {
private static final Logger LOGGER = LogManager.getLogger("ProgramCreator");
public static final int MC_ENTITY = 11;
public static final int MC_MID_TEX_COORD = 12;
public static final int AT_TANGENT = 13;
public static final int AT_MIDBLOCK = 14;
public static final int MC_ENTITY = ImmediateExtendedAttribHandler.LOC_MC_ENTITY;
public static final int MC_MID_TEX_COORD = ImmediateExtendedAttribHandler.LOC_MID_TEX;
public static final int AT_TANGENT = ImmediateExtendedAttribHandler.LOC_TANGENT;
public static final int AT_MIDBLOCK = ImmediateExtendedAttribHandler.LOC_MIDBLOCK;
public static int create(String name, GlShader... shaders) {
int program = GLStateManager.glCreateProgram();
@@ -4,6 +4,7 @@ import lombok.Getter;
import net.coderbot.iris.Iris;
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
import com.gtnewhorizons.angelica.glsm.GLStateManager;
import com.gtnewhorizons.angelica.glsm.ffp.FfpExtendedAttribs;
import com.gtnewhorizons.angelica.glsm.states.AlphaState;
import com.gtnewhorizons.angelica.glsm.states.BlendState;
import net.coderbot.iris.gl.shader.ProgramCreator;
@@ -240,8 +241,7 @@ public class GbufferPrograms {
public static void setBlockEntityDefaults() {
GLStateManager.glVertexAttrib2s(ProgramCreator.MC_ENTITY, (short)-1, (short)-1);
GLStateManager.glVertexAttrib2f(ProgramCreator.MC_MID_TEX_COORD, 0.5f, 0.5f);
GLStateManager.glVertexAttrib4f(ProgramCreator.AT_TANGENT, 1.0f, 0.0f, 0.0f, 1.0f);
FfpExtendedAttribs.setNeutralCurrentValues();
GLStateManager.glVertexAttrib4f(ProgramCreator.AT_MIDBLOCK, 0.0f, 0.0f, 0.0f, 0.0f);
}
@@ -87,7 +87,6 @@ class AttributeTransformer {
if (instancedVertex) {
foldConstantAttribute(transformer, "mc_Entity", "-1.0", "vec2(-1.0, -1.0)", "vec3(-1.0, -1.0, 0.0)", "vec4(-1.0, -1.0, 0.0, 1.0)");
foldConstantAttribute(transformer, "mc_midTexCoord", "0.5", "vec2(0.5, 0.5)", "vec3(0.5, 0.5, 0.0)", "vec4(0.5, 0.5, 0.0, 1.0)");
final StringBuilder init = new StringBuilder(256);
init.append("{ iris_ModelViewMatrix = mat4(iris_InstMat0, iris_InstMat1, iris_InstMat2, iris_InstMat3);");
@@ -1,5 +1,6 @@
package net.coderbot.iris.pipeline.transform;
import com.gtnewhorizons.angelica.glsm.ffp.InstancedAttribs;
import org.taumc.glsl.Transformer;
import java.util.HashMap;
@@ -20,12 +21,12 @@ class CoreTransformHelper {
static void injectMatrixUniforms(Transformer transformer, boolean instancedVertex) {
if (instancedVertex) {
transformer.injectVariable("layout(location = 7) in vec4 iris_InstMat0;");
transformer.injectVariable("layout(location = 8) in vec4 iris_InstMat1;");
transformer.injectVariable("layout(location = 9) in vec4 iris_InstMat2;");
transformer.injectVariable("layout(location = 10) in vec4 iris_InstMat3;");
transformer.injectVariable("layout(location = 11) in vec4 iris_InstColor;");
transformer.injectVariable("layout(location = 12) in vec2 iris_InstLightmap;");
transformer.injectVariable("layout(location = " + InstancedAttribs.LOC_MATRIX_COL0 + ") in vec4 iris_InstMat0;");
transformer.injectVariable("layout(location = " + InstancedAttribs.LOC_MATRIX_COL1 + ") in vec4 iris_InstMat1;");
transformer.injectVariable("layout(location = " + InstancedAttribs.LOC_MATRIX_COL2 + ") in vec4 iris_InstMat2;");
transformer.injectVariable("layout(location = " + InstancedAttribs.LOC_MATRIX_COL3 + ") in vec4 iris_InstMat3;");
transformer.injectVariable("layout(location = " + InstancedAttribs.LOC_COLOR + ") in vec4 iris_InstColor;");
transformer.injectVariable("layout(location = " + InstancedAttribs.LOC_LIGHTMAP + ") in vec2 iris_InstLightmap;");
transformer.injectVariable("mat4 iris_ModelViewMatrix;");
transformer.injectVariable("mat4 iris_ModelViewMatrixInverse;");
transformer.injectVariable("mat3 iris_NormalMatrix;");
@@ -89,7 +89,7 @@ public class PBRAtlasTexture extends AutoClosableAbstractTexture {
}
if (AngelicaConfig.enablePBRDebug) {
TextureExporter.exportTextures("pbr_debug/atlas", id.getResourceDomain() + "_" + id.getResourcePath().replaceAll("/", "_"), glId, mipLevel, atlasWidth, atlasHeight);
TextureExporter.exportTextures("pbr_debug/atlas", id.getResourceDomain() + "_" + id.getResourcePath().replace("/", "_") + ".png", glId, mipLevel, atlasWidth, atlasHeight);
}
}
@@ -2,10 +2,10 @@ package net.coderbot.iris.texture.pbr.loader;
import com.google.common.collect.Lists;
import com.gtnewhorizons.angelica.compat.mojang.NativeImage;
import com.gtnewhorizons.angelica.config.AngelicaConfig;
import com.gtnewhorizons.angelica.glsm.texture.TextureInfo;
import com.gtnewhorizons.angelica.glsm.texture.TextureInfoCache;
import com.gtnewhorizons.angelica.mixins.interfaces.ISpriteExt;
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptions;
import net.coderbot.iris.Iris;
import net.coderbot.iris.texture.format.TextureFormat;
import net.coderbot.iris.texture.format.TextureFormatLoader;
@@ -17,10 +17,13 @@ import net.coderbot.iris.texture.pbr.PBRSpriteHolder;
import net.coderbot.iris.texture.pbr.PBRType;
import net.coderbot.iris.texture.pbr.TextureAtlasSpriteExtension;
import net.coderbot.iris.texture.util.ImageManipulationUtil;
import net.coderbot.iris.texture.util.TextureExporter;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.texture.TextureUtil;
import net.minecraft.client.resources.IResource;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.data.AnimationFrame;
import net.minecraft.client.resources.data.AnimationMetadataSection;
import net.minecraft.util.ResourceLocation;
import org.apache.commons.lang3.tuple.Pair;
@@ -28,7 +31,11 @@ import org.apache.commons.lang3.tuple.Pair;
import javax.annotation.Nullable;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
public static final ChannelMipmapGenerator LINEAR_MIPMAP_GENERATOR = new ChannelMipmapGenerator(
@@ -84,6 +91,45 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
pbrTextureConsumer.acceptSpecularTexture(specularAtlas);
}
}
if (AngelicaConfig.enablePBRDebug && (normalAtlas != null || specularAtlas != null)) {
TextureExporter.exportTextures("pbr_debug/atlas", "base_atlas.png", texMap.getGlTextureId(), mipLevel, atlasWidth, atlasHeight);
}
}
@Nullable
private static NativeImage padAnisotropic(NativeImage image, int frameWidth, int frameHeight) {
final int width = image.getWidth();
final int height = image.getHeight();
final int frames = (frameWidth == width && frameHeight > 0) ? height / frameHeight : 0;
if (frames < 1) {
return null;
}
final int paddedWidth = frameWidth + 16;
final int paddedHeight = frameHeight + 16;
final int framePixels = paddedWidth * paddedHeight;
final NativeImage padded = new NativeImage(paddedWidth, paddedHeight * frames, false);
final int[] frame = new int[framePixels];
for (int f = 0; f < frames; f++) {
Arrays.fill(frame, 0);
image.getRGB(0, f * frameHeight, frameWidth, frameHeight, frame, 0, frameWidth);
TextureUtil.prepareAnisotropicData(frame, frameWidth, frameHeight, 8);
padded.setRGB(0, f * paddedHeight, paddedWidth, paddedHeight, frame, 0, paddedWidth);
}
return padded;
}
private static AnimationMetadataSection withFrameSize(AnimationMetadataSection src, int frameWidth, int frameHeight) {
final List<AnimationFrame> frames = new ArrayList<>(src.getFrameCount());
for (int f = 0; f < src.getFrameCount(); f++) {
frames.add(new AnimationFrame(src.getFrameIndex(f), src.frameHasTime(f) ? src.getFrameTimeSingle(f) : -1));
}
return new AnimationMetadataSection(frames,
src.getFrameWidth() != -1 ? frameWidth : -1,
src.getFrameHeight() != -1 ? frameHeight : -1,
src.getFrameTime());
}
protected static int fetchAtlasMipLevel(TextureMap texMap) {
@@ -104,18 +150,15 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
NativeImage nativeImage = NativeImage.read(resource.getInputStream());
AnimationMetadataSection animationMetadata = (AnimationMetadataSection) resource.getMetadata("animation");
if (animationMetadata == null) {
final IResource resourceOriginal = resourceManager.getResource(imageLocation);
animationMetadata = (AnimationMetadataSection) resourceOriginal.getMetadata("animation");
if (animationMetadata == null) {
animationMetadata = new AnimationMetadataSection(Lists.newArrayList(), -1, -1, -1);
}
animationMetadata = new AnimationMetadataSection(Lists.newArrayList(), -1, -1, -1);
}
final Pair<Integer, Integer> frameSize = this.getFrameSize(nativeImage.getWidth(), nativeImage.getHeight(), animationMetadata);
int frameWidth = frameSize.getLeft();
int frameHeight = frameSize.getRight();
final int targetFrameWidth = sprite.getIconWidth();
final int targetFrameHeight = sprite.getIconHeight();
final int spritePadding = sprite.useAnisotropicFiltering ? 16 : 0;
final int targetFrameWidth = sprite.getIconWidth() - spritePadding;
final int targetFrameHeight = sprite.getIconHeight() - spritePadding;
if (frameWidth != targetFrameWidth || frameHeight != targetFrameHeight) {
final int imageWidth = nativeImage.getWidth();
final int imageHeight = nativeImage.getHeight();
@@ -139,15 +182,8 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
frameWidth = targetFrameWidth;
frameHeight = targetFrameHeight;
if (!animationMetadata.equals(new AnimationMetadataSection(Lists.newArrayList(), -1, -1, -1))) {
final int internalFrameWidth = animationMetadata.frameHeight;
final int internalFrameHeight = animationMetadata.frameWidth;
if (internalFrameWidth != -1) {
animationMetadata.frameWidth = frameWidth;
}
if (internalFrameHeight != -1) {
animationMetadata.frameHeight = frameHeight;
}
if (animationMetadata.getFrameWidth() != -1 || animationMetadata.getFrameHeight() != -1) {
animationMetadata = withFrameSize(animationMetadata, frameWidth, frameHeight);
}
}
@@ -156,7 +192,15 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
final int x = sprite.getOriginX();
final int y = sprite.getOriginY();
pbrSprite = new PBRTextureAtlasSprite(pbrSpriteInfo, animationMetadata, atlasWidth, atlasHeight, x, y, nativeImage, texMap, mipLevel);
boolean padInLoadSprite = sprite.useAnisotropicFiltering;
if (padInLoadSprite) {
final NativeImage padded = padAnisotropic(nativeImage, frameWidth, frameHeight);
if (padded != null) {
nativeImage = padded;
padInLoadSprite = false;
}
}
pbrSprite = new PBRTextureAtlasSprite(pbrSpriteInfo, animationMetadata, atlasWidth, atlasHeight, x, y, nativeImage, padInLoadSprite, mipLevel);
syncAnimation(sprite, pbrSprite);
} catch (FileNotFoundException e) {
//
@@ -217,12 +261,10 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
public static class PBRTextureAtlasSprite extends TextureAtlasSprite implements CustomMipmapGenerator.Provider {
// This feels super janky
protected PBRTextureAtlasSprite(TextureAtlasSpriteInfo info, AnimationMetadataSection animationMetaDataSection, int atlasWidth, int atlasHeight, int x, int y, NativeImage nativeImage, TextureMap texMap, int miplevel) {
protected PBRTextureAtlasSprite(TextureAtlasSpriteInfo info, AnimationMetadataSection animationMetaDataSection, int atlasWidth, int atlasHeight, int x, int y, NativeImage nativeImage, boolean useAnisotropicFiltering, int miplevel) {
super(info.name().toString());
super.loadSprite(Objects.requireNonNull(getMipmapGenerator(info, atlasWidth, atlasHeight)).generateMipLevels(nativeImage, miplevel), animationMetaDataSection, useAnisotropicFiltering);
super.initSprite(atlasWidth, atlasHeight, x, y, false);
final boolean useAnisotropicFiltering = texMap.anisotropicFiltering > 1
|| SodiumGameOptions.needsForcedSpritePadding();
super.loadSprite(getMipmapGenerator(info, atlasWidth, atlasHeight).generateMipLevels(nativeImage, miplevel), animationMetaDataSection, useAnisotropicFiltering);
}
@Override