mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 12:52:19 +00:00
Compare commits
50
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1dd98978ad | ||
|
|
dae986eb0b | ||
|
|
5fdf84edd0 | ||
|
|
b19d023c11 | ||
|
|
41eafbd151 | ||
|
|
dd970b4c6a | ||
|
|
f79ad7f22a | ||
|
|
6947ffa3e2 | ||
|
|
969d2c3710 | ||
|
|
c5988d29c3 | ||
|
|
dc68c2c265 | ||
|
|
51533a81ec | ||
|
|
90eabb5d40 | ||
|
|
74843cb1f9 | ||
|
|
5e0344a529 | ||
|
|
3cdd934987 | ||
|
|
9d90ff137c | ||
|
|
bee9541797 | ||
|
|
b75a5d8f7d | ||
|
|
8d3ab41c53 | ||
|
|
48d032e654 | ||
|
|
1968914582 | ||
|
|
a70bd76ff3 | ||
|
|
db919b5f37 | ||
|
|
cde47ea423 | ||
|
|
5ef6cb11c0 | ||
|
|
b7015bf10e | ||
|
|
46602ab921 | ||
|
|
63e9fa0df1 | ||
|
|
dcea970a77 | ||
|
|
b29240d6da | ||
|
|
9d5a02ed21 | ||
|
|
b454483aae | ||
|
|
72b13543c6 | ||
|
|
36d98fcb22 | ||
|
|
44c5b9617a | ||
|
|
f3f1677db8 | ||
|
|
d396b611ad | ||
|
|
08f4c0f9db | ||
|
|
50b0d22dc2 | ||
|
|
7fed54264e | ||
|
|
be87401be6 | ||
|
|
94254006df | ||
|
|
f79774df65 | ||
|
|
2f2fc22df3 | ||
|
|
26300bbb1b | ||
|
|
88e4d2fd6c | ||
|
|
bb52476d27 | ||
|
|
6d60477b93 | ||
|
|
362724610c |
No files matched your search
@@ -36,3 +36,4 @@ addon.local.gradle
|
||||
addon.local.gradle.kts
|
||||
addon.late.local.gradle
|
||||
addon.late.local.gradle.kts
|
||||
local/
|
||||
+4
-3
@@ -71,9 +71,9 @@ dependencies {
|
||||
|
||||
// Iris Shaders
|
||||
compileOnly('org.jetbrains:annotations:26.0.2')
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.9.0:dev")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.9.6:dev")
|
||||
shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0
|
||||
shadowImplementation("org.taumc:glsl-transformation-lib:0.2.0-25.g3a943bb") {
|
||||
shadowImplementation("org.taumc:glsl-transformation-lib:0.2.0-26.g5ee7d96-GTNH") {
|
||||
exclude module: "antlr4" // we only want to shadow the runtime module
|
||||
}
|
||||
shadowImplementation("org.antlr:antlr4-runtime:4.13.2")
|
||||
@@ -110,11 +110,12 @@ dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds:2.1.10:dev") // Mixin Version
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds-Legacy:1.4.7:dev") // ASM Version
|
||||
|
||||
compileOnly(rfg.deobf("curse.maven:ntm-space-1121235:6974420"))
|
||||
compileOnly(rfg.deobf("maven.modrinth:ntmspace:X5593_H261"))
|
||||
|
||||
compileOnly(rfg.deobf("curse.maven:campfirebackport-387444:4611675"))
|
||||
compileOnly(rfg.deobf("curse.maven:xaeros-minimap-263420:5060684"))
|
||||
compileOnly(rfg.deobf("curse.maven:security-craft-64760:2818228"))
|
||||
compileOnly(rfg.deobf("curse.maven:et-futurum-requiem-441392:5873837"))
|
||||
|
||||
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:CoreTweaks:0.3.3.6-GTNH")
|
||||
// For testing alternative splash screens, can be sourced from https://github.com/MalTeeez/ModernSplash/releases
|
||||
|
||||
+1
-1
@@ -16,5 +16,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.gtnewhorizons.gtnhsettingsconvention") version("2.0.13")
|
||||
id("com.gtnewhorizons.gtnhsettingsconvention") version("2.0.19")
|
||||
}
|
||||
@@ -1,19 +1,21 @@
|
||||
package com.gtnewhorizons.angelica;
|
||||
|
||||
import static com.gtnewhorizons.angelica.AngelicaMod.MOD_ID;
|
||||
|
||||
import com.gtnewhorizons.angelica.common.BlockError;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.config.ConfigMigrator;
|
||||
import com.gtnewhorizons.angelica.proxy.CommonProxy;
|
||||
import com.gtnewhorizons.angelica.utils.AnimationMode;
|
||||
import com.gtnewhorizons.angelica.utils.ManagedEnum;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptions;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import static com.gtnewhorizons.angelica.AngelicaMod.MOD_ID;
|
||||
|
||||
@Mod(
|
||||
modid = MOD_ID,
|
||||
@@ -33,6 +35,15 @@ public class AngelicaMod {
|
||||
public static final String MOD_ID = "angelica";
|
||||
public static final Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
|
||||
private static SodiumGameOptions CONFIG;
|
||||
|
||||
public static SodiumGameOptions options() {
|
||||
if (CONFIG == null) {
|
||||
CONFIG = SodiumGameOptions.load(ConfigMigrator.handleConfigMigration("angelica-options.json"));
|
||||
}
|
||||
return CONFIG;
|
||||
}
|
||||
|
||||
@SidedProxy(clientSide = "com.gtnewhorizons.angelica.proxy.ClientProxy", serverSide = "com.gtnewhorizons.angelica.proxy.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ public class FontStrategist {
|
||||
DefaultResourcePack fontResourcePack = new DefaultResourcePack(packMap);
|
||||
List defaultResourcePacks = ((ResourceAccessor) Minecraft.getMinecraft()).angelica$getDefaultResourcePacks();
|
||||
defaultResourcePacks.add(fontResourcePack);
|
||||
Minecraft.getMinecraft().refreshResources();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.gtnewhorizons.angelica.compat;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.lwjgl.opengl.ARBDebugOutput;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
|
||||
/**
|
||||
* Checks for known problematic driver configurations and applies workarounds. Adapted from Embeddium/Sodium's LateDriverScanner.
|
||||
*
|
||||
* <p>The NVIDIA workaround can be disabled via: {@code -Dangelica.disableNvidiaWorkaround=true}
|
||||
*/
|
||||
public class DriverCompatabilityCheck {
|
||||
private static final Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
|
||||
private static final boolean DISABLE_NVIDIA_WORKAROUND = Boolean.getBoolean("angelica.disableNvidiaWorkaround");
|
||||
|
||||
/**
|
||||
* Should be called after GL context is created and GLStateManager is initialized.
|
||||
*/
|
||||
public static void checkDriverCompatibility() {
|
||||
final String vendor = GL11.glGetString(GL11.GL_VENDOR);
|
||||
final String renderer = GL11.glGetString(GL11.GL_RENDERER);
|
||||
final String version = GL11.glGetString(GL11.GL_VERSION);
|
||||
|
||||
LOGGER.info("OpenGL Vendor: {}", vendor);
|
||||
LOGGER.info("OpenGL Renderer: {}", renderer);
|
||||
LOGGER.info("OpenGL Version: {}", version);
|
||||
|
||||
if (vendor != null && vendor.contains("NVIDIA")) {
|
||||
if (DISABLE_NVIDIA_WORKAROUND) {
|
||||
LOGGER.info("NVIDIA workaround disabled via -Dangelica.disableNvidiaWorkaround=true");
|
||||
} else {
|
||||
applyNvidiaWorkaround();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* https://github.com/godotengine/godot/issues/33969#issuecomment-917846774
|
||||
* Attempt to force the driver to disable its submission thread by enabling synchronous debug output.
|
||||
* This usually suppresses bad behavior from NVIDIA's "Threaded Optimizations" feature.
|
||||
*/
|
||||
private static void applyNvidiaWorkaround() {
|
||||
if (!GLStateManager.capabilities.GL_ARB_debug_output) {
|
||||
LOGGER.warn("Cannot apply NVIDIA workaround: ARB_debug_output not available");
|
||||
return;
|
||||
}
|
||||
|
||||
LOGGER.info("Enabling workaround for NVIDIA threaded optimizations");
|
||||
GL11.glEnable(ARBDebugOutput.GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.compat.iris;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import net.coderbot.iris.parsing.BiomeCategories;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
|
||||
@@ -8,7 +9,7 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* Detects and categorizes biomes from popular modded biome mods using cached class checks.
|
||||
* Currently supports: BiomesOPlenty (BOP), Realistic World Gen (RWG)
|
||||
* Currently supports: BiomesOPlenty (BOP), Realistic World Gen (RWG), lotr (b36.15)
|
||||
*/
|
||||
public class ModdedBiomeDetector {
|
||||
private static boolean initialized = false;
|
||||
@@ -23,12 +24,15 @@ public class ModdedBiomeDetector {
|
||||
// LinkedHashMap maintains insertion order for deterministic behavior
|
||||
private static final Map<Class<?>, BiomeCategories> rwgClassMap = new LinkedHashMap<>();
|
||||
|
||||
private static Class<?> lotrBiomeClass = null;
|
||||
|
||||
private static synchronized void initialize() {
|
||||
if (initialized) return;
|
||||
initialized = true;
|
||||
|
||||
initializeBOP();
|
||||
initializeRWG();
|
||||
initializeLOTR();
|
||||
}
|
||||
|
||||
private static void initializeBOP() {
|
||||
@@ -59,6 +63,16 @@ public class ModdedBiomeDetector {
|
||||
tryAddRWGClass("rwg.biomes.base.BaseBiomeSnowForest", BiomeCategories.TAIGA); // Snow forests are taiga
|
||||
}
|
||||
|
||||
private static void initializeLOTR() {
|
||||
if (ModStatus.isLotrLoaded) {
|
||||
try {
|
||||
lotrBiomeClass = Class.forName("lotr.common.world.biome.LOTRBiome");
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
// lotr not installed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void tryAddRWGClass(String className, BiomeCategories category) {
|
||||
try {
|
||||
final Class<?> clazz = Class.forName(className);
|
||||
@@ -91,12 +105,64 @@ public class ModdedBiomeDetector {
|
||||
// fall through to name/property-based detection
|
||||
|
||||
// Realistic World Gen detection
|
||||
for (Map.Entry<Class<?>, BiomeCategories> entry : rwgClassMap.entrySet()) {
|
||||
if (entry.getKey().isInstance(biome)) {
|
||||
return entry.getValue();
|
||||
if (biome.getBiomeClass().getName().contains("rwg.biomes")) {
|
||||
for (Map.Entry<Class<?>, BiomeCategories> entry : rwgClassMap.entrySet()) {
|
||||
if (entry.getKey().isInstance(biome)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// lotr
|
||||
if (lotrBiomeClass!= null && lotrBiomeClass.isInstance(biome)) {
|
||||
return detectLOTRBiome(biome);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BiomeCategories detectLOTRBiome(BiomeGenBase biome) {
|
||||
return switch (biome.biomeName) {
|
||||
case "river", "farHaradJungleLake", "lake" -> BiomeCategories.RIVER;
|
||||
case "rohan", "rivendell", "rhunIsland", "rhunLandHills", "rhunLandSteppe", "rhunLand", "andrast",
|
||||
"blackrootVale", "lamedon", "imlothMelui", "towerHills", "dorwinion", "dale", "shireMoors", "wold",
|
||||
"anduinVale", "rhun", "lebennin", "pertorogwaith", "breeland", "island", "pinnathGelin",
|
||||
"minhiriath", "pelennor", "adornland", "nanCurunir", "ithilienWasteland", "fangornClearing",
|
||||
"barrowDowns", "dorEnErnilHills", "dorEnErnil", "nurn", "wilderland", "eastBight", "lindon",
|
||||
"eregion", "enedwaith", "meneltarma", "anduinHills", "eriador", "angle", "loneLandsHills",
|
||||
"loneLands", "pelargir", "rohanUrukHighlands", "celebrant", "gondor", "shire", "nurnen", "farHarad" ->
|
||||
BiomeCategories.PLAINS;
|
||||
case "mistyMountains", "windMountains", "farHaradVolcano", "redMountains", "haradMountains",
|
||||
"angmarMountains", "blueMountains", "greyMountains", "whiteMountains", "mordorMountains" ->
|
||||
BiomeCategories.MOUNTAIN;
|
||||
case "shireWoodlands", "rhunIslandForest", "rhunRedForest", "pukel", "lossarnach", "gulfHaradForest",
|
||||
"nearHaradFertileForest", "dolGuldur", "rhunForest", "tauredainClearing", "umbarForest",
|
||||
"farHaradForest", "chetwood", "woodlandRealmHills", "mirkwoodNorth", "whiteDowns", "ithilienHills",
|
||||
"gondorWoodlands", "rohanWoodlands", "fangornWasteland", "mirkwoodMountains", "lindonWoodlands",
|
||||
"lothlorienEdge", "erynVorn", "oldForest", "fangorn", "dunland", "ithilien", "mirkwoodCorrupted",
|
||||
"woodlandRealm", "trollshaws", "lothlorien", "farHaradKanuka" -> BiomeCategories.FOREST;
|
||||
case "mordor", "lastDesert", "harnedor", "easternDesolation", "morgulVale", "gorgoroth", "udun",
|
||||
"nearHaradRedDesert", "nearHaradSemiDesert", "lostladen",
|
||||
"nearHaradHills", "nearHarad", "nanUngol", "dagorlad", "brownLands" -> BiomeCategories.DESERT;
|
||||
case "ironHills", "rivendellHills", "windMountainsFoothills", "lamedonHills", "redMountainsFoothills",
|
||||
"tolfalas", "dorwinionHills", "whiteMountainsFoothills", "blueMountainsFoothills",
|
||||
"greyMountainsFoothills", "mistyMountainsFoothills", "erebor", "angmar", "eriadorDowns",
|
||||
"ettenmoors", "emynMuil" -> BiomeCategories.EXTREME_HILLS;
|
||||
case "deadMarshes", "shireMarshes", "farHaradMangrove", "farHaradSwamp", "swanfleet", "nindalf",
|
||||
"longMarshes", "entwashMouth", "nurnMarshes", "gladdenFields", "midgewater", "anduinMouth" ->
|
||||
BiomeCategories.SWAMP;
|
||||
case "harondor", "nearHaradOasis", "nearHaradRiverbank", "farHaradBushlandHills", "farHaradBushland",
|
||||
"gulfHarad", "nearHaradFertile", "umbarHills", "umbar", "farHaradAridHills", "farHaradArid" ->
|
||||
BiomeCategories.SAVANNA;
|
||||
case "ocean" -> BiomeCategories.OCEAN;
|
||||
case "forodwaith", "forodwaithGlacier", "tundra", "forodwaithMountains" -> BiomeCategories.ICY;
|
||||
case "lindonCoast", "beachWhite", "farHaradCoast", "forodwaithCoast", "beachGravel", "beach" ->
|
||||
BiomeCategories.BEACH;
|
||||
case "coldfells", "wilderlandNorth", "taiga" -> BiomeCategories.TAIGA;
|
||||
case "farHaradJungle", "halfTrollForest", "farHaradJungleMountains",
|
||||
"farHaradCloudForest", "farHaradJungleEdge" -> BiomeCategories.JUNGLE;
|
||||
case "utumno" -> BiomeCategories.NONE;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ public class Camera {
|
||||
public static final Camera INSTANCE = new Camera();
|
||||
|
||||
private final Vector3d pos = new Vector3d();
|
||||
private final Vector3d entityPos = new Vector3d();
|
||||
private final BlockPos blockPos = new BlockPos();
|
||||
private final Vector3f offset = new Vector3f();
|
||||
private final Matrix4f inverseModelView = new Matrix4f();
|
||||
@@ -42,12 +43,14 @@ public class Camera {
|
||||
this.partialTicks = partialTicks;
|
||||
this.entity = entity;
|
||||
|
||||
// Entity position (interpolated, at feet level)
|
||||
// Entity position (interpolated, at eye level)
|
||||
final double entityX = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks;
|
||||
final double entityY = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks;
|
||||
final double entityZ = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks;
|
||||
final double eyeHeight = entity.getEyeHeight();
|
||||
|
||||
entityPos.set(entityX, entityY + eyeHeight, entityZ);
|
||||
|
||||
thirdPerson = Minecraft.getMinecraft().gameSettings.thirdPersonView > 0;
|
||||
|
||||
final double camX, camY, camZ;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.compat.toremove;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
@@ -147,7 +147,7 @@ public abstract class RenderPhase {
|
||||
FOG = new Fog("fog", () -> {
|
||||
// Unclear what this should do
|
||||
// BackgroundRenderer.setFogBlack(), also levelFogColor()
|
||||
SodiumClientMod.LOGGER.debug("Fog - Not setting level fog color");
|
||||
AngelicaMod.LOGGER.debug("Fog - Not setting level fog color");
|
||||
GLStateManager.enableFog();
|
||||
}, GLStateManager::disableFog);
|
||||
BLACK_FOG = new Fog("black_fog", () -> {
|
||||
@@ -156,7 +156,7 @@ public abstract class RenderPhase {
|
||||
}, () -> {
|
||||
// Unclear what this should do
|
||||
// BackgroundRenderer.setFogBlack(), also levelFogColor()
|
||||
SodiumClientMod.LOGGER.debug("Fog - Not setting level fog color");
|
||||
AngelicaMod.LOGGER.debug("Fog - Not setting level fog color");
|
||||
GLStateManager.disableFog();
|
||||
});
|
||||
MAIN_TARGET = new Target("main_target", () -> {
|
||||
@@ -164,7 +164,7 @@ public abstract class RenderPhase {
|
||||
});
|
||||
OUTLINE_TARGET = new Target("outline_target", () -> {
|
||||
// TODO: Sodium
|
||||
SodiumClientMod.LOGGER.debug("NOT enabling the entity outline framebuffer");
|
||||
AngelicaMod.LOGGER.debug("NOT enabling the entity outline framebuffer");
|
||||
//MinecraftClient.getInstance().worldRenderer.getEntityOutlinesFramebuffer().beginWrite(false);
|
||||
}, () -> {
|
||||
Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
|
||||
@@ -172,7 +172,7 @@ public abstract class RenderPhase {
|
||||
TRANSLUCENT_TARGET = new Target("translucent_target", () -> {
|
||||
if (Minecraft.isFancyGraphicsEnabled()) {
|
||||
// TODO: Sodium
|
||||
SodiumClientMod.LOGGER.debug("NOT enabling the translucent framebuffer");
|
||||
AngelicaMod.LOGGER.debug("NOT enabling the translucent framebuffer");
|
||||
// MinecraftClient.getInstance().worldRenderer.getTranslucentFramebuffer().beginWrite(false);
|
||||
}
|
||||
|
||||
@@ -345,7 +345,7 @@ public abstract class RenderPhase {
|
||||
super("lightmap", () -> {
|
||||
if (lightmap) {
|
||||
// TODO: Sodium - LightmapTextureManager
|
||||
SodiumClientMod.LOGGER.debug("Lightmap - enable (not implemented)");
|
||||
AngelicaMod.LOGGER.debug("Lightmap - enable (not implemented)");
|
||||
// throw new RuntimeException("Not Implemented Yet");
|
||||
// MinecraftClient.getInstance().gameRenderer.getLightmapTextureManager().enable();
|
||||
|
||||
@@ -354,7 +354,7 @@ public abstract class RenderPhase {
|
||||
}, () -> {
|
||||
if (lightmap) {
|
||||
// TODO: Sodium - LightmapTextureManager
|
||||
SodiumClientMod.LOGGER.debug("Lightmap - disable (not implemented)");
|
||||
AngelicaMod.LOGGER.debug("Lightmap - disable (not implemented)");
|
||||
// throw new RuntimeException("Not Implemented Yet");
|
||||
// MinecraftClient.getInstance().gameRenderer.getLightmapTextureManager().disable();
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ public class AngelicaConfig {
|
||||
"net.minecraft.block.BlockStairs"
|
||||
})
|
||||
public static String[] blockCrackFixBlacklist;
|
||||
|
||||
|
||||
@Config.Comment({"Block classes that have render pass other than 0 but still need to be manipulated.",
|
||||
"Add a block class here if you see flickering (z-fighting) with fixBlockCrack enabled"
|
||||
})
|
||||
@@ -217,8 +217,16 @@ public class AngelicaConfig {
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean enableHardcodedCustomUniforms;
|
||||
|
||||
@Config.Comment("Define IS_IRIS in shader macros.")
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean defineIsIris;
|
||||
|
||||
@Config.Comment("Renders chunks before neighbors are ready. Improves loading at render distance edges, useful for low render distance servers.")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean useVanillaChunkTracking;
|
||||
|
||||
@Config.Comment("Disables additional F3 information added by Angelica.")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean disableF3Additions;
|
||||
|
||||
}
|
||||
@@ -52,6 +52,7 @@ public class DynamicLights {
|
||||
private static final double MAX_RADIUS_SQUARED = MAX_RADIUS * MAX_RADIUS;
|
||||
private final Set<IDynamicLightSource> dynamicLightSources = new ObjectOpenHashSet<>();
|
||||
private final ReentrantReadWriteLock lightSourcesLock = new ReentrantReadWriteLock();
|
||||
private volatile int lightSourceCount = 0;
|
||||
private final ChunkRebuildManager chunkRebuildManager = new ChunkRebuildManager();
|
||||
private long lastUpdate = System.currentTimeMillis();
|
||||
private int lastUpdateCount = 0;
|
||||
@@ -70,6 +71,10 @@ public class DynamicLights {
|
||||
(ShaderForce || !IrisApi.getInstance().isShaderPackInUse());
|
||||
}
|
||||
|
||||
public boolean hasLightSources() {
|
||||
return lightSourceCount > 0;
|
||||
}
|
||||
|
||||
public static IDynamicLightWorldRenderer getActiveRenderer() {
|
||||
return activeRenderer;
|
||||
}
|
||||
@@ -142,7 +147,9 @@ public class DynamicLights {
|
||||
|
||||
public void addLightSource(IDynamicLightSource lightSource) {
|
||||
this.lightSourcesLock.writeLock().lock();
|
||||
this.dynamicLightSources.add(lightSource);
|
||||
if (this.dynamicLightSources.add(lightSource)) {
|
||||
this.lightSourceCount = this.dynamicLightSources.size();
|
||||
}
|
||||
this.lightSourcesLock.writeLock().unlock();
|
||||
}
|
||||
|
||||
@@ -160,6 +167,7 @@ public class DynamicLights {
|
||||
it = dynamicLightSources.next();
|
||||
if (it.equals(lightSource)) {
|
||||
dynamicLightSources.remove();
|
||||
this.lightSourceCount = this.dynamicLightSources.size();
|
||||
if (activeRenderer != null)
|
||||
lightSource.angelica$scheduleTrackedChunksRebuild(activeRenderer);
|
||||
break;
|
||||
@@ -183,6 +191,7 @@ public class DynamicLights {
|
||||
it = dynamicLightSources.next();
|
||||
if (filter.test(it)) {
|
||||
dynamicLightSources.remove();
|
||||
this.lightSourceCount = this.dynamicLightSources.size();
|
||||
if (activeRenderer != null) {
|
||||
if (it.angelica$getLuminance() > 0)
|
||||
it.angelica$resetDynamicLight();
|
||||
@@ -212,6 +221,7 @@ public class DynamicLights {
|
||||
it.angelica$scheduleTrackedChunksRebuild(activeRenderer);
|
||||
}
|
||||
}
|
||||
this.lightSourceCount = 0;
|
||||
|
||||
this.lightSourcesLock.writeLock().unlock();
|
||||
}
|
||||
|
||||
@@ -1019,11 +1019,22 @@ public class DisplayListManager {
|
||||
if (currentRecorder != null) {
|
||||
recordCallList(list);
|
||||
|
||||
if (glListMode == GL11.GL_COMPILE) {
|
||||
return;
|
||||
if (getListMode() != GL11.GL_COMPILE) {
|
||||
// Don't record the GL calls, we already recorded glCallList
|
||||
final CommandRecorder recorder = currentRecorder;
|
||||
currentRecorder = null;
|
||||
|
||||
executeDisplayList(list);
|
||||
|
||||
currentRecorder = recorder;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
executeDisplayList(list);
|
||||
}
|
||||
|
||||
private static void executeDisplayList(int list) {
|
||||
final CompiledDisplayList compiled = displayListCache.get(list);
|
||||
if (compiled != null) {
|
||||
final int prevList = currentRenderingList;
|
||||
|
||||
@@ -19,9 +19,6 @@ import org.lwjgl.opengl.GL43;
|
||||
import org.lwjgl.opengl.KHRDebug;
|
||||
import org.lwjgl.opengl.KHRDebugCallback;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
import static org.lwjgl.opengl.ARBDebugOutput.glDebugMessageCallbackARB;
|
||||
|
||||
@@ -35,20 +32,9 @@ public final class GLDebug {
|
||||
LOGGER.warn("setupDebugMessageCallback called from non-main thread!");
|
||||
return 0;
|
||||
}
|
||||
return setupDebugMessageCallback(System.err);
|
||||
return setupDebugMessageCallbackImpl();
|
||||
}
|
||||
|
||||
private static void trace(Consumer<String> output) {
|
||||
/*
|
||||
* We can not just use a fixed stacktrace element offset, because some methods
|
||||
* are intercepted and some are not. So, check the package name.
|
||||
*/
|
||||
StackTraceElement[] elems = filterStackTrace(new Throwable(), 4).getStackTrace();
|
||||
for (StackTraceElement ste : elems) {
|
||||
output.accept(ste.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static Throwable filterStackTrace(Throwable throwable, int offset) {
|
||||
StackTraceElement[] elems = throwable.getStackTrace();
|
||||
StackTraceElement[] filtered = new StackTraceElement[elems.length];
|
||||
@@ -66,36 +52,48 @@ public final class GLDebug {
|
||||
return throwable;
|
||||
}
|
||||
|
||||
public static void printTrace(PrintStream stream) {
|
||||
trace(new Consumer<String>() {
|
||||
boolean first = true;
|
||||
private static String buildStackTrace() {
|
||||
StackTraceElement[] elems = filterStackTrace(new Throwable(), 4).getStackTrace();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (StackTraceElement elem : elems) {
|
||||
sb.append("\n\t").append(elem.toString());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void accept(String str) {
|
||||
if (first) {
|
||||
printDetail(stream, "Stacktrace", str);
|
||||
first = false;
|
||||
} else {
|
||||
printDetailLine(stream, "Stacktrace", str);
|
||||
}
|
||||
}
|
||||
});
|
||||
private static void logDebugMessage(int id, String source, String type, String severity, String message) {
|
||||
String fullMessage = String.format("[GL] %s %s (0x%X) from %s: %s%s", severity, type, id, source, message, buildStackTrace());
|
||||
|
||||
if ("HIGH".equals(severity)) {
|
||||
LOGGER.error(fullMessage);
|
||||
} else if ("MEDIUM".equals(severity)) {
|
||||
LOGGER.warn(fullMessage);
|
||||
} else {
|
||||
LOGGER.info(fullMessage);
|
||||
}
|
||||
}
|
||||
|
||||
private static void logDebugMessageAMD(int id, String category, String severity, String message) {
|
||||
String fullMessage = String.format("[GL] %s %s (0x%X): %s%s", severity, category, id, message, buildStackTrace());
|
||||
|
||||
if ("HIGH".equals(severity)) {
|
||||
LOGGER.error(fullMessage);
|
||||
} else if ("MEDIUM".equals(severity)) {
|
||||
LOGGER.warn(fullMessage);
|
||||
} else {
|
||||
LOGGER.info(fullMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up debug callbacks
|
||||
* @return 0 for failure, 1 for success, 2 for restart required.
|
||||
*/
|
||||
public static int setupDebugMessageCallback(PrintStream stream) {
|
||||
private static int setupDebugMessageCallbackImpl() {
|
||||
if (GLStateManager.capabilities.OpenGL43 || GLStateManager.capabilities.GL_KHR_debug) {
|
||||
LOGGER.info("[GL] Using OpenGL 4.3 for error logging.");
|
||||
KHRDebugCallback proc = new KHRDebugCallback((source, type, id, severity, message) -> {
|
||||
stream.println("[LWJGL] OpenGL debug message");
|
||||
printDetail(stream, "ID", String.format("0x%X", id));
|
||||
printDetail(stream, "Source", getDebugSource(source));
|
||||
printDetail(stream, "Type", getDebugType(type));
|
||||
printDetail(stream, "Severity", getDebugSeverity(severity));
|
||||
printDetail(stream, "Message", message);
|
||||
printTrace(stream);
|
||||
final KHRDebugCallback proc = new KHRDebugCallback((source, type, id, severity, message) -> {
|
||||
logDebugMessage(id, getDebugSource(source), getDebugType(type), getDebugSeverity(severity), message);
|
||||
});
|
||||
GL43.glDebugMessageControl(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_HIGH, null, true);
|
||||
GL43.glDebugMessageControl(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_MEDIUM, null, false);
|
||||
@@ -114,14 +112,8 @@ public final class GLDebug {
|
||||
return 1;
|
||||
} else if (GLStateManager.capabilities.GL_ARB_debug_output) {
|
||||
LOGGER.info("[GL] Using ARB_debug_output for error logging.");
|
||||
ARBDebugOutputCallback proc = new ARBDebugOutputCallback((source, type, id, severity, message) -> {
|
||||
stream.println("[LWJGL] ARB_debug_output message");
|
||||
printDetail(stream, "ID", String.format("0x%X", id));
|
||||
printDetail(stream, "Source", getSourceARB(source));
|
||||
printDetail(stream, "Type", getTypeARB(type));
|
||||
printDetail(stream, "Severity", getSeverityARB(severity));
|
||||
printDetail(stream, "Message", message);
|
||||
printTrace(stream);
|
||||
final ARBDebugOutputCallback proc = new ARBDebugOutputCallback((source, type, id, severity, message) -> {
|
||||
logDebugMessage(id, getSourceARB(source), getTypeARB(type), getSeverityARB(severity), message);
|
||||
});
|
||||
ARBDebugOutput.glDebugMessageControlARB(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_HIGH, null, true);
|
||||
ARBDebugOutput.glDebugMessageControlARB(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, GL43.GL_DEBUG_SEVERITY_MEDIUM, null, false);
|
||||
@@ -134,13 +126,8 @@ public final class GLDebug {
|
||||
return 1;
|
||||
} else if (GLStateManager.capabilities.GL_AMD_debug_output) {
|
||||
LOGGER.info("[GL] Using AMD_debug_output for error logging.");
|
||||
AMDDebugOutputCallback proc = new AMDDebugOutputCallback((id, category, severity, message) -> {
|
||||
stream.println("[LWJGL] AMD_debug_output message");
|
||||
printDetail(stream, "ID", String.format("0x%X", id));
|
||||
printDetail(stream, "Category", getCategoryAMD(category));
|
||||
printDetail(stream, "Severity", getSeverityAMD(severity));
|
||||
printDetail(stream, "Message", message);
|
||||
printTrace(stream);
|
||||
final AMDDebugOutputCallback proc = new AMDDebugOutputCallback((id, category, severity, message) -> {
|
||||
logDebugMessageAMD(id, getCategoryAMD(category), getSeverityAMD(severity), message);
|
||||
});
|
||||
AMDDebugOutput.glDebugMessageEnableAMD(0, GL43.GL_DEBUG_SEVERITY_HIGH, null, true);
|
||||
AMDDebugOutput.glDebugMessageEnableAMD(0, GL43.GL_DEBUG_SEVERITY_MEDIUM, null, false);
|
||||
@@ -176,17 +163,6 @@ public final class GLDebug {
|
||||
}
|
||||
}
|
||||
|
||||
private static void printDetail(PrintStream stream, String type, String message) {
|
||||
stream.printf("\t%s: %s\n", type, message);
|
||||
}
|
||||
|
||||
private static void printDetailLine(PrintStream stream, String type, String message) {
|
||||
stream.append(" ");
|
||||
for (int i = 0; i < type.length(); i++) {
|
||||
stream.append(" ");
|
||||
}
|
||||
stream.append(message).append("\n");
|
||||
}
|
||||
|
||||
private static String getDebugSource(int source) {
|
||||
return switch (source) {
|
||||
@@ -577,6 +553,57 @@ public final class GLDebug {
|
||||
};
|
||||
}
|
||||
|
||||
public static String getFramebufferStatusName(int status) {
|
||||
return switch (status) {
|
||||
case GL30.GL_FRAMEBUFFER_COMPLETE -> "COMPLETE";
|
||||
case GL30.GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT -> "INCOMPLETE_ATTACHMENT";
|
||||
case GL30.GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT -> "INCOMPLETE_MISSING_ATTACHMENT";
|
||||
case GL30.GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER -> "INCOMPLETE_DRAW_BUFFER";
|
||||
case GL30.GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER -> "INCOMPLETE_READ_BUFFER";
|
||||
case GL30.GL_FRAMEBUFFER_UNSUPPORTED -> "UNSUPPORTED";
|
||||
case GL30.GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE -> "INCOMPLETE_MULTISAMPLE";
|
||||
case 0 -> "NO_FRAMEBUFFER_BOUND";
|
||||
default -> String.format("UNKNOWN(0x%X)", status);
|
||||
};
|
||||
}
|
||||
|
||||
public static String getInternalFormatName(int format) {
|
||||
return switch (format) {
|
||||
// Basic
|
||||
case GL11.GL_RGBA -> "RGBA";
|
||||
case GL11.GL_RGB -> "RGB";
|
||||
// 8-bit normalized
|
||||
case GL30.GL_R8 -> "R8";
|
||||
case GL30.GL_RG8 -> "RG8";
|
||||
case GL11.GL_RGB8 -> "RGB8";
|
||||
case GL11.GL_RGBA8 -> "RGBA8";
|
||||
// 8-bit signed normalized
|
||||
case 0x8F94 -> "R8_SNORM";
|
||||
case 0x8F95 -> "RG8_SNORM";
|
||||
case 0x8F96 -> "RGB8_SNORM";
|
||||
case 0x8F97 -> "RGBA8_SNORM";
|
||||
// 16-bit normalized
|
||||
case GL30.GL_R16 -> "R16";
|
||||
case GL30.GL_RG16 -> "RG16";
|
||||
case GL11.GL_RGB16 -> "RGB16";
|
||||
case GL11.GL_RGBA16 -> "RGBA16";
|
||||
// 16-bit float
|
||||
case GL30.GL_R16F -> "R16F";
|
||||
case GL30.GL_RG16F -> "RG16F";
|
||||
case GL30.GL_RGB16F -> "RGB16F";
|
||||
case GL30.GL_RGBA16F -> "RGBA16F";
|
||||
// 32-bit float
|
||||
case GL30.GL_R32F -> "R32F";
|
||||
case GL30.GL_RG32F -> "RG32F";
|
||||
case GL30.GL_RGB32F -> "RGB32F";
|
||||
case GL30.GL_RGBA32F -> "RGBA32F";
|
||||
// Packed
|
||||
case GL30.GL_R11F_G11F_B10F -> "R11F_G11F_B10F";
|
||||
case GL11.GL_RGB10_A2 -> "RGB10_A2";
|
||||
default -> String.format("0x%X", format);
|
||||
};
|
||||
}
|
||||
|
||||
private static DebugState debugState;
|
||||
|
||||
private interface DebugState {
|
||||
|
||||
@@ -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;
|
||||
@@ -421,6 +422,7 @@ public class GLStateManager {
|
||||
|
||||
public static void init() {
|
||||
RenderSystem.initRenderer();
|
||||
IrisSamplers.initRenderer();
|
||||
|
||||
if(BYPASS_CACHE) {
|
||||
LOGGER.info("GLStateManager cache bypassed");
|
||||
@@ -3785,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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,20 +4,32 @@ import com.gtnewhorizons.angelica.glsm.dsa.DSAARB;
|
||||
import com.gtnewhorizons.angelica.glsm.dsa.DSAAccess;
|
||||
import com.gtnewhorizons.angelica.glsm.dsa.DSACore;
|
||||
import com.gtnewhorizons.angelica.glsm.dsa.DSAUnsupported;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureInfoCache;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3i;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.ARBBufferStorage;
|
||||
import org.lwjgl.opengl.ARBClearBufferObject;
|
||||
import org.lwjgl.opengl.ARBClearTexture;
|
||||
import org.lwjgl.opengl.ARBShaderImageLoadStore;
|
||||
import org.lwjgl.opengl.ARBShaderStorageBufferObject;
|
||||
import org.lwjgl.opengl.EXTShaderImageLoadStore;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL33;
|
||||
import org.lwjgl.opengl.GL40;
|
||||
import org.lwjgl.opengl.GL42;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
import org.lwjgl.opengl.GL44;
|
||||
import org.lwjgl.opengl.NVXGpuMemoryInfo;
|
||||
|
||||
import net.coderbot.iris.gl.shader.StandardMacros;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
@@ -31,6 +43,19 @@ public class RenderSystem {
|
||||
private static final Logger LOGGER = LogManager.getLogger("RenderSystem");
|
||||
private static DSAAccess dsaState;
|
||||
private static boolean supportsCompute;
|
||||
private static boolean supportsImageLoadStore;
|
||||
private static boolean supportsSSBO;
|
||||
private static boolean supportsBufferStorage;
|
||||
private static boolean supportsClearTexture;
|
||||
private static boolean supportsTesselation;
|
||||
private static boolean supportsSamplerObjects;
|
||||
private static int maxImageUnits;
|
||||
private static int maxSSBOBindings;
|
||||
private static int maxGlslVersion;
|
||||
private static boolean supportsGpuShader4;
|
||||
|
||||
// Sampler object state tracking (null if unsupported)
|
||||
private static int[] samplers;
|
||||
|
||||
private RenderSystem() {}
|
||||
|
||||
@@ -54,6 +79,51 @@ public class RenderSystem {
|
||||
}
|
||||
|
||||
supportsCompute = supportsCompute();
|
||||
supportsTesselation = GLStateManager.capabilities.GL_ARB_tessellation_shader || GLStateManager.capabilities.OpenGL40;
|
||||
|
||||
supportsImageLoadStore = GLStateManager.capabilities.OpenGL42 || GLStateManager.capabilities.GL_ARB_shader_image_load_store || GLStateManager.capabilities.GL_EXT_shader_image_load_store;
|
||||
supportsSSBO = GLStateManager.capabilities.OpenGL43 || GLStateManager.capabilities.GL_ARB_shader_storage_buffer_object;
|
||||
supportsBufferStorage = GLStateManager.capabilities.OpenGL44 || GLStateManager.capabilities.GL_ARB_buffer_storage;
|
||||
supportsClearTexture = GLStateManager.capabilities.OpenGL44 || GLStateManager.capabilities.GL_ARB_clear_texture;
|
||||
|
||||
// Cache maximum image units
|
||||
if (supportsImageLoadStore) {
|
||||
if (GLStateManager.capabilities.OpenGL42) {
|
||||
maxImageUnits = GL11.glGetInteger(GL42.GL_MAX_IMAGE_UNITS);
|
||||
} else if (GLStateManager.capabilities.GL_ARB_shader_image_load_store) {
|
||||
maxImageUnits = GL11.glGetInteger(ARBShaderImageLoadStore.GL_MAX_IMAGE_UNITS);
|
||||
} else {
|
||||
maxImageUnits = GL11.glGetInteger(EXTShaderImageLoadStore.GL_MAX_IMAGE_UNITS_EXT);
|
||||
}
|
||||
} else {
|
||||
maxImageUnits = 0;
|
||||
}
|
||||
|
||||
// Cache maximum SSBO bindings
|
||||
if (supportsSSBO) {
|
||||
if (GLStateManager.capabilities.OpenGL43) {
|
||||
maxSSBOBindings = GL11.glGetInteger(GL43.GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS);
|
||||
} else {
|
||||
maxSSBOBindings = GL11.glGetInteger(ARBShaderStorageBufferObject.GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS);
|
||||
}
|
||||
} else {
|
||||
maxSSBOBindings = 0;
|
||||
}
|
||||
|
||||
// Check for sampler objects support (GL 3.3+ or ARB extension)
|
||||
supportsSamplerObjects = GLStateManager.capabilities.OpenGL33
|
||||
|| GLStateManager.capabilities.GL_ARB_sampler_objects;
|
||||
if (supportsSamplerObjects) {
|
||||
samplers = new int[GL11.glGetInteger(GL20.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS)];
|
||||
}
|
||||
|
||||
maxGlslVersion = Integer.parseInt(StandardMacros.getGlVersion(GL20.GL_SHADING_LANGUAGE_VERSION));
|
||||
supportsGpuShader4 = GLStateManager.capabilities.GL_EXT_gpu_shader4;
|
||||
|
||||
LOGGER.info("Max GLSL version: {}, GPU Shader4: {}", maxGlslVersion, supportsGpuShader4);
|
||||
LOGGER.info("Image Load/Store: {}, Max Image Units: {}", supportsImageLoadStore, maxImageUnits);
|
||||
LOGGER.info("SSBO: {}, Max SSBO Bindings: {}", supportsSSBO, maxSSBOBindings);
|
||||
LOGGER.info("Buffer Storage: {}, Clear Texture: {}, Sampler Objects: {}", supportsBufferStorage, supportsClearTexture, supportsSamplerObjects);
|
||||
}
|
||||
|
||||
public static void generateMipmaps(int texture, int mipmapTarget) {
|
||||
@@ -65,8 +135,11 @@ public class RenderSystem {
|
||||
}
|
||||
|
||||
public static void texImage2D(int texture, int target, int level, int internalformat, int width, int height, int border, int format, int type, @Nullable ByteBuffer pixels) {
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, texture);
|
||||
GLStateManager.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
GLStateManager.glBindTexture(target, texture);
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
if (target == GL11.GL_TEXTURE_2D && level == 0) {
|
||||
TextureInfoCache.INSTANCE.onTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
}
|
||||
}
|
||||
|
||||
public static void uniformMatrix4fv(int location, boolean transpose, FloatBuffer matrix) {
|
||||
@@ -147,6 +220,17 @@ public class RenderSystem {
|
||||
dsaState.textureSubImage2D(texture, target, level, xoffset, yoffset, width, height, format, type, pixels);
|
||||
}
|
||||
|
||||
|
||||
public static void texImage1D(int texture, int target, int level, int internalformat, int width, int border, int format, int type, ByteBuffer pixels) {
|
||||
GL11.glBindTexture(target, texture);
|
||||
GL11.glTexImage1D(target, level, internalformat, width, border, format, type, pixels);
|
||||
}
|
||||
|
||||
public static void texImage3D(int texture, int target, int level, int internalformat, int width, int height, int depth, int border, int format, int type, ByteBuffer pixels) {
|
||||
GL11.glBindTexture(target, texture);
|
||||
GL12.glTexImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels);
|
||||
}
|
||||
|
||||
public static String getProgramInfoLog(int program) {
|
||||
return GL20.glGetProgramInfoLog(program, GL20.glGetProgrami(program, GL20.GL_INFO_LOG_LENGTH));
|
||||
}
|
||||
@@ -208,13 +292,27 @@ public class RenderSystem {
|
||||
}
|
||||
|
||||
public static int getMaxImageUnits() {
|
||||
if (GLStateManager.capabilities.OpenGL42) {
|
||||
return GL11.glGetInteger(GL42.GL_MAX_IMAGE_UNITS);
|
||||
} else if (GLStateManager.capabilities.GL_EXT_shader_image_load_store) {
|
||||
return GL11.glGetInteger(EXTShaderImageLoadStore.GL_MAX_IMAGE_UNITS_EXT);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return maxImageUnits;
|
||||
}
|
||||
|
||||
public static boolean supportsImageLoadStore() {
|
||||
return supportsImageLoadStore;
|
||||
}
|
||||
|
||||
public static boolean supportsSSBO() {
|
||||
return supportsSSBO;
|
||||
}
|
||||
|
||||
public static boolean supportsBufferStorage() {
|
||||
return supportsBufferStorage;
|
||||
}
|
||||
|
||||
public static boolean supportsClearTexture() {
|
||||
return supportsClearTexture;
|
||||
}
|
||||
|
||||
public static int getMaxSSBOBindings() {
|
||||
return maxSSBOBindings;
|
||||
}
|
||||
|
||||
public static void getProgramiv(int program, int value, IntBuffer storage) {
|
||||
@@ -229,6 +327,14 @@ public class RenderSystem {
|
||||
GL43.glDispatchCompute(workGroups.x, workGroups.y, workGroups.z);
|
||||
}
|
||||
|
||||
public static void dispatchComputeIndirect(long offset) {
|
||||
GL43.glDispatchComputeIndirect(offset);
|
||||
}
|
||||
|
||||
public static void bindBuffer(int target, int buffer) {
|
||||
GL15.glBindBuffer(target, buffer);
|
||||
}
|
||||
|
||||
public static void memoryBarrier(int barriers) {
|
||||
if (supportsCompute) {
|
||||
GL42.glMemoryBarrier(barriers);
|
||||
@@ -255,6 +361,10 @@ public class RenderSystem {
|
||||
dsaState.bindTextureToUnit(unit, texture);
|
||||
}
|
||||
|
||||
public static void bindTextureToUnit(int target, int unit, int texture) {
|
||||
dsaState.bindTextureToUnit(target, unit, texture);
|
||||
}
|
||||
|
||||
public static final FloatBuffer PROJECTION_MATRIX_BUFFER = BufferUtils.createFloatBuffer(16);
|
||||
public static void setupProjectionMatrix(Matrix4f matrix) {
|
||||
GLStateManager.glMatrixMode(GL11.GL_PROJECTION);
|
||||
@@ -290,4 +400,122 @@ public class RenderSystem {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static int createBuffers() {
|
||||
return GL15.glGenBuffers();
|
||||
}
|
||||
|
||||
public static void bindBufferBase(int target, int index, int buffer) {
|
||||
GL30.glBindBufferBase(target, index, buffer);
|
||||
}
|
||||
|
||||
public static void bufferStorage(int target, long size, int flags) {
|
||||
if (GLStateManager.capabilities.OpenGL44) {
|
||||
GL44.glBufferStorage(target, size, flags);
|
||||
} else if (GLStateManager.capabilities.GL_ARB_buffer_storage) {
|
||||
ARBBufferStorage.glBufferStorage(target, size, flags);
|
||||
} else {
|
||||
// Fallback: use mutable storage
|
||||
GL15.glBufferData(target, size, GL15.GL_DYNAMIC_DRAW);
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearBufferSubData(int target, int internalFormat, long offset, long size, int format, int type, int[] data) {
|
||||
final ByteBuffer buf = BufferUtils.createByteBuffer(data.length * 4);
|
||||
buf.asIntBuffer().put(data);
|
||||
if (GLStateManager.capabilities.OpenGL43) {
|
||||
GL43.glClearBufferSubData(target, internalFormat, offset, size, format, type, buf);
|
||||
} else if (GLStateManager.capabilities.GL_ARB_clear_buffer_object) {
|
||||
ARBClearBufferObject.glClearBufferSubData(target, internalFormat, offset, size, format, type, buf);
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteBuffers(int buffer) {
|
||||
GL15.glDeleteBuffers(buffer);
|
||||
}
|
||||
|
||||
public static long getVRAM() {
|
||||
if (GLStateManager.capabilities.GL_NVX_gpu_memory_info) {
|
||||
return GL11.glGetInteger(NVXGpuMemoryInfo.GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX) * 1024L;
|
||||
} else {
|
||||
// Default to 4GB if we can't query VRAM
|
||||
return 4294967296L;
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearTexImage(int texture, int target, int level, int format, int type) {
|
||||
if (GLStateManager.capabilities.OpenGL44) {
|
||||
GL44.glClearTexImage(texture, level, format, type, (ByteBuffer) null);
|
||||
} else {
|
||||
ARBClearTexture.glClearTexImage(texture, level, format, type, (ByteBuffer) null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void textureStorage1D(int texture, int target, int levels, int internalFormat, int width) {
|
||||
dsaState.textureStorage1D(texture, target, levels, internalFormat, width);
|
||||
}
|
||||
|
||||
public static void textureStorage2D(int texture, int target, int levels, int internalFormat, int width, int height) {
|
||||
dsaState.textureStorage2D(texture, target, levels, internalFormat, width, height);
|
||||
}
|
||||
|
||||
public static void textureStorage3D(int texture, int target, int levels, int internalFormat, int width, int height, int depth) {
|
||||
dsaState.textureStorage3D(texture, target, levels, internalFormat, width, height, depth);
|
||||
}
|
||||
|
||||
public static int getMaxGlslVersion() {
|
||||
return maxGlslVersion;
|
||||
}
|
||||
|
||||
public static boolean supportsGpuShader4() {
|
||||
return supportsGpuShader4;
|
||||
}
|
||||
|
||||
public static boolean supportsSnormFormats() {
|
||||
return GLStateManager.capabilities.OpenGL31;
|
||||
}
|
||||
|
||||
public static boolean supportsPackedFloatRenderable() {
|
||||
return GLStateManager.capabilities.OpenGL30 && maxGlslVersion >= 130;
|
||||
}
|
||||
|
||||
public static boolean supportsTesselation() {
|
||||
return supportsTesselation;
|
||||
}
|
||||
|
||||
public static boolean supportsSamplerObjects() {
|
||||
return supportsSamplerObjects;
|
||||
}
|
||||
|
||||
public static int genSampler() {
|
||||
if (!supportsSamplerObjects) return 0;
|
||||
return GL33.glGenSamplers();
|
||||
}
|
||||
|
||||
public static void destroySampler(int sampler) {
|
||||
if (!supportsSamplerObjects || sampler == 0) return;
|
||||
GL33.glDeleteSamplers(sampler);
|
||||
}
|
||||
|
||||
public static void samplerParameteri(int sampler, int pname, int param) {
|
||||
if (!supportsSamplerObjects || sampler == 0) return;
|
||||
GL33.glSamplerParameteri(sampler, pname, param);
|
||||
}
|
||||
|
||||
public static void bindSamplerToUnit(int unit, int sampler) {
|
||||
if (!supportsSamplerObjects) return;
|
||||
if (samplers[unit] == sampler) return;
|
||||
GL33.glBindSampler(unit, sampler);
|
||||
samplers[unit] = sampler;
|
||||
}
|
||||
|
||||
public static void unbindAllSamplers() {
|
||||
if (!supportsSamplerObjects) return;
|
||||
for (int i = 0; i < samplers.length; i++) {
|
||||
if (samplers[i] != 0) {
|
||||
GL33.glBindSampler(i, 0);
|
||||
samplers[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,6 +94,11 @@ public class DSAARB extends DSAUnsupported {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTextureToUnit(int target, int unit, int texture) {
|
||||
bindTextureToUnit(unit, texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bufferStorage(int target, FloatBuffer data, int usage) {
|
||||
final int buffer = GL45.glCreateBuffers();
|
||||
@@ -121,4 +126,19 @@ public class DSAARB extends DSAUnsupported {
|
||||
public int createTexture(int target) {
|
||||
return ARBDirectStateAccess.glCreateTextures(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void textureStorage1D(int texture, int target, int levels, int internalFormat, int width) {
|
||||
ARBDirectStateAccess.glTextureStorage1D(texture, levels, internalFormat, width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void textureStorage2D(int texture, int target, int levels, int internalFormat, int width, int height) {
|
||||
ARBDirectStateAccess.glTextureStorage2D(texture, levels, internalFormat, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void textureStorage3D(int texture, int target, int levels, int internalFormat, int width, int height, int depth) {
|
||||
ARBDirectStateAccess.glTextureStorage3D(texture, levels, internalFormat, width, height, depth);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ public interface DSAAccess {
|
||||
void copyTexSubImage2D(int destTexture, int target, int i, int i1, int i2, int i3, int i4, int width, int height);
|
||||
|
||||
void bindTextureToUnit(int unit, int texture);
|
||||
void bindTextureToUnit(int target, int unit, int texture);
|
||||
|
||||
int bufferStorage(int target, FloatBuffer data, int usage);
|
||||
|
||||
@@ -37,4 +38,9 @@ public interface DSAAccess {
|
||||
|
||||
int createFramebuffer();
|
||||
int createTexture(int target);
|
||||
|
||||
// Texture storage methods for custom images
|
||||
void textureStorage1D(int texture, int target, int levels, int internalFormat, int width);
|
||||
void textureStorage2D(int texture, int target, int levels, int internalFormat, int width, int height);
|
||||
void textureStorage3D(int texture, int target, int levels, int internalFormat, int width, int height, int depth);
|
||||
}
|
||||
@@ -2,12 +2,14 @@ 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;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL31;
|
||||
import org.lwjgl.opengl.GL42;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
@@ -74,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);
|
||||
}
|
||||
|
||||
@@ -113,6 +115,12 @@ public class DSAUnsupported implements DSAAccess {
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindTextureToUnit(int target, int unit, int texture) {
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0 + unit);
|
||||
GLStateManager.glBindTexture(target, texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int bufferStorage(int target, FloatBuffer data, int usage) {
|
||||
final int buffer = GL15.glGenBuffers();
|
||||
@@ -126,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;
|
||||
}
|
||||
|
||||
@@ -150,4 +158,28 @@ public class DSAUnsupported implements DSAAccess {
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, texture);
|
||||
return texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void textureStorage1D(int texture, int target, int levels, int internalFormat, int width) {
|
||||
final int previous = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_1D);
|
||||
GL11.glBindTexture(target, texture);
|
||||
GL42.glTexStorage1D(target, levels, internalFormat, width);
|
||||
GL11.glBindTexture(target, previous);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void textureStorage2D(int texture, int target, int levels, int internalFormat, int width, int height) {
|
||||
final int previous = (target == GL11.GL_TEXTURE_2D) ? GLStateManager.getBoundTextureForServerState() : GL11.glGetInteger(GL31.GL_TEXTURE_BINDING_RECTANGLE);
|
||||
GL11.glBindTexture(target, texture);
|
||||
GL42.glTexStorage2D(target, levels, internalFormat, width, height);
|
||||
GL11.glBindTexture(target, previous);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void textureStorage3D(int texture, int target, int levels, int internalFormat, int width, int height, int depth) {
|
||||
final int previous = GL11.glGetInteger(GL12.GL_TEXTURE_BINDING_3D);
|
||||
GL11.glBindTexture(target, texture);
|
||||
GL42.glTexStorage3D(target, levels, internalFormat, width, height, depth);
|
||||
GL11.glBindTexture(target, previous);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+35
-10
@@ -41,10 +41,12 @@ public final class AngelicaRedirector {
|
||||
private static final String Drawable = "org/lwjgl/opengl/Drawable";
|
||||
private static final String GLStateManager = "com/gtnewhorizons/angelica/glsm/GLStateManager";
|
||||
private static final String GL11 = "org/lwjgl/opengl/GL11";
|
||||
private static final String GL11C = "org/lwjgl/opengl/GL11C";
|
||||
private static final String GL12 = "org/lwjgl/opengl/GL12";
|
||||
private static final String GL13 = "org/lwjgl/opengl/GL13";
|
||||
private static final String GL14 = "org/lwjgl/opengl/GL14";
|
||||
private static final String GL20 = "org/lwjgl/opengl/GL20";
|
||||
private static final String GL30 = "org/lwjgl/opengl/GL30";
|
||||
private static final String Project = "org/lwjgl/util/glu/Project";
|
||||
private static final String OpenGlHelper = "net/minecraft/client/renderer/OpenGlHelper";
|
||||
private static final String EXTBlendFunc = "org/lwjgl/opengl/EXTBlendFuncSeparate";
|
||||
@@ -231,12 +233,32 @@ public final class AngelicaRedirector {
|
||||
.add("glStencilOpSeparate")
|
||||
.add("glUseProgram")
|
||||
);
|
||||
methodRedirects.put(GL30, RedirectMap.newMap()
|
||||
.add("glBindFramebuffer")
|
||||
);
|
||||
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"));
|
||||
|
||||
final String glPrefix = "org/lwjgl/opengl/GL";
|
||||
for (var entry : new HashMap<>(methodRedirects).entrySet()) {
|
||||
if (entry.getKey().startsWith(glPrefix)) {
|
||||
methodRedirects.put(entry.getKey() + "C", entry.getValue());
|
||||
cstPoolParser.addString(entry.getKey() + "C");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getTransformerExclusions() {
|
||||
@@ -267,7 +289,7 @@ public final class AngelicaRedirector {
|
||||
boolean redirectInMethod = false;
|
||||
for (AbstractInsnNode node : mn.instructions.toArray()) {
|
||||
if (node instanceof MethodInsnNode mNode) {
|
||||
if (mNode.owner.equals(GL11) && (mNode.name.equals("glEnable") || mNode.name.equals("glDisable")) && mNode.desc.equals("(I)V")) {
|
||||
if ((mNode.owner.equals(GL11) || mNode.owner.equals(GL11C)) && (mNode.name.equals("glEnable") || mNode.name.equals("glDisable")) && mNode.desc.equals("(I)V")) {
|
||||
final AbstractInsnNode prevNode = node.getPrevious();
|
||||
String name = null;
|
||||
if (prevNode instanceof LdcInsnNode ldcNode) {
|
||||
@@ -308,15 +330,18 @@ public final class AngelicaRedirector {
|
||||
}
|
||||
} else {
|
||||
final Map<String, String> redirects = methodRedirects.get(mNode.owner);
|
||||
if (redirects != null && redirects.containsKey(mNode.name)) {
|
||||
if (LOG_SPAM) {
|
||||
final String shortOwner = mNode.owner.substring(mNode.owner.lastIndexOf("/") + 1);
|
||||
LOGGER.info("Redirecting call in {} from {}.{}{} to GLStateManager.{}{}", transformedName, shortOwner, mNode.name, mNode.desc, redirects.get(mNode.name), mNode.desc);
|
||||
if (redirects != null) {
|
||||
final String glsmName = redirects.get(mNode.name);
|
||||
if (glsmName != null) {
|
||||
if (LOG_SPAM) {
|
||||
final String shortOwner = mNode.owner.substring(mNode.owner.lastIndexOf("/") + 1);
|
||||
LOGGER.info("Redirecting call in {} from {}.{}{} to GLStateManager.{}{}", transformedName, shortOwner, mNode.name, mNode.desc, glsmName, mNode.desc);
|
||||
}
|
||||
mNode.owner = GLStateManager;
|
||||
mNode.name = glsmName;
|
||||
changed = true;
|
||||
redirectInMethod = true;
|
||||
}
|
||||
mNode.owner = GLStateManager;
|
||||
mNode.name = redirects.get(mNode.name);
|
||||
changed = true;
|
||||
redirectInMethod = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +188,7 @@ public enum Mixins implements IMixins {
|
||||
, "celeritas.biome_blending.MixinBlockLeaves"
|
||||
, "celeritas.biome_blending.MixinBlockLiquid"
|
||||
, "celeritas.threading.MixinForgeHooksClient"
|
||||
, "celeritas.terrain.MixinChunk"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -195,17 +196,27 @@ public enum Mixins implements IMixins {
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableIris)
|
||||
.addClientMixins(
|
||||
"shaders.MixinEntityRenderer"
|
||||
"shaders.MixinDroppedItemGlintEdges"
|
||||
, "shaders.MixinEntityPickupFX"
|
||||
, "shaders.MixinEntityRenderer"
|
||||
, "shaders.MixinGuiIngameForge"
|
||||
, "shaders.MixinFramebuffer"
|
||||
, "shaders.MixinItem"
|
||||
, "shaders.MixinLocale"
|
||||
, "shaders.MixinOpenGlHelper"
|
||||
, "shaders.MixinRender"
|
||||
, "shaders.MixinRenderBiped"
|
||||
, "shaders.MixinRenderDragon"
|
||||
, "shaders.MixinRenderEntityFlame"
|
||||
, "shaders.MixinRendererLivingEntity"
|
||||
, "shaders.MixinRenderGlobal"
|
||||
, "shaders.MixinRenderHorse"
|
||||
, "shaders.MixinRenderItem"
|
||||
, "shaders.MixinRenderManager"
|
||||
, "shaders.MixinRenderNameTag"
|
||||
, "shaders.MixinRenderPlayerArmor"
|
||||
, "shaders.MixinTileEntityBeaconRenderer"
|
||||
, "shaders.MixinRenderEndPortal"
|
||||
, "shaders.MixinTileEntityRendererDispatcher"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -311,7 +322,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)
|
||||
@@ -444,6 +455,12 @@ public enum Mixins implements IMixins {
|
||||
"MixinBlockTFMagicLeaves"
|
||||
))
|
||||
),
|
||||
ET_FUTURUM_ELYTRA_CAPE(new MixinBuilder("Set custom item ID for elytra with cape texture")
|
||||
.setPhase(Phase.LATE)
|
||||
.addRequiredMod(TargetedMod.ET_FUTURUM_REQUIEM)
|
||||
.setApplyIf(() -> AngelicaConfig.enableIris)
|
||||
.addClientMixins("client.etfuturum.MixinLayerBetterElytra")
|
||||
),
|
||||
MCPATCHER_FORGE(new MixinBuilder()
|
||||
.setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableMCPatcherForgeFeatures)
|
||||
|
||||
@@ -14,6 +14,7 @@ public enum TargetedMod implements ITargetMod {
|
||||
DYNAMIC_SURROUNDINGS_MIST("org.blockartistry.mod.DynSurround.mixinplugin.DynamicSurroundingsEarlyMixins", "dsurround"),
|
||||
DYNAMIC_SURROUNDINGS_ORIGINAL("org.blockartistry.mod.DynSurround.asm.TransformLoader", "dsurround"),
|
||||
DRAGON_API("Reika.DragonAPI.Auxiliary.DragonAPIASMHandler", "DragonAPI"),
|
||||
ET_FUTURUM_REQUIEM(null, "etfuturum"),
|
||||
EXTRAUTILS(null, "ExtraUtilities"),
|
||||
FALSETWEAKS("com.falsepattern.falsetweaks.asm.CoreLoadingPlugin", "falsetweaks"),
|
||||
MINEFACTORY_RELOADED(null, "MineFactoryReloaded"),
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import com.gtnewhorizons.angelica.utils.ConcurrentTileEntityMap;
|
||||
|
||||
public interface IChunkTileEntityMapHolder {
|
||||
ConcurrentTileEntityMap angelica$getConcurrentTEMap();
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
public interface ITileEntityBoundingBoxCache {
|
||||
AxisAlignedBB angelica$getCachedRenderBoundingBox();
|
||||
|
||||
boolean angelica$isInfiniteExtent();
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.gtnewhorizons.angelica.proxy;
|
||||
|
||||
import static com.gtnewhorizons.angelica.AngelicaMod.MOD_ID;
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.gtnewhorizon.gtnhlib.client.model.loading.ModelRegistry;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vao.VAOManager;
|
||||
import com.gtnewhorizons.angelica.commands.AngelicaCommand;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.bettercrashes.BetterCrashesCompat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
@@ -18,6 +16,7 @@ import com.gtnewhorizons.angelica.dynamiclights.config.EntityLightConfig;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.debug.OpenGLDebugging;
|
||||
import com.gtnewhorizons.angelica.hudcaching.HUDCaching;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IGameSettingsExt;
|
||||
import com.gtnewhorizons.angelica.render.CloudRenderer;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
@@ -27,10 +26,7 @@ import com.gtnewhorizons.angelica.rendering.celeritas.threading.ChunkTaskRegistr
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.threading.DefaultChunkTaskProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.threading.ThreadedChunkTaskProvider;
|
||||
import com.gtnewhorizons.angelica.zoom.Zoom;
|
||||
import com.gtnewhorizons.angelica.commands.AngelicaCommand;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.minecraftforge.client.ClientCommandHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
@@ -40,10 +36,11 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import jss.notfine.core.Settings;
|
||||
import jss.notfine.gui.GuiCustomMenu;
|
||||
import jss.notfine.gui.NotFineGameOptionPages;
|
||||
import me.flashyreese.mods.reeses_sodium_options.client.gui.ReeseSodiumVideoOptionsScreen;
|
||||
import me.jellysquid.mods.sodium.client.gui.SodiumOptionsGUI;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.client.IrisDebugScreenHandler;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -51,6 +48,8 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiVideoSettings;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.network.NetHandlerPlayClient;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
@@ -61,14 +60,23 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.client.ClientCommandHandler;
|
||||
import net.minecraftforge.client.event.EntityViewRenderEvent;
|
||||
import net.minecraftforge.client.event.FOVUpdateEvent;
|
||||
import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static com.gtnewhorizons.angelica.AngelicaMod.MOD_ID;
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
@@ -323,6 +331,20 @@ public class ClientProxy extends CommonProxy {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onGuiInit(GuiScreenEvent.InitGuiEvent.Pre event) {
|
||||
if(event.gui instanceof GuiVideoSettings eventGui) {
|
||||
event.setCanceled(true);
|
||||
if(AngelicaConfig.enableNotFineOptions || GuiScreen.isShiftKeyDown()) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiCustomMenu(eventGui.parentGuiScreen, NotFineGameOptionPages.general(), NotFineGameOptionPages.detail(), NotFineGameOptionPages.atmosphere(), NotFineGameOptionPages.particles(), NotFineGameOptionPages.other()));
|
||||
} else if(!AngelicaConfig.enableReesesSodiumOptions || GuiScreen.isCtrlKeyDown()) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new SodiumOptionsGUI(eventGui.parentGuiScreen));
|
||||
} else {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new ReeseSodiumVideoOptionsScreen(eventGui.parentGuiScreen));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* coerce NaN fog values back to 0 (https://bugs.mojang.com/browse/MC-10480) - from ArchaicFix */
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onFogColor(EntityViewRenderEvent.FogColors event) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.world.WorldSlice;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class RenderThreadContext {
|
||||
|
||||
private static final ThreadLocal<WorldSlice> currentWorldSlice = new ThreadLocal<>();
|
||||
|
||||
public static void set(WorldSlice slice) {
|
||||
currentWorldSlice.set(slice);
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
currentWorldSlice.remove();
|
||||
}
|
||||
|
||||
public static TileEntity getSnapshotTE(int x, int y, int z) {
|
||||
final WorldSlice slice = currentWorldSlice.get();
|
||||
if (slice == null) return null;
|
||||
return slice.getTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
public static boolean hasWorldSlice() {
|
||||
return currentWorldSlice.get() != null;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ByteOpenHashMap;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
|
||||
/**
|
||||
* Registry for tracking which TileEntity classes always return INFINITE_EXTENT_AABB.
|
||||
*/
|
||||
public final class TileEntityRenderBoundsRegistry {
|
||||
private static final byte UNKNOWN = 0;
|
||||
private static final byte FINITE = 1;
|
||||
private static final byte INFINITE = 2;
|
||||
|
||||
private static final Reference2ByteOpenHashMap<Class<? extends TileEntity>> classRegistry = new Reference2ByteOpenHashMap<>();
|
||||
|
||||
static {
|
||||
classRegistry.defaultReturnValue(UNKNOWN);
|
||||
}
|
||||
|
||||
private TileEntityRenderBoundsRegistry() {}
|
||||
|
||||
public static boolean isInfiniteExtentsBox(AxisAlignedBB box) {
|
||||
return box == null || Double.isInfinite(box.minX) || Double.isInfinite(box.minY) || Double.isInfinite(box.minZ) || Double.isInfinite(box.maxX) || Double.isInfinite(box.maxY) || Double.isInfinite(box.maxZ);
|
||||
}
|
||||
|
||||
public static boolean isAlwaysInfiniteExtent(TileEntity te) {
|
||||
final Class<? extends TileEntity> clazz = te.getClass();
|
||||
byte result = classRegistry.getByte(clazz);
|
||||
|
||||
if (result != UNKNOWN) {
|
||||
return result == INFINITE;
|
||||
}
|
||||
|
||||
return probeAndCache(te, clazz);
|
||||
}
|
||||
|
||||
private static boolean probeAndCache(TileEntity te, Class<? extends TileEntity> clazz) {
|
||||
boolean isInfinite = false;
|
||||
try {
|
||||
AxisAlignedBB aabb = te.getRenderBoundingBox();
|
||||
isInfinite = isInfiniteExtentsBox(aabb);
|
||||
} catch (Exception ignored) {}
|
||||
|
||||
classRegistry.put(clazz, isInfinite ? INFINITE : FINITE);
|
||||
return isInfinite;
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
classRegistry.clear();
|
||||
}
|
||||
}
|
||||
+125
-36
@@ -1,19 +1,29 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.IDynamicLightSource;
|
||||
|
||||
import java.util.List;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.BlockRenderContext;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.IrisExtendedChunkVertexEncoder;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.light.LightDataCache;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.light.QuadLightingHelper;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.light.VanillaDiffuseProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.world.WorldSlice;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.embeddedt.embeddium.impl.model.light.LightPipeline;
|
||||
import org.embeddedt.embeddium.impl.model.light.data.LightDataAccess;
|
||||
import org.embeddedt.embeddium.impl.model.light.data.QuadLightData;
|
||||
import org.embeddedt.embeddium.impl.model.light.flat.FlatLightPipeline;
|
||||
import org.embeddedt.embeddium.impl.model.light.smooth.SmoothLightPipeline;
|
||||
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFacing;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.ChunkColorWriter;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.ChunkBuildBuffers;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.ChunkBuildContext;
|
||||
@@ -23,23 +33,54 @@ import org.embeddedt.embeddium.impl.render.chunk.terrain.material.Material;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexEncoder;
|
||||
import org.embeddedt.embeddium.impl.util.QuadUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
public static final int NUM_PASSES = 2;
|
||||
|
||||
private final TextureMap textureMap;
|
||||
private final TextureMapExtension textureAtlas;
|
||||
private final ChunkVertexEncoder.Vertex[] vertices = ChunkVertexEncoder.Vertex.uninitializedQuad();
|
||||
@Getter
|
||||
private final WorldSlice worldSlice;
|
||||
@Getter
|
||||
private final BlockRenderContext blockRenderContext = new BlockRenderContext();
|
||||
|
||||
/** Pre-filtered light sources for the current chunk being built. Null if dynamic lights disabled. */
|
||||
private List<IDynamicLightSource> chunkLightSources;
|
||||
private DynamicLights dynamicLightsInstance;
|
||||
|
||||
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;
|
||||
private int originX, originY, originZ;
|
||||
private IBlockAccess blockAccess;
|
||||
|
||||
public AngelicaChunkBuildContext(RenderPassConfiguration<?> renderPassConfiguration, WorldClient world) {
|
||||
super(renderPassConfiguration);
|
||||
this.textureMap = Minecraft.getMinecraft().getTextureMapBlocks();
|
||||
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);
|
||||
}
|
||||
|
||||
public void setupLightPipeline(int minBlockX, int minBlockY, int minBlockZ) {
|
||||
setupLightPipeline(worldSlice, minBlockX, minBlockY, minBlockZ);
|
||||
}
|
||||
|
||||
public void setupLightPipeline(IBlockAccess blockAccess, int minBlockX, int minBlockY, int minBlockZ) {
|
||||
this.blockAccess = blockAccess;
|
||||
this.originX = minBlockX;
|
||||
this.originY = minBlockY;
|
||||
this.originZ = minBlockZ;
|
||||
lightDataCache.setWorld(blockAccess);
|
||||
lightDataCache.reset(minBlockX, minBlockY, minBlockZ);
|
||||
smoothLightPipeline.reset();
|
||||
flatLightPipeline.reset();
|
||||
lightPipelineReady = true;
|
||||
}
|
||||
|
||||
public void setupDynamicLights(int chunkOriginX, int chunkOriginY, int chunkOriginZ) {
|
||||
@@ -52,18 +93,16 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
}
|
||||
}
|
||||
|
||||
public BlockRenderContext getBlockRenderContext() {
|
||||
return this.blockRenderContext;
|
||||
}
|
||||
|
||||
private Material selectMaterial(Material material, TextureAtlasSprite sprite) {
|
||||
private Material selectMaterial(Material material, TextureAtlasSprite sprite, boolean isShaderPackOverride) {
|
||||
// Don't apply transparency-based optimization when shader pack explicitly overrides the material
|
||||
if (!AngelicaMod.options().performance.useRenderPassOptimization || isShaderPackOverride) {
|
||||
return material;
|
||||
}
|
||||
if (sprite != null && sprite.getClass() == TextureAtlasSprite.class && !sprite.hasAnimationMetadata()) {
|
||||
final var transparencyLevel = ((SpriteExtension)sprite).celeritas$getTransparencyLevel();
|
||||
if (transparencyLevel == SpriteTransparencyLevel.OPAQUE && material == AngelicaRenderPassConfiguration.CUTOUT_MIPPED_MATERIAL) {
|
||||
// Downgrade to solid
|
||||
return AngelicaRenderPassConfiguration.SOLID_MATERIAL;
|
||||
} else if (material == AngelicaRenderPassConfiguration.TRANSLUCENT_MATERIAL && transparencyLevel != SpriteTransparencyLevel.TRANSLUCENT) {
|
||||
// Downgrade to cutout
|
||||
return AngelicaRenderPassConfiguration.CUTOUT_MIPPED_MATERIAL;
|
||||
}
|
||||
}
|
||||
@@ -71,8 +110,8 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void copyRawBuffer(int[] rawBuffer, int vertexCount, ChunkBuildBuffers buffers, Material material,
|
||||
int originX, int originY, int originZ) {
|
||||
public void copyRawBuffer(int[] rawBuffer, int vertexCount, ChunkBuildBuffers buffers, Material material, boolean isShaderPackOverride,
|
||||
boolean blockAllowsSmoothLighting) {
|
||||
if (vertexCount == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -84,15 +123,25 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
}
|
||||
|
||||
final boolean hasDynamicLights = chunkLightSources != null && !chunkLightSources.isEmpty();
|
||||
|
||||
final var encoder = buffers.get(material).getEncoder();
|
||||
if (encoder instanceof IrisExtendedChunkVertexEncoder iris) {
|
||||
iris.setContext(blockRenderContext);
|
||||
}
|
||||
final boolean separateAo = BlockRenderingSettings.INSTANCE.shouldUseSeparateAo();
|
||||
final boolean celeritasSmoothLighting = AngelicaMod.options().quality.useCeleritasSmoothLighting;
|
||||
final boolean shaderActive = IrisApi.getInstance().isShaderPackInUse();
|
||||
final boolean useAoCalculation = lightPipelineReady && (separateAo || celeritasSmoothLighting || shaderActive);
|
||||
final boolean stripDiffuse = shaderActive && BlockRenderingSettings.INSTANCE.shouldDisableDirectionalShading();
|
||||
final boolean shade = false; // Vanilla bakes it, or we remove it - so no need to shade
|
||||
final ChunkColorWriter colorEncoder = separateAo ? ChunkColorWriter.SEPARATE_AO : ChunkColorWriter.EMBEDDIUM;
|
||||
|
||||
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(blockAccess, worldX, worldY, worldZ);
|
||||
|
||||
for (int quadIdx = 0; quadIdx < numQuads; quadIdx++) {
|
||||
float uSum = 0, vSum = 0;
|
||||
|
||||
@@ -112,29 +161,69 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
vertex.color = rawBuffer[ptr++];
|
||||
vertex.vanillaNormal = rawBuffer[ptr++];
|
||||
vertex.light = rawBuffer[ptr++];
|
||||
}
|
||||
|
||||
if (hasDynamicLights) {
|
||||
final double dynamicLevel = dynamicLightsInstance.getDynamicLightLevelFromSources(
|
||||
originX + vertex.x, originY + vertex.y, originZ + vertex.z, chunkLightSources);
|
||||
final int trueNormal = QuadUtil.calculateNormal(vertices);
|
||||
final ModelQuadFacing facing = QuadUtil.findNormalFace(trueNormal);
|
||||
final TextureAtlasSprite sprite = this.textureAtlas.celeritas$findFromUV(uSum * 0.25f, vSum * 0.25f);
|
||||
|
||||
if (sprite != null && sprite.hasAnimationMetadata()) {
|
||||
animatedSprites.add(sprite);
|
||||
}
|
||||
|
||||
// Strip vanilla's baked diffuse when shaders want oldLighting=false - multiply by an inversion factor
|
||||
// instead of attempting to mixin/asm all the places that bake it in
|
||||
if (stripDiffuse) {
|
||||
final float inverseDiffuse = VanillaDiffuseProvider.INSTANCE.getInverseDiffuse(facing);
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
vertices[vIdx].color = VanillaDiffuseProvider.multiplyColor(vertices[vIdx].color, inverseDiffuse);
|
||||
}
|
||||
}
|
||||
|
||||
if (useAoCalculation) {
|
||||
final boolean quadIsFullBright = QuadLightingHelper.isQuadFullBright(vertices);
|
||||
|
||||
if (isEmissive || quadIsFullBright) {
|
||||
Arrays.fill(quadLightData.br, 1.0f);
|
||||
if (isEmissive) {
|
||||
Arrays.fill(quadLightData.lm, LightDataAccess.FULL_BRIGHT);
|
||||
} else {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
quadLightData.lm[i] = vertices[i].light;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
quadView.setup(trueNormal, blockX, blockY, blockZ);
|
||||
final ModelQuadFacing lightFace = quadView.getLightFace();
|
||||
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++) {
|
||||
final var vertex = vertices[vIdx];
|
||||
vertex.trueNormal = trueNormal;
|
||||
vertex.color = colorEncoder.writeColor(vertex.color, quadLightData.br[vIdx]);
|
||||
vertex.light = quadLightData.lm[vIdx];
|
||||
}
|
||||
} else {
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
vertices[vIdx].trueNormal = trueNormal;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply dynamic lights after AO calculation so they're not overwritten
|
||||
if (hasDynamicLights) {
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
final var vertex = vertices[vIdx];
|
||||
final double dynamicLevel = dynamicLightsInstance.getDynamicLightLevelFromSources(originX + vertex.x, originY + vertex.y, originZ + vertex.z, chunkLightSources);
|
||||
if (dynamicLevel > 0) {
|
||||
vertex.light = dynamicLightsInstance.getLightmapWithDynamicLight(dynamicLevel, vertex.light);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final int trueNormal = QuadUtil.calculateNormal(vertices);
|
||||
for (int vIdx = 0; vIdx < 4; vIdx++) {
|
||||
vertices[vIdx].trueNormal = trueNormal;
|
||||
}
|
||||
|
||||
final ModelQuadFacing facing = QuadUtil.findNormalFace(trueNormal);
|
||||
final TextureAtlasSprite sprite = ((TextureMapExtension) textureMap).celeritas$findFromUV(uSum * 0.25f, vSum * 0.25f);
|
||||
|
||||
if (sprite != null && sprite.hasAnimationMetadata()) {
|
||||
animatedSprites.add(sprite);
|
||||
}
|
||||
|
||||
final Material correctMaterial = selectMaterial(material, sprite);
|
||||
final Material correctMaterial = selectMaterial(material, sprite, isShaderPackOverride);
|
||||
final var builder = buffers.get(correctMaterial);
|
||||
|
||||
if (correctMaterial != material && builder.getEncoder() instanceof IrisExtendedChunkVertexEncoder iris) {
|
||||
|
||||
+49
-29
@@ -1,7 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProviderHolder;
|
||||
@@ -10,7 +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.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -30,6 +29,7 @@ import org.embeddedt.embeddium.impl.render.chunk.data.BuiltSectionMeshParts;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.data.MinecraftBuiltRenderSectionData;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.occlusion.SectionVisibilityBuilder;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.terrain.material.Material;
|
||||
import org.embeddedt.embeddium.impl.util.task.CancellationToken;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
@@ -49,7 +49,7 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
private static final long DEFERRED_BLOCK_TIMEOUT_MS = 10_000; // 10 seconds
|
||||
private static final int MAX_RETRIES = 2;
|
||||
|
||||
protected record DeferredBlock(int x, int y, int z, Block block, int meta, int pass) {}
|
||||
protected record DeferredBlock(int x, int y, int z, Block block, int meta, int pass, Material materialOverride, boolean isShaderPackOverride) {}
|
||||
|
||||
public AngelicaChunkBuilderMeshingTask(RenderSection render, int time, Vector3d camera) {
|
||||
this.render = render;
|
||||
@@ -108,7 +108,7 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
SmoothBiomeColorCache.setActiveCache(biomeColorCache);
|
||||
|
||||
final IrisShaderProvider provider = IrisShaderProviderHolder.getProvider();
|
||||
final Map<Block, RenderLayer> blockTypeIds = provider != null ? provider.getBlockTypeIds() : null;
|
||||
final Map<Block, BlockRenderLayer> blockTypeIds = provider != null ? provider.getBlockTypeIds() : null;
|
||||
final BlockRenderContext blockRenderContext = buildContext.getBlockRenderContext();
|
||||
|
||||
final boolean threaded = isThreaded();
|
||||
@@ -142,29 +142,32 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
|
||||
final boolean canRenderOffThread = !threaded || canRenderOffThread(block);
|
||||
|
||||
for (int pass = 0; pass < AngelicaChunkBuildContext.NUM_PASSES; pass++) {
|
||||
boolean canRender = block.canRenderInPass(pass);
|
||||
// Check for shader pack override
|
||||
final BlockRenderLayer override = blockTypeIds != null ? blockTypeIds.get(block) : null;
|
||||
|
||||
// Shader pack can override render layer via block.properties
|
||||
if (blockTypeIds != null) {
|
||||
final RenderLayer overrideLayer = blockTypeIds.get(block);
|
||||
if (overrideLayer != null) {
|
||||
canRender = switch (pass) {
|
||||
case 0 -> overrideLayer == RenderLayer.cutout();
|
||||
case 1 -> overrideLayer == RenderLayer.translucent();
|
||||
default -> canRender;
|
||||
};
|
||||
for (int pass = 0; pass < AngelicaChunkBuildContext.NUM_PASSES; pass++) {
|
||||
final boolean canRender;
|
||||
Material materialOverride = null;
|
||||
|
||||
if (override != null) {
|
||||
// Shader pack override controls both pass and material
|
||||
canRender = (pass == override.toVanillaPass());
|
||||
if (canRender) {
|
||||
materialOverride = buffers.getRenderPassConfiguration().getMaterialForRenderType(override);
|
||||
}
|
||||
} else {
|
||||
// Normal block rendering
|
||||
canRender = block.canRenderInPass(pass);
|
||||
}
|
||||
|
||||
if (canRender) {
|
||||
final boolean isShaderPackOverride = materialOverride != null;
|
||||
if (!canRenderOffThread) {
|
||||
deferredBlocks.add(new DeferredBlock(x, y, z, block, meta, pass));
|
||||
deferredBlocks.add(new DeferredBlock(x, y, z, block, meta, pass, materialOverride, isShaderPackOverride));
|
||||
continue;
|
||||
}
|
||||
|
||||
renderBlock(block, x, y, z, pass, tessellator, renderBlocks,
|
||||
buffers, buildContext, blockRenderContext, minX, minY, minZ);
|
||||
renderBlock(block, meta, x, y, z, pass, tessellator, renderBlocks, buffers, buildContext, blockRenderContext, minX, minY, minZ, materialOverride, isShaderPackOverride);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,26 +210,35 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderBlock(Block block, int x, int y, int z, int pass, Tessellator tessellator, RenderBlocks renderBlocks, ChunkBuildBuffers buffers, AngelicaChunkBuildContext buildContext, BlockRenderContext blockRenderContext, int originX, int originY, int originZ) {
|
||||
protected void renderBlock(Block block, int metadata, int x, int y, int z, int pass, Tessellator tessellator, RenderBlocks renderBlocks, ChunkBuildBuffers buffers, AngelicaChunkBuildContext buildContext, BlockRenderContext blockRenderContext, int originX, int originY, int originZ, Material materialOverride, boolean isShaderPackOverride) {
|
||||
|
||||
final Material blockMaterial = block.getMaterial();
|
||||
final boolean isFluid = blockMaterial == Material.water || blockMaterial == Material.lava;
|
||||
final var blockMaterial = block.getMaterial();
|
||||
final boolean isFluid = blockMaterial == net.minecraft.block.material.Material.water || blockMaterial == net.minecraft.block.material.Material.lava;
|
||||
|
||||
// Use material override if provided, otherwise derive from pass
|
||||
// Lava is opaque - use solid to skip unnecessary alpha testing
|
||||
final var passMaterial = blockMaterial == Material.lava ? AngelicaRenderPassConfiguration.SOLID_MATERIAL : buffers.getRenderPassConfiguration().getMaterialForRenderType(BlockRenderLayer.fromVanillaPass(pass));
|
||||
final Material passMaterial;
|
||||
if (materialOverride != null) {
|
||||
passMaterial = materialOverride;
|
||||
} else if (blockMaterial == net.minecraft.block.material.Material.lava) {
|
||||
passMaterial = AngelicaRenderPassConfiguration.SOLID_MATERIAL;
|
||||
} else {
|
||||
passMaterial = buffers.getRenderPassConfiguration().getMaterialForRenderType(BlockRenderLayer.fromVanillaPass(pass));
|
||||
}
|
||||
|
||||
final var encoder = buffers.get(passMaterial).getEncoder();
|
||||
final ContextAwareChunkVertexEncoder contextEncoder = (encoder instanceof ContextAwareChunkVertexEncoder) ? (ContextAwareChunkVertexEncoder) encoder : null;
|
||||
|
||||
blockRenderContext.localPosX = x & 15;
|
||||
blockRenderContext.localPosY = y & 15;
|
||||
blockRenderContext.localPosZ = z & 15;
|
||||
|
||||
if (contextEncoder != null) {
|
||||
blockRenderContext.localPosX = x & 15;
|
||||
blockRenderContext.localPosY = y & 15;
|
||||
blockRenderContext.localPosZ = z & 15;
|
||||
final byte lightValue = (byte) block.getLightValue();
|
||||
if (isFluid) {
|
||||
contextEncoder.prepareToRenderFluid(blockRenderContext, block, lightValue);
|
||||
} else {
|
||||
contextEncoder.prepareToRenderBlock(blockRenderContext, block,
|
||||
contextEncoder.prepareToRenderBlock(blockRenderContext, block, metadata,
|
||||
ExtendedDataHelper.BLOCK_RENDER_TYPE, lightValue);
|
||||
}
|
||||
}
|
||||
@@ -236,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, originX, originY, originZ);
|
||||
// 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;
|
||||
|
||||
@@ -255,9 +275,9 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
mainTessellator.setTranslation(-minX, -minY, -minZ);
|
||||
|
||||
for (DeferredBlock deferred : deferredBlocks) {
|
||||
renderBlock(deferred.block(), deferred.x(), deferred.y(), deferred.z(), deferred.pass(),
|
||||
renderBlock(deferred.block(), deferred.meta(), deferred.x(), deferred.y(), deferred.z(), deferred.pass(),
|
||||
mainTessellator, mainThreadRenderBlocks, buffers, buildContext,
|
||||
blockRenderContext, minX, minY, minZ);
|
||||
blockRenderContext, minX, minY, minZ, deferred.materialOverride(), deferred.isShaderPackOverride());
|
||||
}
|
||||
|
||||
mainTessellator.setTranslation(0, 0, 0);
|
||||
|
||||
+15
@@ -6,7 +6,10 @@ import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.world.ChunkCache;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.RenderSection;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.ChunkBuildContext;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.ChunkBuildOutput;
|
||||
import org.embeddedt.embeddium.impl.util.position.SectionPos;
|
||||
import org.embeddedt.embeddium.impl.util.task.CancellationToken;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
public class AngelicaMainThreadMeshingTask extends AngelicaChunkBuilderMeshingTask {
|
||||
@@ -30,6 +33,18 @@ public class AngelicaMainThreadMeshingTask extends AngelicaChunkBuilderMeshingTa
|
||||
this.blockAccess = new ChunkCache(world, minX - 1, minY - 1, minZ - 1, minX + 17, minY + 17, minZ + 17, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkBuildOutput execute(ChunkBuildContext context, CancellationToken cancellationToken) {
|
||||
final AngelicaChunkBuildContext buildContext = (AngelicaChunkBuildContext) context;
|
||||
|
||||
final int minX = this.render.getOriginX();
|
||||
final int minY = this.render.getOriginY();
|
||||
final int minZ = this.render.getOriginZ();
|
||||
buildContext.setupLightPipeline(blockAccess, minX, minY, minZ);
|
||||
|
||||
return super.execute(context, cancellationToken);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Tessellator getTessellator() {
|
||||
return Tessellator.instance;
|
||||
|
||||
+6
-3
@@ -68,13 +68,16 @@ public class AngelicaRenderPassConfiguration {
|
||||
CUTOUT_MIPPED_MATERIAL = new Material(CUTOUT_MIPPED_PASS, AlphaCutoffParameter.ONE_TENTH, true);
|
||||
|
||||
final ImmutableListMultimap.Builder<BlockRenderLayer, TerrainRenderPass> vanillaRenderStages = ImmutableListMultimap.builder();
|
||||
vanillaRenderStages.put(BlockRenderLayer.TRANSLUCENT, TRANSLUCENT_PASS);
|
||||
vanillaRenderStages.put(BlockRenderLayer.SOLID, SOLID_PASS);
|
||||
vanillaRenderStages.put(BlockRenderLayer.SOLID, CUTOUT_MIPPED_PASS);
|
||||
vanillaRenderStages.put(BlockRenderLayer.CUTOUT, CUTOUT_MIPPED_PASS);
|
||||
vanillaRenderStages.put(BlockRenderLayer.CUTOUT_MIPPED, CUTOUT_MIPPED_PASS);
|
||||
vanillaRenderStages.put(BlockRenderLayer.TRANSLUCENT, TRANSLUCENT_PASS);
|
||||
|
||||
// Material lookup by terrain layer
|
||||
final Map<BlockRenderLayer, Material> renderTypeToMaterialMap = new Reference2ReferenceOpenHashMap<>(4, Reference2ReferenceOpenHashMap.VERY_FAST_LOAD_FACTOR);
|
||||
renderTypeToMaterialMap.put(BlockRenderLayer.SOLID, CUTOUT_MIPPED_MATERIAL);
|
||||
renderTypeToMaterialMap.put(BlockRenderLayer.SOLID, SOLID_MATERIAL);
|
||||
renderTypeToMaterialMap.put(BlockRenderLayer.CUTOUT, CUTOUT_MIPPED_MATERIAL);
|
||||
renderTypeToMaterialMap.put(BlockRenderLayer.CUTOUT_MIPPED, CUTOUT_MIPPED_MATERIAL);
|
||||
renderTypeToMaterialMap.put(BlockRenderLayer.TRANSLUCENT, TRANSLUCENT_MATERIAL);
|
||||
|
||||
return new RenderPassConfiguration<>(renderTypeToMaterialMap, vanillaRenderStages.build().asMap(), CUTOUT_MIPPED_MATERIAL, CUTOUT_MIPPED_MATERIAL, TRANSLUCENT_MATERIAL);
|
||||
|
||||
+13
-11
@@ -1,11 +1,12 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.RenderSectionManagerAccessor;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaRenderQueue;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProviderHolder;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.threading.ChunkTaskProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.threading.ChunkTaskRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.world.cloned.ClonedChunkSectionCache;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
@@ -15,7 +16,6 @@ import org.embeddedt.embeddium.impl.render.chunk.ChunkRenderMatrices;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.RenderSection;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.RenderSectionManager;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.CameraTransform;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.ChunkBuildOutput;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.tasks.ChunkBuilderTask;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.lists.SectionTicker;
|
||||
@@ -23,12 +23,11 @@ import org.embeddedt.embeddium.impl.render.chunk.occlusion.AsyncOcclusionMode;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.sprite.GenericSectionSpriteTicker;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexType;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.CameraTransform;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
import org.embeddedt.embeddium.impl.util.PositionUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.RenderSectionManagerAccessor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -88,7 +87,7 @@ public class AngelicaRenderSectionManager extends RenderSectionManager {
|
||||
|
||||
@Override
|
||||
protected AsyncOcclusionMode getAsyncOcclusionMode() {
|
||||
return AsyncOcclusionMode.EVERYTHING;
|
||||
return AngelicaMod.options().performance.asyncOcclusionMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,7 +97,7 @@ public class AngelicaRenderSectionManager extends RenderSectionManager {
|
||||
|
||||
@Override
|
||||
protected boolean useFogOcclusion() {
|
||||
return true;
|
||||
return AngelicaMod.options().performance.useFogOcclusion && !IrisShaderProviderHolder.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,10 +107,13 @@ public class AngelicaRenderSectionManager extends RenderSectionManager {
|
||||
|
||||
@Override
|
||||
protected boolean shouldUseOcclusionCulling(Viewport positionedViewport, boolean spectator) {
|
||||
if (!spectator) return true;
|
||||
|
||||
final var camBlockPos = positionedViewport.getBlockCoord();
|
||||
return !this.world.getBlock(camBlockPos.x(), camBlockPos.y(), camBlockPos.z()).isOpaqueCube();
|
||||
if (spectator) {
|
||||
final var camBlockPos = positionedViewport.getBlockCoord();
|
||||
if (this.world.getBlock(camBlockPos.x(), camBlockPos.y(), camBlockPos.z()).isOpaqueCube()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return AngelicaMod.options().performance.useOcclusionCulling;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,7 +152,7 @@ public class AngelicaRenderSectionManager extends RenderSectionManager {
|
||||
|
||||
@Override
|
||||
protected boolean allowImportantRebuilds() {
|
||||
return !SodiumClientMod.options().performance.alwaysDeferChunkUpdates;
|
||||
return !AngelicaMod.options().performance.alwaysDeferChunkUpdates;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
public enum BlockRenderLayer {
|
||||
SOLID, // vanilla pass 0
|
||||
TRANSLUCENT; // vanilla pass 1
|
||||
SOLID, // pass 0, no alpha test
|
||||
CUTOUT, // pass 0, alpha test (not mipped)
|
||||
CUTOUT_MIPPED, // pass 0, alpha test (mipped)
|
||||
TRANSLUCENT; // pass 1
|
||||
|
||||
private static final BlockRenderLayer[] VALUES = values();
|
||||
public int toVanillaPass() {
|
||||
return this == TRANSLUCENT ? 1 : 0;
|
||||
}
|
||||
|
||||
public static BlockRenderLayer fromVanillaPass(int pass) {
|
||||
return VALUES[pass];
|
||||
// CUTOUT_MIPPED is the safe default for pass 0
|
||||
// SOLID/CUTOUT are only used for explicit shader pack and material overrides
|
||||
return pass == 0 ? CUTOUT_MIPPED : TRANSLUCENT;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import com.gtnewhorizons.angelica.Tags;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.states.FogState;
|
||||
@@ -20,7 +21,7 @@ public class CeleritasDebugScreenHandler {
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void onRenderGameOverlayTextEvent(RenderGameOverlayEvent.Text event) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (!mc.gameSettings.showDebugInfo) {
|
||||
if (!mc.gameSettings.showDebugInfo || AngelicaConfig.disableF3Additions) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -1,9 +1,14 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.IDynamicLightWorldRenderer;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITileEntityBoundingBoxCache;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import com.gtnewhorizons.angelica.rendering.TileEntityRenderBoundsRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProviderHolder;
|
||||
import net.coderbot.iris.pipeline.ShadowRenderer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
@@ -21,9 +26,6 @@ import org.embeddedt.embeddium.impl.render.chunk.lists.ChunkRenderList;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.lists.SortedRenderLists;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkMeshFormats;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexType;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProviderHolder;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import org.embeddedt.embeddium.impl.render.terrain.SimpleWorldRenderer;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
import org.joml.Matrix4f;
|
||||
@@ -116,7 +118,7 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
}
|
||||
}
|
||||
|
||||
if (SodiumClientMod.options().advanced.useCompactVertexFormat) {
|
||||
if (AngelicaMod.options().performance.useCompactVertexFormat) {
|
||||
return ChunkMeshFormats.COMPACT;
|
||||
}
|
||||
return ChunkMeshFormats.VANILLA_LIKE;
|
||||
@@ -144,7 +146,7 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
|
||||
renderSectionManager.setCameraPosition(transform.x, transform.y, transform.z);
|
||||
|
||||
this.useEntityCulling = true;
|
||||
this.useEntityCulling = AngelicaMod.options().performance.useEntityCulling;
|
||||
|
||||
super.setupTerrain(viewport, cameraState, frame, spectator, updateChunksImmediately);
|
||||
|
||||
@@ -227,10 +229,13 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
return;
|
||||
}
|
||||
|
||||
final AxisAlignedBB aabb = tileEntity.getRenderBoundingBox();
|
||||
final ITileEntityBoundingBoxCache teCache = (ITileEntityBoundingBoxCache) tileEntity;
|
||||
|
||||
if (aabb != TileEntity.INFINITE_EXTENT_AABB && !this.currentViewport.isBoxVisible(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ)) {
|
||||
return;
|
||||
if (!teCache.angelica$isInfiniteExtent()) {
|
||||
final AxisAlignedBB aabb = teCache.angelica$getCachedRenderBoundingBox();
|
||||
if (aabb != null && !this.currentViewport.isBoxVisible(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -244,11 +249,6 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isInfiniteExtentsBox(AxisAlignedBB box) {
|
||||
return box == null || Double.isInfinite(box.minX) || Double.isInfinite(box.minY) || Double.isInfinite(box.minZ)
|
||||
|| Double.isInfinite(box.maxX) || Double.isInfinite(box.maxY) || Double.isInfinite(box.maxZ);
|
||||
}
|
||||
|
||||
public boolean isEntityVisible(Entity entity) {
|
||||
// During shadow pass, don't cull entities - shadow rendering uses different frustum
|
||||
if (!this.useEntityCulling || this.renderSectionManager.isInShadowPass()) {
|
||||
@@ -260,7 +260,7 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
box = entity.boundingBox;
|
||||
}
|
||||
|
||||
if (isInfiniteExtentsBox(box)) {
|
||||
if (TileEntityRenderBoundsRegistry.isInfiniteExtentsBox(box)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import org.embeddedt.embeddium.api.util.NormI8;
|
||||
import org.embeddedt.embeddium.impl.model.quad.ModelQuadView;
|
||||
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFacing;
|
||||
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFlags;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexEncoder;
|
||||
import org.embeddedt.embeddium.impl.util.QuadUtil;
|
||||
|
||||
public class VertexArrayQuadView implements ModelQuadView {
|
||||
private final ChunkVertexEncoder.Vertex[] vertices;
|
||||
private int trueNormal;
|
||||
private int blockX, blockY, blockZ;
|
||||
private ModelQuadFacing lightFace;
|
||||
private int flags;
|
||||
|
||||
public VertexArrayQuadView(ChunkVertexEncoder.Vertex[] vertices) {
|
||||
this.vertices = vertices;
|
||||
}
|
||||
|
||||
public void setup(int trueNormal, int blockX, int blockY, int blockZ) {
|
||||
this.trueNormal = trueNormal;
|
||||
this.blockX = blockX;
|
||||
this.blockY = blockY;
|
||||
this.blockZ = blockZ;
|
||||
this.lightFace = null; // Reset cached lightFace
|
||||
this.flags = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getX(int idx) {
|
||||
return vertices[idx].x - blockX;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getY(int idx) {
|
||||
return vertices[idx].y - blockY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZ(int idx) {
|
||||
return vertices[idx].z - blockZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(int idx) {
|
||||
return vertices[idx].color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTexU(int idx) {
|
||||
return vertices[idx].u;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTexV(int idx) {
|
||||
return vertices[idx].v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLight(int idx) {
|
||||
return vertices[idx].light;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFlags() {
|
||||
if (flags == 0) {
|
||||
flags = ModelQuadFlags.getQuadFlags(this, getLightFace());
|
||||
}
|
||||
return flags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorIndex() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object celeritas$getSprite() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelQuadFacing getLightFace() {
|
||||
if (lightFace == null) {
|
||||
lightFace = computeLightFace(trueNormal);
|
||||
}
|
||||
return lightFace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelQuadFacing getNormalFace() {
|
||||
return QuadUtil.findNormalFace(trueNormal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getForgeNormal(int idx) {
|
||||
return vertices[idx].vanillaNormal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComputedFaceNormal() {
|
||||
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);
|
||||
final float nz = NormI8.unpackZ(normal);
|
||||
|
||||
final float absX = Math.abs(nx);
|
||||
final float absY = Math.abs(ny);
|
||||
final float absZ = Math.abs(nz);
|
||||
|
||||
if (absY >= absX && absY >= absZ) {
|
||||
return ny >= 0 ? ModelQuadFacing.POS_Y : ModelQuadFacing.NEG_Y;
|
||||
} else if (absX >= absZ) {
|
||||
return nx >= 0 ? ModelQuadFacing.POS_X : ModelQuadFacing.NEG_X;
|
||||
} else {
|
||||
return nz >= 0 ? ModelQuadFacing.POS_Z : ModelQuadFacing.NEG_Z;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-6
@@ -1,13 +1,12 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas.api;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
|
||||
import net.minecraft.block.Block;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.GlProgram;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkShaderInterface;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexType;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -27,8 +26,5 @@ public interface IrisShaderProvider {
|
||||
void setRenderPassConfiguration(RenderPassConfiguration<?> configuration);
|
||||
|
||||
/** Block render layer overrides from shader pack */
|
||||
@Nullable Map<Block, RenderLayer> getBlockTypeIds();
|
||||
|
||||
/** Block ID matches for extended vertex data */
|
||||
@Nullable Object2IntMap<Block> getBlockMatches();
|
||||
@Nullable Map<Block, BlockRenderLayer> getBlockTypeIds();
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexEncode
|
||||
|
||||
public interface ContextAwareChunkVertexEncoder extends ChunkVertexEncoder {
|
||||
|
||||
void prepareToRenderBlock(BlockRenderContext ctx, Block block, short renderType, byte lightValue);
|
||||
void prepareToRenderBlock(BlockRenderContext ctx, Block block, int metadata, short renderType, byte lightValue);
|
||||
|
||||
void prepareToRenderFluid(BlockRenderContext ctx, Block block, byte lightValue);
|
||||
|
||||
|
||||
+10
-9
@@ -4,10 +4,10 @@ import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.*;
|
||||
import static com.gtnewhorizons.angelica.rendering.celeritas.iris.IrisExtendedChunkVertexType.STRIDE;
|
||||
import static com.gtnewhorizons.angelica.rendering.celeritas.iris.IrisExtendedChunkVertexType.encodeMidTexture;
|
||||
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProviderHolder;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import lombok.Setter;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.vertices.ExtendedDataHelper;
|
||||
import net.coderbot.iris.vertices.NormalHelper;
|
||||
import net.coderbot.iris.vertices.NormI8;
|
||||
@@ -30,11 +30,10 @@ public class IrisExtendedChunkVertexEncoder implements ContextAwareChunkVertexEn
|
||||
private final ChunkVertexEncoder baseEncoder = IrisExtendedChunkVertexType.BASE_TYPE.createEncoder();
|
||||
private final CeleritasQuadView quad = new CeleritasQuadView();
|
||||
private final Vector3f normal = new Vector3f();
|
||||
private final Object2IntMap<Block> blockMatches;
|
||||
private final Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches;
|
||||
|
||||
public IrisExtendedChunkVertexEncoder() {
|
||||
final IrisShaderProvider provider = IrisShaderProviderHolder.getProvider();
|
||||
this.blockMatches = provider != null ? provider.getBlockMatches() : null;
|
||||
this.blockMetaMatches = BlockRenderingSettings.INSTANCE.getBlockMetaMatches();
|
||||
}
|
||||
|
||||
// Per-quad accumulators
|
||||
@@ -46,9 +45,10 @@ public class IrisExtendedChunkVertexEncoder implements ContextAwareChunkVertexEn
|
||||
private BlockRenderContext context;
|
||||
|
||||
@Override
|
||||
public void prepareToRenderBlock(BlockRenderContext ctx, Block block, short renderType, byte lightValue) {
|
||||
public void prepareToRenderBlock(BlockRenderContext ctx, Block block, int metadata, short renderType, byte lightValue) {
|
||||
this.context = ctx;
|
||||
ctx.blockId = (short) (blockMatches != null ? blockMatches.getOrDefault(block, -1) : -1);
|
||||
Int2IntMap metaMap = blockMetaMatches != null ? blockMetaMatches.get(block) : null;
|
||||
ctx.blockId = (short) (metaMap != null ? metaMap.get(metadata) : -1);
|
||||
ctx.renderType = renderType;
|
||||
ctx.lightValue = lightValue;
|
||||
}
|
||||
@@ -56,7 +56,8 @@ public class IrisExtendedChunkVertexEncoder implements ContextAwareChunkVertexEn
|
||||
@Override
|
||||
public void prepareToRenderFluid(BlockRenderContext ctx, Block block, byte lightValue) {
|
||||
this.context = ctx;
|
||||
ctx.blockId = (short) (blockMatches != null ? blockMatches.getOrDefault(block, -1) : -1);
|
||||
Int2IntMap metaMap = blockMetaMatches != null ? blockMetaMatches.get(block) : null;
|
||||
ctx.blockId = (short) (metaMap != null ? metaMap.get(0) : -1);
|
||||
ctx.renderType = ExtendedDataHelper.FLUID_RENDER_TYPE;
|
||||
ctx.lightValue = lightValue;
|
||||
}
|
||||
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas.light;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public enum EmptyBlockAccess implements IBlockAccess {
|
||||
INSTANCE;
|
||||
|
||||
@Override
|
||||
public Block getBlock(int x, int y, int z) {
|
||||
return Blocks.air;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockMetadata(int x, int y, int z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getTileEntity(int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLightBrightnessForSkyBlocks(int x, int y, int z, int min) {
|
||||
return min << 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isBlockProvidingPowerTo(int x, int y, int z, int direction) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAirBlock(int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeGenBase getBiomeGenForCoords(int x, int z) {
|
||||
return BiomeGenBase.plains;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return 256;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean extendedLevelsInChunkCache() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas.light;
|
||||
|
||||
import lombok.Setter;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.embeddedt.embeddium.impl.model.light.data.LightDataAccess;
|
||||
|
||||
@Setter
|
||||
public class LightDataCache extends LightDataAccess {
|
||||
private IBlockAccess world;
|
||||
|
||||
@Override
|
||||
protected int compute(int x, int y, int z) {
|
||||
final IBlockAccess world = this.world;
|
||||
final Block block = world.getBlock(x, y, z);
|
||||
|
||||
final boolean fo = block.isOpaqueCube();
|
||||
final boolean fc = block.isNormalCube();
|
||||
final int lu = block.getLightValue(world, x, y, z);
|
||||
|
||||
// Optimize: skip light calculation for opaque blocks with no luminance
|
||||
final int bl, sl;
|
||||
if (fo && lu == 0) {
|
||||
bl = 0;
|
||||
sl = 0;
|
||||
} else {
|
||||
final int packed = world.getLightBrightnessForSkyBlocks(x, y, z, 0);
|
||||
bl = (packed >> 4) & 0xF;
|
||||
sl = (packed >> 20) & 0xF;
|
||||
}
|
||||
|
||||
// AO value - blocks that emit light don't contribute to AO
|
||||
final float ao = lu == 0 ? block.getAmbientOcclusionLightValue() : 1.0f;
|
||||
|
||||
// Opacity check - true if block is view-blocking (solid blocks)
|
||||
final boolean op = block.getMaterial().isOpaque() && block.getLightOpacity() > 0;
|
||||
|
||||
return packFC(fc) | packFO(fo) | packOP(op) | packAO(ao) | packLU(lu) | packSL(sl) | packBL(bl);
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
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 {
|
||||
private QuadLightingHelper() {}
|
||||
|
||||
// Known emissive brightness values set by mods/vanilla
|
||||
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;
|
||||
|
||||
// Must be a known emissive brightness value
|
||||
if (first != FULL_BRIGHT_15 && first != FULL_BRIGHT_14) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// All 4 vertices must have the same value
|
||||
for (int i = 1; i < 4; i++) {
|
||||
if (vertices[i].light != first) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas.light;
|
||||
|
||||
import org.embeddedt.embeddium.api.util.ColorABGR;
|
||||
import org.embeddedt.embeddium.impl.model.light.DiffuseProvider;
|
||||
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFacing;
|
||||
|
||||
public enum VanillaDiffuseProvider implements DiffuseProvider {
|
||||
INSTANCE;
|
||||
|
||||
private static final float DOWN = 0.5f; // NEG_Y
|
||||
private static final float UP = 1.0f; // POS_Y
|
||||
private static final float NORTH_SOUTH = 0.8f; // NEG_Z, POS_Z
|
||||
private static final float EAST_WEST = 0.6f; // NEG_X, POS_X
|
||||
|
||||
// Inverse values for stripping vanilla's baked diffuse (when oldLighting=false)
|
||||
private static final float INV_DOWN = 1.0f / DOWN; // 2.0
|
||||
private static final float INV_UP = 1.0f / UP; // 1.0
|
||||
private static final float INV_NORTH_SOUTH = 1.0f / NORTH_SOUTH; // 1.25
|
||||
private static final float INV_EAST_WEST = 1.0f / EAST_WEST; // ~1.667
|
||||
|
||||
@Override
|
||||
public float getDiffuse(float normalX, float normalY, float normalZ, boolean shade) {
|
||||
if (!shade) return 1.0f;
|
||||
return Math.min(normalX * normalX * EAST_WEST + normalY * normalY * (normalY >= 0 ? UP : DOWN) + normalZ * normalZ * NORTH_SOUTH, 1.0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDiffuse(ModelQuadFacing lightFace, boolean shade) {
|
||||
if (!shade) return 1.0f;
|
||||
return switch (lightFace) {
|
||||
case NEG_Y -> DOWN;
|
||||
case POS_Y -> UP;
|
||||
case NEG_Z, POS_Z -> NORTH_SOUTH;
|
||||
case NEG_X, POS_X -> EAST_WEST;
|
||||
case UNASSIGNED -> 1.0f;
|
||||
};
|
||||
}
|
||||
|
||||
public float getInverseDiffuse(ModelQuadFacing lightFace) {
|
||||
return switch (lightFace) {
|
||||
case NEG_Y -> INV_DOWN;
|
||||
case POS_Y -> INV_UP;
|
||||
case NEG_Z, POS_Z -> INV_NORTH_SOUTH;
|
||||
case NEG_X, POS_X -> INV_EAST_WEST;
|
||||
case UNASSIGNED -> 1.0f;
|
||||
};
|
||||
}
|
||||
|
||||
public static int multiplyColor(int color, float factor) {
|
||||
if (factor == 1.0f) {
|
||||
return color;
|
||||
}
|
||||
int r = Math.min(255, (int)(ColorABGR.unpackRed(color) * factor));
|
||||
int g = Math.min(255, (int)(ColorABGR.unpackGreen(color) * factor));
|
||||
int b = Math.min(255, (int)(ColorABGR.unpackBlue(color) * factor));
|
||||
int a = ColorABGR.unpackAlpha(color);
|
||||
return ColorABGR.pack(r, g, b, a);
|
||||
}
|
||||
}
|
||||
+9
-1
@@ -2,6 +2,7 @@ package com.gtnewhorizons.angelica.rendering.celeritas.threading;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderThreadContext;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.AngelicaChunkBuilderMeshingTask;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.SmoothBiomeColorCache;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.WorldClientExtension;
|
||||
@@ -39,7 +40,8 @@ public class ThreadedAngelicaChunkBuilderMeshingTask extends AngelicaChunkBuilde
|
||||
|
||||
@Override
|
||||
public ChunkBuildOutput execute(ChunkBuildContext context, CancellationToken cancellationToken) {
|
||||
initBlockAccess((AngelicaChunkBuildContext) context);
|
||||
final AngelicaChunkBuildContext buildContext = (AngelicaChunkBuildContext) context;
|
||||
initBlockAccess(buildContext);
|
||||
return super.execute(context, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -54,12 +56,14 @@ public class ThreadedAngelicaChunkBuilderMeshingTask extends AngelicaChunkBuilde
|
||||
this.blockAccess = worldSlice;
|
||||
this.biomeColorCache = new SmoothBiomeColorCache(worldSlice);
|
||||
this.biomeColorCache.update(new SectionPos(this.render.getChunkX(), this.render.getChunkY(), this.render.getChunkZ()));
|
||||
buildContext.setupLightPipeline(minX, minY, minZ);
|
||||
} else {
|
||||
// Fallback: direct world access (main thread only)
|
||||
final var world = Minecraft.getMinecraft().theWorld;
|
||||
this.biomeColorCache = ((WorldClientExtension) world).celeritas$getSmoothBiomeColorCache();
|
||||
this.biomeColorCache.update(new SectionPos(this.render.getChunkX(), this.render.getChunkY(), this.render.getChunkZ()));
|
||||
this.blockAccess = new ChunkCache(world, minX - 1, minY - 1, minZ - 1, minX + 17, minY + 17, minZ + 17, 1);
|
||||
buildContext.setupLightPipeline(this.blockAccess, minX, minY, minZ);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,12 +104,16 @@ public class ThreadedAngelicaChunkBuilderMeshingTask extends AngelicaChunkBuilde
|
||||
enteredLocalMode = !TessellatorManager.isOnMainThread();
|
||||
if (enteredLocalMode) {
|
||||
TessellatorManager.enterLocalMode();
|
||||
if (blockAccess instanceof WorldSlice worldSlice) {
|
||||
RenderThreadContext.set(worldSlice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExitExecute() {
|
||||
if (enteredLocalMode) {
|
||||
RenderThreadContext.clear();
|
||||
RenderPassHelper.resetWorldRenderPass();
|
||||
TessellatorManager.exitLocalMode();
|
||||
}
|
||||
|
||||
+38
-23
@@ -4,11 +4,17 @@ import com.falsepattern.endlessids.mixin.helpers.ChunkBiomeHook;
|
||||
import com.gtnewhorizons.angelica.compat.ExtendedBlockStorageExt;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
|
||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectMap;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IChunkTileEntityMapHolder;
|
||||
import com.gtnewhorizons.angelica.utils.ConcurrentTileEntityMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap;
|
||||
import mega.fluidlogged.internal.mixin.hook.FLSubChunk;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.EnumSkyBlock;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
@@ -27,7 +33,7 @@ public class ClonedChunkSection {
|
||||
private ChunkSectionPos pos;
|
||||
private ExtendedBlockStorageExt data;
|
||||
private BiomeGenBase[] biomeData;
|
||||
private final Short2ObjectMap<TileEntity> tileEntities;
|
||||
private final Short2ObjectOpenHashMap<TileEntity> tileEntities;
|
||||
|
||||
private long lastUsedTimestamp = Long.MAX_VALUE;
|
||||
|
||||
@@ -53,7 +59,7 @@ public class ClonedChunkSection {
|
||||
this.pos = pos;
|
||||
this.data = new ExtendedBlockStorageExt(chunk, section);
|
||||
|
||||
int bArrLength;
|
||||
final int bArrLength;
|
||||
if (ModStatus.isEIDBiomeLoaded) {
|
||||
bArrLength = ((ChunkBiomeHook) chunk).getBiomeShortArray().length;
|
||||
} else {
|
||||
@@ -61,26 +67,7 @@ public class ClonedChunkSection {
|
||||
}
|
||||
this.biomeData = new BiomeGenBase[bArrLength];
|
||||
|
||||
this.tileEntities.clear();
|
||||
|
||||
// Check for tile entities
|
||||
for (int y = pos.getMinY(); y <= pos.getMaxY(); y++) {
|
||||
for (int z = pos.getMinZ(); z <= pos.getMaxZ(); z++) {
|
||||
for (int x = pos.getMinX(); x <= pos.getMaxX(); x++) {
|
||||
final int lX = x & 15, lY = y & 15, lZ = z & 15;
|
||||
// We have to use this insanity because in 1.7 the tile entity isn't guaranteed to be created
|
||||
// when the chunk gets scheduled for rendering. So we might have to create it.
|
||||
// Cloning is done on the main thread so this will not introduce threading issues
|
||||
final Block block = data.getBlockByExtId(lX, lY, lZ);
|
||||
if (block.hasTileEntity(data.getExtBlockMetadata(lX, lY, lZ))) {
|
||||
final TileEntity tileEntity = chunk.func_150806_e(x & 15, y, z & 15);
|
||||
if (tileEntity != null) {
|
||||
this.tileEntities.put(ChunkSectionPos.packLocal(tileEntity.xCoord & 15, tileEntity.yCoord & 15, tileEntity.zCoord & 15), tileEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
copyBlockEntities(chunk, pos);
|
||||
|
||||
// Fill biome data
|
||||
for (int z = pos.getMinZ(); z <= pos.getMaxZ(); z++) {
|
||||
@@ -90,6 +77,34 @@ public class ClonedChunkSection {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void copyBlockEntities(Chunk chunk, ChunkSectionPos pos) {
|
||||
this.tileEntities.clear();
|
||||
|
||||
final ConcurrentTileEntityMap map = ((IChunkTileEntityMapHolder) chunk).angelica$getConcurrentTEMap();
|
||||
|
||||
map.withReadLock(() -> {
|
||||
final Object2ObjectOpenHashMap<ChunkPosition, TileEntity> delegate = map.getDelegate();
|
||||
|
||||
if (delegate.isEmpty()) return;
|
||||
|
||||
final int minY = pos.getMinY();
|
||||
final int maxY = pos.getMaxY();
|
||||
|
||||
for (Object2ObjectMap.Entry<ChunkPosition, TileEntity> entry : Object2ObjectMaps.fastIterable(delegate)) {
|
||||
final ChunkPosition tePos = entry.getKey();
|
||||
if (tePos.chunkPosY < minY || tePos.chunkPosY > maxY) continue;
|
||||
|
||||
final TileEntity te = entry.getValue();
|
||||
if (te != null && !te.isInvalid()) {
|
||||
this.tileEntities.put(ChunkSectionPos.packLocal(tePos.chunkPosX & 15, tePos.chunkPosY & 15, tePos.chunkPosZ & 15), te);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.tileEntities.trim();
|
||||
}
|
||||
|
||||
public Block getBlock(int x, int y, int z) {
|
||||
return data.getBlockByExtId(x, y, z);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
package com.gtnewhorizons.angelica.utils;
|
||||
|
||||
import com.gtnewhorizons.angelica.rendering.RenderThreadContext;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
/**
|
||||
* Thread-safe wrapper around Object2ObjectOpenHashMap for chunkTileEntityMap.
|
||||
*/
|
||||
public class ConcurrentTileEntityMap implements Map<ChunkPosition, TileEntity> {
|
||||
private final Object2ObjectOpenHashMap<ChunkPosition, TileEntity> delegate = new Object2ObjectOpenHashMap<>();
|
||||
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
private final ConcurrentLinkedQueue<ChunkPosition> invalidationQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public void queueInvalidation(ChunkPosition pos) {
|
||||
invalidationQueue.add(pos);
|
||||
}
|
||||
|
||||
private void processInvalidationQueue() {
|
||||
ChunkPosition pos;
|
||||
while ((pos = invalidationQueue.poll()) != null) {
|
||||
final TileEntity te = delegate.get(pos);
|
||||
if (te != null && te.isInvalid()) {
|
||||
delegate.remove(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void withReadLock(Runnable action) {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
action.run();
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void withWriteLock(Runnable action) {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
action.run();
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public Object2ObjectOpenHashMap<ChunkPosition, TileEntity> getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public TileEntity putDirect(ChunkPosition key, TileEntity value) {
|
||||
return delegate.put(key, value);
|
||||
}
|
||||
|
||||
private static boolean isRenderWorkerThread() {
|
||||
return RenderThreadContext.hasWorldSlice();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TileEntity get(Object key) {
|
||||
if (!isRenderWorkerThread()) return delegate.get(key);
|
||||
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
final TileEntity te = delegate.get(key);
|
||||
if (te != null && te.isInvalid()) {
|
||||
if (key instanceof ChunkPosition pos) {
|
||||
invalidationQueue.add(pos);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return te;
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity put(ChunkPosition key, TileEntity value) {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
processInvalidationQueue();
|
||||
return delegate.put(key, value);
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity remove(Object key) {
|
||||
if (isRenderWorkerThread()) {
|
||||
if (key instanceof ChunkPosition pos) {
|
||||
invalidationQueue.add(pos);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
processInvalidationQueue();
|
||||
return delegate.remove(key);
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends ChunkPosition, ? extends TileEntity> m) {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
processInvalidationQueue();
|
||||
delegate.putAll(m);
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
invalidationQueue.clear();
|
||||
delegate.clear();
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
if (!isRenderWorkerThread()) return delegate.size();
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
return delegate.size();
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
if (!isRenderWorkerThread()) return delegate.isEmpty();
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
return delegate.isEmpty();
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
if (!isRenderWorkerThread()) return delegate.containsKey(key);
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
return delegate.containsKey(key);
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
if (!isRenderWorkerThread()) return delegate.containsValue(value);
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
return delegate.containsValue(value);
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<ChunkPosition> keySet() {
|
||||
if (isRenderWorkerThread()) {
|
||||
throw new IllegalStateException("keySet() called from render worker. Use withReadLock() for iteration.");
|
||||
}
|
||||
return delegate.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<TileEntity> values() {
|
||||
if (isRenderWorkerThread()) {
|
||||
throw new IllegalStateException("values() called from render worker. Use withReadLock() for iteration.");
|
||||
}
|
||||
return delegate.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Entry<ChunkPosition, TileEntity>> entrySet() {
|
||||
if (isRenderWorkerThread()) {
|
||||
throw new IllegalStateException("entrySet() called from render worker. Use withReadLock() for iteration.");
|
||||
}
|
||||
return delegate.entrySet();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.prupe.mcpatcher.ctm;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
@@ -8,6 +9,9 @@ import com.prupe.mcpatcher.mal.block.BlockStateMatcher;
|
||||
|
||||
final class BlockOrientation extends RenderBlockState {
|
||||
|
||||
private static final boolean fixedBottomFaceUV = (boolean) Launch.blackboard
|
||||
.getOrDefault("hodgepodge.FixesConfig.fixBottomFaceUV", Boolean.FALSE);
|
||||
|
||||
// NEIGHBOR_OFFSETS[a][b][c] = offset from starting block
|
||||
// a: face 0-5
|
||||
// b: neighbor 0-7
|
||||
@@ -16,7 +20,11 @@ final class BlockOrientation extends RenderBlockState {
|
||||
// 1 2 3
|
||||
// c: coordinate (x,y,z) 0-2
|
||||
private static final int[][][] NEIGHBOR_OFFSET = new int[][][] {
|
||||
makeNeighborOffset(WEST_FACE, SOUTH_FACE, EAST_FACE, NORTH_FACE), // BOTTOM_FACE
|
||||
(
|
||||
fixedBottomFaceUV
|
||||
? makeNeighborOffset(EAST_FACE, SOUTH_FACE, WEST_FACE, NORTH_FACE) // BOTTOM_FACE fixedBottomFaceUV
|
||||
: makeNeighborOffset(WEST_FACE, SOUTH_FACE, EAST_FACE, NORTH_FACE) // BOTTOM_FACE not fixed
|
||||
),
|
||||
makeNeighborOffset(WEST_FACE, SOUTH_FACE, EAST_FACE, NORTH_FACE), // TOP_FACE
|
||||
makeNeighborOffset(EAST_FACE, BOTTOM_FACE, WEST_FACE, TOP_FACE), // NORTH_FACE
|
||||
makeNeighborOffset(WEST_FACE, BOTTOM_FACE, EAST_FACE, TOP_FACE), // SOUTH_FACE
|
||||
|
||||
@@ -7,6 +7,8 @@ import java.util.IdentityHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.IIcon;
|
||||
@@ -37,6 +39,7 @@ public class CTMUtils {
|
||||
private static TileLoader tileLoader;
|
||||
|
||||
private static TileOverride lastOverride;
|
||||
private static final Lock lock = new ReentrantLock();
|
||||
|
||||
private static final TileOverrideIterator.IJK ijkIterator = newIJKIterator();
|
||||
private static final TileOverrideIterator.Metadata metadataIterator = newMetadataIterator();
|
||||
@@ -52,64 +55,76 @@ public class CTMUtils {
|
||||
} catch (Exception ignore) {}
|
||||
|
||||
TexturePackChangeHandler.register(new TexturePackChangeHandler(MCPatcherUtils.CONNECTED_TEXTURES, 3) {
|
||||
|
||||
@Override
|
||||
public void initialize() {}
|
||||
public void initialize() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeChange() {
|
||||
RenderPassAPI.instance.clear();
|
||||
lock.lock();
|
||||
try {
|
||||
GlassPaneRenderer.clear();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
renderBlockState.clear();
|
||||
ijkIterator.clear();
|
||||
metadataIterator.clear();
|
||||
allOverrides.clear();
|
||||
blockOverrides.clear();
|
||||
tileOverrides.clear();
|
||||
lastOverride = null;
|
||||
RenderBlocksUtils.blankIcon = null;
|
||||
tileLoader = new TileLoader("textures/blocks", logger);
|
||||
RenderPassAPI.instance.refreshBlendingOptions();
|
||||
|
||||
if (MCPatcherForgeConfig.ConnectedTextures.standard || MCPatcherForgeConfig.ConnectedTextures.nonStandard) {
|
||||
for (ResourceLocation resource : ResourceList.getInstance()
|
||||
.listResources(TexturePackAPI.MCPATCHER_SUBDIR + "ctm", ".properties", true)) {
|
||||
registerOverride(TileOverride.create(resource, tileLoader));
|
||||
RenderPassAPI.instance.clear();
|
||||
try {
|
||||
GlassPaneRenderer.clear();
|
||||
} catch (NoClassDefFoundError e) {
|
||||
// nothing
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
for (ResourceLocation resource : BlendMethod.getAllBlankResources()) {
|
||||
tileLoader.preloadTile(resource, false);
|
||||
renderBlockState.clear();
|
||||
ijkIterator.clear();
|
||||
metadataIterator.clear();
|
||||
allOverrides.clear();
|
||||
blockOverrides.clear();
|
||||
tileOverrides.clear();
|
||||
lastOverride = null;
|
||||
RenderBlocksUtils.blankIcon = null;
|
||||
tileLoader = new TileLoader("textures/blocks", logger);
|
||||
RenderPassAPI.instance.refreshBlendingOptions();
|
||||
|
||||
if (MCPatcherForgeConfig.ConnectedTextures.standard || MCPatcherForgeConfig.ConnectedTextures.nonStandard) {
|
||||
for (ResourceLocation resource : ResourceList.getInstance()
|
||||
.listResources(TexturePackAPI.MCPATCHER_SUBDIR + "ctm", ".properties", true)) {
|
||||
registerOverride(TileOverride.create(resource, tileLoader));
|
||||
}
|
||||
}
|
||||
for (ResourceLocation resource : BlendMethod.getAllBlankResources()) {
|
||||
tileLoader.preloadTile(resource, false);
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterChange() {
|
||||
for (TileOverride override : allOverrides) {
|
||||
override.registerIcons();
|
||||
}
|
||||
for (Map.Entry<Block, List<BlockStateMatcher>> entry : blockOverrides.entrySet()) {
|
||||
for (BlockStateMatcher matcher : entry.getValue()) {
|
||||
TileOverride override = (TileOverride) matcher.getData();
|
||||
if (override.getRenderPass() >= 0) {
|
||||
RenderPassAPI.instance.setRenderPassForBlock(entry.getKey(), override.getRenderPass());
|
||||
lock.lock();
|
||||
try {
|
||||
for (TileOverride override : allOverrides) {
|
||||
override.registerIcons();
|
||||
}
|
||||
for (Map.Entry<Block, List<BlockStateMatcher>> entry : blockOverrides.entrySet()) {
|
||||
for (BlockStateMatcher matcher : entry.getValue()) {
|
||||
TileOverride override = (TileOverride) matcher.getData();
|
||||
if (override.getRenderPass() >= 0) {
|
||||
RenderPassAPI.instance.setRenderPassForBlock(entry.getKey(), override.getRenderPass());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (List<BlockStateMatcher> overrides : blockOverrides.values()) {
|
||||
overrides.sort((m1, m2) -> {
|
||||
TileOverride o1 = (TileOverride) m1.getData();
|
||||
TileOverride o2 = (TileOverride) m2.getData();
|
||||
return o1.compareTo(o2);
|
||||
});
|
||||
}
|
||||
for (List<TileOverride> overrides : tileOverrides.values()) {
|
||||
Collections.sort(overrides);
|
||||
}
|
||||
setBlankResource();
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
for (List<BlockStateMatcher> overrides : blockOverrides.values()) {
|
||||
overrides.sort((m1, m2) -> {
|
||||
TileOverride o1 = (TileOverride) m1.getData();
|
||||
TileOverride o2 = (TileOverride) m2.getData();
|
||||
return o1.compareTo(o2);
|
||||
});
|
||||
}
|
||||
for (List<TileOverride> overrides : tileOverrides.values()) {
|
||||
Collections.sort(overrides);
|
||||
}
|
||||
setBlankResource();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -118,40 +133,53 @@ public class CTMUtils {
|
||||
haveBlockFace = false;
|
||||
}
|
||||
|
||||
public static synchronized IIcon getBlockIcon(IIcon icon, Block block, IBlockAccess blockAccess,
|
||||
int x, int y, int z, int face) {
|
||||
lastOverride = null;
|
||||
if (blockAccess != null && checkFace(face)) {
|
||||
if (!haveBlockFace) {
|
||||
renderBlockState.setBlock(block, blockAccess, x, y, z);
|
||||
renderBlockState.setFace(face);
|
||||
}
|
||||
lastOverride = ijkIterator.go(renderBlockState, icon);
|
||||
if (lastOverride != null) {
|
||||
icon = ijkIterator.getIcon();
|
||||
public static IIcon getBlockIcon(IIcon icon, Block block, IBlockAccess blockAccess,
|
||||
int x, int y, int z, int face) {
|
||||
lock.lock();
|
||||
try {
|
||||
lastOverride = null;
|
||||
if (blockAccess != null && checkFace(face)) {
|
||||
if (!haveBlockFace) {
|
||||
renderBlockState.setBlock(block, blockAccess, x, y, z);
|
||||
renderBlockState.setFace(face);
|
||||
}
|
||||
lastOverride = ijkIterator.go(renderBlockState, icon);
|
||||
if (lastOverride != null) {
|
||||
icon = ijkIterator.getIcon();
|
||||
}
|
||||
}
|
||||
clearBlockFace();
|
||||
IIcon result = lastOverride == null && skipDefaultRendering(block) ? RenderBlocksUtils.blankIcon : icon;
|
||||
return result;
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
clearBlockFace();
|
||||
return lastOverride == null && skipDefaultRendering(block) ? RenderBlocksUtils.blankIcon : icon;
|
||||
}
|
||||
|
||||
public static synchronized IIcon getBlockIcon(IIcon icon, Block block, int face, int metadata) {
|
||||
lastOverride = null;
|
||||
if (checkFace(face) && checkRenderType(block)) {
|
||||
renderBlockState.setBlockMetadata(block, metadata, face);
|
||||
lastOverride = metadataIterator.go(renderBlockState, icon);
|
||||
if (lastOverride != null) {
|
||||
icon = metadataIterator.getIcon();
|
||||
public static IIcon getBlockIcon(IIcon icon, Block block, int face, int metadata) {
|
||||
lock.lock();
|
||||
try {
|
||||
lastOverride = null;
|
||||
if (checkFace(face) && checkRenderType(block)) {
|
||||
renderBlockState.setBlockMetadata(block, metadata, face);
|
||||
lastOverride = metadataIterator.go(renderBlockState, icon);
|
||||
if (lastOverride != null) {
|
||||
icon = metadataIterator.getIcon();
|
||||
}
|
||||
}
|
||||
return icon;
|
||||
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
public static IIcon getBlockIcon(IIcon icon, Block block, int face) {
|
||||
return getBlockIcon(icon, block, face, 0);
|
||||
}
|
||||
|
||||
public static void reset() {}
|
||||
public static void reset() {
|
||||
}
|
||||
|
||||
private static boolean checkFace(int face) {
|
||||
return face < 0 ? MCPatcherForgeConfig.ConnectedTextures.nonStandard : MCPatcherForgeConfig.ConnectedTextures.standard;
|
||||
@@ -165,50 +193,60 @@ public class CTMUtils {
|
||||
};
|
||||
}
|
||||
|
||||
private static synchronized boolean skipDefaultRendering(Block block) {
|
||||
private static boolean skipDefaultRendering(Block block) {
|
||||
return RenderPassAPI.instance.skipDefaultRendering(block);
|
||||
}
|
||||
|
||||
private static synchronized void registerOverride(TileOverride override) {
|
||||
if (override != null && !override.isDisabled()) {
|
||||
boolean registered = false;
|
||||
List<BlockStateMatcher> matchingBlocks = override.getMatchingBlocks();
|
||||
if (!MCPatcherUtils.isNullOrEmpty(matchingBlocks)) {
|
||||
for (BlockStateMatcher matcher : matchingBlocks) {
|
||||
if (matcher == null) {
|
||||
continue;
|
||||
private static void registerOverride(TileOverride override) {
|
||||
lock.lock();
|
||||
try {
|
||||
if (override != null && !override.isDisabled()) {
|
||||
boolean registered = false;
|
||||
List<BlockStateMatcher> matchingBlocks = override.getMatchingBlocks();
|
||||
if (!MCPatcherUtils.isNullOrEmpty(matchingBlocks)) {
|
||||
for (BlockStateMatcher matcher : matchingBlocks) {
|
||||
if (matcher == null) {
|
||||
continue;
|
||||
}
|
||||
Block block = matcher.getBlock();
|
||||
List<BlockStateMatcher> list = blockOverrides.computeIfAbsent(block, k -> new ArrayList<>());
|
||||
list.add(matcher);
|
||||
logger.fine("using %s for block %s", override, BlockAPI.getBlockName(block));
|
||||
registered = true;
|
||||
}
|
||||
Block block = matcher.getBlock();
|
||||
List<BlockStateMatcher> list = blockOverrides.computeIfAbsent(block, k -> new ArrayList<>());
|
||||
list.add(matcher);
|
||||
logger.fine("using %s for block %s", override, BlockAPI.getBlockName(block));
|
||||
registered = true;
|
||||
}
|
||||
Set<String> matchingTiles = override.getMatchingTiles();
|
||||
if (!MCPatcherUtils.isNullOrEmpty(matchingTiles)) {
|
||||
for (String name : matchingTiles) {
|
||||
List<TileOverride> list = tileOverrides.computeIfAbsent(name, k -> new ArrayList<>());
|
||||
list.add(override);
|
||||
logger.fine("using %s for tile %s", override, name);
|
||||
registered = true;
|
||||
}
|
||||
}
|
||||
if (registered) {
|
||||
allOverrides.add(override);
|
||||
}
|
||||
}
|
||||
Set<String> matchingTiles = override.getMatchingTiles();
|
||||
if (!MCPatcherUtils.isNullOrEmpty(matchingTiles)) {
|
||||
for (String name : matchingTiles) {
|
||||
List<TileOverride> list = tileOverrides.computeIfAbsent(name, k -> new ArrayList<>());
|
||||
list.add(override);
|
||||
logger.fine("using %s for tile %s", override, name);
|
||||
registered = true;
|
||||
}
|
||||
}
|
||||
if (registered) {
|
||||
allOverrides.add(override);
|
||||
}
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void setBlankResource() {
|
||||
RenderBlocksUtils.blankIcon = tileLoader.getIcon(RenderPassAPI.instance.getBlankResource());
|
||||
public static void setBlankResource() {
|
||||
lock.lock();
|
||||
try {
|
||||
RenderBlocksUtils.blankIcon = tileLoader.getIcon(RenderPassAPI.instance.getBlankResource());
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public static TileOverrideIterator.IJK newIJKIterator() {
|
||||
private static TileOverrideIterator.IJK newIJKIterator() {
|
||||
return new TileOverrideIterator.IJK(blockOverrides, tileOverrides);
|
||||
}
|
||||
|
||||
public static TileOverrideIterator.Metadata newMetadataIterator() {
|
||||
private static TileOverrideIterator.Metadata newMetadataIterator() {
|
||||
return new TileOverrideIterator.Metadata(blockOverrides, tileOverrides);
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
this.allTileOverrides = allTileOverrides;
|
||||
}
|
||||
|
||||
synchronized void clear() {
|
||||
void clear() {
|
||||
currentIcon = null;
|
||||
blockOverrides = null;
|
||||
tileOverrides = null;
|
||||
@@ -46,7 +46,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
skipOverrides.clear();
|
||||
}
|
||||
|
||||
private synchronized void resetForNextPass() {
|
||||
private void resetForNextPass() {
|
||||
blockOverrides = null;
|
||||
tileOverrides = allTileOverrides.get(currentIcon.getIconName());
|
||||
blockPos = 0;
|
||||
@@ -55,7 +55,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean hasNext() {
|
||||
public boolean hasNext() {
|
||||
if (foundNext) {
|
||||
return true;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized TileOverride next() {
|
||||
public TileOverride next() {
|
||||
if (!foundNext) {
|
||||
throw new IllegalStateException("next called before hasNext() == true");
|
||||
}
|
||||
@@ -89,11 +89,11 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void remove() {
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("remove not supported");
|
||||
}
|
||||
|
||||
private synchronized boolean checkOverride(TileOverride override) {
|
||||
private boolean checkOverride(TileOverride override) {
|
||||
if (override != null && !override.isDisabled() && !skipOverrides.contains(override)) {
|
||||
foundNext = true;
|
||||
nextOverride = override;
|
||||
@@ -103,7 +103,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized TileOverride go(RenderBlockState renderBlockState, IIcon origIcon) {
|
||||
public TileOverride go(RenderBlockState renderBlockState, IIcon origIcon) {
|
||||
this.renderBlockState = renderBlockState;
|
||||
renderBlockState.setFilter(null);
|
||||
currentIcon = origIcon;
|
||||
@@ -133,7 +133,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
return lastMatchedOverride;
|
||||
}
|
||||
|
||||
public synchronized IIcon getIcon() {
|
||||
public IIcon getIcon() {
|
||||
return currentIcon;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized IIcon getTile(TileOverride override, RenderBlockState renderBlockState, IIcon origIcon) {
|
||||
protected IIcon getTile(TileOverride override, RenderBlockState renderBlockState, IIcon origIcon) {
|
||||
return override.getTileWorld(renderBlockState, origIcon);
|
||||
}
|
||||
}
|
||||
@@ -158,7 +158,7 @@ abstract public class TileOverrideIterator implements Iterator<TileOverride> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized IIcon getTile(TileOverride override, RenderBlockState renderBlockState, IIcon origIcon) {
|
||||
protected IIcon getTile(TileOverride override, RenderBlockState renderBlockState, IIcon origIcon) {
|
||||
return override.getTileHeld(renderBlockState, origIcon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package jss.notfine.gui;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import jss.notfine.config.NotFineConfig;
|
||||
import jss.notfine.core.Settings;
|
||||
@@ -297,7 +296,7 @@ public class NotFineGameOptionPages {
|
||||
.setTooltip(I18n.format("sodium.options.use_block_face_culling.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> opts.advanced.useBlockFaceCulling = value, opts -> opts.advanced.useBlockFaceCulling)
|
||||
.setBinding((opts, value) -> opts.performance.useBlockFaceCulling = value, opts -> opts.performance.useBlockFaceCulling)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
@@ -305,14 +304,14 @@ public class NotFineGameOptionPages {
|
||||
.setTooltip(I18n.format("sodium.options.use_compact_vertex_format.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> opts.advanced.useCompactVertexFormat = value, opts -> opts.advanced.useCompactVertexFormat)
|
||||
.setBinding((opts, value) -> opts.performance.useCompactVertexFormat = value, opts -> opts.performance.useCompactVertexFormat)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.use_fog_occlusion.name"))
|
||||
.setTooltip(I18n.format("sodium.options.use_fog_occlusion.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> opts.advanced.useFogOcclusion = value, opts -> opts.advanced.useFogOcclusion)
|
||||
.setBinding((opts, value) -> opts.performance.useFogOcclusion = value, opts -> opts.performance.useFogOcclusion)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
@@ -320,7 +319,7 @@ public class NotFineGameOptionPages {
|
||||
.setName(I18n.format("sodium.options.translucency_sorting.name"))
|
||||
.setTooltip(I18n.format("sodium.options.translucency_sorting.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> opts.advanced.translucencySorting = value, opts -> opts.advanced.translucencySorting)
|
||||
.setBinding((opts, value) -> opts.performance.translucencySorting = value, opts -> opts.performance.translucencySorting)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
@@ -329,7 +328,7 @@ public class NotFineGameOptionPages {
|
||||
.setTooltip(I18n.format("sodium.options.use_entity_culling.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> opts.advanced.useEntityCulling = value, opts -> opts.advanced.useEntityCulling)
|
||||
.setBinding((opts, value) -> opts.performance.useEntityCulling = value, opts -> opts.performance.useEntityCulling)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.use_particle_culling.name"))
|
||||
@@ -345,7 +344,7 @@ public class NotFineGameOptionPages {
|
||||
.setTooltip(I18n.format("sodium.options.animate_only_visible_textures.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> opts.advanced.animateOnlyVisibleTextures = value, opts -> opts.advanced.animateOnlyVisibleTextures)
|
||||
.setBinding((opts, value) -> opts.performance.animateOnlyVisibleTextures = value, opts -> opts.performance.animateOnlyVisibleTextures)
|
||||
.build())
|
||||
.build());
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
|
||||
+2
-2
@@ -4,7 +4,6 @@ import com.gtnewhorizons.angelica.client.gui.FontConfigScreen;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Element;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import jss.notfine.gui.GuiCustomMenu;
|
||||
import net.coderbot.iris.Iris;
|
||||
import me.flashyreese.mods.reeses_sodium_options.client.gui.frame.AbstractFrame;
|
||||
import me.flashyreese.mods.reeses_sodium_options.client.gui.frame.BasicFrame;
|
||||
import me.flashyreese.mods.reeses_sodium_options.client.gui.frame.components.SearchTextFieldComponent;
|
||||
@@ -19,6 +18,7 @@ import me.jellysquid.mods.sodium.client.gui.options.OptionPage;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage;
|
||||
import me.jellysquid.mods.sodium.client.gui.widgets.FlatButtonWidget;
|
||||
import me.jellysquid.mods.sodium.client.util.Dim2i;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gui.screen.ShaderPackScreen;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
@@ -283,7 +283,7 @@ public class ReeseSodiumVideoOptionsScreen extends SodiumOptionsGUI {
|
||||
}
|
||||
if (keyCode == Keyboard.KEY_P) {
|
||||
if(isShiftKeyDown()){
|
||||
this.mc.displayGuiScreen(new GuiCustomMenu(this.prevScreen, SodiumGameOptionPages.general(), SodiumGameOptionPages.quality(), SodiumGameOptionPages.advanced(), SodiumGameOptionPages.performance()));
|
||||
this.mc.displayGuiScreen(new GuiCustomMenu(this.prevScreen, SodiumGameOptionPages.general(), SodiumGameOptionPages.quality(), SodiumGameOptionPages.advanced(), SodiumGameOptionPages.performance(), SodiumGameOptionPages.appearance(), SodiumGameOptionPages.debug()));
|
||||
} else if (isCtrlKeyDown()) {
|
||||
this.mc.displayGuiScreen(new SodiumOptionsGUI(this.prevScreen));
|
||||
}
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.client;
|
||||
|
||||
import com.gtnewhorizons.angelica.Tags;
|
||||
import com.gtnewhorizons.angelica.config.ConfigMigrator;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptions;
|
||||
import me.jellysquid.mods.sodium.proxy.CommonProxy;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@Mod(modid = SodiumClientMod.MODID,
|
||||
name = SodiumClientMod.NAME,
|
||||
version = Tags.VERSION,
|
||||
acceptedMinecraftVersions = "[1.7.10]",
|
||||
acceptableRemoteVersions = "*")
|
||||
public class SodiumClientMod {
|
||||
@SidedProxy(clientSide = "me.jellysquid.mods.sodium.proxy.ClientProxy", serverSide = "me.jellysquid.mods.sodium.proxy.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
private static SodiumGameOptions CONFIG;
|
||||
public static Logger LOGGER = LogManager.getLogger("Embeddium");
|
||||
|
||||
private static String MOD_VERSION = Tags.VERSION;
|
||||
|
||||
public static final String MODID = "embeddium";
|
||||
public static final String NAME = "Embeddium";
|
||||
|
||||
@Getter
|
||||
private static Thread MainThread;
|
||||
|
||||
public SodiumClientMod() {
|
||||
MainThread = Thread.currentThread();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static SodiumGameOptions options() {
|
||||
if (CONFIG == null) {
|
||||
CONFIG = loadConfig();
|
||||
}
|
||||
|
||||
return CONFIG;
|
||||
}
|
||||
|
||||
public static Logger logger() {
|
||||
if (LOGGER == null) {
|
||||
LOGGER = LogManager.getLogger("Embeddium");
|
||||
}
|
||||
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
private static SodiumGameOptions loadConfig() {
|
||||
return SodiumGameOptions.load(ConfigMigrator.handleConfigMigration("angelica-options.json"));
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
if (MOD_VERSION == null) {
|
||||
throw new NullPointerException("Mod version hasn't been populated yet");
|
||||
}
|
||||
|
||||
return MOD_VERSION;
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
proxy.preInit(event);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
proxy.init(event);
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
proxy.postInit(event);
|
||||
}
|
||||
|
||||
public static boolean isDirectMemoryAccessEnabled() {
|
||||
return options().advanced.allowDirectMemoryAccess;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package me.jellysquid.mods.sodium.client.gui;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import jss.notfine.core.Settings;
|
||||
import jss.notfine.core.SettingsManager;
|
||||
@@ -28,6 +27,7 @@ import net.coderbot.iris.gui.option.IrisVideoSettings;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.occlusion.AsyncOcclusionMode;
|
||||
import org.lwjgl.opengl.Display;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -80,19 +80,6 @@ public class SodiumGameOptionPages {
|
||||
.setControl(opt -> new SliderControl(opt, 0, 100, 1, ControlValueFormatter.brightness()))
|
||||
.setBinding((opts, value) -> opts.gammaSetting = value * 0.01F, (opts) -> (int) (opts.gammaSetting / 0.01F))
|
||||
.build());
|
||||
firstGroupBuilder.add(Settings.MODE_LIGHT_FLICKER.option)
|
||||
.add(Settings.MODE_SKY.option)
|
||||
.add(Settings.MODE_SUN_MOON.option)
|
||||
.add(Settings.RENDER_DISTANCE_CLOUDS.option)
|
||||
.add(Settings.CLOUD_HEIGHT.option)
|
||||
.add(Settings.CLOUD_SCALE.option)
|
||||
.add(Settings.MODE_CLOUD_TRANSLUCENCY.option)
|
||||
.add(Settings.MODE_STARS.option)
|
||||
.add(Settings.TOTAL_STARS.option)
|
||||
.add(Settings.HORIZON_DISABLE.option)
|
||||
.add(Settings.FOG_DISABLE.option)
|
||||
.add(Settings.FOG_NEAR_DISTANCE.option)
|
||||
.add(Settings.VOID_FOG.option);
|
||||
groups.add(firstGroupBuilder.build());
|
||||
|
||||
int maxGuiScale = Math.max(3, Math.min(Minecraft.getMinecraft().displayWidth / 320, Minecraft.getMinecraft().displayHeight / 240));
|
||||
@@ -166,24 +153,6 @@ public class SodiumGameOptionPages {
|
||||
.add(Settings.DYNAMIC_FOV.option)
|
||||
.add(Settings.MODE_WATER.option)
|
||||
.add(Settings.MODE_DROPPED_ITEMS.option)
|
||||
.add(
|
||||
OptionImpl.createBuilder(int.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.droppedItemLimit"))
|
||||
.setTooltip(I18n.format("options.angelica.droppedItemLimit.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 32, 2048, 32, ControlValueFormatter.droppedItemLimitLimit()))
|
||||
.setBinding((options, value) -> AngelicaConfig.droppedItemLimit = value, options -> AngelicaConfig.droppedItemLimit)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.build()
|
||||
)
|
||||
.add(
|
||||
OptionImpl.createBuilder(int.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.mobSpawnerRenderDistance"))
|
||||
.setTooltip(I18n.format("options.angelica.mobSpawnerRenderDistance.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 16, 64, 1, ControlValueFormatter.number()))
|
||||
.setBinding((options, value) -> AngelicaConfig.mobSpawnerRenderDistance = value, options -> (int) AngelicaConfig.mobSpawnerRenderDistance)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.build()
|
||||
)
|
||||
.build());
|
||||
|
||||
return new OptionPage(I18n.format("stat.generalButton"), ImmutableList.copyOf(groups));
|
||||
@@ -238,10 +207,10 @@ public class SodiumGameOptionPages {
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.sodium_smooth_lighting.name"))
|
||||
.setTooltip(I18n.format("sodium.options.sodium_smooth_lighting.tooltip"))
|
||||
.setName(I18n.format("sodium.options.celeritas_smooth_lighting.name"))
|
||||
.setTooltip(I18n.format("sodium.options.celeritas_smooth_lighting.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> opts.quality.useSodiumAO = value, opts -> opts.quality.useSodiumAO)
|
||||
.setBinding((opts, value) -> opts.quality.useCeleritasSmoothLighting = value, opts -> opts.quality.useCeleritasSmoothLighting)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
@@ -305,7 +274,7 @@ public class SodiumGameOptionPages {
|
||||
.setTooltip(I18n.format("sodium.options.use_block_face_culling.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> opts.advanced.useBlockFaceCulling = value, opts -> opts.advanced.useBlockFaceCulling)
|
||||
.setBinding((opts, value) -> opts.performance.useBlockFaceCulling = value, opts -> opts.performance.useBlockFaceCulling)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build()
|
||||
)
|
||||
@@ -314,7 +283,7 @@ public class SodiumGameOptionPages {
|
||||
.setTooltip(I18n.format("sodium.options.use_compact_vertex_format.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> opts.advanced.useCompactVertexFormat = value, opts -> opts.advanced.useCompactVertexFormat)
|
||||
.setBinding((opts, value) -> opts.performance.useCompactVertexFormat = value, opts -> opts.performance.useCompactVertexFormat)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build()
|
||||
)
|
||||
@@ -322,7 +291,7 @@ public class SodiumGameOptionPages {
|
||||
.setName(I18n.format("sodium.options.use_fog_occlusion.name"))
|
||||
.setTooltip(I18n.format("sodium.options.use_fog_occlusion.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> opts.advanced.useFogOcclusion = value, opts -> opts.advanced.useFogOcclusion)
|
||||
.setBinding((opts, value) -> opts.performance.useFogOcclusion = value, opts -> opts.performance.useFogOcclusion)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build()
|
||||
@@ -331,7 +300,7 @@ public class SodiumGameOptionPages {
|
||||
.setName(I18n.format("sodium.options.translucency_sorting.name"))
|
||||
.setTooltip(I18n.format("sodium.options.translucency_sorting.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> opts.advanced.translucencySorting = value, opts -> opts.advanced.translucencySorting)
|
||||
.setBinding((opts, value) -> opts.performance.translucencySorting = value, opts -> opts.performance.translucencySorting)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build()
|
||||
@@ -341,7 +310,7 @@ public class SodiumGameOptionPages {
|
||||
.setTooltip(I18n.format("sodium.options.use_entity_culling.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> opts.advanced.useEntityCulling = value, opts -> opts.advanced.useEntityCulling)
|
||||
.setBinding((opts, value) -> opts.performance.useEntityCulling = value, opts -> opts.performance.useEntityCulling)
|
||||
.build()
|
||||
)
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
@@ -357,7 +326,34 @@ public class SodiumGameOptionPages {
|
||||
.setTooltip(I18n.format("sodium.options.animate_only_visible_textures.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> opts.advanced.animateOnlyVisibleTextures = value, opts -> opts.advanced.animateOnlyVisibleTextures)
|
||||
.setBinding((opts, value) -> opts.performance.animateOnlyVisibleTextures = value, opts -> opts.performance.animateOnlyVisibleTextures)
|
||||
.build()
|
||||
)
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.use_render_pass_optimization.name"))
|
||||
.setTooltip(I18n.format("sodium.options.use_render_pass_optimization.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> opts.performance.useRenderPassOptimization = value, opts -> opts.performance.useRenderPassOptimization)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build()
|
||||
)
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.use_occlusion_culling.name"))
|
||||
.setTooltip(I18n.format("sodium.options.use_occlusion_culling.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.EXTREME)
|
||||
.setBinding((opts, value) -> opts.performance.useOcclusionCulling = value, opts -> opts.performance.useOcclusionCulling)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build()
|
||||
)
|
||||
.add(OptionImpl.createBuilder(AsyncOcclusionMode.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.async_occlusion_mode.name"))
|
||||
.setTooltip(I18n.format("sodium.options.async_occlusion_mode.tooltip"))
|
||||
.setControl(o -> new CyclingControl<>(o, AsyncOcclusionMode.class, new String[]{"None", "Only Shadow", "Everything"}))
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> opts.performance.asyncOcclusionMode = value, opts -> opts.performance.asyncOcclusionMode)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build()
|
||||
)
|
||||
.build());
|
||||
@@ -383,22 +379,6 @@ public class SodiumGameOptionPages {
|
||||
)
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(OptionImpl.createBuilder(int.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.itemdisplaylistcount"))
|
||||
.setTooltip(I18n.format("options.angelica.itemdisplaylistcount.tooltip"))
|
||||
.setControl(o -> new SliderControl(o, 256, 1024, 16, ControlValueFormatter.number()))
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> AngelicaConfig.itemRendererCacheSize = value, options -> AngelicaConfig.itemRendererCacheSize)
|
||||
.build()
|
||||
)
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.MODE_GUI_BACKGROUND.option)
|
||||
.add(Settings.GUI_BACKGROUND.option)
|
||||
.build());
|
||||
|
||||
return new OptionPage(I18n.format("sodium.options.pages.advanced"), ImmutableList.copyOf(groups));
|
||||
}
|
||||
|
||||
@@ -440,14 +420,6 @@ public class SodiumGameOptionPages {
|
||||
.setBinding((opts, value) -> opts.performance.useNoErrorGLContext = value, opts -> opts.performance.useNoErrorGLContext)
|
||||
.setFlags(OptionFlag.REQUIRES_GAME_RESTART)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.use_gl_state_cache.name"))
|
||||
.setTooltip(I18n.format("sodium.options.use_gl_state_cache.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.EXTREME)
|
||||
.setBinding((opts, value) -> GLStateManager.BYPASS_CACHE = !value, opts -> !GLStateManager.BYPASS_CACHE)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(boolean.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.aggressiveChunkLoading"))
|
||||
.setTooltip(I18n.format("options.angelica.aggressiveChunkLoading.tooltip"))
|
||||
@@ -456,9 +428,94 @@ public class SodiumGameOptionPages {
|
||||
.setBinding((opts, value) -> AngelicaConfig.useVanillaChunkTracking = value, opts -> AngelicaConfig.useVanillaChunkTracking)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(int.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.cpu_render_ahead_limit.name"))
|
||||
.setTooltip(I18n.format("sodium.options.cpu_render_ahead_limit.tooltip"))
|
||||
.setControl(o -> new SliderControl(o, 0, 9, 1, ControlValueFormatter.quantity("sodium.options.cpu_render_ahead_limit.value")))
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> opts.performance.cpuRenderAheadLimit = value, opts -> opts.performance.cpuRenderAheadLimit)
|
||||
.setEnabled(GLStateManager.capabilities != null && GLStateManager.capabilities.OpenGL32)
|
||||
.build())
|
||||
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(OptionImpl.createBuilder(int.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.droppedItemLimit"))
|
||||
.setTooltip(I18n.format("options.angelica.droppedItemLimit.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 32, 2048, 32, ControlValueFormatter.droppedItemLimitLimit()))
|
||||
.setBinding((options, value) -> AngelicaConfig.droppedItemLimit = value, options -> AngelicaConfig.droppedItemLimit)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(int.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.mobSpawnerRenderDistance"))
|
||||
.setTooltip(I18n.format("options.angelica.mobSpawnerRenderDistance.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 16, 64, 1, ControlValueFormatter.number()))
|
||||
.setBinding((options, value) -> AngelicaConfig.mobSpawnerRenderDistance = value, options -> (int) AngelicaConfig.mobSpawnerRenderDistance)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.build())
|
||||
.add(OptionImpl.createBuilder(int.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.itemdisplaylistcount"))
|
||||
.setTooltip(I18n.format("options.angelica.itemdisplaylistcount.tooltip"))
|
||||
.setControl(o -> new SliderControl(o, 256, 1024, 16, ControlValueFormatter.number()))
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> AngelicaConfig.itemRendererCacheSize = value, options -> AngelicaConfig.itemRendererCacheSize)
|
||||
.build())
|
||||
.build());
|
||||
|
||||
return new OptionPage(I18n.format("sodium.options.pages.performance"), ImmutableList.copyOf(groups));
|
||||
}
|
||||
|
||||
public static OptionPage appearance() {
|
||||
final List<OptionGroup> groups = new ArrayList<>();
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.MODE_SKY.option)
|
||||
.add(Settings.MODE_SUN_MOON.option)
|
||||
.add(Settings.RENDER_DISTANCE_CLOUDS.option)
|
||||
.add(Settings.CLOUD_HEIGHT.option)
|
||||
.add(Settings.CLOUD_SCALE.option)
|
||||
.add(Settings.MODE_CLOUD_TRANSLUCENCY.option)
|
||||
.add(Settings.MODE_STARS.option)
|
||||
.add(Settings.TOTAL_STARS.option)
|
||||
.add(Settings.HORIZON_DISABLE.option)
|
||||
.add(Settings.MODE_LIGHT_FLICKER.option)
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.FOG_DISABLE.option)
|
||||
.add(Settings.FOG_NEAR_DISTANCE.option)
|
||||
.add(Settings.VOID_FOG.option)
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.MODE_GUI_BACKGROUND.option)
|
||||
.add(Settings.GUI_BACKGROUND.option)
|
||||
.add(OptionImpl.createBuilder(boolean.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.disablef3"))
|
||||
.setTooltip(I18n.format("options.angelica.disablef3.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding((opts, value) -> AngelicaConfig.disableF3Additions = value, opts -> AngelicaConfig.disableF3Additions)
|
||||
.build())
|
||||
.build());
|
||||
|
||||
return new OptionPage(I18n.format("sodium.options.pages.appearance"), ImmutableList.copyOf(groups));
|
||||
}
|
||||
|
||||
public static OptionPage debug() {
|
||||
final List<OptionGroup> groups = new ArrayList<>();
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(OptionImpl.createBuilder(boolean.class, sodiumOpts)
|
||||
.setName(I18n.format("sodium.options.use_gl_state_cache.name"))
|
||||
.setTooltip(I18n.format("sodium.options.use_gl_state_cache.tooltip"))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setImpact(OptionImpact.EXTREME)
|
||||
.setBinding((opts, value) -> GLStateManager.BYPASS_CACHE = !value, opts -> !GLStateManager.BYPASS_CACHE)
|
||||
.setFlags(OptionFlag.REQUIRES_RENDERER_RELOAD)
|
||||
.build())
|
||||
.build());
|
||||
|
||||
return new OptionPage(I18n.format("sodium.options.pages.debug"), ImmutableList.copyOf(groups));
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,11 @@ import com.google.gson.FieldNamingPolicy;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.named.GraphicsQuality;
|
||||
import net.coderbot.iris.Iris;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.occlusion.AsyncOcclusionMode;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
@@ -26,21 +28,26 @@ public class SodiumGameOptions {
|
||||
public boolean useVertexArrayObjects = true;
|
||||
public boolean useChunkMultidraw = true;
|
||||
|
||||
public boolean animateOnlyVisibleTextures = true;
|
||||
public boolean useEntityCulling = true;
|
||||
public boolean useParticleCulling = true;
|
||||
public boolean useFogOcclusion = true;
|
||||
public boolean useCompactVertexFormat = true;
|
||||
public boolean useBlockFaceCulling = true;
|
||||
public boolean allowDirectMemoryAccess = true;
|
||||
public boolean ignoreDriverBlacklist = false;
|
||||
public boolean translucencySorting = true;
|
||||
}
|
||||
|
||||
public static class PerformanceSettings {
|
||||
public int chunkBuilderThreads = 0;
|
||||
public boolean alwaysDeferChunkUpdates = true;
|
||||
public boolean useNoErrorGLContext = true;
|
||||
public AsyncOcclusionMode asyncOcclusionMode = AsyncOcclusionMode.EVERYTHING;
|
||||
public boolean useOcclusionCulling = true;
|
||||
|
||||
public boolean animateOnlyVisibleTextures = true;
|
||||
public boolean useEntityCulling = true;
|
||||
public boolean useFogOcclusion = true;
|
||||
public boolean useBlockFaceCulling = true;
|
||||
public boolean useCompactVertexFormat = true;
|
||||
public boolean translucencySorting = true;
|
||||
public boolean useRenderPassOptimization = true;
|
||||
public int cpuRenderAheadLimit = 3;
|
||||
}
|
||||
|
||||
public static class EntityRenderDistance {
|
||||
@@ -55,7 +62,7 @@ public class SodiumGameOptions {
|
||||
}
|
||||
public static class QualitySettings {
|
||||
public GraphicsQuality grassQuality = GraphicsQuality.DEFAULT;
|
||||
public boolean useSodiumAO = false;
|
||||
public boolean useCeleritasSmoothLighting = true;
|
||||
}
|
||||
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
@@ -74,7 +81,7 @@ public class SodiumGameOptions {
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Could not parse config", e);
|
||||
} catch (JsonSyntaxException e) {
|
||||
SodiumClientMod.logger().error("Could not parse config, will fallback to default settings", e);
|
||||
AngelicaMod.LOGGER.error("Could not parse config, will fallback to default settings", e);
|
||||
config = new SodiumGameOptions();
|
||||
resaveConfig = false;
|
||||
}
|
||||
@@ -84,6 +91,11 @@ public class SodiumGameOptions {
|
||||
|
||||
config.configPath = path;
|
||||
|
||||
// Clamp render-ahead to 0 if GL 3.2 fences aren't available
|
||||
if (GLStateManager.capabilities == null || !GLStateManager.capabilities.OpenGL32) {
|
||||
config.performance.cpuRenderAheadLimit = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
if(resaveConfig)
|
||||
config.writeChanges();
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.gtnewhorizons.angelica.compat.mojang.Drawable;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Element;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import jss.notfine.gui.GuiCustomMenu;
|
||||
import net.coderbot.iris.Iris;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.Option;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionFlag;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionGroup;
|
||||
@@ -19,6 +18,7 @@ import me.jellysquid.mods.sodium.client.gui.options.control.element.SodiumContro
|
||||
import me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage;
|
||||
import me.jellysquid.mods.sodium.client.gui.widgets.FlatButtonWidget;
|
||||
import me.jellysquid.mods.sodium.client.util.Dim2i;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gui.screen.ShaderPackScreen;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -62,6 +62,7 @@ public class SodiumOptionsGUI extends ScrollableGuiScreen {
|
||||
this.pages.add(SodiumGameOptionPages.quality());
|
||||
this.pages.add(SodiumGameOptionPages.advanced());
|
||||
this.pages.add(SodiumGameOptionPages.performance());
|
||||
this.pages.add(SodiumGameOptionPages.appearance());
|
||||
|
||||
// Add Dynamic Lights page if enabled
|
||||
if (DynamicLights.configEnabled) {
|
||||
@@ -75,6 +76,8 @@ public class SodiumOptionsGUI extends ScrollableGuiScreen {
|
||||
shaderPacks = new OptionPage(I18n.format("options.iris.shaderPackSelection"), ImmutableList.of());
|
||||
this.pages.add(shaderPacks);
|
||||
}
|
||||
|
||||
this.pages.add(SodiumGameOptionPages.debug());
|
||||
}
|
||||
|
||||
public void setPage(OptionPage page) {
|
||||
@@ -298,7 +301,8 @@ public class SodiumOptionsGUI extends ScrollableGuiScreen {
|
||||
|
||||
if (keyCode == Keyboard.KEY_P && isShiftKeyDown()) {
|
||||
this.mc.displayGuiScreen(new GuiCustomMenu(this.prevScreen, SodiumGameOptionPages.general(),
|
||||
SodiumGameOptionPages.quality(), SodiumGameOptionPages.advanced(), SodiumGameOptionPages.performance()));
|
||||
SodiumGameOptionPages.quality(), SodiumGameOptionPages.advanced(), SodiumGameOptionPages.performance(),
|
||||
SodiumGameOptionPages.appearance(), SodiumGameOptionPages.debug()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package me.jellysquid.mods.sodium.client.gui.options.storage;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
|
||||
public class AngelicaOptionsStorage implements OptionStorage<AngelicaConfig> {
|
||||
|
||||
@@ -18,6 +18,6 @@ public class AngelicaOptionsStorage implements OptionStorage<AngelicaConfig> {
|
||||
@Override
|
||||
public void save() {
|
||||
ConfigurationManager.save(AngelicaConfig.class);
|
||||
SodiumClientMod.logger().info("Flushed changes to Angelica configuration");
|
||||
AngelicaMod.LOGGER.info("Flushed changes to Angelica configuration");
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.gui.options.storage;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
|
||||
@@ -20,6 +20,6 @@ public class MinecraftOptionsStorage implements OptionStorage<GameSettings> {
|
||||
public void save() {
|
||||
this.getData().saveOptions();
|
||||
|
||||
SodiumClientMod.logger().info("Flushed changes to Minecraft configuration");
|
||||
AngelicaMod.LOGGER.info("Flushed changes to Minecraft configuration");
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.gui.options.storage;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import me.jellysquid.mods.sodium.client.gui.SodiumGameOptions;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -9,7 +9,7 @@ public class SodiumOptionsStorage implements OptionStorage<SodiumGameOptions> {
|
||||
private final SodiumGameOptions options;
|
||||
|
||||
public SodiumOptionsStorage() {
|
||||
this.options = SodiumClientMod.options();
|
||||
this.options = AngelicaMod.options();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -25,6 +25,6 @@ public class SodiumOptionsStorage implements OptionStorage<SodiumGameOptions> {
|
||||
throw new RuntimeException("Couldn't save configuration changes", e);
|
||||
}
|
||||
|
||||
SodiumClientMod.logger().info("Flushed changes to Angelica configuration");
|
||||
AngelicaMod.LOGGER.info("Flushed changes to Angelica configuration");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package me.jellysquid.mods.sodium.client.gui.utils;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import net.minecraft.util.Util;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -19,7 +19,7 @@ public class URLUtils {
|
||||
try {
|
||||
Runtime.getRuntime().exec(getURLOpenCommand(url));
|
||||
} catch (IOException exception) {
|
||||
SodiumClientMod.logger().error("Couldn't open url '{}'", url, exception);
|
||||
AngelicaMod.LOGGER.error("Couldn't open url '{}'", url, exception);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.proxy;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import jss.notfine.gui.GuiCustomMenu;
|
||||
import jss.notfine.gui.NotFineGameOptionPages;
|
||||
import me.flashyreese.mods.reeses_sodium_options.client.gui.ReeseSodiumVideoOptionsScreen;
|
||||
import me.jellysquid.mods.sodium.client.gui.SodiumOptionsGUI;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiVideoSettings;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
// FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onGui(GuiScreenEvent.InitGuiEvent.Pre event) {
|
||||
if(event.gui instanceof GuiVideoSettings eventGui) {
|
||||
event.setCanceled(true);
|
||||
if(AngelicaConfig.enableNotFineOptions || GuiScreen.isShiftKeyDown()) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new GuiCustomMenu(eventGui.parentGuiScreen,
|
||||
NotFineGameOptionPages.general(),
|
||||
NotFineGameOptionPages.detail(), NotFineGameOptionPages.atmosphere(),
|
||||
NotFineGameOptionPages.particles(), NotFineGameOptionPages.other()
|
||||
));
|
||||
} else if(!AngelicaConfig.enableReesesSodiumOptions || GuiScreen.isCtrlKeyDown()) {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new SodiumOptionsGUI(eventGui.parentGuiScreen));
|
||||
} else {
|
||||
Minecraft.getMinecraft().displayGuiScreen(new ReeseSodiumVideoOptionsScreen(eventGui.parentGuiScreen));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event) {
|
||||
// Nothing to do here (yet)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
// Nothing to do here (yet)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package me.jellysquid.mods.sodium.proxy;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
|
||||
public class CommonProxy {
|
||||
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
||||
}
|
||||
|
||||
public void init(FMLInitializationEvent event) {}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent event) {}
|
||||
}
|
||||
@@ -9,7 +9,9 @@ import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
@@ -25,7 +27,6 @@ import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
|
||||
import net.coderbot.iris.pipeline.FixedFunctionWorldRenderingPipeline;
|
||||
import net.coderbot.iris.pipeline.PipelineManager;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.shaderpack.DimensionId;
|
||||
import net.coderbot.iris.shaderpack.OptionalBoolean;
|
||||
import net.coderbot.iris.shaderpack.ProgramSet;
|
||||
import net.coderbot.iris.shaderpack.ShaderPack;
|
||||
@@ -389,6 +390,9 @@ public class Iris {
|
||||
// Warm up the threadpool so shader transformations are faster when we need them
|
||||
ShaderTransformExecutor.warmup();
|
||||
|
||||
// Initialize version hoisting pattern based on GL capabilities
|
||||
ShaderTransformer.init();
|
||||
|
||||
PBRTextureManager.INSTANCE.init();
|
||||
|
||||
// Only load the shader pack when we can access OpenGL
|
||||
@@ -408,8 +412,8 @@ public class Iris {
|
||||
// Initialize the pipeline now so that we don't increase world loading time. Just going to guess that
|
||||
// the player is in the overworld.
|
||||
// See: https://github.com/IrisShaders/Iris/issues/323
|
||||
lastDimension = DimensionId.OVERWORLD;
|
||||
Iris.getPipelineManager().preparePipeline(DimensionId.OVERWORLD);
|
||||
lastDimensionName = "Overworld";
|
||||
Iris.getPipelineManager().preparePipeline("Overworld");
|
||||
|
||||
BlockRenderingSettings.INSTANCE.reloadRendererIfRequired();
|
||||
}
|
||||
@@ -713,7 +717,7 @@ public class Iris {
|
||||
// Very important - we need to re-create the pipeline straight away.
|
||||
// https://github.com/IrisShaders/Iris/issues/1330
|
||||
if (Minecraft.getMinecraft().theWorld != null) {
|
||||
Iris.getPipelineManager().preparePipeline(Iris.getCurrentDimension());
|
||||
Iris.getPipelineManager().preparePipeline(Iris.getCurrentDimensionName());
|
||||
|
||||
BlockRenderingSettings.INSTANCE.reloadRendererIfRequired();
|
||||
}
|
||||
@@ -741,44 +745,64 @@ public class Iris {
|
||||
}
|
||||
}
|
||||
|
||||
public static DimensionId lastDimension = null;
|
||||
public static String lastDimensionName = null;
|
||||
public static int lastDimensionId = 0;
|
||||
|
||||
public static DimensionId getCurrentDimension() {
|
||||
/**
|
||||
* Gets the dimension name for the current world.
|
||||
* Returns the dimension name from WorldProvider.getDimensionName() if available.
|
||||
* Falls back to lastDimensionName when no world is loaded.
|
||||
*/
|
||||
public static String getCurrentDimensionName() {
|
||||
final WorldClient level = Minecraft.getMinecraft().theWorld;
|
||||
|
||||
if (level != null) {
|
||||
if (level.provider == null) return DimensionId.OVERWORLD;
|
||||
|
||||
if (level.provider.isHellWorld || level.provider.dimensionId == -1) {
|
||||
return DimensionId.NETHER;
|
||||
} else if (level.provider.dimensionId == 1) {
|
||||
return DimensionId.END;
|
||||
} else {
|
||||
return DimensionId.OVERWORLD;
|
||||
if (level != null && level.provider != null) {
|
||||
String dimensionName = level.provider.getDimensionName();
|
||||
if (dimensionName == null) {
|
||||
dimensionName = "Overworld";
|
||||
logger.warn("WorldProvider.getDimensionName() returned null for dimension ID {}, defaulting to 'Overworld'", level.provider.dimensionId);
|
||||
}
|
||||
lastDimensionName = dimensionName;
|
||||
lastDimensionId = level.provider.dimensionId;
|
||||
return dimensionName;
|
||||
} else {
|
||||
// This prevents us from reloading the shaderpack unless we need to. Otherwise, if the player is in the
|
||||
// nether and quits the game, we might end up reloading the shaders on exit and on entry to the level
|
||||
// This prevents us from reloading the shaderpack unless we need to. Otherwise, if the player is in
|
||||
// another dimension and quits the game, we might end up reloading the shaders on exit and on entry to the level
|
||||
// because the code thinks that the dimension changed.
|
||||
return lastDimension;
|
||||
return lastDimensionName != null ? lastDimensionName : "Overworld";
|
||||
}
|
||||
}
|
||||
|
||||
private static WorldRenderingPipeline createPipeline(DimensionId dimensionId) {
|
||||
/**
|
||||
* Gets the current dimension ID.
|
||||
*/
|
||||
public static int getCurrentDimensionId() {
|
||||
final WorldClient level = Minecraft.getMinecraft().theWorld;
|
||||
if (level != null && level.provider != null) {
|
||||
return level.provider.dimensionId;
|
||||
}
|
||||
return lastDimensionId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a pipeline for a dimension using the dimension name from WorldProvider.getDimensionName().
|
||||
* Supports dimension.properties mappings with wildcard fallback.
|
||||
*/
|
||||
private static WorldRenderingPipeline createPipeline(String dimensionName) {
|
||||
if (currentPack == null) {
|
||||
// Completely disables shader-based rendering
|
||||
return new FixedFunctionWorldRenderingPipeline();
|
||||
}
|
||||
|
||||
final ProgramSet programs = currentPack.getProgramSet(dimensionId);
|
||||
|
||||
final ProgramSet programs = currentPack.getProgramSet(dimensionName);
|
||||
|
||||
try {
|
||||
shaderPackLoadId++;
|
||||
long startTime = System.nanoTime();
|
||||
WorldRenderingPipeline pipeline = new DeferredWorldRenderingPipeline(programs);
|
||||
long endTime = System.nanoTime();
|
||||
logger.info("[Load #{}] Total shaderpack load time for '{}': {} ms", shaderPackLoadId, currentPackName, String.format("%.1f", (endTime - startTime) / 1_000_000.0));
|
||||
logger.info("[Load #{}] Total shaderpack load time for '{}' in dimension '{}': {} ms", shaderPackLoadId, currentPackName, dimensionName, String.format("%.1f", (endTime - startTime) / 1_000_000.0));
|
||||
return pipeline;
|
||||
} catch (Exception e) {
|
||||
logger.error("Failed to create shader rendering pipeline, disabling shaders!", e);
|
||||
@@ -860,14 +884,14 @@ public class Iris {
|
||||
|
||||
private static int getShaderMaterialOverrideId(Block block, int meta) {
|
||||
if (contextHolder == null) {
|
||||
final Object2IntMap<Block> blockMatches = BlockRenderingSettings.INSTANCE.getBlockMatches();
|
||||
if (blockMatches == null) {
|
||||
final Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches = BlockRenderingSettings.INSTANCE.getBlockMetaMatches();
|
||||
if (blockMetaMatches == null) {
|
||||
return -1;
|
||||
}
|
||||
contextHolder = new BlockContextHolder(blockMatches);
|
||||
contextHolder = new BlockContextHolder(blockMetaMatches);
|
||||
|
||||
}
|
||||
contextHolder.set(block, (short) block.getRenderType());
|
||||
contextHolder.set(block, meta, (short) block.getRenderType());
|
||||
return contextHolder.blockId;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@ public class IrisLogging {
|
||||
this.logger.debug(debug);
|
||||
}
|
||||
|
||||
public void debug(String debug, Object... o) {
|
||||
this.logger.debug(debug, o);
|
||||
}
|
||||
|
||||
public void debug(String debug, Throwable t) {
|
||||
this.logger.debug(debug, t);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,39 @@
|
||||
package net.coderbot.iris.block_context;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
/**
|
||||
* Holds block context for shader material ID lookups.
|
||||
*/
|
||||
public class BlockContextHolder {
|
||||
private final Object2IntMap<Block> blockMatches;
|
||||
private final Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches;
|
||||
public int blockId;
|
||||
public short renderType;
|
||||
|
||||
public BlockContextHolder(Object2IntMap<Block> blockMatches) {
|
||||
this.blockMatches = blockMatches;
|
||||
public BlockContextHolder(Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches) {
|
||||
this.blockMetaMatches = blockMetaMatches;
|
||||
this.blockId = -1;
|
||||
this.renderType = -1;
|
||||
}
|
||||
|
||||
public void set(Block block, short renderType) {
|
||||
/**
|
||||
* Set the material ID for a block.
|
||||
* @param block The block
|
||||
* @param meta The block metadata
|
||||
* @param renderType The render type
|
||||
*/
|
||||
public void set(Block block, int meta, short renderType) {
|
||||
Int2IntMap metaMap = this.blockMetaMatches != null ? this.blockMetaMatches.get(block) : null;
|
||||
int id = metaMap != null ? metaMap.get(meta) : -1;
|
||||
|
||||
this.blockId = id;
|
||||
this.renderType = renderType;
|
||||
this.blockId = blockMatches.getOrDefault(block, -1);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.blockId = -1;
|
||||
this.renderType = -1;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package net.coderbot.iris.block_rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap;
|
||||
import net.coderbot.iris.shaderpack.materialmap.BlockEntry;
|
||||
import net.coderbot.iris.shaderpack.materialmap.BlockRenderType;
|
||||
@@ -14,50 +16,63 @@ import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class BlockMaterialMapping {
|
||||
public static Object2IntMap<Block> createBlockStateIdMap(Int2ObjectMap<List<BlockEntry>> blockPropertiesMap) {
|
||||
Object2IntMap<Block> blockMatches = new Object2IntOpenHashMap<>();
|
||||
/**
|
||||
* Creates a two-level map structure for block material IDs.
|
||||
* Based on Iris's BlockState mapping approach adapted for 1.7.10's metadata system.
|
||||
*/
|
||||
public static Reference2ObjectMap<Block, Int2IntMap> createBlockMetaIdMap(Int2ObjectMap<List<BlockEntry>> blockPropertiesMap) {
|
||||
Reference2ObjectMap<Block, Int2IntMap> blockMatches = new Reference2ObjectOpenHashMap<>();
|
||||
|
||||
blockPropertiesMap.forEach((intId, entries) -> {
|
||||
for (BlockEntry entry : entries) {
|
||||
addBlock(entry, blockMatches, intId);
|
||||
addBlockMetas(entry, blockMatches, intId);
|
||||
}
|
||||
});
|
||||
|
||||
return blockMatches;
|
||||
}
|
||||
|
||||
public static Map<Block, RenderLayer> createBlockTypeMap(Map<NamespacedId, BlockRenderType> blockPropertiesMap) {
|
||||
Map<Block, RenderLayer> blockTypeIds = new Reference2ReferenceOpenHashMap<>();
|
||||
public static Map<Block, BlockRenderLayer> createBlockTypeMap(Map<NamespacedId, BlockRenderType> blockPropertiesMap) {
|
||||
Map<Block, BlockRenderLayer> blockTypeIds = new Reference2ReferenceOpenHashMap<>();
|
||||
|
||||
blockPropertiesMap.forEach((id, blockType) -> {
|
||||
ResourceLocation resourceLocation = new ResourceLocation(id.getNamespace(), id.getName());
|
||||
final ResourceLocation resourceLocation = new ResourceLocation(id.getNamespace(), id.getName());
|
||||
final Block block = Block.getBlockFromName(resourceLocation.toString());
|
||||
|
||||
Block block = Block.getBlockFromName(resourceLocation.toString());
|
||||
if (block == null || block == Blocks.air) {
|
||||
return;
|
||||
}
|
||||
|
||||
blockTypeIds.put(block, convertBlockToRenderType(blockType));
|
||||
final BlockRenderLayer layer = convertBlockToRenderLayer(blockType);
|
||||
if (layer != null) {
|
||||
blockTypeIds.put(block, layer);
|
||||
}
|
||||
});
|
||||
|
||||
return blockTypeIds;
|
||||
}
|
||||
|
||||
private static RenderLayer convertBlockToRenderType(BlockRenderType type) {
|
||||
private static BlockRenderLayer convertBlockToRenderLayer(BlockRenderType type) {
|
||||
if (type == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return switch (type) {
|
||||
// Everything renders in cutout or translucent in 1.7.10
|
||||
case SOLID, CUTOUT, CUTOUT_MIPPED -> RenderLayer.cutout();
|
||||
// case SOLID -> RenderLayer.solid();
|
||||
// case CUTOUT_MIPPED -> RenderLayer.cutoutMipped();
|
||||
case TRANSLUCENT -> RenderLayer.translucent();
|
||||
default -> null;
|
||||
};
|
||||
return switch (type) {
|
||||
case SOLID -> BlockRenderLayer.SOLID;
|
||||
case CUTOUT -> BlockRenderLayer.CUTOUT;
|
||||
case CUTOUT_MIPPED -> BlockRenderLayer.CUTOUT_MIPPED;
|
||||
case TRANSLUCENT -> BlockRenderLayer.TRANSLUCENT;
|
||||
};
|
||||
}
|
||||
|
||||
private static void addBlock(BlockEntry entry, Object2IntMap<Block> idMap, int intId) {
|
||||
/**
|
||||
* Adds block+metadata combinations to the material ID map.
|
||||
* Based on Iris's addBlockStates method, adapted for 1.7.10 metadata system.
|
||||
*/
|
||||
private static void addBlockMetas(BlockEntry entry, Reference2ObjectMap<Block, Int2IntMap> idMap, int intId) {
|
||||
final NamespacedId id = entry.getId();
|
||||
final ResourceLocation resourceLocation = new ResourceLocation(id.getNamespace(), id.getName());
|
||||
|
||||
@@ -69,40 +84,25 @@ public class BlockMaterialMapping {
|
||||
return;
|
||||
}
|
||||
|
||||
idMap.put(block, intId);
|
||||
Set<Integer> metas = entry.getMetas();
|
||||
|
||||
// Set<Integer> metas = entry.getMetas();
|
||||
// // All metas match
|
||||
// if (metas.isEmpty()) {
|
||||
// idMap.putIfAbsent(new BlockMatch(block, null), intId);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // A subset of metas match
|
||||
// for(int meta : metas) {
|
||||
// idMap.putIfAbsent(new BlockMatch(block, meta), intId);
|
||||
// }
|
||||
Int2IntMap metaMap = idMap.get(block);
|
||||
if (metaMap == null) {
|
||||
metaMap = new Int2IntOpenHashMap();
|
||||
metaMap.defaultReturnValue(-1);
|
||||
idMap.put(block, metaMap);
|
||||
}
|
||||
|
||||
if (metas.isEmpty()) {
|
||||
// Add all metadata values (0-15) if there aren't any specific ones
|
||||
for (int meta = 0; meta < 16; meta++) {
|
||||
metaMap.putIfAbsent(meta, intId);
|
||||
}
|
||||
} else {
|
||||
// Add only specific metadata values
|
||||
for (int meta : metas) {
|
||||
metaMap.putIfAbsent(meta, intId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We ignore generics here, the actual types don't matter because we just convert
|
||||
// them to strings anyways, and the compiler checks just get in the way.
|
||||
//
|
||||
// If you're able to rewrite this function without SuppressWarnings, feel free.
|
||||
// But otherwise it works fine.
|
||||
// TODO: BlockStateIdMap
|
||||
// @SuppressWarnings({"rawtypes", "unchecked"})
|
||||
// private static boolean checkState(BlockState state, Map<Property<?>, String> expectedValues) {
|
||||
// for (Map.Entry<Property<?>, String> condition : expectedValues.entrySet()) {
|
||||
// Property property = condition.getKey();
|
||||
// String expectedValue = condition.getValue();
|
||||
//
|
||||
// String actualValue = property.getName(state.getValue(property));
|
||||
//
|
||||
// if (!expectedValue.equals(actualValue)) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
package net.coderbot.iris.block_rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
|
||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntFunction;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.shaderpack.materialmap.NamespacedId;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -16,9 +17,10 @@ public class BlockRenderingSettings {
|
||||
|
||||
@Getter
|
||||
private boolean reloadRequired;
|
||||
private Object2IntMap<Block> blockMatches;
|
||||
private Map<Block, RenderLayer> blockTypeIds;
|
||||
private Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches;
|
||||
private Map<Block, BlockRenderLayer> blockTypeIds;
|
||||
private Object2IntFunction<NamespacedId> entityIds;
|
||||
private Object2IntFunction<NamespacedId> itemIds;
|
||||
private float ambientOcclusionLevel;
|
||||
private boolean disableDirectionalShading;
|
||||
private boolean useSeparateAo;
|
||||
@@ -26,7 +28,7 @@ public class BlockRenderingSettings {
|
||||
|
||||
public BlockRenderingSettings() {
|
||||
reloadRequired = false;
|
||||
blockMatches = null;
|
||||
blockMetaMatches = null;
|
||||
blockTypeIds = null;
|
||||
ambientOcclusionLevel = 1.0F;
|
||||
disableDirectionalShading = false;
|
||||
@@ -48,12 +50,12 @@ public class BlockRenderingSettings {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object2IntMap<Block> getBlockMatches() {
|
||||
return blockMatches;
|
||||
public Reference2ObjectMap<Block, Int2IntMap> getBlockMetaMatches() {
|
||||
return blockMetaMatches;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<Block, RenderLayer> getBlockTypeIds() {
|
||||
public Map<Block, BlockRenderLayer> getBlockTypeIds() {
|
||||
return blockTypeIds;
|
||||
}
|
||||
|
||||
@@ -62,16 +64,17 @@ public class BlockRenderingSettings {
|
||||
return entityIds;
|
||||
}
|
||||
|
||||
public void setBlockMatches(Object2IntMap<Block> blockIds) {
|
||||
if (this.blockMatches != null && this.blockMatches.equals(blockIds)) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.reloadRequired = true;
|
||||
this.blockMatches = blockIds;
|
||||
@Nullable
|
||||
public Object2IntFunction<NamespacedId> getItemIds() {
|
||||
return itemIds;
|
||||
}
|
||||
|
||||
public void setBlockTypeIds(Map<Block, RenderLayer> blockTypeIds) {
|
||||
public void setBlockMetaMatches(Reference2ObjectMap<Block, Int2IntMap> blockMetaIds) {
|
||||
this.reloadRequired = true;
|
||||
this.blockMetaMatches = blockMetaIds;
|
||||
}
|
||||
|
||||
public void setBlockTypeIds(Map<Block, BlockRenderLayer> blockTypeIds) {
|
||||
if (this.blockTypeIds != null && this.blockTypeIds.equals(blockTypeIds)) {
|
||||
return;
|
||||
}
|
||||
@@ -85,6 +88,11 @@ public class BlockRenderingSettings {
|
||||
this.entityIds = entityIds;
|
||||
}
|
||||
|
||||
public void setItemIds(Object2IntFunction<NamespacedId> itemIds) {
|
||||
// note: no reload needed, items are rendered every frame.
|
||||
this.itemIds = itemIds;
|
||||
}
|
||||
|
||||
public float getAmbientOcclusionLevel() {
|
||||
return ambientOcclusionLevel;
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@ import net.coderbot.iris.gl.program.ProgramUniforms;
|
||||
import net.coderbot.iris.pipeline.PatchedShaderPrinter;
|
||||
import net.coderbot.iris.pipeline.transform.PatchShaderType;
|
||||
import net.coderbot.iris.rendertarget.RenderTargets;
|
||||
import net.coderbot.iris.gl.state.FogMode;
|
||||
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 +62,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) {
|
||||
@@ -187,7 +147,7 @@ public class CeleritasTerrainPipeline {
|
||||
public ProgramUniforms.Builder initUniforms(int programId) {
|
||||
final ProgramUniforms.Builder uniforms = ProgramUniforms.builder("<celeritas shaders>", programId);
|
||||
|
||||
CommonUniforms.addDynamicUniforms(uniforms);
|
||||
CommonUniforms.addDynamicUniforms(uniforms, FogMode.PER_VERTEX);
|
||||
customUniforms.assignTo(uniforms);
|
||||
|
||||
BuiltinReplacementUniforms.addBuiltinReplacementUniforms(uniforms);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package net.coderbot.iris.celeritas;
|
||||
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.BlockRenderLayer;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.api.IrisShaderProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.IrisExtendedChunkVertexType;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.shadows.ShadowRenderingState;
|
||||
@@ -12,7 +12,6 @@ import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.shader.ChunkShaderInterface;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.terrain.TerrainRenderPass;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.vertex.format.ChunkVertexType;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -62,16 +61,10 @@ public class IrisCeleritasShaderProvider implements IrisShaderProvider {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Map<Block, RenderLayer> getBlockTypeIds() {
|
||||
public Map<Block, BlockRenderLayer> getBlockTypeIds() {
|
||||
return BlockRenderingSettings.INSTANCE.getBlockTypeIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object2IntMap<Block> getBlockMatches() {
|
||||
return BlockRenderingSettings.INSTANCE.getBlockMatches();
|
||||
}
|
||||
|
||||
public void deleteShaders() {
|
||||
overrides.deleteShaders();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class IrisDebugScreenHandler {
|
||||
@SubscribeEvent(priority = EventPriority.LOW)
|
||||
public void onRenderGameOverlayTextEvent(RenderGameOverlayEvent.Text event) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.gameSettings.showDebugInfo) {
|
||||
if (mc.gameSettings.showDebugInfo && !AngelicaConfig.disableF3Additions) {
|
||||
event.right.add(Math.min(event.right.size(), 2), "Direct Buffers: +" + iris$humanReadableByteCountBin(iris$directPool.getMemoryUsed()));
|
||||
|
||||
if (Iris.getIrisConfig().areShadersEnabled()) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package net.coderbot.iris.compat.dh;
|
||||
|
||||
/**
|
||||
* Stub implementation of Distant Horizons compatibility.
|
||||
*/
|
||||
public class DHCompat {
|
||||
public int getDepthTex() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getDepthTexNoTranslucent() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,12 @@ public enum FeatureFlags {
|
||||
COMPUTE_SHADERS(() -> true, RenderSystem::supportsCompute),
|
||||
ENTITY_TRANSLUCENT(() -> true, () -> true),
|
||||
BLOCK_EMISSION_ATTRIBUTE(() -> true, () -> true),
|
||||
CUSTOM_IMAGES(() -> true, RenderSystem::supportsImageLoadStore),
|
||||
SSBO(() -> true, RenderSystem::supportsSSBO),
|
||||
HIGHER_SHADOWCOLOR(() -> true, () -> true),
|
||||
TESSELLATION_SHADERS(() -> true, RenderSystem::supportsTesselation),
|
||||
REVERSED_CULLING(() -> true, () -> true),
|
||||
CAN_DISABLE_WEATHER(() -> true, () -> true),
|
||||
UNKNOWN(() -> false, () -> false);
|
||||
|
||||
private final BooleanSupplier irisRequirement;
|
||||
@@ -53,16 +59,16 @@ public enum FeatureFlags {
|
||||
}
|
||||
|
||||
public static boolean isInvalid(String name) {
|
||||
try {
|
||||
return !FeatureFlags.valueOf(name).isUsable();
|
||||
} catch (IllegalArgumentException e) {
|
||||
return true;
|
||||
}
|
||||
FeatureFlags flag = getValue(name);
|
||||
return flag == UNKNOWN || !flag.isUsable();
|
||||
}
|
||||
|
||||
public static FeatureFlags getValue(String value) {
|
||||
if (value.equalsIgnoreCase("TESSELATION_SHADERS")) {
|
||||
value = "TESSELLATION_SHADERS";
|
||||
}
|
||||
try {
|
||||
return FeatureFlags.valueOf(value);
|
||||
return FeatureFlags.valueOf(value.toUpperCase(java.util.Locale.US));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return FeatureFlags.UNKNOWN;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.coderbot.iris.gl.blending;
|
||||
|
||||
public class AlphaTest {
|
||||
public static final AlphaTest ALWAYS = new AlphaTest(AlphaTestFunction.ALWAYS, 0.0f);
|
||||
|
||||
private final AlphaTestFunction function;
|
||||
private final float reference;
|
||||
|
||||
@@ -16,4 +18,45 @@ public class AlphaTest {
|
||||
public float getReference() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
public String toExpression(String indentation) {
|
||||
return toExpression("gl_FragData[0].a", "iris_currentAlphaTest", indentation);
|
||||
}
|
||||
|
||||
public String toExpression(String alphaAccessor, String alphaThreshold, String indentation) {
|
||||
String expr = function.getExpression();
|
||||
|
||||
if (function == AlphaTestFunction.ALWAYS) {
|
||||
return "// alpha test disabled\n";
|
||||
} else if (function == AlphaTestFunction.NEVER) {
|
||||
return "discard;\n";
|
||||
}
|
||||
|
||||
return indentation + "if (!(" + alphaAccessor + " " + expr + " " + alphaThreshold + ")) {\n" +
|
||||
indentation + " discard;\n" +
|
||||
indentation + "}\n";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((function == null) ? 0 : function.hashCode());
|
||||
result = prime * result + Float.floatToIntBits(reference);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
AlphaTest other = (AlphaTest) obj;
|
||||
if (function != other.function)
|
||||
return false;
|
||||
return Float.floatToIntBits(reference) == Float.floatToIntBits(other.reference);
|
||||
}
|
||||
}
|
||||
@@ -5,33 +5,35 @@ import org.lwjgl.opengl.GL11;
|
||||
import java.util.Optional;
|
||||
|
||||
public enum AlphaTestFunction {
|
||||
NEVER(GL11.GL_NEVER),
|
||||
LESS(GL11.GL_LESS),
|
||||
EQUAL(GL11.GL_EQUAL),
|
||||
LEQUAL(GL11.GL_LEQUAL),
|
||||
GREATER(GL11.GL_GREATER),
|
||||
NOTEQUAL(GL11.GL_NOTEQUAL),
|
||||
GEQUAL(GL11.GL_GEQUAL),
|
||||
ALWAYS(GL11.GL_ALWAYS);
|
||||
NEVER(GL11.GL_NEVER, null),
|
||||
LESS(GL11.GL_LESS, "<"),
|
||||
EQUAL(GL11.GL_EQUAL, "=="),
|
||||
LEQUAL(GL11.GL_LEQUAL, "<="),
|
||||
GREATER(GL11.GL_GREATER, ">"),
|
||||
NOTEQUAL(GL11.GL_NOTEQUAL, "!="),
|
||||
GEQUAL(GL11.GL_GEQUAL, ">="),
|
||||
ALWAYS(GL11.GL_ALWAYS, null);
|
||||
|
||||
private final int glId;
|
||||
private final String expression;
|
||||
|
||||
AlphaTestFunction(int glFormat) {
|
||||
AlphaTestFunction(int glFormat, String expression) {
|
||||
this.glId = glFormat;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
||||
public static Optional<AlphaTestFunction> fromGlId(int glId) {
|
||||
return switch (glId) {
|
||||
case GL11.GL_NEVER -> Optional.of(NEVER);
|
||||
case GL11.GL_LESS -> Optional.of(LESS);
|
||||
case GL11.GL_EQUAL -> Optional.of(EQUAL);
|
||||
case GL11.GL_LEQUAL -> Optional.of(LEQUAL);
|
||||
case GL11.GL_GREATER -> Optional.of(GREATER);
|
||||
case GL11.GL_NOTEQUAL -> Optional.of(NOTEQUAL);
|
||||
case GL11.GL_GEQUAL -> Optional.of(GEQUAL);
|
||||
case GL11.GL_ALWAYS -> Optional.of(ALWAYS);
|
||||
default -> Optional.empty();
|
||||
};
|
||||
return switch (glId) {
|
||||
case GL11.GL_NEVER -> Optional.of(NEVER);
|
||||
case GL11.GL_LESS -> Optional.of(LESS);
|
||||
case GL11.GL_EQUAL -> Optional.of(EQUAL);
|
||||
case GL11.GL_LEQUAL -> Optional.of(LEQUAL);
|
||||
case GL11.GL_GREATER -> Optional.of(GREATER);
|
||||
case GL11.GL_NOTEQUAL -> Optional.of(NOTEQUAL);
|
||||
case GL11.GL_GEQUAL -> Optional.of(GEQUAL);
|
||||
case GL11.GL_ALWAYS -> Optional.of(ALWAYS);
|
||||
default -> Optional.empty();
|
||||
};
|
||||
}
|
||||
|
||||
public static Optional<AlphaTestFunction> fromString(String name) {
|
||||
@@ -54,4 +56,8 @@ public enum AlphaTestFunction {
|
||||
public int getGlId() {
|
||||
return glId;
|
||||
}
|
||||
|
||||
public String getExpression() {
|
||||
return expression;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package net.coderbot.iris.gl.buffer;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
|
||||
public class ShaderStorageBuffer {
|
||||
protected final int index;
|
||||
protected final ShaderStorageInfo info;
|
||||
protected int id;
|
||||
|
||||
public ShaderStorageBuffer(int index, ShaderStorageInfo info) {
|
||||
this.id = RenderSystem.createBuffers();
|
||||
GLDebug.nameObject(GL43.GL_BUFFER, id, "SSBO " + index);
|
||||
this.index = index;
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public final int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public final long getSize() {
|
||||
return info.size();
|
||||
}
|
||||
|
||||
protected void destroy() {
|
||||
RenderSystem.bindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, index, 0);
|
||||
RenderSystem.deleteBuffers(id);
|
||||
}
|
||||
|
||||
public void bind() {
|
||||
RenderSystem.bindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, index, id);
|
||||
}
|
||||
|
||||
public void resizeIfRelative(int width, int height) {
|
||||
if (!info.relative()) return;
|
||||
|
||||
RenderSystem.deleteBuffers(id);
|
||||
int newId = GL15.glGenBuffers();
|
||||
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, newId);
|
||||
|
||||
// Calculation time
|
||||
int newWidth = (int) (width * info.scaleX());
|
||||
int newHeight = (int) (height * info.scaleY());
|
||||
int finalSize = (newHeight * newWidth) * info.size();
|
||||
RenderSystem.bufferStorage(GL43.GL_SHADER_STORAGE_BUFFER, finalSize, 0);
|
||||
RenderSystem.clearBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, GL30.GL_R8, 0, finalSize, GL11.GL_RED, GL11.GL_BYTE, new int[]{0});
|
||||
RenderSystem.bindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, index, newId);
|
||||
id = newId;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package net.coderbot.iris.gl.buffer;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
|
||||
import net.coderbot.iris.gl.sampler.SamplerLimits;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class ShaderStorageBufferHolder {
|
||||
private int cachedWidth;
|
||||
private int cachedHeight;
|
||||
private ShaderStorageBuffer[] buffers;
|
||||
private boolean destroyed;
|
||||
|
||||
public ShaderStorageBufferHolder(Int2ObjectArrayMap<ShaderStorageInfo> overrides, int width, int height) {
|
||||
destroyed = false;
|
||||
cachedWidth = width;
|
||||
cachedHeight = height;
|
||||
buffers = new ShaderStorageBuffer[Collections.max(overrides.keySet()) + 1];
|
||||
overrides.forEach((index, bufferInfo) -> {
|
||||
if (bufferInfo.size() > RenderSystem.getVRAM()) {
|
||||
throw new OutOfVideoMemoryError("We only have " + toMib(RenderSystem.getVRAM()) + "MiB of RAM to work with, but the pack is requesting " + bufferInfo.size() + "! Can't continue.");
|
||||
}
|
||||
|
||||
if (index > SamplerLimits.get().getMaxShaderStorageUnits()) {
|
||||
throw new IllegalStateException("We don't have enough SSBO units??? (index: " + index + ", max: " + SamplerLimits.get().getMaxShaderStorageUnits());
|
||||
}
|
||||
|
||||
buffers[index] = new ShaderStorageBuffer(index, bufferInfo);
|
||||
int buffer = buffers[index].getId();
|
||||
|
||||
if (bufferInfo.relative()) {
|
||||
buffers[index].resizeIfRelative(width, height);
|
||||
} else {
|
||||
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, buffer);
|
||||
RenderSystem.bufferStorage(GL43.GL_SHADER_STORAGE_BUFFER, bufferInfo.size(), 0);
|
||||
RenderSystem.clearBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, GL30.GL_R8, 0, bufferInfo.size(), GL11.GL_RED, GL11.GL_BYTE, new int[]{0});
|
||||
RenderSystem.bindBufferBase(GL43.GL_SHADER_STORAGE_BUFFER, index, buffer);
|
||||
}
|
||||
});
|
||||
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
|
||||
}
|
||||
|
||||
private static long toMib(long x) {
|
||||
return x / 1024L / 1024L;
|
||||
}
|
||||
|
||||
public void hasResizedScreen(int width, int height) {
|
||||
if (width != cachedWidth || height != cachedHeight) {
|
||||
cachedWidth = width;
|
||||
cachedHeight = height;
|
||||
for (ShaderStorageBuffer buffer : buffers) {
|
||||
if (buffer != null) {
|
||||
buffer.resizeIfRelative(width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setupBuffers() {
|
||||
if (destroyed) {
|
||||
throw new IllegalStateException("Tried to use destroyed buffer objects");
|
||||
}
|
||||
|
||||
for (ShaderStorageBuffer buffer : buffers) {
|
||||
if (buffer != null) {
|
||||
buffer.bind();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getBufferIndex(int index) {
|
||||
if (buffers.length < index || buffers[index] == null)
|
||||
throw new RuntimeException("Tried to query a buffer for indirect dispatch that doesn't exist!");
|
||||
|
||||
return buffers[index].getId();
|
||||
}
|
||||
|
||||
public void destroyBuffers() {
|
||||
for (ShaderStorageBuffer buffer : buffers) {
|
||||
if (buffer != null) {
|
||||
buffer.destroy();
|
||||
}
|
||||
}
|
||||
buffers = null;
|
||||
destroyed = true;
|
||||
}
|
||||
|
||||
private static class OutOfVideoMemoryError extends RuntimeException {
|
||||
public OutOfVideoMemoryError(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package net.coderbot.iris.gl.buffer;
|
||||
|
||||
public record ShaderStorageInfo(int size, boolean relative, float scaleX, float scaleY) {
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class GlFramebuffer extends GlResource {
|
||||
|
||||
@Override
|
||||
protected void destroyInternal() {
|
||||
OpenGlHelper.func_153184_g/*glDeleteFramebuffers*/(getGlId());
|
||||
OpenGlHelper.func_153174_h/*glDeleteFramebuffers*/(getGlId());
|
||||
}
|
||||
|
||||
public boolean isComplete() {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.coderbot.iris.gl.framebuffer;
|
||||
|
||||
public record ViewportData(float scale, float viewportX, float viewportY) {
|
||||
private static final ViewportData DEFAULT = new ViewportData(1.0f, 0.0f, 0.0f);
|
||||
|
||||
public static ViewportData defaultValue() {
|
||||
return DEFAULT;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package net.coderbot.iris.gl.image;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import net.coderbot.iris.gl.texture.InternalTextureFormat;
|
||||
import net.coderbot.iris.gl.texture.PixelFormat;
|
||||
import net.coderbot.iris.gl.texture.PixelType;
|
||||
import net.coderbot.iris.gl.texture.TextureType;
|
||||
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||
import org.embeddedt.embeddium.impl.gl.debug.GLDebug;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
|
||||
public class GlImage extends GlObject {
|
||||
protected final String name;
|
||||
protected final String samplerName;
|
||||
protected final TextureType target;
|
||||
protected final PixelFormat format;
|
||||
protected final InternalTextureFormat internalTextureFormat;
|
||||
protected final PixelType pixelType;
|
||||
private final boolean clear;
|
||||
|
||||
public GlImage(String name, String samplerName, TextureType target, PixelFormat format, InternalTextureFormat internalFormat, PixelType pixelType, boolean clear, int width, int height, int depth) {
|
||||
this.setHandle(RenderSystem.createTexture(target.getGlType()));
|
||||
|
||||
this.name = name;
|
||||
this.samplerName = samplerName;
|
||||
this.target = target;
|
||||
this.format = format;
|
||||
this.internalTextureFormat = internalFormat;
|
||||
this.pixelType = pixelType;
|
||||
this.clear = clear;
|
||||
|
||||
GLDebug.nameObject(GL11.GL_TEXTURE, handle(), name);
|
||||
|
||||
GL11.glBindTexture(target.getGlType(), handle());
|
||||
target.apply(handle(), width, height, depth, internalFormat.getGlFormat(), format.getGlFormat(), pixelType.getGlFormat(), null);
|
||||
|
||||
int texture = handle();
|
||||
|
||||
setup(texture, width, height, depth);
|
||||
|
||||
GL11.glBindTexture(target.getGlType(), 0);
|
||||
}
|
||||
|
||||
protected void setup(int texture, int width, int height, int depth) {
|
||||
boolean isInteger = internalTextureFormat.getPixelFormat().isInteger();
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL11.GL_TEXTURE_MIN_FILTER, isInteger ? GL11.GL_NEAREST : GL11.GL_LINEAR);
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL11.GL_TEXTURE_MAG_FILTER, isInteger ? GL11.GL_NEAREST : GL11.GL_LINEAR);
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
|
||||
|
||||
if (height > 0) {
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
if (depth > 0) {
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL12.GL_TEXTURE_WRAP_R, GL12.GL_CLAMP_TO_EDGE);
|
||||
}
|
||||
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL12.GL_TEXTURE_MAX_LEVEL, 0);
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL12.GL_TEXTURE_MIN_LOD, 0);
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL12.GL_TEXTURE_MAX_LOD, 0);
|
||||
RenderSystem.texParameterf(texture, target.getGlType(), GL14.GL_TEXTURE_LOD_BIAS, 0.0F);
|
||||
|
||||
RenderSystem.clearTexImage(texture, target.getGlType(), 0, format.getGlFormat(), pixelType.getGlFormat());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getSamplerName() {
|
||||
return samplerName;
|
||||
}
|
||||
|
||||
public TextureType getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public boolean shouldClear() {
|
||||
return clear;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return handle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the texture to zero. Called each frame for images that need clearing.
|
||||
*/
|
||||
public void clear() {
|
||||
RenderSystem.clearTexImage(handle(), target.getGlType(), 0, format.getGlFormat(), pixelType.getGlFormat());
|
||||
}
|
||||
|
||||
/**
|
||||
* This makes the image aware of a new render target. Depending on the image's properties, it may not follow these targets.
|
||||
*
|
||||
* @param width The width of the main render target.
|
||||
* @param height The height of the main render target.
|
||||
*/
|
||||
public void updateNewSize(int width, int height) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void destroyInternal() {
|
||||
GLStateManager.glDeleteTextures(handle());
|
||||
}
|
||||
|
||||
public InternalTextureFormat getInternalFormat() {
|
||||
return internalTextureFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlImage name " + name + " format " + format + "internalformat " + internalTextureFormat + " pixeltype " + pixelType;
|
||||
}
|
||||
|
||||
public PixelFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
public PixelType getPixelType() {
|
||||
return pixelType;
|
||||
}
|
||||
|
||||
public static class Relative extends GlImage {
|
||||
|
||||
private final float relativeHeight;
|
||||
private final float relativeWidth;
|
||||
|
||||
public Relative(String name, String samplerName, PixelFormat format, InternalTextureFormat internalFormat, PixelType pixelType, boolean clear, float relativeWidth, float relativeHeight, int currentWidth, int currentHeight) {
|
||||
super(name, samplerName, TextureType.TEXTURE_2D, format, internalFormat, pixelType, clear, (int) (currentWidth * relativeWidth), (int) (currentHeight * relativeHeight), 0);
|
||||
|
||||
this.relativeWidth = relativeWidth;
|
||||
this.relativeHeight = relativeHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNewSize(int width, int height) {
|
||||
GL11.glBindTexture(target.getGlType(), handle());
|
||||
target.apply(handle(), (int) (width * relativeWidth), (int) (height * relativeHeight), 0, internalTextureFormat.getGlFormat(), format.getGlFormat(), pixelType.getGlFormat(), null);
|
||||
|
||||
int texture = handle();
|
||||
|
||||
setup(texture, width, height, 0);
|
||||
|
||||
GL11.glBindTexture(target.getGlType(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,6 @@ public class ImageBinding {
|
||||
public void update() {
|
||||
// We can assume that image bindings are supported here as either the EXT extension or 4.2 core, as otherwise ImageLimits
|
||||
// would report that zero image units are supported.
|
||||
RenderSystem.bindImageTexture(imageUnit, textureID.getAsInt(), 0, false, 0, GL15.GL_READ_WRITE, internalFormat);
|
||||
RenderSystem.bindImageTexture(imageUnit, textureID.getAsInt(), 0, true, 0, GL15.GL_READ_WRITE, internalFormat);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.coderbot.iris.gl.image;
|
||||
|
||||
import net.coderbot.iris.gl.texture.InternalTextureFormat;
|
||||
import net.coderbot.iris.gl.texture.PixelFormat;
|
||||
import net.coderbot.iris.gl.texture.PixelType;
|
||||
import net.coderbot.iris.gl.texture.TextureType;
|
||||
|
||||
public record ImageInformation(String name, String samplerName, TextureType target, PixelFormat format,
|
||||
InternalTextureFormat internalTextureFormat,
|
||||
PixelType type, int width, int height, int depth, boolean clear, boolean isRelative,
|
||||
float relativeWidth, float relativeHeight) {
|
||||
}
|
||||
@@ -4,10 +4,12 @@ import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gl.GlResource;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.shaderpack.FilledIndirectPointer;
|
||||
import org.joml.Vector2f;
|
||||
import org.joml.Vector3i;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL42;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
@@ -18,8 +20,8 @@ public final class ComputeProgram extends GlResource {
|
||||
private final ProgramImages images;
|
||||
private Vector3i absoluteWorkGroups;
|
||||
private Vector2f relativeWorkGroups;
|
||||
// private int[] localSize;
|
||||
private final IntBuffer localSizeBuffer;
|
||||
private FilledIndirectPointer indirectPointer;
|
||||
private final IntBuffer localSizeBuffer;
|
||||
private float cachedWidth;
|
||||
private float cachedHeight;
|
||||
private Vector3i cachedWorkGroups;
|
||||
@@ -34,19 +36,21 @@ public final class ComputeProgram extends GlResource {
|
||||
this.images = images;
|
||||
}
|
||||
|
||||
public void setWorkGroupInfo(Vector2f relativeWorkGroups, Vector3i absoluteWorkGroups) {
|
||||
public void setWorkGroupInfo(Vector2f relativeWorkGroups, Vector3i absoluteWorkGroups, FilledIndirectPointer indirectPointer) {
|
||||
this.relativeWorkGroups = relativeWorkGroups;
|
||||
this.absoluteWorkGroups = absoluteWorkGroups;
|
||||
this.indirectPointer = indirectPointer;
|
||||
}
|
||||
|
||||
public Vector3i getWorkGroups(float width, float height) {
|
||||
if (indirectPointer != null) return null;
|
||||
|
||||
if (cachedWidth != width || cachedHeight != height || cachedWorkGroups == null) {
|
||||
this.cachedWidth = width;
|
||||
this.cachedHeight = height;
|
||||
if (this.absoluteWorkGroups != null) {
|
||||
this.cachedWorkGroups = this.absoluteWorkGroups;
|
||||
} else if (relativeWorkGroups != null) {
|
||||
// TODO: This is my best guess at what Optifine does. Can this be confirmed?
|
||||
// Do not use actual localSize here, apparently that's not what we want.
|
||||
this.cachedWorkGroups = new Vector3i((int) Math.ceil(Math.ceil((width * relativeWorkGroups.x)) / localSizeBuffer.get(0)), (int) Math.ceil(Math.ceil((height * relativeWorkGroups.y)) / localSizeBuffer.get(1)), 1);
|
||||
} else {
|
||||
@@ -67,10 +71,15 @@ public final class ComputeProgram extends GlResource {
|
||||
|
||||
public void dispatch(float width, float height) {
|
||||
if (!Iris.getPipelineManager().getPipeline().map(WorldRenderingPipeline::allowConcurrentCompute).orElse(false)) {
|
||||
RenderSystem.memoryBarrier(40);
|
||||
RenderSystem.memoryBarrier(GL42.GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL42.GL_TEXTURE_FETCH_BARRIER_BIT | GL43.GL_SHADER_STORAGE_BARRIER_BIT);
|
||||
}
|
||||
|
||||
RenderSystem.dispatchCompute(getWorkGroups(width, height));
|
||||
if (indirectPointer != null) {
|
||||
RenderSystem.bindBuffer(GL43.GL_DISPATCH_INDIRECT_BUFFER, indirectPointer.buffer());
|
||||
RenderSystem.dispatchComputeIndirect(indirectPointer.offset());
|
||||
} else {
|
||||
RenderSystem.dispatchCompute(getWorkGroups(width, height));
|
||||
}
|
||||
}
|
||||
|
||||
public static void unbind() {
|
||||
|
||||
@@ -3,12 +3,14 @@ package net.coderbot.iris.gl.program;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import net.coderbot.iris.gl.image.ImageHolder;
|
||||
import net.coderbot.iris.gl.sampler.GlSampler;
|
||||
import net.coderbot.iris.gl.sampler.SamplerHolder;
|
||||
import net.coderbot.iris.gl.shader.GlShader;
|
||||
import net.coderbot.iris.gl.shader.ProgramCreator;
|
||||
import net.coderbot.iris.gl.shader.ShaderType;
|
||||
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
|
||||
import net.coderbot.iris.gl.texture.InternalTextureFormat;
|
||||
import net.coderbot.iris.gl.texture.TextureType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
@@ -32,36 +34,31 @@ public class ProgramBuilder extends ProgramUniforms.Builder implements SamplerHo
|
||||
|
||||
public static ProgramBuilder begin(String name, @Nullable String vertexSource, @Nullable String geometrySource,
|
||||
@Nullable String fragmentSource, ImmutableSet<Integer> reservedTextureUnits) {
|
||||
GlShader vertex;
|
||||
GlShader geometry;
|
||||
GlShader fragment;
|
||||
return begin(name, vertexSource, geometrySource, null, null, fragmentSource, reservedTextureUnits);
|
||||
}
|
||||
|
||||
vertex = buildShader(ShaderType.VERTEX, name + ".vsh", vertexSource);
|
||||
public static ProgramBuilder begin(String name, @Nullable String vertexSource, @Nullable String geometrySource,
|
||||
@Nullable String tessControlSource, @Nullable String tessEvalSource,
|
||||
@Nullable String fragmentSource, ImmutableSet<Integer> reservedTextureUnits) {
|
||||
GlShader vertex = buildShader(ShaderType.VERTEX, name + ".vsh", vertexSource);
|
||||
GlShader geometry = geometrySource != null ? buildShader(ShaderType.GEOMETRY, name + ".gsh", geometrySource) : null;
|
||||
GlShader tessControl = tessControlSource != null ? buildShader(ShaderType.TESSELATION_CONTROL, name + ".tcs", tessControlSource) : null;
|
||||
GlShader tessEval = tessEvalSource != null ? buildShader(ShaderType.TESSELATION_EVAL, name + ".tes", tessEvalSource) : null;
|
||||
GlShader fragment = buildShader(ShaderType.FRAGMENT, name + ".fsh", fragmentSource);
|
||||
|
||||
if (geometrySource != null) {
|
||||
geometry = buildShader(ShaderType.GEOMETRY, name + ".gsh", geometrySource);
|
||||
} else {
|
||||
geometry = null;
|
||||
java.util.List<GlShader> shaders = new java.util.ArrayList<>();
|
||||
shaders.add(vertex);
|
||||
if (geometry != null) shaders.add(geometry);
|
||||
if (tessControl != null) shaders.add(tessControl);
|
||||
if (tessEval != null) shaders.add(tessEval);
|
||||
shaders.add(fragment);
|
||||
|
||||
int programId = ProgramCreator.create(name, shaders.toArray(new GlShader[0]));
|
||||
|
||||
for (GlShader shader : shaders) {
|
||||
shader.destroy();
|
||||
}
|
||||
|
||||
fragment = buildShader(ShaderType.FRAGMENT, name + ".fsh", fragmentSource);
|
||||
|
||||
int programId;
|
||||
|
||||
if (geometry != null) {
|
||||
programId = ProgramCreator.create(name, vertex, geometry, fragment);
|
||||
} else {
|
||||
programId = ProgramCreator.create(name, vertex, fragment);
|
||||
}
|
||||
|
||||
vertex.destroy();
|
||||
|
||||
if (geometry != null) {
|
||||
geometry.destroy();
|
||||
}
|
||||
|
||||
fragment.destroy();
|
||||
|
||||
return new ProgramBuilder(name, programId, reservedTextureUnits);
|
||||
}
|
||||
|
||||
@@ -106,17 +103,18 @@ public class ProgramBuilder extends ProgramUniforms.Builder implements SamplerHo
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDefaultSampler(IntSupplier sampler, String... names) {
|
||||
return samplers.addDefaultSampler(sampler, names);
|
||||
public boolean addDefaultSampler(TextureType type, IntSupplier texture, ValueUpdateNotifier notifier, GlSampler sampler, String... names) {
|
||||
return samplers.addDefaultSampler(type, texture, notifier, sampler, names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDynamicSampler(IntSupplier sampler, String... names) {
|
||||
return samplers.addDynamicSampler(sampler, names);
|
||||
public boolean addDynamicSampler(TextureType type, IntSupplier texture, GlSampler sampler, String... names) {
|
||||
return samplers.addDynamicSampler(type, texture, sampler, names);
|
||||
}
|
||||
|
||||
public boolean addDynamicSampler(IntSupplier sampler, ValueUpdateNotifier notifier, String... names) {
|
||||
return samplers.addDynamicSampler(sampler, notifier, names);
|
||||
@Override
|
||||
public boolean addDynamicSampler(TextureType type, IntSupplier texture, ValueUpdateNotifier notifier, GlSampler sampler, String... names) {
|
||||
return samplers.addDynamicSampler(type, texture, notifier, sampler, names);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,10 +5,13 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import net.coderbot.iris.gl.sampler.GlSampler;
|
||||
import net.coderbot.iris.gl.sampler.SamplerBinding;
|
||||
import net.coderbot.iris.gl.sampler.SamplerHolder;
|
||||
import net.coderbot.iris.gl.sampler.SamplerLimits;
|
||||
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
|
||||
import net.coderbot.iris.gl.texture.TextureAccess;
|
||||
import net.coderbot.iris.gl.texture.TextureType;
|
||||
import net.coderbot.iris.shaderpack.PackRenderTargetDirectives;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
|
||||
@@ -73,11 +76,11 @@ public class ProgramSamplers {
|
||||
return new Builder(program, reservedTextureUnits);
|
||||
}
|
||||
|
||||
public static CustomTextureSamplerInterceptor customTextureSamplerInterceptor(SamplerHolder samplerHolder, Object2ObjectMap<String, IntSupplier> customTextureIds) {
|
||||
public static CustomTextureSamplerInterceptor customTextureSamplerInterceptor(SamplerHolder samplerHolder, Object2ObjectMap<String, TextureAccess> customTextureIds) {
|
||||
return customTextureSamplerInterceptor(samplerHolder, customTextureIds, ImmutableSet.of());
|
||||
}
|
||||
|
||||
public static CustomTextureSamplerInterceptor customTextureSamplerInterceptor(SamplerHolder samplerHolder, Object2ObjectMap<String, IntSupplier> customTextureIds, ImmutableSet<Integer> flippedAtLeastOnceSnapshot) {
|
||||
public static CustomTextureSamplerInterceptor customTextureSamplerInterceptor(SamplerHolder samplerHolder, Object2ObjectMap<String, TextureAccess> customTextureIds, ImmutableSet<Integer> flippedAtLeastOnceSnapshot) {
|
||||
return new CustomTextureSamplerInterceptor(samplerHolder, customTextureIds, flippedAtLeastOnceSnapshot);
|
||||
}
|
||||
|
||||
@@ -145,35 +148,31 @@ public class ProgramSamplers {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDefaultSampler(IntSupplier sampler, String... names) {
|
||||
public boolean addDefaultSampler(TextureType type, IntSupplier texture, ValueUpdateNotifier notifier, GlSampler sampler, String... names) {
|
||||
if (nextUnit != 0) {
|
||||
// TODO: Relax this restriction!
|
||||
throw new IllegalStateException("Texture unit 0 is already used.");
|
||||
}
|
||||
|
||||
return addDynamicSampler(sampler, true, null, names);
|
||||
if (notifier != null) {
|
||||
notifiersToReset.add(notifier);
|
||||
}
|
||||
|
||||
return addDynamicSampler(type, texture, sampler, true, notifier, names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a sampler
|
||||
* @return false if this sampler is not active, true if at least one of the names referred to an active sampler
|
||||
*/
|
||||
@Override
|
||||
public boolean addDynamicSampler(IntSupplier sampler, String... names) {
|
||||
return addDynamicSampler(sampler, false, null, names);
|
||||
public boolean addDynamicSampler(TextureType type, IntSupplier texture, GlSampler sampler, String... names) {
|
||||
return addDynamicSampler(type, texture, sampler, false, null, names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a sampler
|
||||
* @return false if this sampler is not active, true if at least one of the names referred to an active sampler
|
||||
*/
|
||||
@Override
|
||||
public boolean addDynamicSampler(IntSupplier sampler, ValueUpdateNotifier notifier, String... names) {
|
||||
public boolean addDynamicSampler(TextureType type, IntSupplier texture, ValueUpdateNotifier notifier, GlSampler sampler, String... names) {
|
||||
notifiersToReset.add(notifier);
|
||||
return addDynamicSampler(sampler, false, notifier, names);
|
||||
return addDynamicSampler(type, texture, sampler, false, notifier, names);
|
||||
}
|
||||
|
||||
private boolean addDynamicSampler(IntSupplier sampler, boolean used, ValueUpdateNotifier notifier, String... names) {
|
||||
private boolean addDynamicSampler(TextureType type, IntSupplier texture, GlSampler sampler, boolean used, ValueUpdateNotifier notifier, String... names) {
|
||||
for (String name : names) {
|
||||
int location = RenderSystem.getUniformLocation(program, name);
|
||||
|
||||
@@ -187,8 +186,6 @@ public class ProgramSamplers {
|
||||
throw new IllegalStateException("No more available texture units while activating sampler " + name);
|
||||
}
|
||||
|
||||
//System.out.println("Binding dynamic sampler " + name + " to texture unit " + nextUnit);
|
||||
|
||||
// Set up this sampler uniform to use this particular texture unit.
|
||||
calls.add(new GlUniform1iCall(location, nextUnit));
|
||||
|
||||
@@ -200,7 +197,7 @@ public class ProgramSamplers {
|
||||
return false;
|
||||
}
|
||||
|
||||
samplers.add(new SamplerBinding(nextUnit, sampler, notifier));
|
||||
samplers.add(new SamplerBinding(type, nextUnit, texture, sampler, notifier));
|
||||
|
||||
remainingUnits -= 1;
|
||||
nextUnit += 1;
|
||||
@@ -209,8 +206,6 @@ public class ProgramSamplers {
|
||||
nextUnit += 1;
|
||||
}
|
||||
|
||||
//System.out.println("The next unit is " + nextUnit + ", there are " + remainingUnits + " units remaining.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -221,10 +216,10 @@ public class ProgramSamplers {
|
||||
|
||||
public static final class CustomTextureSamplerInterceptor implements SamplerHolder {
|
||||
private final SamplerHolder samplerHolder;
|
||||
private final Object2ObjectMap<String, IntSupplier> customTextureIds;
|
||||
private final Object2ObjectMap<String, TextureAccess> customTextureIds;
|
||||
private final ImmutableSet<String> deactivatedOverrides;
|
||||
|
||||
private CustomTextureSamplerInterceptor(SamplerHolder samplerHolder, Object2ObjectMap<String, IntSupplier> customTextureIds, ImmutableSet<Integer> flippedAtLeastOnceSnapshot) {
|
||||
private CustomTextureSamplerInterceptor(SamplerHolder samplerHolder, Object2ObjectMap<String, TextureAccess> customTextureIds, ImmutableSet<Integer> flippedAtLeastOnceSnapshot) {
|
||||
this.samplerHolder = samplerHolder;
|
||||
this.customTextureIds = customTextureIds;
|
||||
|
||||
@@ -244,7 +239,7 @@ public class ProgramSamplers {
|
||||
private IntSupplier getOverride(IntSupplier existing, String... names) {
|
||||
for (String name : names) {
|
||||
if (customTextureIds.containsKey(name) && !deactivatedOverrides.contains(name)) {
|
||||
return customTextureIds.get(name);
|
||||
return customTextureIds.get(name).getTextureId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,24 +267,21 @@ public class ProgramSamplers {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDefaultSampler(IntSupplier sampler, String... names) {
|
||||
sampler = getOverride(sampler, names);
|
||||
|
||||
return samplerHolder.addDefaultSampler(sampler, names);
|
||||
public boolean addDefaultSampler(TextureType type, IntSupplier texture, ValueUpdateNotifier notifier, GlSampler sampler, String... names) {
|
||||
texture = getOverride(texture, names);
|
||||
return samplerHolder.addDefaultSampler(type, texture, notifier, sampler, names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDynamicSampler(IntSupplier sampler, String... names) {
|
||||
sampler = getOverride(sampler, names);
|
||||
|
||||
return samplerHolder.addDynamicSampler(sampler, names);
|
||||
public boolean addDynamicSampler(TextureType type, IntSupplier texture, GlSampler sampler, String... names) {
|
||||
texture = getOverride(texture, names);
|
||||
return samplerHolder.addDynamicSampler(type, texture, sampler, names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDynamicSampler(IntSupplier sampler, ValueUpdateNotifier notifier, String... names) {
|
||||
sampler = getOverride(sampler, names);
|
||||
|
||||
return samplerHolder.addDynamicSampler(sampler, notifier, names);
|
||||
public boolean addDynamicSampler(TextureType type, IntSupplier texture, ValueUpdateNotifier notifier, GlSampler sampler, String... names) {
|
||||
texture = getOverride(texture, names);
|
||||
return samplerHolder.addDynamicSampler(type, texture, notifier, sampler, names);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.coderbot.iris.gl.sampler;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
public class GlSampler extends GlObject {
|
||||
public GlSampler(boolean linear, boolean mipmapped, boolean shadow, boolean hardwareShadow) {
|
||||
if (!RenderSystem.supportsSamplerObjects()) {
|
||||
this.setHandle(0);
|
||||
return;
|
||||
}
|
||||
|
||||
this.setHandle(RenderSystem.genSampler());
|
||||
|
||||
RenderSystem.samplerParameteri(getId(), GL11.GL_TEXTURE_MIN_FILTER, linear ? GL11.GL_LINEAR : GL11.GL_NEAREST);
|
||||
RenderSystem.samplerParameteri(getId(), GL11.GL_TEXTURE_MAG_FILTER, linear ? GL11.GL_LINEAR : GL11.GL_NEAREST);
|
||||
RenderSystem.samplerParameteri(getId(), GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
|
||||
RenderSystem.samplerParameteri(getId(), GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
|
||||
|
||||
if (mipmapped) {
|
||||
RenderSystem.samplerParameteri(getId(), GL11.GL_TEXTURE_MIN_FILTER, linear ? GL11.GL_LINEAR_MIPMAP_LINEAR : GL11.GL_NEAREST_MIPMAP_NEAREST);
|
||||
}
|
||||
|
||||
if (hardwareShadow) {
|
||||
RenderSystem.samplerParameteri(getId(), GL14.GL_TEXTURE_COMPARE_MODE, GL30.GL_COMPARE_REF_TO_TEXTURE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void destroyInternal() {
|
||||
RenderSystem.destroySampler(handle());
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return handle();
|
||||
}
|
||||
}
|
||||
@@ -2,17 +2,22 @@ package net.coderbot.iris.gl.sampler;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
|
||||
import net.coderbot.iris.gl.texture.TextureType;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
public class SamplerBinding {
|
||||
private final TextureType textureType;
|
||||
private final int textureUnit;
|
||||
private final IntSupplier texture;
|
||||
private final int sampler;
|
||||
private final ValueUpdateNotifier notifier;
|
||||
|
||||
public SamplerBinding(int textureUnit, IntSupplier texture, ValueUpdateNotifier notifier) {
|
||||
public SamplerBinding(TextureType type, int textureUnit, IntSupplier texture, GlSampler sampler, ValueUpdateNotifier notifier) {
|
||||
this.textureType = type;
|
||||
this.textureUnit = textureUnit;
|
||||
this.texture = texture;
|
||||
this.sampler = sampler == null ? 0 : sampler.getId();
|
||||
this.notifier = notifier;
|
||||
}
|
||||
|
||||
@@ -25,6 +30,7 @@ public class SamplerBinding {
|
||||
}
|
||||
|
||||
private void updateSampler() {
|
||||
RenderSystem.bindTextureToUnit(textureUnit, texture.getAsInt());
|
||||
RenderSystem.bindSamplerToUnit(textureUnit, sampler);
|
||||
RenderSystem.bindTextureToUnit(textureType.getGlType(), textureUnit, texture.getAsInt());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.coderbot.iris.gl.sampler;
|
||||
|
||||
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
|
||||
import net.coderbot.iris.gl.texture.TextureType;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
@@ -15,7 +16,25 @@ public interface SamplerHolder {
|
||||
* Throws an exception if texture unit 0 is already allocated or reserved in some way. Do not call this
|
||||
* function after calls to addDynamicSampler, it must be called before any calls to addDynamicSampler.
|
||||
*/
|
||||
boolean addDefaultSampler(IntSupplier sampler, String... names);
|
||||
boolean addDynamicSampler(IntSupplier sampler, String... names);
|
||||
boolean addDynamicSampler(IntSupplier sampler, ValueUpdateNotifier notifier, String... names);
|
||||
default boolean addDefaultSampler(IntSupplier texture, String... names) {
|
||||
return addDefaultSampler(TextureType.TEXTURE_2D, texture, null, null, names);
|
||||
}
|
||||
|
||||
boolean addDefaultSampler(TextureType type, IntSupplier texture, ValueUpdateNotifier notifier, GlSampler sampler, String... names);
|
||||
|
||||
default boolean addDynamicSampler(IntSupplier texture, String... names) {
|
||||
return addDynamicSampler(TextureType.TEXTURE_2D, texture, null, names);
|
||||
}
|
||||
|
||||
default boolean addDynamicSampler(TextureType type, IntSupplier texture, String... names) {
|
||||
return addDynamicSampler(type, texture, null, names);
|
||||
}
|
||||
|
||||
boolean addDynamicSampler(TextureType type, IntSupplier texture, GlSampler sampler, String... names);
|
||||
|
||||
default boolean addDynamicSampler(IntSupplier texture, ValueUpdateNotifier notifier, String... names) {
|
||||
return addDynamicSampler(TextureType.TEXTURE_2D, texture, notifier, null, names);
|
||||
}
|
||||
|
||||
boolean addDynamicSampler(TextureType type, IntSupplier texture, ValueUpdateNotifier notifier, GlSampler sampler, String... names);
|
||||
}
|
||||
@@ -1,16 +1,28 @@
|
||||
package net.coderbot.iris.gl.sampler;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
|
||||
public class SamplerLimits {
|
||||
private static SamplerLimits instance;
|
||||
private final int maxTextureUnits;
|
||||
private final int maxDrawBuffers;
|
||||
private static SamplerLimits instance;
|
||||
private final int maxShaderStorageUnits;
|
||||
|
||||
private SamplerLimits() {
|
||||
this.maxTextureUnits = GL11.glGetInteger(GL20.GL_MAX_TEXTURE_IMAGE_UNITS);
|
||||
this.maxDrawBuffers = GL11.glGetInteger(GL20.GL_MAX_DRAW_BUFFERS);
|
||||
this.maxShaderStorageUnits = RenderSystem.supportsSSBO() ? GL11.glGetInteger(GL43.GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS) : 0;
|
||||
}
|
||||
|
||||
public static SamplerLimits get() {
|
||||
if (instance == null) {
|
||||
instance = new SamplerLimits();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public int getMaxTextureUnits() {
|
||||
@@ -21,11 +33,7 @@ public class SamplerLimits {
|
||||
return maxDrawBuffers;
|
||||
}
|
||||
|
||||
public static SamplerLimits get() {
|
||||
if (instance == null) {
|
||||
instance = new SamplerLimits();
|
||||
}
|
||||
|
||||
return instance;
|
||||
public int getMaxShaderStorageUnits() {
|
||||
return maxShaderStorageUnits;
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import java.util.Locale;
|
||||
* A compiled OpenGL shader object.
|
||||
*/
|
||||
public class GlShader extends GlResource {
|
||||
private static final Logger LOGGER = LogManager.getLogger(GlShader.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger("GlShader");
|
||||
|
||||
private final String name;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.lwjgl.opengl.KHRDebug;
|
||||
|
||||
public class ProgramCreator {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(ProgramCreator.class);
|
||||
private static final Logger LOGGER = LogManager.getLogger("ProgramCreator");
|
||||
|
||||
public static final int MC_ENTITY = 11;
|
||||
public static final int MC_MID_TEX_COORD = 12;
|
||||
|
||||
@@ -4,6 +4,7 @@ package net.coderbot.iris.gl.shader;
|
||||
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
import org.lwjgl.opengl.GL40;
|
||||
import org.lwjgl.opengl.GL43;
|
||||
|
||||
/**
|
||||
@@ -12,6 +13,8 @@ import org.lwjgl.opengl.GL43;
|
||||
public enum ShaderType {
|
||||
VERTEX(GL20.GL_VERTEX_SHADER),
|
||||
GEOMETRY(GL32.GL_GEOMETRY_SHADER),
|
||||
TESSELATION_CONTROL(GL40.GL_TESS_CONTROL_SHADER),
|
||||
TESSELATION_EVAL(GL40.GL_TESS_EVALUATION_SHADER),
|
||||
FRAGMENT(GL20.GL_FRAGMENT_SHADER),
|
||||
COMPUTE(GL43.GL_COMPUTE_SHADER);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.coderbot.iris.gl.shader;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.Tags;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import net.coderbot.iris.parsing.BiomeCategories;
|
||||
import net.coderbot.iris.pipeline.HandRenderer;
|
||||
@@ -75,6 +76,9 @@ public class StandardMacros {
|
||||
define(standardDefines, "MC_RENDER_QUALITY", "1.0");
|
||||
define(standardDefines, "MC_SHADOW_QUALITY", "1.0");
|
||||
define(standardDefines, "IS_ANGELICA");
|
||||
if (AngelicaConfig.defineIsIris) {
|
||||
define(standardDefines, "IS_IRIS");
|
||||
}
|
||||
define(standardDefines, "ANGELICA_VERSION", makeAngelicaVersion());
|
||||
define(standardDefines, "MC_HAND_DEPTH", Float.toString(HandRenderer.DEPTH));
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.coderbot.iris.gl.state;
|
||||
|
||||
public enum FogMode {
|
||||
/**
|
||||
* Fog is disabled.
|
||||
*/
|
||||
OFF,
|
||||
|
||||
/**
|
||||
* Per-vertex fog, applicable to most geometry.
|
||||
*/
|
||||
PER_VERTEX,
|
||||
|
||||
/**
|
||||
* Per-fragment fog, for extra-long geometry like beacon beams.
|
||||
*/
|
||||
PER_FRAGMENT
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package net.coderbot.iris.gl.texture;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import net.coderbot.iris.shaderpack.texture.TextureFilteringData;
|
||||
import org.embeddedt.embeddium.impl.gl.GlObject;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.memAlloc;
|
||||
import static com.gtnewhorizon.gtnhlib.bytebuf.MemoryUtilities.memFree;
|
||||
|
||||
public class GlTexture extends GlObject implements TextureAccess {
|
||||
private final TextureType target;
|
||||
|
||||
public GlTexture(TextureType target, int sizeX, int sizeY, int sizeZ, int internalFormat, int format, int pixelType, byte[] pixels, TextureFilteringData filteringData) {
|
||||
this.setHandle(GL11.glGenTextures());
|
||||
bindTextureForSetup(target.getGlType(), handle());
|
||||
|
||||
TextureUploadHelper.resetTextureUploadState();
|
||||
|
||||
final ByteBuffer buffer = memAlloc(pixels.length);
|
||||
buffer.put(pixels);
|
||||
buffer.flip();
|
||||
target.apply(this.handle(), sizeX, sizeY, sizeZ, internalFormat, format, pixelType, buffer);
|
||||
memFree(buffer);
|
||||
|
||||
final int texture = this.handle();
|
||||
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL11.GL_TEXTURE_MIN_FILTER, filteringData.shouldBlur() ? GL11.GL_LINEAR : GL11.GL_NEAREST);
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL11.GL_TEXTURE_MAG_FILTER, filteringData.shouldBlur() ? GL11.GL_LINEAR : GL11.GL_NEAREST);
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL11.GL_TEXTURE_WRAP_S, filteringData.shouldClamp() ? GL12.GL_CLAMP_TO_EDGE : GL11.GL_REPEAT);
|
||||
|
||||
if (sizeY > 0) {
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL11.GL_TEXTURE_WRAP_T, filteringData.shouldClamp() ? GL12.GL_CLAMP_TO_EDGE : GL11.GL_REPEAT);
|
||||
}
|
||||
|
||||
if (sizeZ > 0) {
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL12.GL_TEXTURE_WRAP_R, filteringData.shouldClamp() ? GL12.GL_CLAMP_TO_EDGE : GL11.GL_REPEAT);
|
||||
}
|
||||
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL12.GL_TEXTURE_MAX_LEVEL, 0);
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL12.GL_TEXTURE_MIN_LOD, 0);
|
||||
RenderSystem.texParameteri(texture, target.getGlType(), GL12.GL_TEXTURE_MAX_LOD, 0);
|
||||
RenderSystem.texParameterf(texture, target.getGlType(), GL14.GL_TEXTURE_LOD_BIAS, 0.0F);
|
||||
|
||||
bindTextureForSetup(target.getGlType(), 0);
|
||||
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public static void bindTextureForSetup(int glType, int glId) {
|
||||
GL11.glBindTexture(glType, glId);
|
||||
}
|
||||
|
||||
public TextureType getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void bind(int unit) {
|
||||
RenderSystem.bindTextureToUnit(target.getGlType(), unit, handle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureType getType() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntSupplier getTextureId() {
|
||||
return this::handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void destroyInternal() {
|
||||
GLStateManager.glDeleteTextures(handle());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.coderbot.iris.gl.texture;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import net.coderbot.iris.gl.GlVersion;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
@@ -105,4 +106,29 @@ public enum InternalTextureFormat {
|
||||
public GlVersion getMinimumGlVersion() {
|
||||
return minimumGlVersion;
|
||||
}
|
||||
|
||||
public InternalTextureFormat getColorRenderableFallback() {
|
||||
if (!RenderSystem.supportsSnormFormats()) {
|
||||
return switch (this) {
|
||||
case R8_SNORM, RG8_SNORM, RGB8_SNORM, RGBA8_SNORM -> RGBA16F;
|
||||
case R16_SNORM, RG16_SNORM, RGB16_SNORM, RGBA16_SNORM -> RGBA16F;
|
||||
default -> this.getPackedFloatFallback();
|
||||
};
|
||||
}
|
||||
return this.getPackedFloatFallback();
|
||||
}
|
||||
|
||||
private InternalTextureFormat getPackedFloatFallback() {
|
||||
if (!RenderSystem.supportsPackedFloatRenderable()) {
|
||||
return switch (this) {
|
||||
case R11F_G11F_B10F, RGB9_E5 -> RGBA16F;
|
||||
case RGB8 -> RGBA8;
|
||||
case RGB16 -> RGBA16;
|
||||
case RGB16F -> RGBA16F;
|
||||
case RGB32F -> RGBA32F;
|
||||
default -> this;
|
||||
};
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public enum PixelType {
|
||||
UNSIGNED_SHORT_4_4_4_4_REV(GL12.GL_UNSIGNED_SHORT_4_4_4_4_REV, GlVersion.GL_12),
|
||||
UNSIGNED_SHORT_5_5_5_1(GL12.GL_UNSIGNED_SHORT_5_5_5_1, GlVersion.GL_12),
|
||||
UNSIGNED_SHORT_1_5_5_5_REV(GL12.GL_UNSIGNED_SHORT_1_5_5_5_REV, GlVersion.GL_12),
|
||||
UNSIGNED_INT(GL11.GL_UNSIGNED_BYTE, GlVersion.GL_11),
|
||||
UNSIGNED_INT(GL11.GL_UNSIGNED_INT, GlVersion.GL_11),
|
||||
UNSIGNED_INT_8_8_8_8(GL12.GL_UNSIGNED_INT_8_8_8_8, GlVersion.GL_12),
|
||||
UNSIGNED_INT_8_8_8_8_REV(GL12.GL_UNSIGNED_INT_8_8_8_8_REV, GlVersion.GL_12),
|
||||
UNSIGNED_INT_10_10_10_2(GL12.GL_UNSIGNED_INT_10_10_10_2, GlVersion.GL_12),
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package net.coderbot.iris.gl.texture;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
public interface TextureAccess {
|
||||
TextureType getType();
|
||||
|
||||
IntSupplier getTextureId();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.coderbot.iris.gl.texture;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public abstract class TextureDefinition {
|
||||
protected String name;
|
||||
|
||||
public static class PNGDefinition extends TextureDefinition {
|
||||
public PNGDefinition(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class RawDefinition extends TextureDefinition {
|
||||
private final TextureType target;
|
||||
private final int sizeX;
|
||||
private final int sizeY;
|
||||
private final int sizeZ;
|
||||
private final InternalTextureFormat internalFormat;
|
||||
private final PixelFormat format;
|
||||
private final PixelType pixelType;
|
||||
|
||||
public RawDefinition(String path, TextureType target, InternalTextureFormat internalFormat, int sizeX, int sizeY, int sizeZ, PixelFormat format, PixelType pixelType) {
|
||||
this.name = path;
|
||||
this.target = target;
|
||||
this.sizeX = sizeX;
|
||||
this.sizeY = sizeY;
|
||||
this.sizeZ = sizeZ;
|
||||
this.internalFormat = internalFormat;
|
||||
this.format = format;
|
||||
this.pixelType = pixelType;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.coderbot.iris.gl.texture;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL31;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Optional;
|
||||
|
||||
public enum TextureType {
|
||||
TEXTURE_1D(GL11.GL_TEXTURE_1D),
|
||||
TEXTURE_2D(GL11.GL_TEXTURE_2D),
|
||||
TEXTURE_3D(GL12.GL_TEXTURE_3D),
|
||||
TEXTURE_RECTANGLE(GL31.GL_TEXTURE_RECTANGLE);
|
||||
|
||||
private final int glType;
|
||||
|
||||
TextureType(int glType) {
|
||||
this.glType = glType;
|
||||
}
|
||||
|
||||
public static Optional<TextureType> fromString(String name) {
|
||||
try {
|
||||
return Optional.of(TextureType.valueOf(name));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
public int getGlType() {
|
||||
return glType;
|
||||
}
|
||||
|
||||
public void apply(int texture, int sizeX, int sizeY, int sizeZ, int internalFormat, int format, int pixelType, ByteBuffer pixels) {
|
||||
switch (this) {
|
||||
case TEXTURE_1D -> RenderSystem.texImage1D(texture, glType, 0, internalFormat, sizeX, 0, format, pixelType, pixels);
|
||||
case TEXTURE_2D, TEXTURE_RECTANGLE -> RenderSystem.texImage2D(texture, glType, 0, internalFormat, sizeX, sizeY, 0, format, pixelType, pixels);
|
||||
case TEXTURE_3D -> RenderSystem.texImage3D(texture, glType, 0, internalFormat, sizeX, sizeY, sizeZ, 0, format, pixelType, pixels);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loaded 100 of 203 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user