mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-20 20:32:14 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36d98fcb22 | ||
|
|
44c5b9617a | ||
|
|
f3f1677db8 | ||
|
|
d396b611ad | ||
|
|
08f4c0f9db | ||
|
|
50b0d22dc2 | ||
|
|
7fed54264e | ||
|
|
be87401be6 |
No files matched your search
+1
-1
@@ -16,5 +16,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.gtnewhorizons.gtnhsettingsconvention") version("2.0.13")
|
||||
id("com.gtnewhorizons.gtnhsettingsconvention") version("2.0.18")
|
||||
}
|
||||
@@ -66,6 +66,7 @@ import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.GLContext;
|
||||
import org.lwjgl.opengl.KHRDebug;
|
||||
@@ -3786,4 +3787,56 @@ public class GLStateManager {
|
||||
return VENDOR == NVIDIA;
|
||||
}
|
||||
|
||||
@Getter protected static int drawFramebuffer = 0;
|
||||
@Getter protected static int readFramebuffer = 0;
|
||||
|
||||
public static void glBindFramebuffer(int target, int framebuffer) {
|
||||
if (target == GL30.GL_FRAMEBUFFER) {
|
||||
if (drawFramebuffer == framebuffer && readFramebuffer == framebuffer) return;
|
||||
drawFramebuffer = framebuffer;
|
||||
readFramebuffer = framebuffer;
|
||||
} else if (target == GL30.GL_DRAW_FRAMEBUFFER) {
|
||||
if (drawFramebuffer == framebuffer) return;
|
||||
drawFramebuffer = framebuffer;
|
||||
} else if (target == GL30.GL_READ_FRAMEBUFFER) {
|
||||
if (readFramebuffer == framebuffer) return;
|
||||
readFramebuffer = framebuffer;
|
||||
}
|
||||
GL30.glBindFramebuffer(target, framebuffer);
|
||||
}
|
||||
|
||||
public static void glDeleteFramebuffers(int framebuffer) {
|
||||
if (drawFramebuffer == framebuffer) drawFramebuffer = 0;
|
||||
if (readFramebuffer == framebuffer) readFramebuffer = 0;
|
||||
GL30.glDeleteFramebuffers(framebuffer);
|
||||
}
|
||||
|
||||
public static int glGenFramebuffers() {
|
||||
return GL30.glGenFramebuffers();
|
||||
}
|
||||
|
||||
public static int glCheckFramebufferStatus(int target) {
|
||||
return GL30.glCheckFramebufferStatus(target);
|
||||
}
|
||||
|
||||
public static void glFramebufferTexture2D(int target, int attachment, int textarget, int texture, int level) {
|
||||
GL30.glFramebufferTexture2D(target, attachment, textarget, texture, level);
|
||||
}
|
||||
|
||||
public static void setActiveTexture(int textureUnit) {
|
||||
glActiveTexture(textureUnit);
|
||||
}
|
||||
|
||||
public static void setLightmapTextureCoords(int unit, float x, float y) {
|
||||
GL13.glMultiTexCoord2f(unit, x, y);
|
||||
if (unit == GL13.GL_TEXTURE1) {
|
||||
OpenGlHelper.lastBrightnessX = x;
|
||||
OpenGlHelper.lastBrightnessY = y;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFramebufferEnabled() {
|
||||
return OpenGlHelper.framebufferSupported && Minecraft.getMinecraft().gameSettings.fboEnable;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.gtnewhorizons.angelica.glsm.dsa;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
@@ -77,13 +76,13 @@ public class DSAUnsupported implements DSAAccess {
|
||||
|
||||
@Override
|
||||
public void readBuffer(int framebuffer, int buffer) {
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
GLStateManager.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
GL11.glReadBuffer(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBuffers(int framebuffer, IntBuffer buffers) {
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
GLStateManager.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
GL20.glDrawBuffers(buffers);
|
||||
}
|
||||
|
||||
@@ -135,21 +134,21 @@ public class DSAUnsupported implements DSAAccess {
|
||||
@Override
|
||||
public void blitFramebuffer(int source, int dest, int offsetX, int offsetY, int width, int height, int offsetX2, int offsetY2, int width2, int height2,
|
||||
int bufferChoice, int filter) {
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_READ_FRAMEBUFFER, source);
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_DRAW_FRAMEBUFFER, dest);
|
||||
GLStateManager.glBindFramebuffer(GL30.GL_READ_FRAMEBUFFER, source);
|
||||
GLStateManager.glBindFramebuffer(GL30.GL_DRAW_FRAMEBUFFER, dest);
|
||||
GL30.glBlitFramebuffer(offsetX, offsetY, width, height, offsetX2, offsetY2, width2, height2, bufferChoice, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void framebufferTexture2D(int fb, int fbtarget, int attachment, int target, int texture, int levels) {
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(fbtarget, fb);
|
||||
GLStateManager.glBindFramebuffer(fbtarget, fb);
|
||||
GL30.glFramebufferTexture2D(fbtarget, attachment, target, texture, levels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int createFramebuffer() {
|
||||
final int framebuffer = OpenGlHelper.func_153165_e/*glGenFramebuffers*/();
|
||||
OpenGlHelper.func_153171_g/*glBindFramebuffer*/(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
final int framebuffer = GLStateManager.glGenFramebuffers();
|
||||
GLStateManager.glBindFramebuffer(GL30.GL_FRAMEBUFFER, framebuffer);
|
||||
return framebuffer;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiIngame;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -68,7 +67,7 @@ public class HUDCaching {
|
||||
XaeroMinimapCore.beforeIngameGuiRender(partialTicks);
|
||||
}
|
||||
|
||||
if (!OpenGlHelper.isFramebufferEnabled()) {
|
||||
if (!GLStateManager.isFramebufferEnabled()) {
|
||||
ingame.renderGameOverlay(partialTicks, hasScreen, mouseX, mouseY);
|
||||
return;
|
||||
}
|
||||
|
||||
+9
-1
@@ -233,7 +233,15 @@ public final class AngelicaRedirector {
|
||||
);
|
||||
methodRedirects.put(OpenGlHelper, RedirectMap.newMap()
|
||||
.add("glBlendFunc", "tryBlendFuncSeparate")
|
||||
.add("func_148821_a", "tryBlendFuncSeparate"));
|
||||
.add("func_148821_a", "tryBlendFuncSeparate")
|
||||
.add("func_153171_g", "glBindFramebuffer")
|
||||
.add("func_153174_h", "glDeleteFramebuffers")
|
||||
.add("func_153165_e", "glGenFramebuffers")
|
||||
.add("func_153167_i", "glCheckFramebufferStatus")
|
||||
.add("func_153188_a", "glFramebufferTexture2D")
|
||||
.add("setActiveTexture")
|
||||
.add("setLightmapTextureCoords")
|
||||
.add("isFramebufferEnabled"));
|
||||
methodRedirects.put(EXTBlendFunc, RedirectMap.newMap().add("glBlendFuncSeparateEXT", "tryBlendFuncSeparate"));
|
||||
methodRedirects.put(ARBMultiTexture, RedirectMap.newMap().add("glActiveTextureARB"));
|
||||
methodRedirects.put(Project, RedirectMap.newMap().add("gluPerspective"));
|
||||
|
||||
@@ -200,7 +200,6 @@ public enum Mixins implements IMixins {
|
||||
, "shaders.MixinFramebuffer"
|
||||
, "shaders.MixinItem"
|
||||
, "shaders.MixinLocale"
|
||||
, "shaders.MixinOpenGlHelper"
|
||||
, "shaders.MixinRender"
|
||||
, "shaders.MixinRenderBiped"
|
||||
, "shaders.MixinRenderEntityFlame"
|
||||
@@ -315,7 +314,7 @@ public enum Mixins implements IMixins {
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.NTM_SPACE)
|
||||
.setApplyIf(() -> CompatConfig.fixNTMSpace && AngelicaConfig.enableIris)
|
||||
.addClientMixins("client.ntmSpace.MixinSkyProviderCelestial_ShaderCompat")),
|
||||
.addClientMixins("client.ntmSpace.MixinSkyProviderCelestial_ShaderCompat", "client.ntmSpace.MixinSkyProviderLaytheSunset")),
|
||||
|
||||
SPEEDUP_CAMPFIRE_BACKPORT_ANIMATIONS(new MixinBuilder("Add animation speedup support to Campfire Backport")
|
||||
.setPhase(Phase.LATE)
|
||||
|
||||
@@ -31,7 +31,6 @@ import jss.notfine.core.Settings;
|
||||
import jss.notfine.gui.options.named.GraphicsQualityOff;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.client.resources.IReloadableResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
@@ -40,6 +39,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
// Shared constants.
|
||||
@@ -337,12 +337,12 @@ public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
texColor = newColor;
|
||||
}
|
||||
|
||||
GLStateManager.glActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE1);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, COLOR_TEX.getGlTextureId());
|
||||
GLStateManager.enableTexture();
|
||||
|
||||
// Bind the clouds texture last so the shader's sampler2D is correct.
|
||||
GLStateManager.glActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0);
|
||||
mc.renderEngine.bindTexture(texture);
|
||||
|
||||
vbo.setupState();
|
||||
@@ -384,9 +384,9 @@ public class CloudRenderer implements IResourceManagerReloadListener {
|
||||
vbo.cleanupState(); // Unbind buffer and disable pointers.
|
||||
|
||||
// Disable our coloring.
|
||||
GLStateManager.glActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE1);
|
||||
GLStateManager.disableTexture();
|
||||
GLStateManager.glActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0);
|
||||
|
||||
// Reset texture matrix.
|
||||
GLStateManager.glMatrixMode(GL11.GL_TEXTURE);
|
||||
|
||||
+18
-7
@@ -7,6 +7,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.BlockRenderContext;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.IrisExtendedChunkVertexEncoder;
|
||||
import org.embeddedt.embeddium.impl.model.light.LightPipeline;
|
||||
import org.embeddedt.embeddium.impl.model.light.flat.FlatLightPipeline;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.ChunkColorWriter;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.light.LightDataCache;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.light.QuadLightingHelper;
|
||||
@@ -49,6 +51,7 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
|
||||
private final LightDataCache lightDataCache = new LightDataCache();
|
||||
private final SmoothLightPipeline smoothLightPipeline;
|
||||
private final FlatLightPipeline flatLightPipeline;
|
||||
private final QuadLightData quadLightData = new QuadLightData();
|
||||
private final VertexArrayQuadView quadView;
|
||||
private boolean lightPipelineReady = false;
|
||||
@@ -59,6 +62,7 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
this.textureAtlas = (TextureMapExtension) Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
this.worldSlice = new WorldSlice(world);
|
||||
this.smoothLightPipeline = new SmoothLightPipeline(lightDataCache, VanillaDiffuseProvider.INSTANCE, false);
|
||||
this.flatLightPipeline = new FlatLightPipeline(lightDataCache, VanillaDiffuseProvider.INSTANCE, false);
|
||||
this.quadView = new VertexArrayQuadView(vertices);
|
||||
}
|
||||
|
||||
@@ -73,6 +77,7 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
lightDataCache.setWorld(blockAccess);
|
||||
lightDataCache.reset(minBlockX, minBlockY, minBlockZ);
|
||||
smoothLightPipeline.reset();
|
||||
flatLightPipeline.reset();
|
||||
lightPipelineReady = true;
|
||||
}
|
||||
|
||||
@@ -103,7 +108,8 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void copyRawBuffer(int[] rawBuffer, int vertexCount, ChunkBuildBuffers buffers, Material material, boolean isShaderPackOverride) {
|
||||
public void copyRawBuffer(int[] rawBuffer, int vertexCount, ChunkBuildBuffers buffers, Material material, boolean isShaderPackOverride,
|
||||
boolean blockAllowsSmoothLighting) {
|
||||
if (vertexCount == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -126,6 +132,14 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
int ptr = 0;
|
||||
final int numQuads = vertexCount / 4;
|
||||
|
||||
final int blockX = blockRenderContext.localPosX;
|
||||
final int blockY = blockRenderContext.localPosY;
|
||||
final int blockZ = blockRenderContext.localPosZ;
|
||||
final int worldX = originX + blockX;
|
||||
final int worldY = originY + blockY;
|
||||
final int worldZ = originZ + blockZ;
|
||||
final boolean isEmissive = useAoCalculation && QuadLightingHelper.isBlockEmissive(worldSlice, worldX, worldY, worldZ);
|
||||
|
||||
for (int quadIdx = 0; quadIdx < numQuads; quadIdx++) {
|
||||
float uSum = 0, vSum = 0;
|
||||
|
||||
@@ -165,11 +179,6 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
}
|
||||
|
||||
if (useAoCalculation) {
|
||||
final int blockX = blockRenderContext.localPosX;
|
||||
final int blockY = blockRenderContext.localPosY;
|
||||
final int blockZ = blockRenderContext.localPosZ;
|
||||
|
||||
final boolean isEmissive = LightDataAccess.unpackEM(lightDataCache.get(originX + blockX, originY + blockY, originZ + blockZ));
|
||||
final boolean quadIsFullBright = QuadLightingHelper.isQuadFullBright(vertices);
|
||||
|
||||
if (isEmissive || quadIsFullBright) {
|
||||
@@ -184,7 +193,9 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
} else {
|
||||
quadView.setup(trueNormal, blockX, blockY, blockZ);
|
||||
final ModelQuadFacing lightFace = quadView.getLightFace();
|
||||
smoothLightPipeline.calculate(quadView, originX + blockX, originY + blockY, originZ + blockZ, quadLightData, lightFace, lightFace, shade, true);
|
||||
final LightPipeline pipeline = blockAllowsSmoothLighting ? smoothLightPipeline : flatLightPipeline;
|
||||
final ModelQuadFacing cullFace = quadView.getCullFace();
|
||||
pipeline.calculate(quadView, worldX, worldY, worldZ, quadLightData, cullFace, lightFace, shade, true);
|
||||
}
|
||||
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
|
||||
+10
-1
@@ -9,6 +9,7 @@ import com.gtnewhorizons.angelica.rendering.celeritas.iris.ContextAwareChunkVert
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceMap;
|
||||
import net.coderbot.iris.vertices.ExtendedDataHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -247,7 +248,15 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
block.canRenderInPass(pass);
|
||||
tessellator.startDrawingQuads();
|
||||
renderBlocks.renderBlockByRenderType(block, x, y, z);
|
||||
buildContext.copyRawBuffer(tessellator.rawBuffer, tessellator.vertexCount, buffers, passMaterial, isShaderPackOverride);
|
||||
// In modern versions, block models can specify whether to enable AO or not, but here we must
|
||||
// rely on render ID heuristics to figure out which models would have turned it off
|
||||
int vanillaRenderId = block.getRenderType();
|
||||
boolean blockAllowsSmoothLighting = Minecraft.isAmbientOcclusionEnabled() // smooth lighting on
|
||||
&& block.getLightValue() == 0 // does not emit real block light
|
||||
&& vanillaRenderId != 1 // is not a "cross" block
|
||||
&& vanillaRenderId != 40; // is not a double plant block
|
||||
buildContext.copyRawBuffer(tessellator.rawBuffer, tessellator.vertexCount, buffers, passMaterial,
|
||||
isShaderPackOverride, blockAllowsSmoothLighting);
|
||||
tessellator.reset();
|
||||
tessellator.isDrawing = false;
|
||||
|
||||
|
||||
+21
-1
@@ -12,6 +12,7 @@ public class VertexArrayQuadView implements ModelQuadView {
|
||||
private int trueNormal;
|
||||
private int blockX, blockY, blockZ;
|
||||
private ModelQuadFacing lightFace;
|
||||
private int flags;
|
||||
|
||||
public VertexArrayQuadView(ChunkVertexEncoder.Vertex[] vertices) {
|
||||
this.vertices = vertices;
|
||||
@@ -23,6 +24,7 @@ public class VertexArrayQuadView implements ModelQuadView {
|
||||
this.blockY = blockY;
|
||||
this.blockZ = blockZ;
|
||||
this.lightFace = null; // Reset cached lightFace
|
||||
this.flags = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,7 +64,10 @@ public class VertexArrayQuadView implements ModelQuadView {
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
return ModelQuadFlags.getQuadFlags(this, getLightFace());
|
||||
if (flags == 0) {
|
||||
flags = ModelQuadFlags.getQuadFlags(this, getLightFace());
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,6 +103,21 @@ public class VertexArrayQuadView implements ModelQuadView {
|
||||
return trueNormal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cull face of a quad. This is distinct from the light face, as it will not be set for non-axis-aligned
|
||||
* and non-block-grid-aligned quads (i.e. quads on the surface of the 1x1x1 cube).
|
||||
* @return the cull face if present, or UNASSIGNED
|
||||
*/
|
||||
public ModelQuadFacing getCullFace() {
|
||||
// In modern, only quads that are aligned to the block grid can have a cull face, as otherwise
|
||||
// they should not participate in face culling (an adjacent block wouldn't obscure an inset quad)
|
||||
if ((getFlags() & ModelQuadFlags.IS_ALIGNED) == 0) {
|
||||
return ModelQuadFacing.UNASSIGNED;
|
||||
}
|
||||
|
||||
return getNormalFace();
|
||||
}
|
||||
|
||||
private static ModelQuadFacing computeLightFace(int normal) {
|
||||
final float nx = NormI8.unpackX(normal);
|
||||
final float ny = NormI8.unpackY(normal);
|
||||
|
||||
+1
-12
@@ -35,17 +35,6 @@ public class LightDataCache extends LightDataAccess {
|
||||
// Opacity check - true if block is view-blocking (solid blocks)
|
||||
final boolean op = block.getMaterial().isOpaque() && block.getLightOpacity() > 0;
|
||||
|
||||
boolean em;
|
||||
if (lu > 0) {
|
||||
em = true;
|
||||
} else {
|
||||
try {
|
||||
em = block.getMixedBrightnessForBlock(EmptyBlockAccess.INSTANCE, x, y, z) == QuadLightingHelper.FULL_BRIGHT_15;
|
||||
} catch (Exception e) {
|
||||
em = false;
|
||||
}
|
||||
}
|
||||
|
||||
return packFC(fc) | packFO(fo) | packOP(op) | packEM(em) | packAO(ao) | packLU(lu) | packSL(sl) | packBL(bl);
|
||||
return packFC(fc) | packFO(fo) | packOP(op) | packAO(ao) | packLU(lu) | packSL(sl) | packBL(bl);
|
||||
}
|
||||
}
|
||||
+11
@@ -1,5 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas.light;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexEncoder;
|
||||
|
||||
public final class QuadLightingHelper {
|
||||
@@ -9,6 +11,15 @@ public final class QuadLightingHelper {
|
||||
public static final int FULL_BRIGHT_15 = (15 << 20) | (15 << 4); // 15728880
|
||||
public static final int FULL_BRIGHT_14 = (14 << 20) | (14 << 4); // 14680288
|
||||
|
||||
public static boolean isBlockEmissive(IBlockAccess world, int x, int y, int z) {
|
||||
final Block block = world.getBlock(x, y, z);
|
||||
try {
|
||||
return block.getMixedBrightnessForBlock(EmptyBlockAccess.INSTANCE, x, y, z) == FULL_BRIGHT_15;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isQuadFullBright(ChunkVertexEncoder.Vertex[] vertices) {
|
||||
final int first = vertices[0].light;
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.coderbot.iris.pipeline.transform.PatchShaderType;
|
||||
import net.coderbot.iris.rendertarget.RenderTargets;
|
||||
import net.coderbot.iris.uniforms.CommonUniforms;
|
||||
import net.coderbot.iris.uniforms.builtin.BuiltinReplacementUniforms;
|
||||
import net.coderbot.iris.shaderpack.ProgramSource;
|
||||
import net.coderbot.iris.uniforms.custom.CustomUniforms;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -60,124 +61,82 @@ public class CeleritasTerrainPipeline {
|
||||
IntFunction<ProgramImages> createTerrainImages,
|
||||
IntFunction<ProgramImages> createShadowImages,
|
||||
CustomUniforms customUniforms,
|
||||
String terrainSourceName,
|
||||
String translucentSourceName,
|
||||
String shadowSourceName,
|
||||
Optional<ProgramSource> terrainSource,
|
||||
Optional<ProgramSource> translucentSource,
|
||||
Optional<ProgramSource> shadowSource,
|
||||
CompletableFuture<Map<PatchShaderType, String>> terrainFuture,
|
||||
CompletableFuture<Map<PatchShaderType, String>> translucentFuture,
|
||||
CompletableFuture<Map<PatchShaderType, String>> shadowFuture,
|
||||
RenderTargets renderTargets,
|
||||
ImmutableSet<Integer> flippedAfterPrepare,
|
||||
ImmutableSet<Integer> flippedAfterTranslucent,
|
||||
@Nullable GlFramebuffer shadowFramebuffer,
|
||||
int[] terrainDrawBuffers
|
||||
@Nullable GlFramebuffer shadowFramebuffer
|
||||
) {
|
||||
this.customUniforms = customUniforms;
|
||||
|
||||
// Initialize PassInfo for each pass
|
||||
for (IrisTerrainPass pass : IrisTerrainPass.VALUES) {
|
||||
passInfoMap.put(pass, new PassInfo());
|
||||
}
|
||||
|
||||
// Process terrain shaders (used for GBUFFER_SOLID and GBUFFER_CUTOUT)
|
||||
if (terrainFuture != null) {
|
||||
try {
|
||||
final Map<PatchShaderType, String> result = terrainFuture.join();
|
||||
final PassInfo solidInfo = passInfoMap.get(IrisTerrainPass.GBUFFER_SOLID);
|
||||
final PassInfo cutoutInfo = passInfoMap.get(IrisTerrainPass.GBUFFER_CUTOUT);
|
||||
|
||||
solidInfo.setSource(PatchShaderType.VERTEX, result.get(PatchShaderType.VERTEX));
|
||||
solidInfo.setSource(PatchShaderType.GEOMETRY, result.get(PatchShaderType.GEOMETRY));
|
||||
solidInfo.setSource(PatchShaderType.FRAGMENT, result.get(PatchShaderType.FRAGMENT));
|
||||
|
||||
cutoutInfo.setSource(PatchShaderType.VERTEX, result.get(PatchShaderType.VERTEX));
|
||||
cutoutInfo.setSource(PatchShaderType.GEOMETRY, result.get(PatchShaderType.GEOMETRY));
|
||||
cutoutInfo.setSource(PatchShaderType.FRAGMENT, result.get(PatchShaderType.FRAGMENT));
|
||||
|
||||
PatchedShaderPrinter.debugPatchedShaders(terrainSourceName + "_celeritas",
|
||||
result.get(PatchShaderType.VERTEX), result.get(PatchShaderType.GEOMETRY), result.get(PatchShaderType.FRAGMENT));
|
||||
} catch (Exception e) {
|
||||
Iris.logger.error("Failed to transform terrain shader for Celeritas: {}", terrainSourceName, e);
|
||||
throw new RuntimeException("Shader transformation failed for " + terrainSourceName, e);
|
||||
}
|
||||
}
|
||||
|
||||
// Process translucent shaders (used for GBUFFER_TRANSLUCENT)
|
||||
if (translucentFuture != null) {
|
||||
try {
|
||||
final Map<PatchShaderType, String> result = translucentFuture.join();
|
||||
final PassInfo translucentInfo = passInfoMap.get(IrisTerrainPass.GBUFFER_TRANSLUCENT);
|
||||
|
||||
translucentInfo.setSource(PatchShaderType.VERTEX, result.get(PatchShaderType.VERTEX));
|
||||
translucentInfo.setSource(PatchShaderType.GEOMETRY, result.get(PatchShaderType.GEOMETRY));
|
||||
translucentInfo.setSource(PatchShaderType.FRAGMENT, result.get(PatchShaderType.FRAGMENT));
|
||||
|
||||
PatchedShaderPrinter.debugPatchedShaders(translucentSourceName + "_celeritas",
|
||||
result.get(PatchShaderType.VERTEX), result.get(PatchShaderType.GEOMETRY), result.get(PatchShaderType.FRAGMENT));
|
||||
} catch (Exception e) {
|
||||
Iris.logger.error("Failed to transform translucent shader for Celeritas: {}", translucentSourceName, e);
|
||||
throw new RuntimeException("Shader transformation failed for " + translucentSourceName, e);
|
||||
}
|
||||
}
|
||||
|
||||
// Process shadow shaders (used for SHADOW and SHADOW_CUTOUT)
|
||||
if (shadowFuture != null) {
|
||||
try {
|
||||
final Map<PatchShaderType, String> result = shadowFuture.join();
|
||||
final PassInfo shadowInfo = passInfoMap.get(IrisTerrainPass.SHADOW);
|
||||
final PassInfo shadowCutoutInfo = passInfoMap.get(IrisTerrainPass.SHADOW_CUTOUT);
|
||||
|
||||
shadowInfo.setSource(PatchShaderType.VERTEX, result.get(PatchShaderType.VERTEX));
|
||||
shadowInfo.setSource(PatchShaderType.GEOMETRY, result.get(PatchShaderType.GEOMETRY));
|
||||
shadowInfo.setSource(PatchShaderType.FRAGMENT, result.get(PatchShaderType.FRAGMENT));
|
||||
|
||||
shadowCutoutInfo.setSource(PatchShaderType.VERTEX, result.get(PatchShaderType.VERTEX));
|
||||
shadowCutoutInfo.setSource(PatchShaderType.GEOMETRY, result.get(PatchShaderType.GEOMETRY));
|
||||
shadowCutoutInfo.setSource(PatchShaderType.FRAGMENT, result.get(PatchShaderType.FRAGMENT));
|
||||
|
||||
PatchedShaderPrinter.debugPatchedShaders(shadowSourceName + "_celeritas",
|
||||
result.get(PatchShaderType.VERTEX), result.get(PatchShaderType.GEOMETRY), result.get(PatchShaderType.FRAGMENT));
|
||||
} catch (Exception e) {
|
||||
Iris.logger.error("Failed to transform shadow shader for Celeritas: {}", shadowSourceName, e);
|
||||
throw new RuntimeException("Shader transformation failed for " + shadowSourceName, e);
|
||||
}
|
||||
}
|
||||
|
||||
// Set up framebuffers for each pass
|
||||
// Shadow passes use the shadow framebuffer
|
||||
if (shadowFramebuffer != null) {
|
||||
passInfoMap.get(IrisTerrainPass.SHADOW).framebuffer = shadowFramebuffer;
|
||||
passInfoMap.get(IrisTerrainPass.SHADOW_CUTOUT).framebuffer = shadowFramebuffer;
|
||||
}
|
||||
|
||||
// GBuffer passes use render target framebuffers
|
||||
if (renderTargets != null && terrainDrawBuffers != null) {
|
||||
final GlFramebuffer solidFb = renderTargets.createGbufferFramebuffer(flippedAfterPrepare, terrainDrawBuffers);
|
||||
final GlFramebuffer translucentFb = renderTargets.createGbufferFramebuffer(flippedAfterTranslucent, terrainDrawBuffers);
|
||||
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_SOLID).framebuffer = solidFb;
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_CUTOUT).framebuffer = solidFb;
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_TRANSLUCENT).framebuffer = translucentFb;
|
||||
}
|
||||
|
||||
// Set blend mode overrides
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_SOLID).blendModeOverride = BlendModeOverride.OFF;
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_CUTOUT).blendModeOverride = BlendModeOverride.OFF;
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_TRANSLUCENT).blendModeOverride = null; // Default blending
|
||||
passInfoMap.get(IrisTerrainPass.SHADOW).blendModeOverride = BlendModeOverride.OFF;
|
||||
passInfoMap.get(IrisTerrainPass.SHADOW_CUTOUT).blendModeOverride = BlendModeOverride.OFF;
|
||||
|
||||
// Set alpha references
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_SOLID).alphaReference = 0.0f;
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_CUTOUT).alphaReference = 0.1f;
|
||||
passInfoMap.get(IrisTerrainPass.GBUFFER_TRANSLUCENT).alphaReference = 0.0f;
|
||||
passInfoMap.get(IrisTerrainPass.SHADOW).alphaReference = 0.0f;
|
||||
passInfoMap.get(IrisTerrainPass.SHADOW_CUTOUT).alphaReference = 0.1f;
|
||||
|
||||
this.createTerrainSamplers = createTerrainSamplers;
|
||||
this.createShadowSamplers = createShadowSamplers;
|
||||
this.createTerrainImages = createTerrainImages;
|
||||
this.createShadowImages = createShadowImages;
|
||||
|
||||
// Build program source map (local - only needed during construction)
|
||||
final EnumMap<IrisTerrainPass, Optional<ProgramSource>> gbufferProgramSource = new EnumMap<>(IrisTerrainPass.class);
|
||||
gbufferProgramSource.put(IrisTerrainPass.GBUFFER_SOLID, terrainSource);
|
||||
gbufferProgramSource.put(IrisTerrainPass.GBUFFER_CUTOUT, terrainSource);
|
||||
gbufferProgramSource.put(IrisTerrainPass.GBUFFER_TRANSLUCENT, translucentSource.isPresent() ? translucentSource : terrainSource);
|
||||
gbufferProgramSource.put(IrisTerrainPass.SHADOW, shadowSource);
|
||||
|
||||
// Initialize PassInfo, framebuffers, blend modes, and alpha in single pass
|
||||
for (IrisTerrainPass pass : IrisTerrainPass.VALUES) {
|
||||
PassInfo passInfo = new PassInfo();
|
||||
passInfoMap.put(pass, passInfo);
|
||||
|
||||
// Set up framebuffer
|
||||
if (pass == IrisTerrainPass.SHADOW || pass == IrisTerrainPass.SHADOW_CUTOUT) {
|
||||
passInfo.framebuffer = shadowFramebuffer;
|
||||
} else if (renderTargets != null) {
|
||||
ImmutableSet<Integer> flipped = pass == IrisTerrainPass.GBUFFER_TRANSLUCENT ? flippedAfterTranslucent : flippedAfterPrepare;
|
||||
|
||||
Optional<ProgramSource> programSource = gbufferProgramSource.get(pass);
|
||||
programSource.ifPresentOrElse(source -> passInfo.framebuffer = renderTargets.createGbufferFramebuffer(flipped, source.getDirectives().getDrawBuffers()), () -> passInfo.framebuffer = renderTargets.createGbufferFramebuffer(flipped, new int[] {0}));
|
||||
}
|
||||
|
||||
// Set blend mode override
|
||||
passInfo.blendModeOverride = switch (pass) {
|
||||
case GBUFFER_TRANSLUCENT -> null; // Default blending
|
||||
default -> BlendModeOverride.OFF;
|
||||
};
|
||||
|
||||
// Set alpha reference
|
||||
passInfo.alphaReference = switch (pass) {
|
||||
case GBUFFER_CUTOUT, SHADOW_CUTOUT -> 0.1f;
|
||||
default -> 0.0f;
|
||||
};
|
||||
}
|
||||
|
||||
// Process and apply shader sources
|
||||
processShaderFuture(terrainFuture, terrainSource, passInfoMap.get(IrisTerrainPass.GBUFFER_SOLID), passInfoMap.get(IrisTerrainPass.GBUFFER_CUTOUT));
|
||||
processShaderFuture(translucentFuture, translucentSource, passInfoMap.get(IrisTerrainPass.GBUFFER_TRANSLUCENT));
|
||||
processShaderFuture(shadowFuture, shadowSource, passInfoMap.get(IrisTerrainPass.SHADOW), passInfoMap.get(IrisTerrainPass.SHADOW_CUTOUT));
|
||||
}
|
||||
|
||||
private void processShaderFuture(@Nullable CompletableFuture<Map<PatchShaderType, String>> future, Optional<ProgramSource> source, PassInfo... targets) {
|
||||
if (future == null || source.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final String sourceName = source.get().getName();
|
||||
try {
|
||||
final Map<PatchShaderType, String> result = future.join();
|
||||
for (PassInfo target : targets) {
|
||||
target.setSource(PatchShaderType.VERTEX, result.get(PatchShaderType.VERTEX));
|
||||
target.setSource(PatchShaderType.GEOMETRY, result.get(PatchShaderType.GEOMETRY));
|
||||
target.setSource(PatchShaderType.FRAGMENT, result.get(PatchShaderType.FRAGMENT));
|
||||
}
|
||||
PatchedShaderPrinter.debugPatchedShaders(sourceName + "_celeritas",
|
||||
result.get(PatchShaderType.VERTEX), result.get(PatchShaderType.GEOMETRY), result.get(PatchShaderType.FRAGMENT));
|
||||
} catch (Exception e) {
|
||||
Iris.logger.error("Failed to transform shader for Celeritas: {}", sourceName, e);
|
||||
throw new RuntimeException("Shader transformation failed for " + sourceName, e);
|
||||
}
|
||||
}
|
||||
|
||||
public PassInfo getPassInfo(IrisTerrainPass pass) {
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float delta) {
|
||||
GLStateManager.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
||||
if(dirty) {
|
||||
dirty = false;
|
||||
this.initGui();
|
||||
@@ -174,7 +174,7 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
} else {
|
||||
this.fontRendererObj.drawStringWithShadow(irisTextComponent, 2, this.height - 10, 0xFFFFFF);
|
||||
}
|
||||
|
||||
|
||||
GLStateManager.glPopAttrib();
|
||||
}
|
||||
|
||||
@@ -507,7 +507,7 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
}
|
||||
|
||||
public boolean isDisplayingComment() {
|
||||
return this.hoveredElementCommentTimer > 20 &&
|
||||
return this.hoveredElementCommentTimer > 10 &&
|
||||
this.hoveredElementCommentTitle.isPresent() &&
|
||||
!this.hoveredElementCommentBody.isEmpty();
|
||||
}
|
||||
|
||||
@@ -524,19 +524,16 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
final GlFramebuffer celeritasShadowFb = (shadowRenderTargets != null && shadowRenderer != null)
|
||||
? shadowRenderTargets.createShadowFramebuffer(shadowRenderTargets.snapshot(), new int[] {0, 1})
|
||||
: null;
|
||||
final int[] celeritasTerrainDrawBuffers = terrainSource
|
||||
.map(source -> source.getDirectives().getDrawBuffers())
|
||||
.orElse(new int[] {0});
|
||||
|
||||
this.celeritasTerrainPipeline = new CeleritasTerrainPipeline(createTerrainSamplers,
|
||||
shadowRenderer == null ? null : createShadowTerrainSamplers, createTerrainImages,
|
||||
shadowRenderer == null ? null : createShadowTerrainImages, this.customUniforms,
|
||||
terrainSource.map(ProgramSource::getName).orElse(null),
|
||||
translucentSource.map(ProgramSource::getName).orElse(null),
|
||||
shadowSource.map(ProgramSource::getName).orElse(null),
|
||||
terrainSource,
|
||||
translucentSource,
|
||||
shadowSource,
|
||||
celeritasTerrainFuture, celeritasTranslucentFuture, celeritasShadowFuture,
|
||||
renderTargets, flippedAfterPrepare, flippedAfterTranslucent,
|
||||
celeritasShadowFb, celeritasTerrainDrawBuffers);
|
||||
celeritasShadowFb);
|
||||
|
||||
this.dhCompat = new DHCompat();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import net.coderbot.iris.uniforms.CelestialUniforms;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.culling.Frustrum;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
@@ -538,7 +537,7 @@ public class ShadowRenderer {
|
||||
return;
|
||||
}
|
||||
int brightness = tile.getWorldObj().getLightBrightnessForSkyBlocks(tile.xCoord, tile.yCoord, tile.zCoord, 0);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) brightness % 65536, (float) brightness / 65536);
|
||||
GLStateManager.setLightmapTextureCoords(GL13.GL_TEXTURE1, (float) brightness % 65536, (float) brightness / 65536);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(tile,
|
||||
(double)tile.xCoord - cameraX,
|
||||
|
||||
@@ -203,7 +203,14 @@ public class ShaderPack {
|
||||
this.shaderPackOptions = new ShaderPackOptions(graph, changedConfigs);
|
||||
graph = this.shaderPackOptions.getIncludes();
|
||||
|
||||
Iterable<StringPair> finalEnvironmentDefines = environmentDefines;
|
||||
List<StringPair> finalEnvironmentDefines = new ArrayList<>();
|
||||
environmentDefines.forEach(finalEnvironmentDefines::add);
|
||||
for (FeatureFlags flag : FeatureFlags.values()) {
|
||||
if (flag.isUsable()) {
|
||||
finalEnvironmentDefines.add(new StringPair("IRIS_FEATURE_" + flag.name(), ""));
|
||||
}
|
||||
}
|
||||
|
||||
this.shaderProperties = Optional.ofNullable(readProperties(root, "shaders.properties"))
|
||||
.map(source -> new ShaderProperties(source, shaderPackOptions, finalEnvironmentDefines))
|
||||
.orElseGet(ShaderProperties::empty);
|
||||
@@ -220,15 +227,6 @@ public class ShaderPack {
|
||||
IrisApi.getInstance().getConfig().setShadersEnabledAndApply(false);
|
||||
}
|
||||
|
||||
List<String> optionalFeatureFlags = shaderProperties.getOptionalFeatureFlags().stream().filter(flag -> !FeatureFlags.isInvalid(flag)).collect(Collectors.toList());
|
||||
|
||||
if (!optionalFeatureFlags.isEmpty()) {
|
||||
List<StringPair> newEnvDefines = new ArrayList<>();
|
||||
environmentDefines.forEach(newEnvDefines::add);
|
||||
optionalFeatureFlags.forEach(flag -> newEnvDefines.add(new StringPair("IRIS_FEATURE_" + flag, "")));
|
||||
environmentDefines = ImmutableList.copyOf(newEnvDefines);
|
||||
}
|
||||
|
||||
ProfileSet profiles = ProfileSet.fromTree(shaderProperties.getProfiles(), this.shaderPackOptions.getOptionSet());
|
||||
this.profile = profiles.scan(this.shaderPackOptions.getOptionSet(), this.shaderPackOptions.getOptionValues());
|
||||
|
||||
|
||||
@@ -26,10 +26,11 @@ public class ItemMaterialHelper {
|
||||
|
||||
/**
|
||||
* Get the material ID for an ItemStack.
|
||||
* Checks item.properties first, then block.properties if the item is an ItemBlock.
|
||||
* For ItemBlock: checks block.properties first, then item.properties.
|
||||
* For other items: checks item.properties only.
|
||||
*
|
||||
* @param itemStack The item stack to get material ID for
|
||||
* @return The material ID, or -1 if not found in either map
|
||||
* @return The material ID, or -1 if not found
|
||||
*/
|
||||
public static int getMaterialId(ItemStack itemStack) {
|
||||
if (itemStack == null || itemStack.getItem() == null) {
|
||||
@@ -68,50 +69,42 @@ public class ItemMaterialHelper {
|
||||
|
||||
/**
|
||||
* Perform the actual material ID lookup without caching.
|
||||
*
|
||||
* For block items (ItemBlock): use block.properties first, then fall back to item.properties.
|
||||
* For non-block items: use item.properties only.
|
||||
*
|
||||
* This matches modern Iris behavior where block items use block IDs and non-block items use item IDs.
|
||||
*/
|
||||
private static int lookupMaterialId(Item item, int metadata) {
|
||||
String itemIdString = (String) Item.itemRegistry.getNameForObject(item);
|
||||
if (itemIdString == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ResourceLocation itemId = new ResourceLocation(itemIdString);
|
||||
NamespacedId namespacedId = new NamespacedId(itemId.getResourceDomain(), itemId.getResourcePath());
|
||||
|
||||
// First, check item.properties
|
||||
Object2IntFunction<NamespacedId> itemIds = BlockRenderingSettings.INSTANCE.getItemIds();
|
||||
if (itemIds != null) {
|
||||
int id = itemIds.applyAsInt(namespacedId);
|
||||
if (id != -1) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
// Second, check block.properties if this is an ItemBlock
|
||||
// For ItemBlock: check block.properties first
|
||||
if (item instanceof ItemBlock) {
|
||||
ItemBlock itemBlock = (ItemBlock) item;
|
||||
Block block = itemBlock.field_150939_a; // The block this item places
|
||||
final ItemBlock itemBlock = (ItemBlock) item;
|
||||
final Block block = itemBlock.field_150939_a; // The block this item places
|
||||
|
||||
if (block == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Convert item damage to block metadata
|
||||
int blockMeta = itemBlock.getMetadata(metadata);
|
||||
|
||||
Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches = BlockRenderingSettings.INSTANCE.getBlockMetaMatches();
|
||||
if (blockMetaMatches != null) {
|
||||
Int2IntMap metaMap = blockMetaMatches.get(block);
|
||||
if (metaMap != null) {
|
||||
int id = metaMap.get(blockMeta);
|
||||
if (id != -1) {
|
||||
return id;
|
||||
if (block != null) {
|
||||
Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches = BlockRenderingSettings.INSTANCE.getBlockMetaMatches();
|
||||
if (blockMetaMatches != null) {
|
||||
Int2IntMap metaMap = blockMetaMatches.get(block);
|
||||
if (metaMap != null) {
|
||||
int id = metaMap.get(itemBlock.getMetadata(metadata));
|
||||
if (id != -1) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not found in either map
|
||||
// Fall back to item.properties
|
||||
Object2IntFunction<NamespacedId> itemIds = BlockRenderingSettings.INSTANCE.getItemIds();
|
||||
if (itemIds != null) {
|
||||
String itemIdString = (String) Item.itemRegistry.getNameForObject(item);
|
||||
if (itemIdString != null) {
|
||||
ResourceLocation itemId = new ResourceLocation(itemIdString);
|
||||
return itemIds.applyAsInt(new NamespacedId(itemId.getResourceDomain(), itemId.getResourcePath()));
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -17,7 +17,6 @@ import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.shadows.ShadowRenderingState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
@@ -31,6 +30,7 @@ import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkShaderFogComponent;
|
||||
import org.embeddedt.embeddium.impl.render.terrain.SimpleWorldRenderer;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.ViewportProvider;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@@ -144,7 +144,7 @@ public class MixinRenderGlobal implements IRenderGlobalExt {
|
||||
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
|
||||
GLStateManager.glActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.getTextureMapBlocks().getGlTextureId());
|
||||
GLStateManager.glEnable(GL11.GL_TEXTURE_2D);
|
||||
|
||||
|
||||
+6
-5
@@ -1,7 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.mcpatcherforge.cit.client.renderer.entity;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -13,6 +13,7 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Overwrite;
|
||||
@@ -224,9 +225,9 @@ public abstract class MixinRenderEntityLiving extends Render {
|
||||
this.renderEquippedItems(entity, p_76986_9_);
|
||||
float f14 = entity.getBrightness(p_76986_9_);
|
||||
j = this.getColorMultiplier(entity, f14, p_76986_9_);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GLStateManager.setActiveTexture(GL13.GL_TEXTURE1);
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GLStateManager.setActiveTexture(GL13.GL_TEXTURE0);
|
||||
|
||||
if ((j >> 24 & 255) > 0 || entity.hurtTime > 0 || entity.deathTime > 0) {
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
@@ -274,9 +275,9 @@ public abstract class MixinRenderEntityLiving extends Render {
|
||||
logger.error("Couldn't render entity", exception);
|
||||
}
|
||||
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
||||
GLStateManager.setActiveTexture(GL13.GL_TEXTURE1);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
||||
GLStateManager.setActiveTexture(GL13.GL_TEXTURE0);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glPopMatrix();
|
||||
this.passSpecialRender(entity, x, y, z);
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.mixins.early.shaders;
|
||||
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(OpenGlHelper.class)
|
||||
public class MixinOpenGlHelper {
|
||||
@Unique private static int iris$drawFramebuffer = 0;
|
||||
@Unique private static int iris$readFramebuffer = 0;
|
||||
|
||||
@Inject(method="func_153171_g", at=@At("HEAD"), cancellable=true)
|
||||
private static void iris$avoidRedundantBind(int target, int framebuffer, CallbackInfo ci) {
|
||||
if (target == GL30.GL_FRAMEBUFFER) {
|
||||
if (iris$drawFramebuffer == target && iris$readFramebuffer == target) {
|
||||
ci.cancel();
|
||||
} else {
|
||||
iris$drawFramebuffer = framebuffer;
|
||||
iris$readFramebuffer = framebuffer;
|
||||
}
|
||||
} else if (target == GL30.GL_DRAW_FRAMEBUFFER) {
|
||||
if (iris$drawFramebuffer == target) {
|
||||
ci.cancel();
|
||||
} else {
|
||||
iris$drawFramebuffer = framebuffer;
|
||||
}
|
||||
} else if (target == GL30.GL_READ_FRAMEBUFFER) {
|
||||
if (iris$readFramebuffer == target) {
|
||||
ci.cancel();
|
||||
} else {
|
||||
iris$readFramebuffer = framebuffer;
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("Invalid framebuffer target: " + target);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method="func_153174_h", at=@At("HEAD"))
|
||||
private static void iris$trackFramebufferDelete(int framebuffer, CallbackInfo ci) {
|
||||
if (iris$drawFramebuffer == framebuffer) {
|
||||
iris$drawFramebuffer = 0;
|
||||
}
|
||||
|
||||
if (iris$readFramebuffer == framebuffer) {
|
||||
iris$readFramebuffer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+11
@@ -20,6 +20,17 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(RendererLivingEntity.class)
|
||||
public class MixinRendererLivingEntity {
|
||||
/**
|
||||
* Reset currentRenderedItemId at the start of rendering each living entity, otherwise entity materials don't apply.
|
||||
*/
|
||||
@Inject(
|
||||
method = "doRender(Lnet/minecraft/entity/EntityLivingBase;DDDFF)V",
|
||||
at = @At("HEAD")
|
||||
)
|
||||
private void iris$resetItemIdAtStart(EntityLivingBase entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) {
|
||||
CapturedRenderingState.INSTANCE.setCurrentRenderedItem(0);
|
||||
}
|
||||
|
||||
@WrapOperation(
|
||||
method="doRender",
|
||||
at=@At(value="INVOKE", target="Lnet/minecraft/client/renderer/entity/RendererLivingEntity;getColorMultiplier(Lnet/minecraft/entity/EntityLivingBase;FF)I")
|
||||
|
||||
+25
-5
@@ -30,10 +30,29 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
@Mixin(value = SkyProviderCelestial.class, priority = 100)
|
||||
public class MixinSkyProviderCelestial_ShaderCompat {
|
||||
|
||||
/// Simple white 2x2 texture
|
||||
@Unique
|
||||
private static ResourceLocation GL_TEXTURE_2D_WORKAROUND = new ResourceLocation("angelica:textures/shaders_workaround.png"); /// Simple white 2x2 texture
|
||||
private static ResourceLocation GL_TEXTURE_2D_WORKAROUND = new ResourceLocation("angelica:textures/shaders_workaround.png");
|
||||
|
||||
/// Fixes
|
||||
// Fixes
|
||||
|
||||
/**
|
||||
* Disables {@link GL11#glDisable(int GL_TEXTURE_2D)} call
|
||||
* @see #iris$atmosphereBlend$renderInDefaultProgram(CallbackInfo, Minecraft, LocalIntRef)
|
||||
*/
|
||||
@WrapWithCondition(method = "renderSunset", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 0), remap = false)
|
||||
private boolean iris$sunset$revertTextureDisable(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables {@link GL11#glEnable(int GL_TEXTURE_2D)} call
|
||||
* @see #iris$atmosphereBlend$renderInDefaultProgram(CallbackInfo, Minecraft, LocalIntRef)
|
||||
*/
|
||||
@WrapWithCondition(method = "renderSunset", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 0), remap = false)
|
||||
private boolean iris$sunsetBlend$revertTextureEnable(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces sunset to render with the default program
|
||||
@@ -41,13 +60,14 @@ public class MixinSkyProviderCelestial_ShaderCompat {
|
||||
* Fixes sunset not rendering at all with shaders enabled
|
||||
*/
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/hbm/dim/SkyProviderCelestial;renderSunset(FLnet/minecraft/client/multiplayer/WorldClient;Lnet/minecraft/client/Minecraft;)V"), remap = false)
|
||||
public void iris$sunset$renderInDefaultProgram(CallbackInfo ci, @Share("sunset$previousProgram") LocalIntRef sunset$previousProgram) {
|
||||
public void iris$sunset$renderInDefaultProgram(CallbackInfo ci, @Local(argsOnly = true) Minecraft mc, @Share("sunset$previousProgram") LocalIntRef sunset$previousProgram) {
|
||||
sunset$previousProgram.set(GLStateManager.getActiveProgram());
|
||||
GLStateManager.glUseProgram(0);
|
||||
mc.getTextureManager().bindTexture(GL_TEXTURE_2D_WORKAROUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the program back before {@link #iris$sunset$renderInDefaultProgram(CallbackInfo, LocalIntRef)} call
|
||||
* Sets the program back before {@link #iris$sunset$renderInDefaultProgram(CallbackInfo, Minecraft, LocalIntRef)} call
|
||||
*/
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/hbm/dim/SkyProviderCelestial;renderSunset(FLnet/minecraft/client/multiplayer/WorldClient;Lnet/minecraft/client/Minecraft;)V", shift = At.Shift.AFTER), remap = false)
|
||||
public void iris$sunset$restorePreviousProgram(CallbackInfo ci, @Share("sunset$previousProgram") LocalIntRef sunset$previousProgram) {
|
||||
@@ -200,7 +220,7 @@ public class MixinSkyProviderCelestial_ShaderCompat {
|
||||
GLStateManager.glUseProgram(ringsFront$previousProgram.get());
|
||||
}
|
||||
|
||||
/// Pipeline setup
|
||||
// Pipeline setup
|
||||
|
||||
@Inject(method = "render", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/Tessellator;instance:Lnet/minecraft/client/renderer/Tessellator;"))
|
||||
private void iris$renderSky$beginNormalSky(CallbackInfo ci, @Share("pipeline") LocalRef<WorldRenderingPipeline> pipeline) {
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.gtnewhorizons.angelica.mixins.late.client.ntmSpace;
|
||||
|
||||
import com.hbm.dim.laythe.SkyProviderLaytheSunset;
|
||||
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
||||
@Mixin(value = SkyProviderLaytheSunset.class, priority = 100)
|
||||
public class MixinSkyProviderLaytheSunset {
|
||||
|
||||
/**
|
||||
* Disables {@link GL11#glDisable(int GL_TEXTURE_2D)} call
|
||||
*/
|
||||
@WrapWithCondition(method = "renderSunset", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 0), remap = false)
|
||||
private boolean iris$sunset$revertTextureDisable(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables {@link GL11#glEnable(int GL_TEXTURE_2D)} call
|
||||
*/
|
||||
@WrapWithCondition(method = "renderSunset", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 0), remap = false)
|
||||
private boolean iris$sunsetBlend$revertTextureEnable(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user