mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-19 20:09:39 +00:00
Various Mixin-related Fixes (#890)
* Update deps * Remove dead code * Add missing `@Override` annotations * Fix generics * Add `serialVersionUID`s * Address deprecation warnings * Use `@WrapWithCondition` v2 * Misc cleanup * Use AccessTransformers if possible * Fix mixin conflicts * Add `@Mutable` annotations * Fix injection targets * Update deps
This commit is contained in:
1 parent
611bbf02c8
commit
bb5526598e
158 files changed
+252
-619
No files matched your search
@@ -306,7 +306,8 @@ public class Iris {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Map<String, String> changedConfigs = tryReadConfigProperties(shaderPackConfigTxt).map(properties -> (Map<String, String>) (Map) properties)
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<String, String> changedConfigs = tryReadConfigProperties(shaderPackConfigTxt).map(properties -> (Map<String, String>) (Map<?, ?>) properties)
|
||||
.orElse(new HashMap<>());
|
||||
|
||||
changedConfigs.putAll(shaderPackOptionQueue);
|
||||
|
||||
@@ -102,7 +102,8 @@ public class GlFramebuffer extends GlResource {
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_DRAW_FRAMEBUFFER, getGlId());
|
||||
}
|
||||
|
||||
protected void destroyInternal() {
|
||||
@Override
|
||||
protected void destroyInternal() {
|
||||
OpenGlHelper.func_153184_g/*glDeleteFramebuffers*/(getGlId());
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,8 @@ public final class ComputeProgram extends GlResource {
|
||||
GL20.glUseProgram(0);
|
||||
}
|
||||
|
||||
public void destroyInternal() {
|
||||
@Override
|
||||
public void destroyInternal() {
|
||||
GL20.glDeleteProgram(getGlId());
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ public final class Program extends GlResource {
|
||||
GL20.glUseProgram(0);
|
||||
}
|
||||
|
||||
public void destroyInternal() {
|
||||
@Override
|
||||
public void destroyInternal() {
|
||||
GL20.glDeleteProgram(getGlId());
|
||||
}
|
||||
|
||||
|
||||
@@ -148,9 +148,6 @@ public class ProgramUniforms {
|
||||
@Override
|
||||
public Builder addUniform(UniformUpdateFrequency updateFrequency, Uniform uniform) {
|
||||
Objects.requireNonNull(uniform);
|
||||
if(uniform == null) {
|
||||
throw new NullPointerException("uniform");
|
||||
}
|
||||
|
||||
switch (updateFrequency) {
|
||||
case ONCE:
|
||||
|
||||
@@ -2,23 +2,18 @@ package net.coderbot.iris.gui;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.gui.element.ShaderPackOptionList;
|
||||
import net.coderbot.iris.shaderpack.option.menu.OptionMenuContainer;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
|
||||
public class NavigationController {
|
||||
private final OptionMenuContainer container;
|
||||
|
||||
private ShaderPackOptionList optionList;
|
||||
|
||||
@Getter
|
||||
private String currentScreen = null;
|
||||
private final Deque<String> history = new ArrayDeque<>();
|
||||
|
||||
public NavigationController(OptionMenuContainer container) {
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public void back() {
|
||||
if (history.size() > 0) {
|
||||
history.removeLast();
|
||||
|
||||
@@ -153,7 +153,8 @@ public class IrisElementRow {
|
||||
this.onClick = onClick;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean mouseClicked(double mx, double my, int button) {
|
||||
if (this.disabled) {
|
||||
return false;
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ShaderPackOptionList extends IrisGuiSlot {
|
||||
row.add(element);
|
||||
|
||||
if (row.size() >= columns) {
|
||||
this.addEntry(new ElementRowEntry(screen, this.navigation, row));
|
||||
this.addEntry(new ElementRowEntry(this.navigation, row));
|
||||
row = new ArrayList<>(); // Clearing the list would affect the row entry created above
|
||||
}
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class ShaderPackOptionList extends IrisGuiSlot {
|
||||
row.add(AbstractElementWidget.EMPTY);
|
||||
}
|
||||
|
||||
this.addEntry(new ElementRowEntry(screen, this.navigation, row));
|
||||
this.addEntry(new ElementRowEntry(this.navigation, row));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ public class ShaderPackSelectionList extends IrisGuiSlot {
|
||||
}
|
||||
|
||||
public void addPackEntry(int index, String name) {
|
||||
final ShaderPackEntry entry = new ShaderPackEntry(index, this, name);
|
||||
final ShaderPackEntry entry = new ShaderPackEntry(this, name);
|
||||
|
||||
Iris.getIrisConfig().getShaderPackName().ifPresent(currentPackName -> {
|
||||
if (name.equals(currentPackName)) {
|
||||
|
||||
@@ -11,15 +11,12 @@ import java.util.List;
|
||||
public class ElementRowEntry extends BaseEntry {
|
||||
|
||||
private final List<AbstractElementWidget<?>> widgets;
|
||||
private final ShaderPackScreen screen;
|
||||
|
||||
private int cachedWidth;
|
||||
private int cachedPosX;
|
||||
|
||||
public ElementRowEntry(ShaderPackScreen screen, NavigationController navigation, List<AbstractElementWidget<?>> widgets) {
|
||||
public ElementRowEntry(NavigationController navigation, List<AbstractElementWidget<?>> widgets) {
|
||||
super(navigation);
|
||||
|
||||
this.screen = screen;
|
||||
this.widgets = widgets;
|
||||
}
|
||||
|
||||
@@ -51,10 +48,12 @@ public class ElementRowEntry extends BaseEntry {
|
||||
return MathHelper.clamp_int((int) Math.floor(widgets.size() * positionAcrossWidget), 0, widgets.size() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int button) {
|
||||
return this.widgets.get(getHoveredWidget(mouseX)).mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseReleased(int mouseX, int mouseY, int button) {
|
||||
return this.widgets.get(getHoveredWidget(mouseX)).mouseReleased(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public class HeaderEntry extends BaseEntry {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEntry(ShaderPackScreen screen, int index, int x, int y, int slotWidth, int slotHeight, Tessellator tessellator, int mouseX, int mouseY, boolean isMouseOver) {
|
||||
// Draw dividing line
|
||||
// fill(x - 3, (y + slotHeight) - 2, x + slotWidth, (y + slotHeight) - 1, 0x66BEBEBE);
|
||||
@@ -101,6 +102,7 @@ public class HeaderEntry extends BaseEntry {
|
||||
ShaderPackScreen.TOP_LAYER_RENDER_QUEUE.add(() -> GuiUtil.drawTextPanel(font, text, x - (font.getStringWidth(text) + 10), y - 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(int mouseX, int mouseY, int button) {
|
||||
final boolean backButtonResult = backButton != null && backButton.mouseClicked(mouseX, mouseY, button);
|
||||
final boolean utilButtonResult = utilityButtons.mouseClicked(mouseX, mouseY, button);
|
||||
|
||||
@@ -10,13 +10,11 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
public class ShaderPackEntry extends BaseEntry {
|
||||
@Getter private final String packName;
|
||||
private final ShaderPackSelectionList shaderPackSelectionList;
|
||||
private final int index;
|
||||
|
||||
public ShaderPackEntry(int index, ShaderPackSelectionList list, String packName) {
|
||||
public ShaderPackEntry(ShaderPackSelectionList list, String packName) {
|
||||
super(list);
|
||||
this.packName = packName;
|
||||
this.shaderPackSelectionList = list;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public boolean isApplied() {
|
||||
|
||||
@@ -55,6 +55,7 @@ public class TopButtonRowEntry extends BaseEntry {
|
||||
this.shaderPackSelectionList.getScreen().refreshScreenSwitchButton();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawEntry(ShaderPackScreen screen, int index, int x, int y, int listWidth, Tessellator tessellator, int mouseX, int mouseY, boolean isMouseOver) {
|
||||
this.buttons.setWidth(this.enableDisableButton, (listWidth - 1) - REFRESH_BUTTON_WIDTH);
|
||||
this.enableDisableButton.centerX = x + (int)(listWidth * 0.5);
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.coderbot.iris.gui.element.widget;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class IrisButton extends GuiButton {
|
||||
protected final Consumer<IrisButton> onPress;
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
package net.coderbot.iris.gui.option;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
public class IrisVideoSettings {
|
||||
public static int shadowDistance = 32;
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.lwjgl.Sys;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
@@ -66,7 +65,6 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
private boolean optionMenuOpen = false;
|
||||
|
||||
private boolean dropChanges = false;
|
||||
private static final String development = "Development Environment";
|
||||
private String developmentComponent;
|
||||
private String updateComponent;
|
||||
|
||||
@@ -235,10 +233,6 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
}
|
||||
|
||||
if (inWorld) {
|
||||
final String showOrHide = this.guiHidden
|
||||
? I18n.format("options.iris.gui.show")
|
||||
: I18n.format("options.iris.gui.hide");
|
||||
|
||||
final float endOfLastButton = this.width / 2.0f + 154.0f;
|
||||
final float freeSpace = this.width - endOfLastButton;
|
||||
final int x;
|
||||
@@ -320,7 +314,7 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
if (Iris.getCurrentPack().isPresent()) {
|
||||
final ShaderPack currentPack = Iris.getCurrentPack().get();
|
||||
|
||||
this.navigation = new NavigationController(currentPack.getMenuContainer());
|
||||
this.navigation = new NavigationController();
|
||||
|
||||
if (this.shaderOptionList != null) {
|
||||
this.shaderOptionList.applyShaderPack(currentPack);
|
||||
|
||||
@@ -17,7 +17,7 @@ import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class PipelineManager {
|
||||
private static PipelineManager instance;
|
||||
|
||||
private final Function<DimensionId, WorldRenderingPipeline> pipelineFactory;
|
||||
private final Map<DimensionId, WorldRenderingPipeline> pipelinesPerDimension = new HashMap<>();
|
||||
private WorldRenderingPipeline pipeline = new FixedFunctionWorldRenderingPipeline();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package net.coderbot.iris.pipeline;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
|
||||
public enum WorldRenderingPhase {
|
||||
NONE,
|
||||
SKY,
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ShaderTransformer {
|
||||
private static final Pattern inOutVaryingPattern = Pattern.compile("(?m)^\\s*(in|out)(\\s+)");
|
||||
|
||||
private static final int CACHE_SIZE = 100;
|
||||
private static final Object2ObjectLinkedOpenHashMap<TransformKey, Map<PatchShaderType, String>> shaderTransformationCache = new Object2ObjectLinkedOpenHashMap<>();
|
||||
private static final Object2ObjectLinkedOpenHashMap<TransformKey<?>, Map<PatchShaderType, String>> shaderTransformationCache = new Object2ObjectLinkedOpenHashMap<>();
|
||||
private static final boolean useCache = true;
|
||||
|
||||
/**
|
||||
@@ -70,23 +70,11 @@ public class ShaderTransformer {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public Patch patchType() {
|
||||
return patchType;
|
||||
}
|
||||
|
||||
public EnumMap<PatchShaderType, String> inputs() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
public P params() {
|
||||
return params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if (obj == null || obj.getClass() != this.getClass()) return false;
|
||||
var that = (TransformKey) obj;
|
||||
var that = (TransformKey<?>) obj;
|
||||
return Objects.equals(this.patchType, that.patchType) &&
|
||||
Objects.equals(this.inputs, that.inputs) &&
|
||||
Objects.equals(this.params, that.params);
|
||||
@@ -119,7 +107,7 @@ public class ShaderTransformer {
|
||||
inputs.put(PatchShaderType.GEOMETRY, geometry);
|
||||
inputs.put(PatchShaderType.FRAGMENT, fragment);
|
||||
|
||||
var key = new TransformKey(patchType, inputs, parameters);
|
||||
var key = new TransformKey<>(patchType, inputs, parameters);
|
||||
|
||||
result = shaderTransformationCache.getAndMoveToFirst(key);
|
||||
if(result == null || !useCache) {
|
||||
|
||||
@@ -10,11 +10,7 @@ import java.util.Map;
|
||||
public class TransformPatcher {
|
||||
|
||||
private static final int MAX_CACHE_ENTRIES = 400;
|
||||
private static final Map<TransformPatcher.CacheKey, Map<PatchShaderType, String>> cache = new LinkedHashMap<>(MAX_CACHE_ENTRIES + 1, .75F, true) {
|
||||
public boolean removeEldestEntry(Map.Entry eldest) {
|
||||
return size() > MAX_CACHE_ENTRIES;
|
||||
}
|
||||
};
|
||||
private static final Map<TransformPatcher.CacheKey, Map<PatchShaderType, String>> cache = new LinkedHashMap<>(MAX_CACHE_ENTRIES + 1, .75F, true);
|
||||
|
||||
private static final boolean useCache = true;
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import net.coderbot.iris.samplers.IrisImages;
|
||||
import net.coderbot.iris.samplers.IrisSamplers;
|
||||
import net.coderbot.iris.shaderpack.ComputeSource;
|
||||
import net.coderbot.iris.shaderpack.PackDirectives;
|
||||
import net.coderbot.iris.shaderpack.PackRenderTargetDirectives;
|
||||
import net.coderbot.iris.shaderpack.ProgramDirectives;
|
||||
import net.coderbot.iris.shaderpack.ProgramSource;
|
||||
import net.coderbot.iris.shadows.ShadowRenderTargets;
|
||||
@@ -64,9 +63,6 @@ public class CompositeRenderer {
|
||||
this.renderTargets = renderTargets;
|
||||
this.customTextureIds = customTextureIds;
|
||||
|
||||
final PackRenderTargetDirectives renderTargetDirectives = packDirectives.getRenderTargetDirectives();
|
||||
final Map<Integer, PackRenderTargetDirectives.RenderTargetSettings> renderTargetSettings = renderTargetDirectives.getRenderTargetSettings();
|
||||
|
||||
final ImmutableList.Builder<Pass> passes = ImmutableList.builder();
|
||||
final ImmutableSet.Builder<Integer> flippedAtLeastOnce = new ImmutableSet.Builder<>();
|
||||
|
||||
@@ -136,7 +132,6 @@ public class CompositeRenderer {
|
||||
pass.framebuffer = framebuffer;
|
||||
pass.viewportScale = directives.getViewportScale();
|
||||
pass.mipmappedBuffers = directives.getMipmappedBuffers();
|
||||
pass.flippedAtLeastOnce = flippedAtLeastOnceSnapshot;
|
||||
|
||||
passes.add(pass);
|
||||
}
|
||||
@@ -175,7 +170,6 @@ public class CompositeRenderer {
|
||||
Program program;
|
||||
ComputeProgram[] computes;
|
||||
GlFramebuffer framebuffer;
|
||||
ImmutableSet<Integer> flippedAtLeastOnce;
|
||||
ImmutableSet<Integer> stageReadsFromAlt;
|
||||
ImmutableSet<Integer> mipmappedBuffers;
|
||||
float viewportScale;
|
||||
|
||||
@@ -22,7 +22,6 @@ import net.coderbot.iris.rendertarget.RenderTargets;
|
||||
import net.coderbot.iris.samplers.IrisImages;
|
||||
import net.coderbot.iris.samplers.IrisSamplers;
|
||||
import net.coderbot.iris.shaderpack.ComputeSource;
|
||||
import net.coderbot.iris.shaderpack.PackRenderTargetDirectives;
|
||||
import net.coderbot.iris.shaderpack.ProgramDirectives;
|
||||
import net.coderbot.iris.shaderpack.ProgramSet;
|
||||
import net.coderbot.iris.shaderpack.ProgramSource;
|
||||
@@ -69,9 +68,6 @@ public class FinalPassRenderer {
|
||||
this.centerDepthSampler = centerDepthSampler;
|
||||
this.customTextureIds = customTextureIds;
|
||||
|
||||
final PackRenderTargetDirectives renderTargetDirectives = pack.getPackDirectives().getRenderTargetDirectives();
|
||||
final Map<Integer, PackRenderTargetDirectives.RenderTargetSettings> renderTargetSettings = renderTargetDirectives.getRenderTargetSettings();
|
||||
|
||||
this.noiseTexture = noiseTexture;
|
||||
this.renderTargets = renderTargets;
|
||||
this.finalPass = pack.getCompositeFinal().map(source -> {
|
||||
|
||||
@@ -30,7 +30,6 @@ public class FullScreenQuadRenderer {
|
||||
end();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void begin() {
|
||||
GLStateManager.disableDepthTest();
|
||||
|
||||
@@ -55,7 +54,6 @@ public class FullScreenQuadRenderer {
|
||||
GLStateManager.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void end() {
|
||||
DefaultVertexFormat.POSITION_TEXTURE.clearBufferState();
|
||||
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
|
||||
@@ -5,13 +5,11 @@ import com.google.common.collect.ImmutableSet;
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
|
||||
import net.coderbot.iris.gl.sampler.SamplerHolder;
|
||||
import net.coderbot.iris.gl.state.StateUpdateNotifiers;
|
||||
import net.coderbot.iris.pipeline.DeferredWorldRenderingPipeline;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.rendertarget.RenderTarget;
|
||||
import net.coderbot.iris.rendertarget.RenderTargets;
|
||||
import net.coderbot.iris.shaderpack.PackRenderTargetDirectives;
|
||||
import net.coderbot.iris.shadows.ShadowRenderTargets;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
@@ -162,7 +162,8 @@ public class ConstDirectiveParser {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConstDirective { " + type + " " + key + " = " + value + "; }";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.coderbot.iris.shaderpack.materialmap.BlockRenderType;
|
||||
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.coderbot.iris.shaderpack.option.ShaderPackOptions;
|
||||
import net.coderbot.iris.shaderpack.preprocessor.PropertiesPreprocessor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@@ -202,8 +203,8 @@ public class IdMap {
|
||||
ArrayList<ItemStack> leaves = OreDictionary.getOres("treeLeaves");
|
||||
for (ItemStack leaf : leaves) {
|
||||
if (leaf.getItem() instanceof ItemBlock) {
|
||||
Iris.logger.warn("Found leaf " + leaf.getItem().itemRegistry.getNameForObject(leaf.getItem()));
|
||||
value.append(" ").append(leaf.getItem().itemRegistry.getNameForObject(leaf.getItem()));
|
||||
Iris.logger.warn("Found leaf " + Item.itemRegistry.getNameForObject(leaf.getItem()));
|
||||
value.append(" ").append(Item.itemRegistry.getNameForObject(leaf.getItem()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -11,7 +11,9 @@ import java.util.function.BiConsumer;
|
||||
* Properties backed by a {@link java.util.LinkedHashMap}, in order to preserve iteration order
|
||||
*/
|
||||
public class OrderBackedProperties extends Properties {
|
||||
private transient final Map<Object, Object> backing = Object2ObjectMaps.synchronize(new Object2ObjectLinkedOpenHashMap<>());
|
||||
|
||||
private static final long serialVersionUID = 1555967254721760731L;
|
||||
private transient final Map<Object, Object> backing = Object2ObjectMaps.synchronize(new Object2ObjectLinkedOpenHashMap<>());
|
||||
|
||||
@Override
|
||||
public synchronized Object put(Object key, Object value) {
|
||||
|
||||
-11
@@ -322,13 +322,9 @@ public class AdvancedShadowCullingFrustum extends Frustrum {
|
||||
* @return 0 if nothing is visible, 1 if everything is visible, 2 if only some corners are visible.
|
||||
*/
|
||||
private int checkCornerVisibility(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) {
|
||||
boolean inside = true;
|
||||
float outsideBoundX;
|
||||
float outsideBoundY;
|
||||
float outsideBoundZ;
|
||||
float insideBoundX;
|
||||
float insideBoundY;
|
||||
float insideBoundZ;
|
||||
|
||||
for (int i = 0; i < planeCount; ++i) {
|
||||
Vector4f plane = this.planes[i];
|
||||
@@ -338,32 +334,25 @@ public class AdvancedShadowCullingFrustum extends Frustrum {
|
||||
|
||||
if (plane.x() < 0) {
|
||||
outsideBoundX = minX;
|
||||
insideBoundX = maxX;
|
||||
} else {
|
||||
outsideBoundX = maxX;
|
||||
insideBoundX = minX;
|
||||
}
|
||||
|
||||
if (plane.y() < 0) {
|
||||
outsideBoundY = minY;
|
||||
insideBoundY = maxY;
|
||||
} else {
|
||||
outsideBoundY = maxY;
|
||||
insideBoundY = minY;
|
||||
}
|
||||
|
||||
if (plane.z() < 0) {
|
||||
outsideBoundZ = minZ;
|
||||
insideBoundZ = maxZ;
|
||||
} else {
|
||||
outsideBoundZ = maxZ;
|
||||
insideBoundZ = minZ;
|
||||
}
|
||||
|
||||
if (Math.fma(plane.x(), outsideBoundX, Math.fma(plane.y(), outsideBoundY, plane.z() * outsideBoundZ)) < -plane.w()) {
|
||||
return 0;
|
||||
}
|
||||
inside &= Math.fma(plane.x(), insideBoundX, Math.fma(plane.y(), insideBoundY, plane.z() * insideBoundZ)) >= -plane.w();
|
||||
}
|
||||
|
||||
return 2;
|
||||
|
||||
@@ -41,7 +41,8 @@ public class IrisChunkProgram extends ChunkProgram {
|
||||
this.irisProgramImages = irisProgramImages;
|
||||
}
|
||||
|
||||
public void setup(MatrixStack matrixStack, float modelScale, float textureScale) {
|
||||
@Override
|
||||
public void setup(MatrixStack matrixStack, float modelScale, float textureScale) {
|
||||
super.setup(matrixStack, modelScale, textureScale);
|
||||
|
||||
if (irisProgramUniforms != null) {
|
||||
|
||||
@@ -2,8 +2,6 @@ package net.coderbot.iris.texture.pbr;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.AutoClosableAbstractTexture;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.TextureAtlasSpriteAccessor;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.TextureMapAccessor;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.texture.util.TextureExporter;
|
||||
@@ -36,7 +34,7 @@ public class PBRAtlasTexture extends AutoClosableAbstractTexture {
|
||||
public PBRAtlasTexture(TextureMap textureMap, PBRType type) {
|
||||
this.texMap = textureMap;
|
||||
this.type = type;
|
||||
id = type.appendToFileLocation(((TextureMapAccessor)textureMap).getLocationBlocksTexture());
|
||||
id = type.appendToFileLocation(TextureMap.locationBlocksTexture);
|
||||
|
||||
}
|
||||
|
||||
@@ -112,11 +110,10 @@ public class PBRAtlasTexture extends AutoClosableAbstractTexture {
|
||||
|
||||
protected void uploadSprite(TextureAtlasSprite sprite) {
|
||||
|
||||
final TextureAtlasSpriteAccessor accessor = (TextureAtlasSpriteAccessor) sprite;
|
||||
if (accessor.getMetadata().getFrameCount() > 1) {
|
||||
final AnimationMetadataSection metadata = accessor.getMetadata();
|
||||
if (sprite.animationMetadata.getFrameCount() > 1) {
|
||||
final AnimationMetadataSection metadata = sprite.animationMetadata;
|
||||
final int frameCount = sprite.getFrameCount();
|
||||
for (int frame = accessor.getFrame(); frame >= 0; frame--) {
|
||||
for (int frame = sprite.frameCounter; frame >= 0; frame--) {
|
||||
final int frameIndex = metadata.getFrameIndex(frame);
|
||||
if (frameIndex >= 0 && frameIndex < frameCount) {
|
||||
TextureUtil.uploadTextureMipmap(sprite.getFrameTextureData(frameIndex), sprite.getIconWidth(), sprite.getIconHeight(), sprite.getOriginX(), sprite.getOriginY(), false, false);
|
||||
|
||||
@@ -4,10 +4,7 @@ import com.google.common.collect.Lists;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.NativeImage;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureInfo;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureInfoCache;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.AnimationMetadataSectionAccessor;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ISpriteExt;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.TextureAtlasSpriteAccessor;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.TextureMapAccessor;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.texture.format.TextureFormat;
|
||||
import net.coderbot.iris.texture.format.TextureFormatLoader;
|
||||
@@ -32,7 +29,6 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
|
||||
public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
public static final ChannelMipmapGenerator LINEAR_MIPMAP_GENERATOR = new ChannelMipmapGenerator(
|
||||
LinearBlendFunction.INSTANCE,
|
||||
@@ -41,6 +37,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
LinearBlendFunction.INSTANCE
|
||||
);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void load(TextureMap texMap, IResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer) {
|
||||
final TextureInfo textureInfo = TextureInfoCache.INSTANCE.getInfo(texMap.getGlTextureId());
|
||||
@@ -50,7 +47,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
|
||||
PBRAtlasTexture normalAtlas = null;
|
||||
PBRAtlasTexture specularAtlas = null;
|
||||
for (TextureAtlasSprite sprite : (Collection<TextureAtlasSprite>) ((TextureMapAccessor) texMap).getMapUploadedSprites().values()) {
|
||||
for (TextureAtlasSprite sprite : (Collection<TextureAtlasSprite>) texMap.mapUploadedSprites.values()) {
|
||||
if (!(sprite.getIconName().equals("missingno"))) {
|
||||
TextureAtlasSprite normalSprite = createPBRSprite(sprite, resourceManager, texMap, atlasWidth, atlasHeight, mipLevel, PBRType.NORMAL);
|
||||
TextureAtlasSprite specularSprite = createPBRSprite(sprite, resourceManager, texMap, atlasWidth, atlasHeight, mipLevel, PBRType.SPECULAR);
|
||||
@@ -77,19 +74,19 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
if (normalAtlas.tryUpload(atlasWidth,
|
||||
atlasHeight,
|
||||
mipLevel,
|
||||
((TextureMapAccessor) texMap).getAnisotropicFiltering())) {
|
||||
texMap.anisotropicFiltering)) {
|
||||
pbrTextureConsumer.acceptNormalTexture(normalAtlas);
|
||||
}
|
||||
}
|
||||
if (specularAtlas != null) {
|
||||
if (specularAtlas.tryUpload(atlasWidth, atlasHeight, mipLevel, ((TextureMapAccessor) texMap).getAnisotropicFiltering())) {
|
||||
if (specularAtlas.tryUpload(atlasWidth, atlasHeight, mipLevel, texMap.anisotropicFiltering)) {
|
||||
pbrTextureConsumer.acceptSpecularTexture(specularAtlas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static int fetchAtlasMipLevel(TextureMap texMap) {
|
||||
return ((TextureMapAccessor) texMap).getMipmapLevels();
|
||||
return texMap.mipmapLevels;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -138,20 +135,19 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
frameHeight = targetFrameHeight;
|
||||
|
||||
if (!animationMetadata.equals(new AnimationMetadataSection(Lists.newArrayList(), -1, -1, -1))) {
|
||||
final AnimationMetadataSectionAccessor animationAccessor = (AnimationMetadataSectionAccessor) animationMetadata;
|
||||
final int internalFrameWidth = animationAccessor.getFrameHeight();
|
||||
final int internalFrameHeight = animationAccessor.getFrameHeight();
|
||||
final int internalFrameWidth = animationMetadata.frameHeight;
|
||||
final int internalFrameHeight = animationMetadata.frameWidth;
|
||||
if (internalFrameWidth != -1) {
|
||||
animationAccessor.setFrameWidth(frameWidth);
|
||||
animationMetadata.frameWidth = frameWidth;
|
||||
}
|
||||
if (internalFrameHeight != -1) {
|
||||
animationAccessor.setFrameHeight(frameHeight);
|
||||
animationMetadata.frameHeight = frameHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final ResourceLocation pbrSpriteName = new ResourceLocation(spriteName.getResourceDomain(), spriteName.getResourcePath() + pbrType.getSuffix());
|
||||
final TextureAtlasSpriteInfo pbrSpriteInfo = new PBRTextureAtlasSpriteInfo(pbrSpriteName, frameWidth, frameHeight, animationMetadata, pbrType);
|
||||
final TextureAtlasSpriteInfo pbrSpriteInfo = new PBRTextureAtlasSpriteInfo(pbrSpriteName, frameWidth, frameHeight, pbrType);
|
||||
|
||||
final int x = sprite.getOriginX();
|
||||
final int y = sprite.getOriginY();
|
||||
@@ -174,16 +170,14 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
return;
|
||||
}
|
||||
|
||||
final TextureAtlasSpriteAccessor sourceAccessor = ((TextureAtlasSpriteAccessor) source);
|
||||
final AnimationMetadataSection sourceMetadata = sourceAccessor.getMetadata();
|
||||
final AnimationMetadataSection sourceMetadata = source.animationMetadata;
|
||||
|
||||
int ticks = 0;
|
||||
for (int f = 0; f < sourceAccessor.getFrame(); f++) {
|
||||
for (int f = 0; f < source.frameCounter; f++) {
|
||||
ticks += sourceMetadata.getFrameTimeSingle(f);
|
||||
}
|
||||
|
||||
final TextureAtlasSpriteAccessor targetAccessor = ((TextureAtlasSpriteAccessor) target);
|
||||
final AnimationMetadataSection targetMetadata = targetAccessor.getMetadata();
|
||||
final AnimationMetadataSection targetMetadata = target.animationMetadata;
|
||||
|
||||
int cycleTime = 0;
|
||||
final int frameCount = targetMetadata.getFrameCount();
|
||||
@@ -203,15 +197,15 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
}
|
||||
}
|
||||
|
||||
targetAccessor.setFrame(targetFrame);
|
||||
targetAccessor.setSubFrame(ticks + sourceAccessor.getSubFrame());
|
||||
target.frameCounter = targetFrame;
|
||||
target.tickCounter = ticks + source.tickCounter;
|
||||
}
|
||||
|
||||
protected static class PBRTextureAtlasSpriteInfo extends TextureAtlasSpriteInfo {
|
||||
protected final PBRType pbrType;
|
||||
|
||||
public PBRTextureAtlasSpriteInfo(ResourceLocation name, int width, int height, AnimationMetadataSection metadata, PBRType pbrType) {
|
||||
super(name, width, height, metadata);
|
||||
public PBRTextureAtlasSpriteInfo(ResourceLocation name, int width, int height, PBRType pbrType) {
|
||||
super(name, width, height);
|
||||
this.pbrType = pbrType;
|
||||
}
|
||||
}
|
||||
@@ -221,7 +215,7 @@ public class AtlasPBRLoader implements PBRTextureLoader<TextureMap> {
|
||||
protected PBRTextureAtlasSprite(TextureAtlasSpriteInfo info, AnimationMetadataSection animationMetaDataSection, int atlasWidth, int atlasHeight, int x, int y, NativeImage nativeImage, TextureMap texMap, int miplevel) {
|
||||
super(info.name().toString());
|
||||
super.initSprite(atlasWidth, atlasHeight, x, y, false);
|
||||
super.loadSprite(getMipmapGenerator(info, atlasWidth, atlasHeight).generateMipLevels(nativeImage, miplevel), animationMetaDataSection, (float)((TextureMapAccessor) texMap).getAnisotropicFiltering() > 1.0F);
|
||||
super.loadSprite(getMipmapGenerator(info, atlasWidth, atlasHeight).generateMipLevels(nativeImage, miplevel), animationMetaDataSection, texMap.anisotropicFiltering > 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.coderbot.iris.texture.pbr.loader;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.SimpleTextureAccessor;
|
||||
import net.coderbot.iris.texture.pbr.PBRType;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.client.renderer.texture.SimpleTexture;
|
||||
@@ -13,7 +12,7 @@ import java.io.IOException;
|
||||
public class SimplePBRLoader implements PBRTextureLoader<SimpleTexture> {
|
||||
@Override
|
||||
public void load(SimpleTexture texture, IResourceManager resourceManager, PBRTextureConsumer pbrTextureConsumer) {
|
||||
ResourceLocation location = ((SimpleTextureAccessor) texture).getLocation();
|
||||
ResourceLocation location = texture.textureLocation;
|
||||
|
||||
AbstractTexture normalTexture = createPBRTexture(location, resourceManager, PBRType.NORMAL);
|
||||
AbstractTexture specularTexture = createPBRTexture(location, resourceManager, PBRType.SPECULAR);
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
package net.coderbot.iris.texture.pbr.loader;
|
||||
|
||||
import net.minecraft.client.resources.data.AnimationMetadataSection;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class TextureAtlasSpriteInfo {
|
||||
private final ResourceLocation name;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final AnimationMetadataSection metadata;
|
||||
|
||||
public TextureAtlasSpriteInfo(ResourceLocation arg, int i, int j, AnimationMetadataSection arg2) {
|
||||
public TextureAtlasSpriteInfo(ResourceLocation arg, int i, int j) {
|
||||
this.name = arg;
|
||||
this.width = i;
|
||||
this.height = j;
|
||||
this.metadata = arg2;
|
||||
}
|
||||
|
||||
public ResourceLocation name() {
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.gtnewhorizon.gtnhlib.bytebuf.MemoryStack;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
|
||||
@@ -201,10 +201,6 @@ public class HardcodedCustomUniforms {
|
||||
return blindFactorSqrt * blindFactorSqrt;
|
||||
}
|
||||
|
||||
private static float frac(float value) {
|
||||
return java.lang.Math.abs(value % 1);
|
||||
}
|
||||
|
||||
private static float getAdjTime() {
|
||||
return Math.abs(((((WorldTimeUniforms.getWorldDayTime()) / 1000.0f) + 6.0f) % 24.0f) - 12.0f);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import static net.coderbot.iris.gl.uniform.UniformUpdateFrequency.PER_FRAME;
|
||||
|
||||
@@ -54,7 +53,6 @@ public final class IdMapUniforms {
|
||||
private final boolean applyOldHandLight;
|
||||
private int intID;
|
||||
private int lightValue;
|
||||
private Vector3f lightColor;
|
||||
|
||||
HeldItemSupplier(InteractionHand hand, Object2IntFunction<NamespacedId> itemIdMap, boolean shouldApplyOldHandLight) {
|
||||
this.hand = hand;
|
||||
@@ -65,7 +63,6 @@ public final class IdMapUniforms {
|
||||
private void invalidate() {
|
||||
intID = -1;
|
||||
lightValue = 0;
|
||||
lightColor = IrisItemLightProvider.DEFAULT_LIGHT_COLOR;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
@@ -100,8 +97,6 @@ public final class IdMapUniforms {
|
||||
if (applyOldHandLight) {
|
||||
lightProvider = applyOldHandLighting(player, lightProvider);
|
||||
}
|
||||
|
||||
lightColor = lightProvider.getLightColor(Minecraft.getMinecraft().thePlayer, heldStack);
|
||||
}
|
||||
|
||||
private IrisItemLightProvider applyOldHandLighting(@NotNull EntityPlayer player, IrisItemLightProvider existing) {
|
||||
@@ -135,9 +130,5 @@ public final class IdMapUniforms {
|
||||
public int getLightValue() {
|
||||
return lightValue;
|
||||
}
|
||||
|
||||
public Vector3f getLightColor() {
|
||||
return lightColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,8 +25,8 @@ public class IrisExclusiveUniforms {
|
||||
uniforms.uniform1b(UniformUpdateFrequency.PER_FRAME, "firstPersonCamera", IrisExclusiveUniforms::isFirstPersonCamera);
|
||||
uniforms.uniform1b(UniformUpdateFrequency.PER_TICK, "isSpectator", IrisExclusiveUniforms::isSpectator);
|
||||
uniforms.uniform3d(UniformUpdateFrequency.PER_FRAME, "eyePosition", IrisExclusiveUniforms::getEyePosition);
|
||||
Vector4f zero = new Vector4f(0, 0, 0, 0);
|
||||
// TODO: Iris Shaders
|
||||
// Vector4f zero = new Vector4f(0, 0, 0, 0);
|
||||
// uniforms.uniform4f(UniformUpdateFrequency.PER_TICK, "lightningBoltPosition", () -> {
|
||||
// if (Minecraft.getMinecraft().theWorld != null) {
|
||||
// return StreamSupport.stream(Minecraft.getMinecraft().theWorld.entitiesForRendering().spliterator(), false).filter(bolt -> bolt instanceof LightningBolt).findAny().map(bolt -> {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.coderbot.iris.vertices;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Math;
|
||||
|
||||
/**
|
||||
* Provides some utilities for working with packed normal vectors. Each normal component provides 8 bits of
|
||||
@@ -54,15 +53,6 @@ public class NormI8 {
|
||||
return ((int) (x * 127) & 0xFF) | (((int) (y * 127) & 0xFF) << 8) | (((int) (z * 127) & 0xFF) << 16) | (((int) w & 0xFF) << 24);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes a float in the range of -1.0..1.0 to a normalized unsigned integer in the range of 0..255 which can then
|
||||
* be passed to graphics memory.
|
||||
*/
|
||||
private static int encode(float comp) {
|
||||
// TODO: is the clamp necessary here? our inputs should always be normalized vector components
|
||||
return ((int) (Math.clamp(comp, -1.0F, 1.0F) * COMPONENT_RANGE) & 255);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpacks the x-component of the packed normal, denormalizing it to a float in the range of -1.0..1.0.
|
||||
* @param norm The packed normal
|
||||
|
||||
Reference in new issue
Block a user