mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-21 12:52:19 +00:00
Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f2fc22df3 | ||
|
|
26300bbb1b | ||
|
|
88e4d2fd6c | ||
|
|
bb52476d27 | ||
|
|
6d60477b93 | ||
|
|
362724610c | ||
|
|
ea4a3cdf0b | ||
|
|
65959268d0 | ||
|
|
58d820cd7e | ||
|
|
685d68bd9c | ||
|
|
ad63d2d62c | ||
|
|
d2730ccca8 | ||
|
|
e9257b8739 | ||
|
|
3984225faa |
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/
|
||||
+8
-2
@@ -55,6 +55,12 @@ configurations {
|
||||
testCompileClasspath.extendsFrom(embedOnly)
|
||||
}
|
||||
|
||||
|
||||
// Exclude self-reference from all configurations - prevents transitive Angelica deps from resolving against this project
|
||||
configurations.all {
|
||||
exclude group: "com.github.GTNewHorizons", module: "Angelica"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.7.14:dev")
|
||||
|
||||
@@ -74,8 +80,8 @@ dependencies {
|
||||
compileOnly "org.apache.ant:ant:1.8.2"
|
||||
|
||||
// Celeritas (transitive=false: deps provided by GTNHLib/runtime)
|
||||
embedOnly("org.embeddedt.celeritas:celeritas-common:2.5.0-GTNH") { transitive = false }
|
||||
embedOnly("org.embeddedt.celeritas:celeritas-lwjgl2-service:2.5.0-GTNH") { transitive = false }
|
||||
embedOnly("org.embeddedt.celeritas:celeritas-common:2.5.2-GTNH") { transitive = false }
|
||||
embedOnly("org.embeddedt.celeritas:celeritas-lwjgl2-service:2.5.2-GTNH") { transitive = false }
|
||||
|
||||
// Because who doesn't want NEI
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.8.35-GTNH:dev')
|
||||
|
||||
+32
-2
@@ -39,11 +39,33 @@ remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/co
|
||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
||||
developmentEnvironmentUserName = Developer
|
||||
|
||||
# Enables modern Java syntax support. Valid values:
|
||||
# - false: No modern syntax, Java 8 only
|
||||
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
|
||||
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
|
||||
# - modern: Native modern Java bytecode, no downgrading
|
||||
enableModernJavaSyntax = jvmDowngrader
|
||||
jvmDowngraderStubsProvider = gtnhlib
|
||||
|
||||
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
|
||||
# and should *not* be used in most situations. -1 disables this.
|
||||
# forceToolchainVersion = -1
|
||||
|
||||
# Target JVM version for JVM Downgrader bytecode downgrading.
|
||||
# Only used when enableModernJavaSyntax = jvmDowngrader
|
||||
# downgradeTargetVersion = 8
|
||||
|
||||
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
|
||||
# Classes will be available in META-INF/versions/N/ for each version N in this list.
|
||||
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
|
||||
jvmDowngraderMultiReleaseVersions = 17, 21, 25
|
||||
|
||||
#forceToolchainVersion = 25
|
||||
# Specifies how JVM Downgrader API stubs are provided. Options:
|
||||
# - shade: Shade minimized stubs into the jar
|
||||
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
|
||||
# - external: Another dependency provides stubs (no constraint, no warning)
|
||||
# - (empty): Warning reminding you to configure stubs
|
||||
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
|
||||
jvmDowngraderStubsProvider = gtnhlib
|
||||
|
||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
||||
@@ -57,6 +79,14 @@ generateGradleTokenClass = com.gtnewhorizons.angelica.Tags
|
||||
# Name of the token containing the project's current version to generate/replace.
|
||||
gradleTokenVersion = VERSION
|
||||
|
||||
# [DEPRECATED]
|
||||
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
|
||||
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
|
||||
# version in @Mod([...], version = VERSION, [...]).
|
||||
# Leave these properties empty to skip individual token replacements.
|
||||
# replaceGradleTokenInFile =
|
||||
|
||||
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
|
||||
# leave this property empty.
|
||||
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
|
||||
|
||||
Vendored
BIN
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -114,7 +114,6 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -172,7 +171,6 @@ fi
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
@@ -212,8 +210,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+1
-2
@@ -70,11 +70,10 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
+1
-1
@@ -16,5 +16,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id("com.gtnewhorizons.gtnhsettingsconvention") version("2.0.11")
|
||||
id("com.gtnewhorizons.gtnhsettingsconvention") version("2.0.13")
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import com.gtnewhorizon.gtnhlib.util.font.GlyphReplacements;
|
||||
import com.gtnewhorizons.angelica.config.FontConfig;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.FontRendererAccessor;
|
||||
import cpw.mods.fml.client.SplashProgress;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import net.coderbot.iris.gl.program.Program;
|
||||
import net.coderbot.iris.gl.program.ProgramBuilder;
|
||||
@@ -508,10 +507,16 @@ public class BatchingFontRenderer {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (FontConfig.enableCustomFont) {
|
||||
if (FontConfig.enableCustomFont && FontConfig.enableGlyphReplacements) {
|
||||
String chrReplacement = GlyphReplacements.customGlyphs.get(String.valueOf(chr));
|
||||
if (chrReplacement != null) {
|
||||
chr = chrReplacement.charAt(0);
|
||||
char replacement = chrReplacement.charAt(0);
|
||||
boolean isReplacementCharAvailable =
|
||||
FontProviderCustom.getPrimary().isGlyphAvailable(replacement)
|
||||
|| FontProviderCustom.getFallback().isGlyphAvailable(replacement);
|
||||
if (isReplacementCharAvailable) {
|
||||
chr = replacement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.gtnewhorizons.angelica.client.gui;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.config.EntityLightConfig;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.config.EntityLightConfigStorage;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.config.EntityTypeEntry;
|
||||
import jss.notfine.core.Settings;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.Option;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionGroup;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpl;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionImpact;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionPage;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.control.TickBoxControl;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DynamicLightsOptionPages {
|
||||
|
||||
public static OptionPage dynamicLights() {
|
||||
if (!DynamicLights.configEnabled) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<OptionGroup> groups = new ArrayList<>();
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.DYNAMIC_LIGHTS.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS_SHADER_FORCE.option)
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.DYNAMIC_LIGHTS_FRUSTUM_CULLING.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS_ADAPTIVE_TICKING.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS_CULL_TIMEOUT.option)
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.DYNAMIC_LIGHTS_SLOW_DIST.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS_SLOWER_DIST.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS_BACKGROUND_DIST.option)
|
||||
.build());
|
||||
|
||||
// Entity type toggles - grouped by mod ID
|
||||
List<EntityTypeEntry> allEntities = EntityLightConfig.getAllEntityTypes();
|
||||
Map<String, List<EntityTypeEntry>> byMod = new LinkedHashMap<>();
|
||||
|
||||
for (EntityTypeEntry entry : allEntities) {
|
||||
byMod.computeIfAbsent(entry.getModId(), _ -> new ArrayList<>()).add(entry);
|
||||
}
|
||||
|
||||
// Create a group for each mod's entities
|
||||
for (Map.Entry<String, List<EntityTypeEntry>> modEntry : byMod.entrySet()) {
|
||||
String modId = modEntry.getKey();
|
||||
List<EntityTypeEntry> entities = modEntry.getValue();
|
||||
|
||||
OptionGroup.Builder groupBuilder = OptionGroup.createBuilder();
|
||||
|
||||
for (EntityTypeEntry entity : entities) {
|
||||
Option<Boolean> option = createEntityOption(entity);
|
||||
if (option != null) {
|
||||
groupBuilder.add(option);
|
||||
}
|
||||
}
|
||||
|
||||
// Only add group if it has options
|
||||
OptionGroup group = groupBuilder.build();
|
||||
if (!group.getOptions().isEmpty()) {
|
||||
groups.add(group);
|
||||
}
|
||||
}
|
||||
|
||||
return new OptionPage(I18n.format("options.dynamiclights.page"), ImmutableList.copyOf(groups));
|
||||
}
|
||||
|
||||
private static Option<Boolean> createEntityOption(EntityTypeEntry entry) {
|
||||
final String className = entry.getClassName();
|
||||
|
||||
// Resolve class once during option creation, not on every get/set
|
||||
Class<?> resolvedClass;
|
||||
try {
|
||||
resolvedClass = Class.forName(className);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// Class not loaded, skip this option
|
||||
return null;
|
||||
}
|
||||
|
||||
final Class<?> entityClass = resolvedClass;
|
||||
|
||||
return OptionImpl.createBuilder(Boolean.class, EntityLightConfigStorage.INSTANCE)
|
||||
.setName(entry.getDisplayName() + " (" + entry.getModId() + ")")
|
||||
.setTooltip(I18n.format("options.dynamiclights.entity.tooltip", entry.getDisplayName()))
|
||||
.setControl(TickBoxControl::new)
|
||||
.setBinding(
|
||||
(_, value) -> EntityLightConfig.setEntityTypeEnabled(entityClass, value),
|
||||
storage -> EntityLightConfig.isEntityTypeEnabled(entityClass)
|
||||
)
|
||||
.setImpact(OptionImpact.LOW)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -70,4 +70,11 @@ public class FontConfig {
|
||||
@Config.DefaultFloat(1.5F)
|
||||
@Config.RangeFloat(min = 0.1F, max = 3F)
|
||||
public static float customFontScale;
|
||||
|
||||
@Config.Comment({"Mods can provide Angelica with a mapping of special characters to either get replaced with " +
|
||||
"different characters or rendered using the default Unicode font. Setting this to false disables the " +
|
||||
"replacement, which is useful in cases where custom fonts have direct support for these special characters. ",
|
||||
"See for additional details: https://github.com/GTNewHorizons/Angelica/issues/1239#issuecomment-3729877936"})
|
||||
@Config.DefaultBoolean(true)
|
||||
public static boolean enableGlyphReplacements;
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Calculates the appropriate tick mode for a dynamic light source based on distance from camera and position relative to camera direction.
|
||||
*/
|
||||
public final class AdaptiveTickCalculator {
|
||||
|
||||
// Distance thresholds in blocks (configurable via settings)
|
||||
private static int slowDistance = 32; // ~2 chunks
|
||||
private static int slowerDistance = 64; // ~4 chunks
|
||||
private static int backgroundDistance = 128; // ~8 chunks
|
||||
|
||||
// Squared thresholds for efficient distance comparison
|
||||
private static int slowDistanceSq = slowDistance * slowDistance;
|
||||
private static int slowerDistanceSq = slowerDistance * slowerDistance;
|
||||
private static int backgroundDistanceSq = backgroundDistance * backgroundDistance;
|
||||
|
||||
private AdaptiveTickCalculator() {}
|
||||
|
||||
/**
|
||||
* Calculate the appropriate tick mode for a light source.
|
||||
*/
|
||||
public static AdaptiveTickMode calculate(@NotNull IDynamicLightSource source, double cameraX, double cameraY, double cameraZ, double lookDirX, double lookDirZ) {
|
||||
double dx = source.angelica$getDynamicLightX() - cameraX;
|
||||
double dy = source.angelica$getDynamicLightY() - cameraY;
|
||||
double dz = source.angelica$getDynamicLightZ() - cameraZ;
|
||||
|
||||
double distSq = dx * dx + dy * dy + dz * dz;
|
||||
|
||||
// Check if behind camera (dot product of direction to source with look direction)
|
||||
// Only use X and Z for horizontal check (more stable as player looks up/down)
|
||||
double dot = dx * lookDirX + dz * lookDirZ;
|
||||
boolean behindCamera = dot < 0;
|
||||
|
||||
// Behind camera always gets BACKGROUND mode
|
||||
if (behindCamera) {
|
||||
return AdaptiveTickMode.BACKGROUND;
|
||||
}
|
||||
|
||||
// Distance-based mode selection
|
||||
if (distSq > backgroundDistanceSq) {
|
||||
return AdaptiveTickMode.BACKGROUND;
|
||||
}
|
||||
if (distSq > slowerDistanceSq) {
|
||||
return AdaptiveTickMode.SLOWER;
|
||||
}
|
||||
if (distSq > slowDistanceSq) {
|
||||
return AdaptiveTickMode.SLOW;
|
||||
}
|
||||
|
||||
return AdaptiveTickMode.REAL_TIME;
|
||||
}
|
||||
|
||||
public static void setSlowDistance(int distance) {
|
||||
slowDistance = distance;
|
||||
slowDistanceSq = distance * distance;
|
||||
}
|
||||
|
||||
public static void setSlowerDistance(int distance) {
|
||||
slowerDistance = distance;
|
||||
slowerDistanceSq = distance * distance;
|
||||
}
|
||||
|
||||
public static void setBackgroundDistance(int distance) {
|
||||
backgroundDistance = distance;
|
||||
backgroundDistanceSq = distance * distance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights;
|
||||
|
||||
/**
|
||||
* Defines tick modes for adaptive dynamic light updates. Distant or off-screen light sources update less frequently to save CPU.
|
||||
*/
|
||||
public enum AdaptiveTickMode {
|
||||
/** Updates every tick - for nearby, visible light sources */
|
||||
REAL_TIME(1),
|
||||
/** Updates every 5 ticks - for light sources at moderate distance */
|
||||
SLOW(5),
|
||||
/** Updates every 10 ticks - for light sources at far distance */
|
||||
SLOWER(10),
|
||||
/** Updates every 20 ticks - for light sources behind the camera or very far */
|
||||
BACKGROUND(20);
|
||||
|
||||
private final int delay;
|
||||
|
||||
AdaptiveTickMode(int delay) {
|
||||
this.delay = delay;
|
||||
}
|
||||
|
||||
public int getDelay() {
|
||||
return delay;
|
||||
}
|
||||
|
||||
public boolean shouldTickThisFrame(int worldTick, int sourceHash) {
|
||||
if (delay <= 1) {
|
||||
return true;
|
||||
}
|
||||
return (worldTick % delay) == Math.abs(sourceHash % delay);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.util.CoordinatePacker;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
import it.unimi.dsi.fastutil.longs.LongIterator;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
/**
|
||||
* Manages deferred chunk rebuilds for dynamic lights with optional frustum culling. Instead of scheduling chunk rebuilds immediately
|
||||
* when light sources move, this tracks pending rebuilds and only schedules visible chunks.
|
||||
*/
|
||||
public class ChunkRebuildManager {
|
||||
|
||||
/** Maps packed chunk position to ticks waiting */
|
||||
private final Long2IntOpenHashMap pendingRebuilds = new Long2IntOpenHashMap();
|
||||
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
|
||||
/** Maximum ticks a pending rebuild can wait before being forced through */
|
||||
private static int maxTicksWaiting = 100;
|
||||
|
||||
/** Reusable lists for processVisible - only used from render thread */
|
||||
private final LongArrayList candidates = new LongArrayList();
|
||||
private final LongArrayList toRebuild = new LongArrayList();
|
||||
private final LongArrayList toIncrement = new LongArrayList();
|
||||
|
||||
public static void setMaxTicksWaiting(int ticks) {
|
||||
maxTicksWaiting = Math.max(20, Math.min(ticks, 600)); // Clamp 1-30 seconds (20-600 ticks)
|
||||
}
|
||||
|
||||
public void requestRebuild(int x, int y, int z) {
|
||||
final long packed = CoordinatePacker.pack(x, y, z);
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
// Reset wait counter if already pending, otherwise add new entry
|
||||
pendingRebuilds.put(packed, 0);
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void processVisible(Viewport viewport, @NotNull IDynamicLightWorldRenderer renderer) {
|
||||
candidates.clear();
|
||||
toRebuild.clear();
|
||||
toIncrement.clear();
|
||||
|
||||
// Phase 1: Collect all pending chunks with read lock (fast)
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
if (pendingRebuilds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// Collect candidates that might need processing
|
||||
final var iterator = pendingRebuilds.long2IntEntrySet().fastIterator();
|
||||
while (iterator.hasNext()) {
|
||||
final var entry = iterator.next();
|
||||
final long packed = entry.getLongKey();
|
||||
final int ticksWaiting = entry.getIntValue();
|
||||
|
||||
// Force process if no viewport or waited too long
|
||||
if (viewport == null || ticksWaiting >= maxTicksWaiting) {
|
||||
toRebuild.add(packed);
|
||||
} else {
|
||||
candidates.add(packed);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
|
||||
// Phase 2: Check visibility
|
||||
for (int i = 0; i < candidates.size(); i++) {
|
||||
long packed = candidates.getLong(i);
|
||||
int x = CoordinatePacker.unpackX(packed);
|
||||
int y = CoordinatePacker.unpackY(packed);
|
||||
int z = CoordinatePacker.unpackZ(packed);
|
||||
|
||||
if (isChunkVisible(viewport, x, y, z)) {
|
||||
toRebuild.add(packed);
|
||||
} else {
|
||||
toIncrement.add(packed);
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 3: Update map with write lock (brief)
|
||||
if (!toRebuild.isEmpty() || !toIncrement.isEmpty()) {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
// Remove chunks we're going to rebuild
|
||||
LongIterator rebuildIter = toRebuild.iterator();
|
||||
while (rebuildIter.hasNext()) {
|
||||
pendingRebuilds.remove(rebuildIter.nextLong());
|
||||
}
|
||||
LongIterator incIter = toIncrement.iterator();
|
||||
while (incIter.hasNext()) {
|
||||
long packed = incIter.nextLong();
|
||||
int current = pendingRebuilds.get(packed);
|
||||
if (pendingRebuilds.containsKey(packed)) {
|
||||
pendingRebuilds.put(packed, current + 1);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// Phase 4: Schedule rebuilds outside of lock
|
||||
for (int i = 0; i < toRebuild.size(); i++) {
|
||||
final long packed = toRebuild.getLong(i);
|
||||
renderer.scheduleRebuildForChunk(
|
||||
CoordinatePacker.unpackX(packed),
|
||||
CoordinatePacker.unpackY(packed),
|
||||
CoordinatePacker.unpackZ(packed),
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isChunkVisible(Viewport viewport, int chunkX, int chunkY, int chunkZ) {
|
||||
// Convert chunk section coords to block coords
|
||||
int blockX = chunkX << 4;
|
||||
int blockY = chunkY << 4;
|
||||
int blockZ = chunkZ << 4;
|
||||
|
||||
// Check if the 16x16x16 chunk section box is visible
|
||||
return viewport.isBoxVisible(
|
||||
blockX, blockY, blockZ,
|
||||
blockX + 16, blockY + 16, blockZ + 16
|
||||
);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
pendingRebuilds.clear();
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public int getPendingCount() {
|
||||
lock.readLock().lock();
|
||||
try {
|
||||
return pendingRebuilds.size();
|
||||
} finally {
|
||||
lock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ import com.gtnewhorizons.angelica.api.IDynamicLightProducer;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.battlegear2.Battlegear2Compat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.config.EntityLightConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.PrimedEntityAccessor;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import mods.battlegear2.api.core.IBattlePlayer;
|
||||
@@ -21,12 +23,17 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.embeddedt.embeddium.impl.render.viewport.Viewport;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.function.Predicate;
|
||||
@@ -36,6 +43,8 @@ public class DynamicLights {
|
||||
private static IDynamicLightWorldRenderer activeRenderer;
|
||||
public static DynamicLightsMode Mode = DynamicLightsMode.OFF;
|
||||
public static boolean ShaderForce = false;
|
||||
public static boolean FrustumCullingEnabled = true;
|
||||
public static boolean AdaptiveTickingEnabled = true;
|
||||
|
||||
public static final boolean configEnabled = AngelicaConfig.enableDynamicLights;
|
||||
|
||||
@@ -43,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 final ChunkRebuildManager chunkRebuildManager = new ChunkRebuildManager();
|
||||
private long lastUpdate = System.currentTimeMillis();
|
||||
private int lastUpdateCount = 0;
|
||||
|
||||
@@ -82,8 +92,43 @@ public class DynamicLights {
|
||||
this.lastUpdate = now;
|
||||
this.lastUpdateCount = 0;
|
||||
|
||||
// Get camera info for adaptive ticking
|
||||
double cameraX = 0, cameraY = 0, cameraZ = 0;
|
||||
double lookDirX = 0, lookDirZ = 1;
|
||||
int worldTick = 0;
|
||||
|
||||
if (AdaptiveTickingEnabled) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.theWorld != null && mc.renderViewEntity != null) {
|
||||
cameraX = mc.renderViewEntity.posX;
|
||||
cameraY = mc.renderViewEntity.posY + mc.renderViewEntity.getEyeHeight();
|
||||
cameraZ = mc.renderViewEntity.posZ;
|
||||
worldTick = (int) (mc.theWorld.getTotalWorldTime() & 0x7FFFFFFF);
|
||||
|
||||
// Calculate look direction from yaw (normalized horizontal direction)
|
||||
float yaw = mc.renderViewEntity.rotationYaw;
|
||||
double yawRad = Math.toRadians(yaw);
|
||||
lookDirX = -Math.sin(yawRad);
|
||||
lookDirZ = Math.cos(yawRad);
|
||||
}
|
||||
}
|
||||
|
||||
this.lightSourcesLock.readLock().lock();
|
||||
for (var lightSource : this.dynamicLightSources) {
|
||||
// Entity type filter
|
||||
if (!EntityLightConfig.isEntityTypeEnabled(lightSource)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Adaptive ticking filter
|
||||
if (AdaptiveTickingEnabled) {
|
||||
AdaptiveTickMode mode = AdaptiveTickCalculator.calculate(
|
||||
lightSource, cameraX, cameraY, cameraZ, lookDirX, lookDirZ);
|
||||
if (!mode.shouldTickThisFrame(worldTick, lightSource.hashCode())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (lightSource.angelica$updateDynamicLight(renderer))
|
||||
this.lastUpdateCount++;
|
||||
}
|
||||
@@ -290,6 +335,51 @@ public class DynamicLights {
|
||||
return this.getLightmapWithDynamicLight(this.getDynamicLightLevel(x, y, z), lightmap);
|
||||
}
|
||||
|
||||
public List<IDynamicLightSource> getSourcesForChunk(int chunkMinX, int chunkMinY, int chunkMinZ) {
|
||||
// Chunk center
|
||||
final double centerX = chunkMinX + 8.0;
|
||||
final double centerY = chunkMinY + 8.0;
|
||||
final double centerZ = chunkMinZ + 8.0;
|
||||
|
||||
// Max distance from chunk center to any corner is sqrt(3) * 8 ≈ 13.86
|
||||
// Add MAX_RADIUS to get the search radius (13.86 + 7.75)^2 ≈ 467
|
||||
final double searchRadiusSq = 470.0; // Slightly padded for safety
|
||||
|
||||
List<IDynamicLightSource> result = null;
|
||||
|
||||
this.lightSourcesLock.readLock().lock();
|
||||
try {
|
||||
for (IDynamicLightSource source : this.dynamicLightSources) {
|
||||
double dx = source.angelica$getDynamicLightX() - centerX;
|
||||
double dy = source.angelica$getDynamicLightY() - centerY;
|
||||
double dz = source.angelica$getDynamicLightZ() - centerZ;
|
||||
double distSq = dx * dx + dy * dy + dz * dz;
|
||||
|
||||
if (distSq <= searchRadiusSq) {
|
||||
if (result == null) {
|
||||
result = new ArrayList<>();
|
||||
}
|
||||
result.add(source);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
this.lightSourcesLock.readLock().unlock();
|
||||
}
|
||||
|
||||
return result != null ? result : Collections.emptyList();
|
||||
}
|
||||
|
||||
public double getDynamicLightLevelFromSources(double x, double y, double z, List<IDynamicLightSource> sources) {
|
||||
if (sources == null || sources.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
double result = 0;
|
||||
for (int i = 0, size = sources.size(); i < size; i++) {
|
||||
result = maxDynamicLightLevelExact(x, y, z, sources.get(i), result);
|
||||
}
|
||||
return MathHelper.clamp_double(result, 0, 15);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the lightmap with combined light levels.
|
||||
*
|
||||
@@ -335,9 +425,32 @@ public class DynamicLights {
|
||||
}
|
||||
|
||||
public static void scheduleChunkRebuild(@NotNull IDynamicLightWorldRenderer renderer, int x, int y, int z) {
|
||||
if (FrustumCullingEnabled && instance != null) {
|
||||
instance.chunkRebuildManager.requestRebuild(x, y, z);
|
||||
} else {
|
||||
renderer.scheduleRebuildForChunk(x, y, z, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static void scheduleChunkRebuildForRemoval(@NotNull IDynamicLightWorldRenderer renderer, int x, int y, int z) {
|
||||
renderer.scheduleRebuildForChunk(x, y, z, false);
|
||||
}
|
||||
|
||||
public static void scheduleChunkRebuildForRemoval(@NotNull IDynamicLightWorldRenderer renderer, long chunkPos) {
|
||||
scheduleChunkRebuildForRemoval(renderer, CoordinatePacker.unpackX(chunkPos), CoordinatePacker.unpackY(chunkPos), CoordinatePacker.unpackZ(chunkPos));
|
||||
}
|
||||
|
||||
public void processChunkRebuilds(@Nullable Viewport viewport) {
|
||||
if (activeRenderer == null) {
|
||||
return;
|
||||
}
|
||||
chunkRebuildManager.processVisible(viewport, activeRenderer);
|
||||
}
|
||||
|
||||
public ChunkRebuildManager getChunkRebuildManager() {
|
||||
return chunkRebuildManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the tracked chunk sets.
|
||||
*
|
||||
@@ -378,10 +491,7 @@ public class DynamicLights {
|
||||
* @param submergedInWater {@code true} if the stack is submerged in water, else {@code false}
|
||||
* @return the luminance of the item
|
||||
*/
|
||||
public static int getLuminanceFromItemStack(@NotNull ItemStack stack, boolean submergedInWater) {
|
||||
// TODO only have certain items not glow in water?
|
||||
if (submergedInWater) return 0;
|
||||
|
||||
public static int getLuminanceFromItemStack(@NotNull ItemStack stack) {
|
||||
Item item = stack.getItem();
|
||||
if (item instanceof ItemBlock itemBlock) {
|
||||
Block block = itemBlock.field_150939_a;
|
||||
@@ -399,49 +509,53 @@ public class DynamicLights {
|
||||
|
||||
public static int getLuminanceFromEntity(@NotNull Entity entity) {
|
||||
|
||||
if (entity.fire > 0) return 15;
|
||||
if (entity.isBurning()) return 15;
|
||||
|
||||
boolean inWater = entity.isInsideOfMaterial(Material.water);
|
||||
|
||||
// TODO only have certain items not glow in water?
|
||||
if (inWater) return 0;
|
||||
|
||||
if (entity instanceof EntityItem item) {
|
||||
return getLuminanceFromItemStack(item.getEntityItem(), item.isInsideOfMaterial(Material.water));
|
||||
return getLuminanceFromItemStack(item.getEntityItem());
|
||||
}
|
||||
|
||||
int luminance = 0;
|
||||
if (entity instanceof EntityLivingBase living) {
|
||||
int luminance = 0;
|
||||
|
||||
boolean inWater = living.isInsideOfMaterial(Material.water);
|
||||
|
||||
// check equipment + hand for light (should work for all entities)
|
||||
ItemStack itemStack;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if ((itemStack = living.getEquipmentInSlot(i)) != null) {
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(itemStack, inWater));
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(itemStack));
|
||||
}
|
||||
}
|
||||
|
||||
if (ModStatus.isBattlegearLoaded &&
|
||||
living instanceof EntityPlayer player &&
|
||||
player instanceof IBattlePlayer battlePlayer &&
|
||||
battlePlayer.battlegear2$isBattlemode()
|
||||
) {
|
||||
ItemStack offhand = Battlegear2Compat.getBattlegear2Offhand(player);
|
||||
if (offhand != null) {
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand, inWater));
|
||||
if (living instanceof EntityPlayer player) {
|
||||
if (ModStatus.isBattlegearLoaded &&
|
||||
player instanceof IBattlePlayer battlePlayer &&
|
||||
battlePlayer.battlegear2$isBattlemode()
|
||||
) {
|
||||
ItemStack offhand = Battlegear2Compat.getBattlegear2Offhand(player);
|
||||
if (offhand != null) {
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ModStatus.isBackhandLoaded && living instanceof EntityPlayer player){
|
||||
ItemStack offhand = ModStatus.backhandCompat.getOffhandItem(player);
|
||||
if (offhand != null) {
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand, inWater));
|
||||
else if (ModStatus.isBackhandLoaded){
|
||||
ItemStack offhand = ModStatus.backhandCompat.getOffhandItem(player);
|
||||
if (offhand != null) {
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(offhand));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ModStatus.isBaublesLoaded && living instanceof EntityPlayer player){
|
||||
var playerBaubles = PlayerHandler.getPlayerBaubles(player);
|
||||
if (playerBaubles != null){
|
||||
for (int i = 0; i < playerBaubles.getSizeInventory(); i++){
|
||||
var stack = playerBaubles.getStackInSlot(i);
|
||||
if (stack != null){
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(stack, inWater));
|
||||
if (ModStatus.isBaublesLoaded){
|
||||
var playerBaubles = PlayerHandler.getPlayerBaubles(player);
|
||||
if (playerBaubles != null){
|
||||
for (int i = 0; i < playerBaubles.getSizeInventory(); i++){
|
||||
var stack = playerBaubles.getStackInSlot(i);
|
||||
if (stack != null){
|
||||
luminance = Math.max(luminance, getLuminanceFromItemStack(stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -451,7 +565,10 @@ public class DynamicLights {
|
||||
}
|
||||
|
||||
// TODO: Creepers? TNT? Dusts?
|
||||
if (entity instanceof PrimedEntityAccessor primedEntity) {
|
||||
luminance = Math.max(luminance, primedEntity.angelica$getLuminance());
|
||||
}
|
||||
|
||||
return 0;
|
||||
return luminance;
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,7 @@ public interface IDynamicLightSource {
|
||||
* Executed at each tick.
|
||||
*/
|
||||
void angelica$dynamicLightTick();
|
||||
default void angelica$updateLights() {}
|
||||
|
||||
boolean angelica$updateDynamicLight(@NotNull IDynamicLightWorldRenderer renderer);
|
||||
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights.config;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.concurrent.cas.CasMap;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.IDynamicLightSource;
|
||||
import cpw.mods.fml.common.registry.EntityRegistry;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public final class EntityLightConfig {
|
||||
private static final Logger LOGGER = LogManager.getLogger("Angelica/DynamicLights");
|
||||
|
||||
private static final Set<String> disabledClassNames = ConcurrentHashMap.newKeySet();
|
||||
private static final CasMap<Class<?>, Boolean> enabledCache = new CasMap<>();
|
||||
|
||||
private static File configFile;
|
||||
private static boolean initialized = false;
|
||||
|
||||
private EntityLightConfig() {}
|
||||
|
||||
public static void init(@NotNull File configDir) {
|
||||
if (initialized) return;
|
||||
|
||||
configFile = new File(configDir, "angelica-dynamiclights-entities.txt");
|
||||
load();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public static boolean isEntityTypeEnabled(@NotNull IDynamicLightSource source) {
|
||||
if (!initialized) return true;
|
||||
return isEntityTypeEnabled(source.getClass());
|
||||
}
|
||||
|
||||
public static boolean isEntityTypeEnabled(@NotNull Class<?> entityClass) {
|
||||
if (!initialized) return true;
|
||||
|
||||
Boolean cached = enabledCache.get(entityClass);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
final boolean enabled = !disabledClassNames.contains(entityClass.getName());
|
||||
Boolean existing = enabledCache.putIfAbsent(entityClass, enabled);
|
||||
return existing != null ? existing : enabled;
|
||||
}
|
||||
|
||||
public static void setEntityTypeEnabled(@NotNull Class<?> entityClass, boolean enabled) {
|
||||
enabledCache.put(entityClass, enabled);
|
||||
|
||||
final String className = entityClass.getName();
|
||||
if (enabled) {
|
||||
disabledClassNames.remove(className);
|
||||
} else {
|
||||
disabledClassNames.add(className);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static List<EntityTypeEntry> getAllEntityTypes() {
|
||||
List<EntityTypeEntry> entries = new ArrayList<>();
|
||||
Set<String> seenClasses = new HashSet<>();
|
||||
|
||||
Map<String, Class<? extends Entity>> stringToClass = EntityList.stringToClassMapping;
|
||||
|
||||
for (Map.Entry<String, Class<? extends Entity>> entry : stringToClass.entrySet()) {
|
||||
String entityId = entry.getKey();
|
||||
Class<?> entityClass = entry.getValue();
|
||||
String className = entityClass.getName();
|
||||
|
||||
if (seenClasses.contains(className)) continue;
|
||||
seenClasses.add(className);
|
||||
|
||||
String modId = getModIdForEntity(entityClass, entityId);
|
||||
String displayName = getDisplayName(entityId, entityClass);
|
||||
boolean enabled = !disabledClassNames.contains(className);
|
||||
|
||||
entries.add(new EntityTypeEntry(displayName, className, modId, enabled));
|
||||
}
|
||||
|
||||
// Sort by mod ID, then by display name
|
||||
entries.sort((a, b) -> {
|
||||
int modCompare = a.getModId().compareToIgnoreCase(b.getModId());
|
||||
if (modCompare != 0) return modCompare;
|
||||
return a.getDisplayName().compareToIgnoreCase(b.getDisplayName());
|
||||
});
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static String getModIdForEntity(Class<?> entityClass, String entityId) {
|
||||
// Check EntityRegistry for mod entity entries
|
||||
if (Entity.class.isAssignableFrom(entityClass)) {
|
||||
EntityRegistry.EntityRegistration registration = EntityRegistry.instance()
|
||||
.lookupModSpawn((Class<? extends Entity>) entityClass, false);
|
||||
if (registration != null && registration.getContainer() != null) {
|
||||
return registration.getContainer().getModId();
|
||||
}
|
||||
}
|
||||
|
||||
// Check if it's a vanilla entity (no dot in entity ID)
|
||||
if (!entityId.contains(".")) {
|
||||
return "minecraft";
|
||||
}
|
||||
|
||||
// Extract mod ID from entity ID (format: modid.EntityName)
|
||||
int dotIndex = entityId.indexOf('.');
|
||||
if (dotIndex > 0) {
|
||||
return entityId.substring(0, dotIndex);
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
private static String getDisplayName(String entityId, Class<?> entityClass) {
|
||||
// Use the simple class name, removing package
|
||||
String simpleName = entityClass.getSimpleName();
|
||||
if (simpleName.isEmpty()) {
|
||||
// Anonymous class, use entity ID
|
||||
return entityId;
|
||||
}
|
||||
return simpleName;
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
if (configFile == null || !configFile.exists()) return;
|
||||
|
||||
disabledClassNames.clear();
|
||||
enabledCache.clear();
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(configFile))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
line = line.trim();
|
||||
if (line.isEmpty() || line.startsWith("#")) continue;
|
||||
|
||||
// Lines are entity class names that are DISABLED
|
||||
disabledClassNames.add(line);
|
||||
}
|
||||
LOGGER.info("Loaded {} disabled entity types from config", disabledClassNames.size());
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("Failed to load entity light config: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void save() {
|
||||
if (configFile == null) return;
|
||||
|
||||
try (BufferedWriter writer = new BufferedWriter(new FileWriter(configFile))) {
|
||||
writer.write("# Angelica Dynamic Lights - Disabled Entity Types");
|
||||
writer.newLine();
|
||||
writer.write("# Each line is a fully qualified class name of an entity type that is DISABLED.");
|
||||
writer.newLine();
|
||||
writer.write("# Remove a line to re-enable dynamic lighting for that entity type.");
|
||||
writer.newLine();
|
||||
writer.newLine();
|
||||
|
||||
List<String> sorted = new ArrayList<>(disabledClassNames);
|
||||
Collections.sort(sorted);
|
||||
|
||||
for (String className : sorted) {
|
||||
writer.write(className);
|
||||
writer.newLine();
|
||||
}
|
||||
|
||||
LOGGER.info("Saved {} disabled entity types to config", disabledClassNames.size());
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("Failed to save entity light config: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights.config;
|
||||
|
||||
import me.jellysquid.mods.sodium.client.gui.options.storage.OptionStorage;
|
||||
|
||||
public class EntityLightConfigStorage implements OptionStorage<EntityLightConfigStorage> {
|
||||
|
||||
public static final EntityLightConfigStorage INSTANCE = new EntityLightConfigStorage();
|
||||
|
||||
private EntityLightConfigStorage() {}
|
||||
|
||||
@Override
|
||||
public EntityLightConfigStorage getData() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
EntityLightConfig.save();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gtnewhorizons.angelica.dynamiclights.config;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class EntityTypeEntry {
|
||||
private final String displayName;
|
||||
private final String className;
|
||||
private final String modId;
|
||||
private boolean enabled;
|
||||
|
||||
public EntityTypeEntry(@NotNull String displayName, @NotNull String className, @NotNull String modId, boolean enabled) {
|
||||
this.displayName = displayName;
|
||||
this.className = className;
|
||||
this.modId = modId;
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
public String getModId() {
|
||||
return modId;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return displayName + " (" + modId + ") [" + (enabled ? "ON" : "OFF") + "]";
|
||||
}
|
||||
}
|
||||
@@ -369,6 +369,8 @@ public class DisplayListManager {
|
||||
// Flush any pending delta, then record pop.
|
||||
flushMatrix();
|
||||
currentRecorder.recordPopMatrix();
|
||||
// Invalidate cached transform
|
||||
matrixGeneration++;
|
||||
}
|
||||
|
||||
public static void recordViewport(int x, int y, int width, int height) {
|
||||
|
||||
@@ -328,6 +328,7 @@ public class GLStateManager {
|
||||
@Getter protected static final ViewPortStateStack viewportState = new ViewPortStateStack();
|
||||
|
||||
@Getter protected static int activeProgram = 0;
|
||||
@Getter protected static int listBase = 0;
|
||||
|
||||
public static void reset() {
|
||||
runningSplash = true;
|
||||
@@ -420,6 +421,7 @@ public class GLStateManager {
|
||||
|
||||
public static void init() {
|
||||
RenderSystem.initRenderer();
|
||||
IrisSamplers.initRenderer();
|
||||
|
||||
if(BYPASS_CACHE) {
|
||||
LOGGER.info("GLStateManager cache bypassed");
|
||||
@@ -804,6 +806,7 @@ public class GLStateManager {
|
||||
return switch (pname) {
|
||||
case GL11.GL_ALPHA_TEST_FUNC -> alphaState.getFunction();
|
||||
case GL11.GL_DEPTH_FUNC -> depthState.getFunc();
|
||||
case GL11.GL_LIST_BASE -> listBase;
|
||||
case GL11.GL_LIST_MODE -> DisplayListManager.getListMode();
|
||||
case GL11.GL_MATRIX_MODE -> matrixMode.getMode();
|
||||
case GL11.GL_SHADE_MODEL -> shadeModelState.getValue();
|
||||
@@ -2137,7 +2140,7 @@ public class GLStateManager {
|
||||
// TODO: Iris Notifier
|
||||
if (HAS_MULTIPLE_SET.contains(pname)) {
|
||||
GL11.glFog(pname, param);
|
||||
|
||||
|
||||
if (pname == GL11.GL_FOG_COLOR && isCachingEnabled()) {
|
||||
final float red = param.get(0);
|
||||
final float green = param.get(1);
|
||||
@@ -2459,7 +2462,7 @@ public class GLStateManager {
|
||||
// Reset relative transform - subsequent transforms are relative to loaded matrix
|
||||
DisplayListManager.resetRelativeTransform();
|
||||
if (mode == RecordMode.COMPILE) {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isCachingEnabled()) {
|
||||
@@ -3584,24 +3587,28 @@ public class GLStateManager {
|
||||
|
||||
// Display List Commands
|
||||
public static void glCallLists(IntBuffer lists) {
|
||||
if (DisplayListManager.isRecording()) {
|
||||
throw new UnsupportedOperationException("glCallLists in display lists not yet implemented - if you see this, please report!");
|
||||
while (lists.hasRemaining()) {
|
||||
final int listId = lists.get() + listBase;
|
||||
glCallList(listId);
|
||||
}
|
||||
}
|
||||
|
||||
public static void glCallLists(ShortBuffer lists) {
|
||||
while (lists.hasRemaining()) {
|
||||
final int listId = (lists.get() & 0xFFFF) + listBase;
|
||||
glCallList(listId);
|
||||
}
|
||||
GL11.glCallLists(lists);
|
||||
}
|
||||
|
||||
public static void glCallLists(ByteBuffer lists) {
|
||||
if (DisplayListManager.isRecording()) {
|
||||
throw new UnsupportedOperationException("glCallLists in display lists not yet implemented - if you see this, please report!");
|
||||
while (lists.hasRemaining()) {
|
||||
final int listId = (lists.get() & 0xFF) + listBase;
|
||||
glCallList(listId);
|
||||
}
|
||||
GL11.glCallLists(lists);
|
||||
}
|
||||
|
||||
public static void glListBase(int base) {
|
||||
if (DisplayListManager.isRecording()) {
|
||||
throw new UnsupportedOperationException("glListBase in display lists not yet implemented - if you see this, please report!");
|
||||
}
|
||||
GL11.glListBase(base);
|
||||
listBase = base;
|
||||
}
|
||||
|
||||
// Clip Plane Commands
|
||||
|
||||
@@ -10,14 +10,23 @@ 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 java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
@@ -31,6 +40,16 @@ 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 supportsSamplerObjects;
|
||||
private static int maxImageUnits;
|
||||
private static int maxSSBOBindings;
|
||||
|
||||
// Sampler object state tracking (null if unsupported)
|
||||
private static int[] samplers;
|
||||
|
||||
private RenderSystem() {}
|
||||
|
||||
@@ -54,6 +73,46 @@ public class RenderSystem {
|
||||
}
|
||||
|
||||
supportsCompute = supportsCompute();
|
||||
|
||||
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)];
|
||||
}
|
||||
|
||||
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 +124,8 @@ 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);
|
||||
GL11.glBindTexture(target, texture);
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
}
|
||||
|
||||
public static void uniformMatrix4fv(int location, boolean transpose, FloatBuffer matrix) {
|
||||
@@ -147,6 +206,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 +278,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 +313,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 +347,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 +386,100 @@ 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) {
|
||||
if (GLStateManager.capabilities.OpenGL43) {
|
||||
GL43.glClearBufferSubData(target, internalFormat, offset, size, format, type, (ByteBuffer) null);
|
||||
} else if (GLStateManager.capabilities.GL_ARB_clear_buffer_object) {
|
||||
ARBClearBufferObject.glClearBufferSubData(target, internalFormat, offset, size, format, type, (ByteBuffer) null);
|
||||
}
|
||||
}
|
||||
|
||||
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 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);
|
||||
}
|
||||
@@ -4,10 +4,13 @@ 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;
|
||||
@@ -113,6 +116,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();
|
||||
@@ -150,4 +159,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);
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,8 @@ public enum Mixins implements IMixins {
|
||||
, "angelica.dynamiclights.MixinEntity"
|
||||
, "angelica.dynamiclights.MixinWorld"
|
||||
, "angelica.dynamiclights.MixinItemRenderer"
|
||||
, "angelica.dynamiclights.MixinEntityCreeper"
|
||||
, "angelica.dynamiclights.MixinEntityTNTPrimed"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -200,9 +202,13 @@ public enum Mixins implements IMixins {
|
||||
, "shaders.MixinLocale"
|
||||
, "shaders.MixinOpenGlHelper"
|
||||
, "shaders.MixinRender"
|
||||
, "shaders.MixinRenderBiped"
|
||||
, "shaders.MixinRenderEntityFlame"
|
||||
, "shaders.MixinRendererLivingEntity"
|
||||
, "shaders.MixinRenderGlobal"
|
||||
, "shaders.MixinRenderHorse"
|
||||
, "shaders.MixinRenderItem"
|
||||
, "shaders.MixinRenderPlayerArmor"
|
||||
, "shaders.MixinTileEntityBeaconRenderer"
|
||||
)
|
||||
),
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
public interface PrimedEntityAccessor {
|
||||
int angelica$getLuminance();
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import com.gtnewhorizons.angelica.debug.F3Direction;
|
||||
import com.gtnewhorizons.angelica.debug.FrametimeGraph;
|
||||
import com.gtnewhorizons.angelica.debug.TPSGraph;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
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;
|
||||
@@ -21,6 +22,7 @@ import com.gtnewhorizons.angelica.mixins.interfaces.IGameSettingsExt;
|
||||
import com.gtnewhorizons.angelica.render.CloudRenderer;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasDebugScreenHandler;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.CeleritasSetup;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.threading.ChunkTaskRegistry;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.threading.DefaultChunkTaskProvider;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.threading.ThreadedChunkTaskProvider;
|
||||
@@ -65,9 +67,7 @@ import net.minecraftforge.client.event.GuiOpenEvent;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import org.embeddedt.embeddium.impl.gl.device.GLRenderDevice;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
@@ -115,8 +115,10 @@ public class ClientProxy extends CommonProxy {
|
||||
HUDCaching.init();
|
||||
}
|
||||
if (AngelicaConfig.enableCeleritas) {
|
||||
GLRenderDevice.VANILLA_STATE_RESETTER = () -> GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
CeleritasSetup.ensureInitialized();
|
||||
MinecraftForge.EVENT_BUS.register(CeleritasDebugScreenHandler.INSTANCE);
|
||||
} else {
|
||||
LOGGER.info("Celeritas is disabled, skipping initialization from init()");
|
||||
}
|
||||
if (AngelicaConfig.enableIris) {
|
||||
MinecraftForge.EVENT_BUS.register(IrisDebugScreenHandler.INSTANCE);
|
||||
@@ -141,6 +143,9 @@ public class ClientProxy extends CommonProxy {
|
||||
if (AngelicaConfig.enableZoom) {
|
||||
Zoom.init();
|
||||
}
|
||||
if (AngelicaConfig.enableDynamicLights) {
|
||||
EntityLightConfig.init(new java.io.File(mc.mcDataDir, "config"));
|
||||
}
|
||||
|
||||
// Register debug commands in dev environment only
|
||||
if (!AngelicaTweaker.isObfEnv()) {
|
||||
|
||||
+117
-27
@@ -1,15 +1,29 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.IDynamicLightSource;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.BlockRenderContext;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.iris.IrisExtendedChunkVertexEncoder;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.ChunkColorWriter;
|
||||
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 org.embeddedt.embeddium.impl.model.light.smooth.SmoothLightPipeline;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.world.WorldSlice;
|
||||
import lombok.Getter;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
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.world.IBlockAccess;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import org.embeddedt.embeddium.impl.model.light.data.LightDataAccess;
|
||||
import org.embeddedt.embeddium.impl.model.light.data.QuadLightData;
|
||||
import org.embeddedt.embeddium.impl.model.quad.properties.ModelQuadFacing;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.compile.ChunkBuildBuffers;
|
||||
@@ -23,30 +37,61 @@ import org.embeddedt.embeddium.impl.util.QuadUtil;
|
||||
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();
|
||||
|
||||
private List<IDynamicLightSource> chunkLightSources;
|
||||
private DynamicLights dynamicLightsInstance;
|
||||
|
||||
private final LightDataCache lightDataCache = new LightDataCache();
|
||||
private final SmoothLightPipeline smoothLightPipeline;
|
||||
private final QuadLightData quadLightData = new QuadLightData();
|
||||
private final VertexArrayQuadView quadView;
|
||||
private boolean lightPipelineReady = false;
|
||||
private int originX, originY, originZ;
|
||||
|
||||
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.quadView = new VertexArrayQuadView(vertices);
|
||||
}
|
||||
|
||||
public BlockRenderContext getBlockRenderContext() {
|
||||
return this.blockRenderContext;
|
||||
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.originX = minBlockX;
|
||||
this.originY = minBlockY;
|
||||
this.originZ = minBlockZ;
|
||||
lightDataCache.setWorld(blockAccess);
|
||||
lightDataCache.reset(minBlockX, minBlockY, minBlockZ);
|
||||
smoothLightPipeline.reset();
|
||||
lightPipelineReady = true;
|
||||
}
|
||||
|
||||
public void setupDynamicLights(int chunkOriginX, int chunkOriginY, int chunkOriginZ) {
|
||||
if (DynamicLights.isEnabled()) {
|
||||
this.dynamicLightsInstance = DynamicLights.get();
|
||||
this.chunkLightSources = dynamicLightsInstance.getSourcesForChunk(chunkOriginX, chunkOriginY, chunkOriginZ);
|
||||
} else {
|
||||
this.dynamicLightsInstance = null;
|
||||
this.chunkLightSources = null;
|
||||
}
|
||||
}
|
||||
|
||||
private Material selectMaterial(Material material, TextureAtlasSprite sprite) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -54,8 +99,7 @@ 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) {
|
||||
if (vertexCount == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -66,12 +110,14 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
throw new IllegalStateException("Only quads are supported, got: " + vertexCount);
|
||||
}
|
||||
|
||||
final DynamicLights dynamicLights = DynamicLights.isEnabled() ? DynamicLights.get() : null;
|
||||
|
||||
final var encoder = buffers.get(material).getEncoder();
|
||||
if (encoder instanceof IrisExtendedChunkVertexEncoder iris) {
|
||||
iris.setContext(blockRenderContext);
|
||||
}
|
||||
final boolean hasDynamicLights = chunkLightSources != null && !chunkLightSources.isEmpty();
|
||||
final boolean separateAo = BlockRenderingSettings.INSTANCE.shouldUseSeparateAo();
|
||||
final boolean celeritasSmoothLighting = SodiumClientMod.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;
|
||||
@@ -95,27 +141,71 @@ public class AngelicaChunkBuildContext extends ChunkBuildContext {
|
||||
vertex.color = rawBuffer[ptr++];
|
||||
vertex.vanillaNormal = rawBuffer[ptr++];
|
||||
vertex.light = rawBuffer[ptr++];
|
||||
|
||||
if (dynamicLights != null) {
|
||||
final double dynamicLevel = dynamicLights.getDynamicLightLevel(originX + vertex.x, originY + vertex.y, originZ + vertex.z);
|
||||
if (dynamicLevel > 0) {
|
||||
vertex.light = dynamicLights.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);
|
||||
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 int blockX = blockRenderContext.localPosX;
|
||||
final int blockY = blockRenderContext.localPosY;
|
||||
final int blockZ = blockRenderContext.localPosZ;
|
||||
|
||||
final boolean isEmissive = LightDataAccess.unpackEM(lightDataCache.get(originX + blockX, originY + blockY, originZ + blockZ));
|
||||
final boolean quadIsFullBright = QuadLightingHelper.isQuadFullBright(vertices);
|
||||
|
||||
if (isEmissive || quadIsFullBright) {
|
||||
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();
|
||||
smoothLightPipeline.calculate(quadView, originX + blockX, originY + blockY, originZ + blockZ, quadLightData, lightFace, 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 Material correctMaterial = selectMaterial(material, sprite);
|
||||
final var builder = buffers.get(correctMaterial);
|
||||
|
||||
|
||||
+13
-9
@@ -93,6 +93,8 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
final int maxY = minY + 16;
|
||||
final int maxZ = minZ + 16;
|
||||
|
||||
buildContext.setupDynamicLights(minX, minY, minZ);
|
||||
|
||||
final BlockPos blockPos = new BlockPos(minX, minY, minZ);
|
||||
final IBlockAccess region = getBlockAccess();
|
||||
final SmoothBiomeColorCache biomeColorCache = getBiomeColorCache();
|
||||
@@ -161,7 +163,7 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
continue;
|
||||
}
|
||||
|
||||
renderBlock(block, x, y, z, pass, tessellator, renderBlocks,
|
||||
renderBlock(block, meta, x, y, z, pass, tessellator, renderBlocks,
|
||||
buffers, buildContext, blockRenderContext, minX, minY, minZ);
|
||||
}
|
||||
}
|
||||
@@ -205,7 +207,7 @@ 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) {
|
||||
|
||||
final Material blockMaterial = block.getMaterial();
|
||||
final boolean isFluid = blockMaterial == Material.water || blockMaterial == Material.lava;
|
||||
@@ -216,24 +218,26 @@ public abstract class AngelicaChunkBuilderMeshingTask extends ChunkBuilderTask<C
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
setRenderPass(pass);
|
||||
// Trigger side effects from canRenderInPass (some ISBRHs like BuildCraft set global state in this method that gets read elsewhere renderWorldBlock)
|
||||
block.canRenderInPass(pass);
|
||||
tessellator.startDrawingQuads();
|
||||
renderBlocks.renderBlockByRenderType(block, x, y, z);
|
||||
buildContext.copyRawBuffer(tessellator.rawBuffer, tessellator.vertexCount, buffers,
|
||||
passMaterial, originX, originY, originZ);
|
||||
buildContext.copyRawBuffer(tessellator.rawBuffer, tessellator.vertexCount, buffers, passMaterial);
|
||||
tessellator.reset();
|
||||
tessellator.isDrawing = false;
|
||||
|
||||
@@ -252,7 +256,7 @@ 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);
|
||||
}
|
||||
|
||||
+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;
|
||||
|
||||
+17
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import com.gtnewhorizons.angelica.Tags;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.states.FogState;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
@@ -33,6 +34,10 @@ public class CeleritasDebugScreenHandler {
|
||||
event.left.add(getFogDebugString());
|
||||
}
|
||||
|
||||
if (DynamicLights.configEnabled && DynamicLights.isEnabled()) {
|
||||
event.left.add(getDynamicLightsDebugString());
|
||||
}
|
||||
|
||||
event.right.add("");
|
||||
event.right.add(EnumChatFormatting.GREEN + "Angelica " + Tags.VERSION + " [Celeritas Renderer]");
|
||||
event.right.addAll(renderer.getDebugStrings());
|
||||
@@ -58,4 +63,16 @@ public class CeleritasDebugScreenHandler {
|
||||
fog.getFogColor().y,
|
||||
fog.getFogColor().z);
|
||||
}
|
||||
|
||||
public static String getDynamicLightsDebugString() {
|
||||
final DynamicLights dl = DynamicLights.get();
|
||||
int sources = dl.getLightSourcesCount();
|
||||
int updated = dl.getLastUpdateCount();
|
||||
|
||||
if (DynamicLights.FrustumCullingEnabled) {
|
||||
int pending = dl.getChunkRebuildManager().getPendingCount();
|
||||
return String.format("DynLights: %d src, %d upd, %d pending", sources, updated, pending);
|
||||
}
|
||||
return String.format("DynLights: %d sources, %d updated", sources, updated);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import org.embeddedt.embeddium.impl.gl.device.GLRenderDevice;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
public class CeleritasSetup {
|
||||
private static boolean initialized = false;
|
||||
|
||||
public static void ensureInitialized() {
|
||||
if (!initialized && AngelicaConfig.enableCeleritas) {
|
||||
GLRenderDevice.VANILLA_STATE_RESETTER = () -> GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
|
||||
LOGGER.debug("Celeritas init");
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -148,6 +148,11 @@ public class CeleritasWorldRenderer extends SimpleWorldRenderer<WorldClient, Ang
|
||||
|
||||
super.setupTerrain(viewport, cameraState, frame, spectator, updateChunksImmediately);
|
||||
|
||||
// Process deferred dynamic light chunk rebuilds with frustum culling
|
||||
if (DynamicLights.isEnabled() && DynamicLights.FrustumCullingEnabled) {
|
||||
DynamicLights.get().processChunkRebuilds(viewport);
|
||||
}
|
||||
|
||||
// Collect tile entities for shadow pass rendering
|
||||
if (renderSectionManager.isInShadowPass() && IrisShaderProviderHolder.isActive()) {
|
||||
collectTileEntitiesForShadow();
|
||||
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
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;
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@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() {
|
||||
return ModelQuadFlags.getQuadFlags(this, getLightFace());
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
-4
@@ -1,6 +1,5 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas.api;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.minecraft.block.Block;
|
||||
import org.embeddedt.embeddium.impl.gl.shader.GlProgram;
|
||||
import org.embeddedt.embeddium.impl.render.chunk.RenderPassConfiguration;
|
||||
@@ -28,7 +27,4 @@ public interface IrisShaderProvider {
|
||||
|
||||
/** Block render layer overrides from shader pack */
|
||||
@Nullable Map<Block, RenderLayer> getBlockTypeIds();
|
||||
|
||||
/** Block ID matches for extended vertex data */
|
||||
@Nullable Object2IntMap<Block> getBlockMatches();
|
||||
}
|
||||
+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;
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
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;
|
||||
|
||||
boolean em;
|
||||
if (lu > 0) {
|
||||
em = true;
|
||||
} else {
|
||||
try {
|
||||
em = block.getMixedBrightnessForBlock(EmptyBlockAccess.INSTANCE, x, y, z) == QuadLightingHelper.FULL_BRIGHT_15;
|
||||
} catch (Exception e) {
|
||||
em = false;
|
||||
}
|
||||
}
|
||||
|
||||
return packFC(fc) | packFO(fo) | packOP(op) | packEM(em) | packAO(ao) | packLU(lu) | packSL(sl) | packBL(bl);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.gtnewhorizons.angelica.rendering.celeritas.light;
|
||||
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -39,7 +39,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 +55,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkSectionPos;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.CompatMathHelper;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.IDynamicLightSource;
|
||||
|
||||
import java.util.List;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.world.cloned.ChunkRenderContext;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.world.cloned.ClonedChunkSection;
|
||||
import com.gtnewhorizons.angelica.rendering.celeritas.world.cloned.ClonedChunkSectionCache;
|
||||
@@ -95,6 +98,9 @@ public class WorldSlice implements IBlockAccessExtended, FLBlockAccess {
|
||||
private ChunkSectionPos origin;
|
||||
private StructureBoundingBox volume;
|
||||
|
||||
private List<IDynamicLightSource> chunkLightSources;
|
||||
private DynamicLights dynamicLightsInstance;
|
||||
|
||||
public static ChunkRenderContext prepare(World world, ChunkSectionPos origin, ClonedChunkSectionCache sectionCache) {
|
||||
final Chunk chunk = world.getChunkFromChunkCoords(origin.x, origin.z);
|
||||
final ExtendedBlockStorage section = chunk.getBlockStorageArray()[origin.y];
|
||||
@@ -181,6 +187,15 @@ public class WorldSlice implements IBlockAccessExtended, FLBlockAccess {
|
||||
this.baseZ = (this.origin.z - NEIGHBOR_CHUNK_RADIUS) << 4;
|
||||
Arrays.fill(this.biomeData, null);
|
||||
|
||||
// Pre-filter dynamic light sources for this chunk section
|
||||
if (DynamicLights.isEnabled()) {
|
||||
this.dynamicLightsInstance = DynamicLights.get();
|
||||
this.chunkLightSources = dynamicLightsInstance.getSourcesForChunk(this.origin.getMinX(), this.origin.getMinY(), this.origin.getMinZ());
|
||||
} else {
|
||||
this.dynamicLightsInstance = null;
|
||||
this.chunkLightSources = null;
|
||||
}
|
||||
|
||||
for (int x = 0; x < SECTION_LENGTH; x++) {
|
||||
for (int y = 0; y < SECTION_LENGTH; y++) {
|
||||
for (int z = 0; z < SECTION_LENGTH; z++) {
|
||||
@@ -220,8 +235,13 @@ public class WorldSlice implements IBlockAccessExtended, FLBlockAccess {
|
||||
blockBrightness = min;
|
||||
}
|
||||
|
||||
if (DynamicLights.isEnabled() && !getBlock(x, y, z).isOpaqueCube()) {
|
||||
return DynamicLights.get().getLightmapWithDynamicLight(x, y, z, (skyBrightness << 20 | blockBrightness << 4));
|
||||
if (chunkLightSources != null && !chunkLightSources.isEmpty() && !getBlock(x, y, z).isOpaqueCube()) {
|
||||
final int lightmap = skyBrightness << 20 | blockBrightness << 4;
|
||||
final double dynamicLevel = dynamicLightsInstance.getDynamicLightLevelFromSources(x + 0.5, y + 0.5, z + 0.5, chunkLightSources);
|
||||
if (dynamicLevel > 0) {
|
||||
return dynamicLightsInstance.getLightmapWithDynamicLight(dynamicLevel, lightmap);
|
||||
}
|
||||
return lightmap;
|
||||
}
|
||||
|
||||
return skyBrightness << 20 | blockBrightness << 4;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package jss.notfine.core;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.AdaptiveTickCalculator;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.ChunkRebuildManager;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLightsMode;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -60,6 +62,42 @@ public enum Settings {
|
||||
DynamicLights.ShaderForce = (boolean) this.option.getStore();
|
||||
}
|
||||
},
|
||||
DYNAMIC_LIGHTS_FRUSTUM_CULLING(new NotFineOptionTickBox(true, OptionImpact.MEDIUM)){
|
||||
@Override
|
||||
public void applyChanges() {
|
||||
DynamicLights.FrustumCullingEnabled = (boolean) this.option.getStore();
|
||||
}
|
||||
},
|
||||
DYNAMIC_LIGHTS_ADAPTIVE_TICKING(new NotFineOptionTickBox(true, OptionImpact.MEDIUM)){
|
||||
@Override
|
||||
public void applyChanges() {
|
||||
DynamicLights.AdaptiveTickingEnabled = (boolean) this.option.getStore();
|
||||
}
|
||||
},
|
||||
DYNAMIC_LIGHTS_SLOW_DIST(new NotFineOptionSlider(32, 16, 64, 8, OptionImpact.LOW)){
|
||||
@Override
|
||||
public void applyChanges() {
|
||||
AdaptiveTickCalculator.setSlowDistance((int) this.option.getStore());
|
||||
}
|
||||
},
|
||||
DYNAMIC_LIGHTS_SLOWER_DIST(new NotFineOptionSlider(64, 32, 128, 16, OptionImpact.LOW)){
|
||||
@Override
|
||||
public void applyChanges() {
|
||||
AdaptiveTickCalculator.setSlowerDistance((int) this.option.getStore());
|
||||
}
|
||||
},
|
||||
DYNAMIC_LIGHTS_BACKGROUND_DIST(new NotFineOptionSlider(128, 64, 256, 16, OptionImpact.LOW)){
|
||||
@Override
|
||||
public void applyChanges() {
|
||||
AdaptiveTickCalculator.setBackgroundDistance((int) this.option.getStore());
|
||||
}
|
||||
},
|
||||
DYNAMIC_LIGHTS_CULL_TIMEOUT(new NotFineOptionSlider(100, 20, 200, 20, OptionImpact.LOW)){
|
||||
@Override
|
||||
public void applyChanges() {
|
||||
ChunkRebuildManager.setMaxTicksWaiting((int) this.option.getStore());
|
||||
}
|
||||
},
|
||||
HORIZON_DISABLE(new NotFineOptionTickBox(true, OptionImpact.LOW)),
|
||||
FOG_DISABLE(new NotFineOptionTickBox(false, OptionImpact.LOW)),
|
||||
FOG_NEAR_DISTANCE(new NotFineOptionSliderPercentage(75, 1, 100, 1, OptionImpact.LOW)),
|
||||
|
||||
@@ -189,8 +189,6 @@ public class NotFineGameOptionPages {
|
||||
.add(Settings.MODE_WATER.option)
|
||||
.add(Settings.DOWNFALL_DISTANCE.option)
|
||||
.add(Settings.MODE_VIGNETTE.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS.option, DynamicLights.configEnabled)
|
||||
.add(Settings.DYNAMIC_LIGHTS_SHADER_FORCE.option, DynamicLights.configEnabled)
|
||||
.add(Settings.MODE_SHADOWS.option)
|
||||
.add(Settings.VOID_FOG.option)
|
||||
.add(Settings.MODE_DROPPED_ITEMS.option)
|
||||
|
||||
-12
@@ -5,19 +5,7 @@ import me.jellysquid.mods.sodium.client.util.Dim2i;
|
||||
|
||||
public interface OptionExtended<T> extends Option<T> {
|
||||
|
||||
boolean isHighlight();
|
||||
|
||||
void setHighlight(boolean highlight);
|
||||
|
||||
Dim2i getDim2i();
|
||||
|
||||
void setDim2i(Dim2i dim2i);
|
||||
|
||||
Dim2i getParentDimension();
|
||||
|
||||
void setParentDimension(Dim2i dim2i);
|
||||
|
||||
boolean isSelected();
|
||||
|
||||
void setSelected(boolean selected);
|
||||
}
|
||||
+86
-38
@@ -14,6 +14,7 @@ import me.jellysquid.mods.sodium.client.gui.SodiumGameOptionPages;
|
||||
import me.jellysquid.mods.sodium.client.gui.SodiumOptionsGUI;
|
||||
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;
|
||||
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;
|
||||
@@ -28,6 +29,7 @@ import org.lwjgl.input.Keyboard;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ReeseSodiumVideoOptionsScreen extends SodiumOptionsGUI {
|
||||
@@ -39,7 +41,6 @@ public class ReeseSodiumVideoOptionsScreen extends SodiumOptionsGUI {
|
||||
private static final AtomicReference<Integer> optionPageScrollBarOffset = new AtomicReference<>(0);
|
||||
|
||||
private static final AtomicReference<String> lastSearch = new AtomicReference<>("");
|
||||
private static final AtomicReference<Integer> lastSearchIndex = new AtomicReference<>(0);
|
||||
|
||||
private AbstractFrame frame;
|
||||
private SearchTextFieldComponent searchTextField;
|
||||
@@ -51,8 +52,14 @@ public class ReeseSodiumVideoOptionsScreen extends SodiumOptionsGUI {
|
||||
// Hackalicious! Rebuild UI
|
||||
@Override
|
||||
public void rebuildGUI() {
|
||||
// Preserve search focus state across rebuilds
|
||||
boolean wasSearchFocused = this.searchTextField != null && this.searchTextField.isFocused();
|
||||
this.children.clear();
|
||||
this.initGui();
|
||||
if (wasSearchFocused && this.searchTextField != null) {
|
||||
this.searchTextField.setFocused(true);
|
||||
this.setFocused(this.searchTextField);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,62 +105,85 @@ public class ReeseSodiumVideoOptionsScreen extends SodiumOptionsGUI {
|
||||
this.applyButton = new FlatButtonWidget(applyButtonDim, "Apply", this::applyChanges);
|
||||
this.closeButton = new FlatButtonWidget(closeButtonDim, "Close", this::onClose);
|
||||
|
||||
// Pre-compute button text and widths to avoid duplicate calculations
|
||||
final String irisText = Iris.enabled ? I18n.format(IrisApi.getInstance().getMainScreenLanguageKey()) : null;
|
||||
final int irisWidth = irisText != null ? this.mc.fontRenderer.getStringWidth(irisText) : 0;
|
||||
final String fontConfigText = AngelicaConfig.enableFontRenderer ? I18n.format("options.angelica.fontconfig") : null;
|
||||
final int fontConfigWidth = fontConfigText != null ? this.mc.fontRenderer.getStringWidth(fontConfigText) : 0;
|
||||
|
||||
// Total width reserved for buttons (used for search field sizing)
|
||||
int buttonsWidth = 0;
|
||||
if (irisText != null) buttonsWidth += irisWidth + 12;
|
||||
if (fontConfigText != null) buttonsWidth += fontConfigWidth + 14;
|
||||
|
||||
// Create search field before parentBasicFrameBuilder (which needs the predicate)
|
||||
Dim2i searchTextFieldDim = new Dim2i(tabFrameDim.getOriginX(), tabFrameDim.getOriginY() - 26, tabFrameDim.getWidth() - buttonsWidth, 20);
|
||||
this.searchTextField = new SearchTextFieldComponent(searchTextFieldDim, this.pages, tabFrameSelectedTab,
|
||||
tabFrameScrollBarOffset, optionPageScrollBarOffset, tabFrameDim.getHeight(), this, lastSearch);
|
||||
|
||||
basicFrameBuilder = this.parentBasicFrameBuilder(basicFrameDim, tabFrameDim);
|
||||
|
||||
int cumulativeXShift = 0;
|
||||
|
||||
if (Iris.enabled) {
|
||||
//int size = this.client.textRenderer.getWidth(new TranslatableText(IrisApi.getInstance().getMainScreenLanguageKey()));
|
||||
final String irisText = I18n.format(IrisApi.getInstance().getMainScreenLanguageKey());
|
||||
final int size = this.mc.fontRenderer.getStringWidth(irisText);
|
||||
final Dim2i shaderPackButtonDim = new Dim2i(tabFrameDim.getLimitX() - size - 10, tabFrameDim.getOriginY() - 26, 10 + size, 20);
|
||||
cumulativeXShift += size + 12;
|
||||
|
||||
// Add buttons after basicFrameBuilder is created
|
||||
int buttonX = tabFrameDim.getLimitX();
|
||||
if (irisText != null) {
|
||||
buttonX -= irisWidth + 10;
|
||||
final Dim2i shaderPackButtonDim = new Dim2i(buttonX, tabFrameDim.getOriginY() - 26, irisWidth + 10, 20);
|
||||
final FlatButtonWidget shaderPackButton = new FlatButtonWidget(shaderPackButtonDim, irisText, () -> mc.displayGuiScreen(new ShaderPackScreen(this)));
|
||||
basicFrameBuilder.addChild(dim -> shaderPackButton);
|
||||
buttonX -= 2; // gap between buttons
|
||||
}
|
||||
|
||||
if (AngelicaConfig.enableFontRenderer) {
|
||||
final String fontConfigText = I18n.format("options.angelica.fontconfig");
|
||||
final int size = this.mc.fontRenderer.getStringWidth(fontConfigText);
|
||||
final Dim2i fontConfigButtonDim = new Dim2i(tabFrameDim.getLimitX() - size - 12 - cumulativeXShift, tabFrameDim.getOriginY() - 26, 12 + size, 20);
|
||||
cumulativeXShift += size + 14;
|
||||
|
||||
if (fontConfigText != null) {
|
||||
buttonX -= fontConfigWidth + 12;
|
||||
final Dim2i fontConfigButtonDim = new Dim2i(buttonX, tabFrameDim.getOriginY() - 26, fontConfigWidth + 12, 20);
|
||||
final FlatButtonWidget fontConfigButton = new FlatButtonWidget(fontConfigButtonDim, fontConfigText, () -> mc.displayGuiScreen(new FontConfigScreen(this)));
|
||||
basicFrameBuilder.addChild(dim -> fontConfigButton);
|
||||
}
|
||||
|
||||
Dim2i searchTextFieldDim = new Dim2i(tabFrameDim.getOriginX(), tabFrameDim.getOriginY() - 26, tabFrameDim.getWidth() - cumulativeXShift, 20);
|
||||
this.searchTextField = new SearchTextFieldComponent(searchTextFieldDim, this.pages, tabFrameSelectedTab,
|
||||
tabFrameScrollBarOffset, optionPageScrollBarOffset, tabFrameDim.getHeight(), this, lastSearch, lastSearchIndex);
|
||||
|
||||
basicFrameBuilder.addChild(dim -> this.searchTextField);
|
||||
|
||||
return basicFrameBuilder;
|
||||
}
|
||||
|
||||
public BasicFrame.Builder parentBasicFrameBuilder(Dim2i parentBasicFrameDim, Dim2i tabFrameDim) {
|
||||
return BasicFrame.createBuilder()
|
||||
final Predicate<Option<?>> optionPredicate = searchTextField.getOptionPredicate();
|
||||
final boolean noResults = searchTextField.hasNoResults();
|
||||
|
||||
BasicFrame.Builder builder = BasicFrame.createBuilder()
|
||||
.setDimension(parentBasicFrameDim)
|
||||
.shouldRenderOutline(false)
|
||||
.addChild(parentDim -> TabFrame.createBuilder()
|
||||
.setDimension(tabFrameDim)
|
||||
.shouldRenderOutline(false)
|
||||
.setTabSectionScrollBarOffset(tabFrameScrollBarOffset)
|
||||
.setTabSectionSelectedTab(tabFrameSelectedTab)
|
||||
.addTabs(tabs -> this.pages
|
||||
.stream()
|
||||
.filter(page -> !page.getGroups().isEmpty())
|
||||
.forEach(page -> tabs.add(Tab.createBuilder().from(page, optionPageScrollBarOffset)))
|
||||
)
|
||||
.onSetTab(() -> {
|
||||
optionPageScrollBarOffset.set(0);
|
||||
})
|
||||
.build()
|
||||
)
|
||||
.shouldRenderOutline(false);
|
||||
|
||||
if (noResults) {
|
||||
// Show "No matching options" message centered in the tab area
|
||||
final String noResultsText = I18n.format("options.angelica.search.no_results");
|
||||
builder.addChild(dim -> new me.jellysquid.mods.sodium.client.gui.widgets.AbstractWidget() {
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float delta) {
|
||||
int textWidth = mc.fontRenderer.getStringWidth(noResultsText);
|
||||
int x = tabFrameDim.getCenterX() - textWidth / 2;
|
||||
int y = tabFrameDim.getCenterY();
|
||||
drawString(noResultsText, x, y, 0x808080);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
builder.addChild(parentDim -> TabFrame.createBuilder()
|
||||
.setDimension(tabFrameDim)
|
||||
.shouldRenderOutline(false)
|
||||
.setTabSectionScrollBarOffset(tabFrameScrollBarOffset)
|
||||
.setTabSectionSelectedTab(tabFrameSelectedTab)
|
||||
.addTabs(tabs -> this.pages
|
||||
.stream()
|
||||
.filter(this::canShowPage)
|
||||
.forEach(page -> tabs.add(Tab.createBuilder().from(page, optionPredicate, optionPageScrollBarOffset)))
|
||||
)
|
||||
.onSetTab(() -> {
|
||||
optionPageScrollBarOffset.set(0);
|
||||
})
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
return builder
|
||||
.addChild(dim -> this.undoButton)
|
||||
.addChild(dim -> this.applyButton)
|
||||
.addChild(dim -> this.closeButton);
|
||||
@@ -224,6 +254,25 @@ public class ReeseSodiumVideoOptionsScreen extends SodiumOptionsGUI {
|
||||
this.getAllOptions().forEach(Option::reset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a page has any options that match the current search filter.
|
||||
*/
|
||||
private boolean canShowPage(OptionPage page) {
|
||||
if (page.getGroups().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Predicate<Option<?>> predicate = searchTextField.getOptionPredicate();
|
||||
for (OptionGroup group : page.getGroups()) {
|
||||
for (Option<?> option : group.getOptions()) {
|
||||
if (predicate.test(option)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(char typedChar, int keyCode) {
|
||||
if(keyCode == Keyboard.KEY_ESCAPE && !shouldCloseOnEsc()) {
|
||||
@@ -253,7 +302,6 @@ public class ReeseSodiumVideoOptionsScreen extends SodiumOptionsGUI {
|
||||
@Override
|
||||
public void onClose() {
|
||||
lastSearch.set("");
|
||||
lastSearchIndex.set(0);
|
||||
super.onClose();
|
||||
}
|
||||
}
|
||||
+29
-9
@@ -18,18 +18,21 @@ import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class OptionPageFrame extends AbstractFrame {
|
||||
protected static final SodiumControlElementFactory elementFactory = new SodiumControlElementFactory();
|
||||
protected final Dim2i originalDim;
|
||||
protected final OptionPage page;
|
||||
protected final Predicate<Option<?>> optionFilter;
|
||||
private long lastTime = 0;
|
||||
private ControlElement<?> lastHoveredElement = null;
|
||||
|
||||
public OptionPageFrame(Dim2i dim, boolean renderOutline, OptionPage page) {
|
||||
public OptionPageFrame(Dim2i dim, boolean renderOutline, OptionPage page, Predicate<Option<?>> optionFilter) {
|
||||
super(dim, renderOutline);
|
||||
this.originalDim = new Dim2i(dim.getOriginX(), dim.getOriginY(), dim.getWidth(), dim.getHeight());
|
||||
this.page = page;
|
||||
this.optionFilter = optionFilter;
|
||||
this.setupFrame();
|
||||
this.buildFrame();
|
||||
}
|
||||
@@ -48,9 +51,12 @@ public class OptionPageFrame extends AbstractFrame {
|
||||
OptionGroup lastGroup = this.page.getGroups().get(this.page.getGroups().size() - 1);
|
||||
|
||||
for (OptionGroup group : this.page.getGroups()) {
|
||||
y += group.getOptions().size() * 18;
|
||||
if (group != lastGroup) {
|
||||
y += 4;
|
||||
int visibleCount = (int) group.getOptions().stream() .filter(optionFilter::test) .count();
|
||||
if (visibleCount > 0) {
|
||||
y += visibleCount * 18;
|
||||
if (group != lastGroup) {
|
||||
y += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,19 +79,27 @@ public class OptionPageFrame extends AbstractFrame {
|
||||
|
||||
int y = 0;
|
||||
for (OptionGroup group : this.page.getGroups()) {
|
||||
// Add each option's control element
|
||||
boolean hasVisibleOptions = false;
|
||||
|
||||
// Add each option's control element (if it passes the filter)
|
||||
for (Option<?> option : group.getOptions()) {
|
||||
if (!optionFilter.test(option)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
hasVisibleOptions = true;
|
||||
final Control<?> control = option.getControl();
|
||||
final ControlElement<?> element = control.createElement(new Dim2i(this.dim.getOriginX(), this.dim.getOriginY() + y, this.dim.getWidth(), 18), elementFactory);
|
||||
// This is probably not safe
|
||||
this.children.add((AbstractWidget) element);
|
||||
|
||||
// Move down to the next option
|
||||
y += 18;
|
||||
}
|
||||
|
||||
// Add padding beneath each option group
|
||||
y += 4;
|
||||
// Add padding beneath each option group (only if it had visible options)
|
||||
if (hasVisibleOptions) {
|
||||
y += 4;
|
||||
}
|
||||
}
|
||||
|
||||
super.buildFrame();
|
||||
@@ -160,6 +174,7 @@ public class OptionPageFrame extends AbstractFrame {
|
||||
private Dim2i dim;
|
||||
private boolean renderOutline;
|
||||
private OptionPage page;
|
||||
private Predicate<Option<?>> optionFilter = opt -> true;
|
||||
|
||||
public Builder setDimension(Dim2i dim) {
|
||||
this.dim = dim;
|
||||
@@ -176,11 +191,16 @@ public class OptionPageFrame extends AbstractFrame {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setOptionFilter(Predicate<Option<?>> optionFilter) {
|
||||
this.optionFilter = optionFilter;
|
||||
return this;
|
||||
}
|
||||
|
||||
public OptionPageFrame build() {
|
||||
Validate.notNull(this.dim, "Dimension must be specified");
|
||||
Validate.notNull(this.page, "Option Page must be specified");
|
||||
|
||||
return new OptionPageFrame(this.dim, this.renderOutline, this.page);
|
||||
return new OptionPageFrame(this.dim, this.renderOutline, this.page, this.optionFilter);
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
-71
@@ -2,7 +2,6 @@ package me.flashyreese.mods.reeses_sodium_options.client.gui.frame.components;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.flashyreese.mods.reeses_sodium_options.client.gui.OptionExtended;
|
||||
import me.flashyreese.mods.reeses_sodium_options.client.gui.ReeseSodiumVideoOptionsScreen;
|
||||
import me.flashyreese.mods.reeses_sodium_options.util.StringUtils;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.Option;
|
||||
@@ -18,8 +17,10 @@ import net.minecraft.util.MathHelper;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -34,7 +35,6 @@ public class SearchTextFieldComponent extends AbstractWidget {
|
||||
private final int tabDimHeight;
|
||||
private final ReeseSodiumVideoOptionsScreen sodiumVideoOptionsScreen;
|
||||
private final AtomicReference<String> lastSearch;
|
||||
private final AtomicReference<Integer> lastSearchIndex;
|
||||
protected boolean selecting;
|
||||
protected String text = "";
|
||||
protected int maxLength = 100;
|
||||
@@ -50,7 +50,10 @@ public class SearchTextFieldComponent extends AbstractWidget {
|
||||
private boolean focused;
|
||||
private int lastCursorPosition = this.getCursor();
|
||||
|
||||
public SearchTextFieldComponent(Dim2i dim, List<OptionPage> pages, AtomicReference<String> tabFrameSelectedTab, AtomicReference<Integer> tabFrameScrollBarOffset, AtomicReference<Integer> optionPageScrollBarOffset, int tabDimHeight, ReeseSodiumVideoOptionsScreen sodiumVideoOptionsScreen, AtomicReference<String> lastSearch, AtomicReference<Integer> lastSearchIndex) {
|
||||
// Set of options matching the current search query (null = show all)
|
||||
private Set<Option<?>> matchingOptions = null;
|
||||
|
||||
public SearchTextFieldComponent(Dim2i dim, List<OptionPage> pages, AtomicReference<String> tabFrameSelectedTab, AtomicReference<Integer> tabFrameScrollBarOffset, AtomicReference<Integer> optionPageScrollBarOffset, int tabDimHeight, ReeseSodiumVideoOptionsScreen sodiumVideoOptionsScreen, AtomicReference<String> lastSearch) {
|
||||
this.dim = dim;
|
||||
this.pages = pages;
|
||||
this.tabFrameSelectedTab = tabFrameSelectedTab;
|
||||
@@ -59,12 +62,30 @@ public class SearchTextFieldComponent extends AbstractWidget {
|
||||
this.tabDimHeight = tabDimHeight;
|
||||
this.sodiumVideoOptionsScreen = sodiumVideoOptionsScreen;
|
||||
this.lastSearch = lastSearch;
|
||||
this.lastSearchIndex = lastSearchIndex;
|
||||
if (!lastSearch.get().trim().isEmpty()) {
|
||||
this.write(lastSearch.get());
|
||||
|
||||
// Initialize text from lastSearch without triggering rebuild
|
||||
String initialSearch = lastSearch.get().trim();
|
||||
if (!initialSearch.isEmpty()) {
|
||||
this.text = initialSearch;
|
||||
this.selectionStart = initialSearch.length();
|
||||
this.selectionEnd = initialSearch.length();
|
||||
// Initialize matching options for the restored search
|
||||
this.matchingOptions = new HashSet<>(StringUtils.fuzzySearch(this.pages, initialSearch, 2));
|
||||
}
|
||||
}
|
||||
|
||||
public Predicate<Option<?>> getOptionPredicate() {
|
||||
return matchingOptions == null ? opt -> true : matchingOptions::contains;
|
||||
}
|
||||
|
||||
public boolean hasSearchQuery() {
|
||||
return !this.text.trim().isEmpty();
|
||||
}
|
||||
|
||||
public boolean hasNoResults() {
|
||||
return hasSearchQuery() && matchingOptions != null && matchingOptions.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float delta) {
|
||||
if (!this.isVisible()) {
|
||||
@@ -118,17 +139,22 @@ public class SearchTextFieldComponent extends AbstractWidget {
|
||||
|
||||
@Override
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
// Right-click to clear search
|
||||
if (button == 1 && this.dim.containsCursor(mouseX, mouseY)) {
|
||||
this.text = "";
|
||||
this.selectionStart = 0;
|
||||
this.selectionEnd = 0;
|
||||
this.firstCharacterIndex = 0;
|
||||
this.onChanged("");
|
||||
this.setFocused(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
final int i = MathHelper.floor_double(mouseX) - this.dim.getOriginX() - 6;
|
||||
final String string = this.textRenderer.trimStringToWidth(this.text.substring(this.firstCharacterIndex), this.getInnerWidth());
|
||||
this.setCursor(this.textRenderer.trimStringToWidth(string, i).length() + this.firstCharacterIndex);
|
||||
|
||||
this.setFocused(this.dim.containsCursor(mouseX, mouseY));
|
||||
this.pages.forEach(page -> page
|
||||
.getOptions()
|
||||
.stream()
|
||||
.filter(OptionExtended.class::isInstance)
|
||||
.map(OptionExtended.class::cast)
|
||||
.forEach(optionExtended -> optionExtended.setSelected(false)));
|
||||
return this.isFocused();
|
||||
}
|
||||
|
||||
@@ -192,22 +218,16 @@ public class SearchTextFieldComponent extends AbstractWidget {
|
||||
}
|
||||
|
||||
private void onChanged(String newText) {
|
||||
this.pages.forEach(page -> page
|
||||
.getOptions()
|
||||
.stream()
|
||||
.filter(OptionExtended.class::isInstance)
|
||||
.map(OptionExtended.class::cast)
|
||||
.forEach(optionExtended -> optionExtended.setHighlight(false)));
|
||||
|
||||
this.lastSearch.set(newText.trim());
|
||||
if (this.editable && (!newText.trim().isEmpty())) {
|
||||
final List<Option<?>> fuzzy = StringUtils.fuzzySearch(this.pages, newText, 2);
|
||||
fuzzy.stream()
|
||||
.filter(OptionExtended.class::isInstance)
|
||||
.map(OptionExtended.class::cast)
|
||||
.forEach(optionExtended -> optionExtended.setHighlight(true));
|
||||
|
||||
if (this.editable && !newText.trim().isEmpty()) {
|
||||
final List<Option<?>> fuzzy = StringUtils.fuzzySearch(this.pages, newText, 2);
|
||||
this.matchingOptions = new HashSet<>(fuzzy);
|
||||
} else {
|
||||
this.matchingOptions = null;
|
||||
}
|
||||
|
||||
this.sodiumVideoOptionsScreen.rebuildGUI();
|
||||
}
|
||||
|
||||
private void erase(int offset) {
|
||||
@@ -296,8 +316,6 @@ public class SearchTextFieldComponent extends AbstractWidget {
|
||||
if (!this.selecting) {
|
||||
this.setSelectionEnd(this.selectionStart);
|
||||
}
|
||||
|
||||
this.onChanged(this.text);
|
||||
}
|
||||
|
||||
public void moveCursor(int offset) {
|
||||
@@ -368,12 +386,6 @@ public class SearchTextFieldComponent extends AbstractWidget {
|
||||
//
|
||||
@Override
|
||||
public boolean keyTyped(char typedChar, int keyCode) {
|
||||
this.pages.forEach(page2 -> page2
|
||||
.getOptions()
|
||||
.stream()
|
||||
.filter(OptionExtended.class::isInstance)
|
||||
.map(OptionExtended.class::cast)
|
||||
.forEach(optionExtended2 -> optionExtended2.setSelected(false)));
|
||||
if (!this.isActive()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -404,42 +416,6 @@ public class SearchTextFieldComponent extends AbstractWidget {
|
||||
return true;
|
||||
} else {
|
||||
switch (keyCode) {
|
||||
case Keyboard.KEY_RETURN: // GLFW.GLFW_KEY_ENTER
|
||||
if (this.editable) {
|
||||
int count = 0;
|
||||
for (OptionPage page : this.pages) {
|
||||
for (Option<?> option : page.getOptions()) {
|
||||
if(option instanceof OptionExtended<?> optionExtended) {
|
||||
if (optionExtended.isHighlight() && optionExtended.getParentDimension() != null) {
|
||||
if (count == this.lastSearchIndex.get()) {
|
||||
final Dim2i optionDim = optionExtended.getDim2i();
|
||||
final Dim2i parentDim = optionExtended.getParentDimension();
|
||||
final int maxOffset = parentDim.getHeight() - this.tabDimHeight;
|
||||
final int input = optionDim.getOriginY() - parentDim.getOriginY();
|
||||
final int inputOffset = input + optionDim.getHeight() == parentDim.getHeight() ? parentDim.getHeight() : input;
|
||||
final int offset = inputOffset * maxOffset / parentDim.getHeight();
|
||||
|
||||
int total = this.pages.stream().mapToInt(page2 -> Math.toIntExact(page2.getOptions().stream().filter(OptionExtended.class::isInstance).map(OptionExtended.class::cast).filter(OptionExtended::isHighlight).count())).sum();
|
||||
|
||||
final int value = total == this.lastSearchIndex.get() + 1 ? 0 : this.lastSearchIndex.get() + 1;
|
||||
optionExtended.setSelected(true);
|
||||
this.lastSearchIndex.set(value);
|
||||
this.tabFrameSelectedTab.set(page.getName());
|
||||
// todo: calculate tab frame scroll bar offset
|
||||
this.tabFrameScrollBarOffset.set(0);
|
||||
|
||||
this.optionPageScrollBarOffset.set(offset);
|
||||
this.setFocused(false);
|
||||
this.sodiumVideoOptionsScreen.rebuildGUI();
|
||||
return true;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case Keyboard.KEY_BACK: // GLFW.GLFW_KEY_BACKSPACE
|
||||
if (this.editable) {
|
||||
this.selecting = false;
|
||||
@@ -481,9 +457,7 @@ public class SearchTextFieldComponent extends AbstractWidget {
|
||||
default:
|
||||
if (ChatAllowedCharacters.isAllowedCharacter(typedChar)) {
|
||||
if (this.editable) {
|
||||
this.lastSearch.set(this.text.trim());
|
||||
this.write(Character.toString(typedChar));
|
||||
this.lastSearchIndex.set(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package me.flashyreese.mods.reeses_sodium_options.client.gui.frame.tab;
|
||||
import me.flashyreese.mods.reeses_sodium_options.client.gui.frame.AbstractFrame;
|
||||
import me.flashyreese.mods.reeses_sodium_options.client.gui.frame.OptionPageFrame;
|
||||
import me.flashyreese.mods.reeses_sodium_options.client.gui.frame.ScrollableFrame;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.Option;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.OptionPage;
|
||||
import me.jellysquid.mods.sodium.client.util.Dim2i;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class Tab<T extends AbstractFrame> {
|
||||
private final String title;
|
||||
@@ -49,6 +51,10 @@ public class Tab<T extends AbstractFrame> {
|
||||
}
|
||||
|
||||
public Tab<ScrollableFrame> from(OptionPage page, AtomicReference<Integer> verticalScrollBarOffset) {
|
||||
return from(page, opt -> true, verticalScrollBarOffset);
|
||||
}
|
||||
|
||||
public Tab<ScrollableFrame> from(OptionPage page, Predicate<Option<?>> optionFilter, AtomicReference<Integer> verticalScrollBarOffset) {
|
||||
return new Tab<>(page.getName(), dim2i -> ScrollableFrame
|
||||
.createBuilder()
|
||||
.setDimension(dim2i)
|
||||
@@ -56,6 +62,7 @@ public class Tab<T extends AbstractFrame> {
|
||||
.createBuilder()
|
||||
.setDimension(new Dim2i(dim2i.getOriginX(), dim2i.getOriginY(), dim2i.getWidth(), dim2i.getHeight()))
|
||||
.setOptionPage(page)
|
||||
.setOptionFilter(optionFilter)
|
||||
.build())
|
||||
.setVerticalScrollBarOffset(verticalScrollBarOffset)
|
||||
.build());
|
||||
|
||||
@@ -38,27 +38,29 @@ public class StringUtils {
|
||||
|
||||
for (OptionPage page : pages) {
|
||||
for (Option<?> option : page.getOptions()) {
|
||||
String sentence = (option.getName()/* +
|
||||
" " +
|
||||
option.getTooltip().getString()+
|
||||
" " +
|
||||
option.getImpact().toString()*/).toLowerCase();
|
||||
String name = option.getName().toLowerCase();
|
||||
String tooltip = option.getTooltip().toLowerCase();
|
||||
|
||||
boolean containsAllWords = true;
|
||||
for (String word : targetWords) {
|
||||
boolean containsWord = false;
|
||||
for (String sentenceWord : sentence.toLowerCase().split("\\s+")) {
|
||||
int distance = levenshteinDistance(word, sentenceWord);
|
||||
if (distance <= maxDistance) {
|
||||
containsWord = true;
|
||||
break;
|
||||
}
|
||||
// Starts with match
|
||||
if (sentenceWord.startsWith(word)) {
|
||||
|
||||
// Fuzzy match on name (handles typos)
|
||||
// Use stricter matching for short words to avoid false positives (e.g., "fps" matching "fog")
|
||||
int effectiveMaxDistance = word.length() < 4 ? Math.min(1, maxDistance) : maxDistance;
|
||||
for (String nameWord : name.split("\\s+")) {
|
||||
int distance = levenshteinDistance(word, nameWord);
|
||||
if (distance <= effectiveMaxDistance || nameWord.startsWith(word)) {
|
||||
containsWord = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Substring match on tooltip (for discoverability like "fps" -> "frames per second")
|
||||
if (!containsWord && tooltip.contains(word)) {
|
||||
containsWord = true;
|
||||
}
|
||||
|
||||
if (!containsWord) {
|
||||
containsAllWords = false;
|
||||
break;
|
||||
|
||||
@@ -238,10 +238,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())
|
||||
@@ -264,8 +264,6 @@ public class SodiumGameOptionPages {
|
||||
)*/
|
||||
.add(Settings.MODE_SHADOWS.option)
|
||||
.add(Settings.MODE_VIGNETTE.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS.option, DynamicLights.configEnabled)
|
||||
.add(Settings.DYNAMIC_LIGHTS_SHADER_FORCE.option, DynamicLights.configEnabled)
|
||||
.build());
|
||||
|
||||
|
||||
|
||||
@@ -55,7 +55,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()
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package me.jellysquid.mods.sodium.client.gui;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.client.gui.DynamicLightsOptionPages;
|
||||
import com.gtnewhorizons.angelica.client.gui.ScrollableGuiScreen;
|
||||
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;
|
||||
@@ -61,6 +63,14 @@ public class SodiumOptionsGUI extends ScrollableGuiScreen {
|
||||
this.pages.add(SodiumGameOptionPages.advanced());
|
||||
this.pages.add(SodiumGameOptionPages.performance());
|
||||
|
||||
// Add Dynamic Lights page if enabled
|
||||
if (DynamicLights.configEnabled) {
|
||||
var dlPage = DynamicLightsOptionPages.dynamicLights();
|
||||
if (dlPage != null) {
|
||||
this.pages.add(dlPage);
|
||||
}
|
||||
}
|
||||
|
||||
if (Iris.enabled) {
|
||||
shaderPacks = new OptionPage(I18n.format("options.iris.shaderPackSelection"), ImmutableList.of());
|
||||
this.pages.add(shaderPacks);
|
||||
|
||||
@@ -214,8 +214,5 @@ public class OptionImpl<S, T> implements OptionExtended<T> {
|
||||
|
||||
|
||||
@Setter @Getter private Dim2i parentDimension;
|
||||
@Setter @Getter private Dim2i dim2i;
|
||||
@Setter @Getter private boolean highlight;
|
||||
@Setter @Getter private boolean selected;
|
||||
|
||||
}
|
||||
-13
@@ -1,6 +1,5 @@
|
||||
package me.jellysquid.mods.sodium.client.gui.options.control.element;
|
||||
|
||||
import me.flashyreese.mods.reeses_sodium_options.client.gui.OptionExtended;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.Option;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.control.ControlElement;
|
||||
import me.jellysquid.mods.sodium.client.gui.widgets.AbstractWidget;
|
||||
@@ -15,9 +14,6 @@ public class SodiumControlElement<T> extends AbstractWidget implements ControlEl
|
||||
public SodiumControlElement(Option<T> option, Dim2i dim) {
|
||||
this.option = option;
|
||||
this.dim = dim;
|
||||
if(option instanceof OptionExtended<?> optionExtended) {
|
||||
optionExtended.setDim2i(dim);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,16 +37,7 @@ public class SodiumControlElement<T> extends AbstractWidget implements ControlEl
|
||||
|
||||
this.hovered = this.dim.containsCursor(mouseX, mouseY);
|
||||
|
||||
|
||||
this.drawRect(this.dim.getOriginX(), this.dim.getOriginY(), this.dim.getLimitX(), this.dim.getLimitY(), this.hovered ? 0xE0000000 : 0x90000000);
|
||||
if(option instanceof OptionExtended<?> optionExtended && (optionExtended.isHighlight())) {
|
||||
final String replacement = optionExtended.isSelected() ? EnumChatFormatting.DARK_GREEN.toString() : EnumChatFormatting.YELLOW.toString();
|
||||
|
||||
label = label.replace(EnumChatFormatting.WHITE.toString(), EnumChatFormatting.WHITE + replacement);
|
||||
label = label.replace(EnumChatFormatting.STRIKETHROUGH.toString(), EnumChatFormatting.STRIKETHROUGH + replacement);
|
||||
label = label.replace(EnumChatFormatting.ITALIC.toString(), EnumChatFormatting.ITALIC + replacement);
|
||||
|
||||
}
|
||||
this.drawString(label, this.dim.getOriginX() + 6, this.dim.getCenterY() - 4, 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -408,8 +409,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 +714,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 +742,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 +881,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,12 @@
|
||||
package net.coderbot.iris.block_rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
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,14 +17,19 @@ 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);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -57,7 +65,11 @@ public class BlockMaterialMapping {
|
||||
};
|
||||
}
|
||||
|
||||
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 +81,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 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 Reference2ObjectMap<Block, Int2IntMap> blockMetaMatches;
|
||||
private Map<Block, RenderLayer> 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,8 +50,8 @@ public class BlockRenderingSettings {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object2IntMap<Block> getBlockMatches() {
|
||||
return blockMatches;
|
||||
public Reference2ObjectMap<Block, Int2IntMap> getBlockMetaMatches() {
|
||||
return blockMetaMatches;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -62,13 +64,14 @@ public class BlockRenderingSettings {
|
||||
return entityIds;
|
||||
}
|
||||
|
||||
public void setBlockMatches(Object2IntMap<Block> blockIds) {
|
||||
if (this.blockMatches != null && this.blockMatches.equals(blockIds)) {
|
||||
return;
|
||||
}
|
||||
@Nullable
|
||||
public Object2IntFunction<NamespacedId> getItemIds() {
|
||||
return itemIds;
|
||||
}
|
||||
|
||||
public void setBlockMetaMatches(Reference2ObjectMap<Block, Int2IntMap> blockMetaIds) {
|
||||
this.reloadRequired = true;
|
||||
this.blockMatches = blockIds;
|
||||
this.blockMetaMatches = blockMetaIds;
|
||||
}
|
||||
|
||||
public void setBlockTypeIds(Map<Block, RenderLayer> blockTypeIds) {
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.coderbot.iris.celeritas;
|
||||
|
||||
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;
|
||||
@@ -66,12 +65,6 @@ public class IrisCeleritasShaderProvider implements IrisShaderProvider {
|
||||
return BlockRenderingSettings.INSTANCE.getBlockTypeIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object2IntMap<Block> getBlockMatches() {
|
||||
return BlockRenderingSettings.INSTANCE.getBlockMatches();
|
||||
}
|
||||
|
||||
public void deleteShaders() {
|
||||
overrides.deleteShaders();
|
||||
}
|
||||
|
||||
@@ -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,8 @@ 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),
|
||||
UNKNOWN(() -> false, () -> false);
|
||||
|
||||
private final BooleanSupplier irisRequirement;
|
||||
|
||||
@@ -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) {
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -106,17 +108,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;
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.coderbot.iris.gl.texture;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
public class TextureWrapper implements TextureAccess {
|
||||
private final IntSupplier texture;
|
||||
private final TextureType type;
|
||||
|
||||
public TextureWrapper(IntSupplier texture, TextureType type) {
|
||||
this.texture = texture;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntSupplier getTextureId() {
|
||||
return this.texture;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package net.coderbot.iris.helpers;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record Tri<X, Y, Z>(X first, Y second, Z third) {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if (!(obj instanceof Tri tri)) return false;
|
||||
return Objects.equals(tri.first, this.first) && Objects.equals(tri.second, this.second) && Objects.equals(tri.third, this.third);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "First: " + first.toString() + " Second: " + second.toString() + " Third: " + third.toString();
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public class GbufferPrograms {
|
||||
public static void beginEntities() {
|
||||
checkReentrancy();
|
||||
setPhase(WorldRenderingPhase.ENTITIES);
|
||||
setBlockEntityDefaults();
|
||||
entities = true;
|
||||
}
|
||||
|
||||
@@ -52,6 +53,7 @@ public class GbufferPrograms {
|
||||
public static void beginBlockEntities() {
|
||||
checkReentrancy();
|
||||
setPhase(WorldRenderingPhase.BLOCK_ENTITIES);
|
||||
setBlockEntityDefaults();
|
||||
blockEntities = true;
|
||||
}
|
||||
|
||||
@@ -68,6 +70,7 @@ public class GbufferPrograms {
|
||||
GL20.glVertexAttrib2s(ProgramCreator.MC_ENTITY, (short)-1, (short)-1);
|
||||
GL20.glVertexAttrib2f(ProgramCreator.MC_MID_TEX_COORD, 0.5f, 0.5f);
|
||||
GL20.glVertexAttrib4f(ProgramCreator.AT_TANGENT, 1.0f, 0.0f, 0.0f, 1.0f);
|
||||
GL20.glVertexAttrib4f(ProgramCreator.AT_MIDBLOCK, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
public static WorldRenderingPhase getCurrentPhase() {
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
package net.coderbot.iris.pipeline;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.EntityRendererAccessor;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMaps;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gl.texture.GlTexture;
|
||||
import net.coderbot.iris.gl.texture.TextureAccess;
|
||||
import net.coderbot.iris.gl.texture.TextureType;
|
||||
import net.coderbot.iris.gl.texture.TextureWrapper;
|
||||
import net.coderbot.iris.rendertarget.NativeImageBackedCustomTexture;
|
||||
import net.coderbot.iris.rendertarget.NativeImageBackedNoiseTexture;
|
||||
import net.coderbot.iris.shaderpack.PackDirectives;
|
||||
@@ -29,24 +35,25 @@ import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
public class CustomTextureManager {
|
||||
private final EnumMap<TextureStage, Object2ObjectMap<String, IntSupplier>> customTextureIdMap = new EnumMap<>(TextureStage.class);
|
||||
private final IntSupplier noise;
|
||||
@Getter private final EnumMap<TextureStage, Object2ObjectMap<String, TextureAccess>> customTextureIdMap = new EnumMap<>(TextureStage.class);
|
||||
@Getter private final Object2ObjectMap<String, TextureAccess> irisCustomTextures = new Object2ObjectOpenHashMap<>();
|
||||
private final TextureAccess noise;
|
||||
|
||||
/**
|
||||
* List of all OpenGL texture objects owned by this CustomTextureManager that need to be deleted in order to avoid
|
||||
* leaks.
|
||||
* List of all OpenGL texture objects owned by this CustomTextureManager that need to be deleted in order to avoid leaks.
|
||||
* Make sure any textures added to this list call releaseId from the close method.
|
||||
*/
|
||||
private final List<AbstractTexture> ownedTextures = new ArrayList<>();
|
||||
private final List<GlTexture> ownedRawTextures = new ArrayList<>();
|
||||
|
||||
public CustomTextureManager(PackDirectives packDirectives,
|
||||
EnumMap<TextureStage, Object2ObjectMap<String, CustomTextureData>> customTextureDataMap,
|
||||
Object2ObjectMap<String, CustomTextureData> irisCustomTextureDataMap,
|
||||
Optional<CustomTextureData> customNoiseTextureData) {
|
||||
customTextureDataMap.forEach((textureStage, customTextureStageDataMap) -> {
|
||||
Object2ObjectMap<String, IntSupplier> customTextureIds = new Object2ObjectOpenHashMap<>();
|
||||
final Object2ObjectMap<String, TextureAccess> customTextureIds = new Object2ObjectOpenHashMap<>();
|
||||
|
||||
customTextureStageDataMap.forEach((samplerName, textureData) -> {
|
||||
try {
|
||||
@@ -60,6 +67,14 @@ public class CustomTextureManager {
|
||||
customTextureIdMap.put(textureStage, customTextureIds);
|
||||
});
|
||||
|
||||
irisCustomTextureDataMap.forEach((name, texture) -> {
|
||||
try {
|
||||
irisCustomTextures.put(name, createCustomTexture(texture));
|
||||
} catch (IOException e) {
|
||||
Iris.logger.error("Unable to parse the image data for the custom texture on sampler " + name, e);
|
||||
}
|
||||
});
|
||||
|
||||
noise = customNoiseTextureData.flatMap(textureData -> {
|
||||
try {
|
||||
return Optional.of(createCustomTexture(textureData));
|
||||
@@ -71,75 +86,85 @@ public class CustomTextureManager {
|
||||
}).orElseGet(() -> {
|
||||
final int noiseTextureResolution = packDirectives.getNoiseTextureResolution();
|
||||
|
||||
AbstractTexture texture = new NativeImageBackedNoiseTexture(noiseTextureResolution);
|
||||
final AbstractTexture texture = new NativeImageBackedNoiseTexture(noiseTextureResolution);
|
||||
ownedTextures.add(texture);
|
||||
|
||||
return texture::getGlTextureId;
|
||||
return new TextureWrapper(texture::getGlTextureId, TextureType.TEXTURE_2D);
|
||||
});
|
||||
}
|
||||
|
||||
private IntSupplier createCustomTexture(CustomTextureData textureData) throws IOException {
|
||||
private TextureAccess createCustomTexture(CustomTextureData textureData) throws IOException {
|
||||
if (textureData instanceof CustomTextureData.PngData) {
|
||||
AbstractTexture texture = new NativeImageBackedCustomTexture((CustomTextureData.PngData) textureData);
|
||||
final AbstractTexture texture = new NativeImageBackedCustomTexture((CustomTextureData.PngData) textureData);
|
||||
ownedTextures.add(texture);
|
||||
|
||||
return texture::getGlTextureId;
|
||||
}
|
||||
// TODO: Iris
|
||||
// else if (textureData instanceof CustomTextureData.LightmapMarker) {
|
||||
// // Special code path for the light texture. While shader packs hardcode the primary light texture, it's
|
||||
// // possible that a mod will create a different light texture, so this code path is robust to that.
|
||||
// return () -> ((LightTextureAccessor) Minecraft.getMinecraft().gameRenderer.lightTexture()).getLightTexture().getId();
|
||||
// }
|
||||
else if (textureData instanceof CustomTextureData.ResourceData) {
|
||||
CustomTextureData.ResourceData resourceData = (CustomTextureData.ResourceData) textureData;
|
||||
String namespace = resourceData.getNamespace();
|
||||
return new TextureWrapper(texture::getGlTextureId, TextureType.TEXTURE_2D);
|
||||
} else if (textureData instanceof CustomTextureData.LightmapMarker) {
|
||||
// Special code path for the light texture. While shader packs hardcode the primary light texture, it's possible that a mod will
|
||||
// create a different light texture, so this code path is robust to that.
|
||||
return new TextureWrapper(() -> ((EntityRendererAccessor) Minecraft.getMinecraft().entityRenderer).getLightmapTexture().getGlTextureId(), TextureType.TEXTURE_2D);
|
||||
} else if (textureData instanceof CustomTextureData.RawData1D rawData) {
|
||||
final GlTexture texture = new GlTexture(TextureType.TEXTURE_1D, rawData.getSizeX(), 0, 0, rawData.getInternalFormat().getGlFormat(), rawData.getPixelFormat().getGlFormat(), rawData.getPixelType().getGlFormat(), rawData.getContent(), rawData.getFilteringData());
|
||||
ownedRawTextures.add(texture);
|
||||
return texture;
|
||||
} else if (textureData instanceof CustomTextureData.RawDataRect rawData) {
|
||||
final GlTexture texture = new GlTexture(TextureType.TEXTURE_RECTANGLE, rawData.getSizeX(), rawData.getSizeY(), 0, rawData.getInternalFormat().getGlFormat(), rawData.getPixelFormat().getGlFormat(), rawData.getPixelType().getGlFormat(), rawData.getContent(), rawData.getFilteringData());
|
||||
ownedRawTextures.add(texture);
|
||||
return texture;
|
||||
} else if (textureData instanceof CustomTextureData.RawData2D rawData) {
|
||||
final GlTexture texture = new GlTexture(TextureType.TEXTURE_2D, rawData.getSizeX(), rawData.getSizeY(), 0, rawData.getInternalFormat().getGlFormat(), rawData.getPixelFormat().getGlFormat(), rawData.getPixelType().getGlFormat(), rawData.getContent(), rawData.getFilteringData());
|
||||
ownedRawTextures.add(texture);
|
||||
return texture;
|
||||
} else if (textureData instanceof CustomTextureData.RawData3D rawData) {
|
||||
final GlTexture texture = new GlTexture(TextureType.TEXTURE_3D, rawData.getSizeX(), rawData.getSizeY(), rawData.getSizeZ(), rawData.getInternalFormat().getGlFormat(), rawData.getPixelFormat().getGlFormat(), rawData.getPixelType().getGlFormat(), rawData.getContent(), rawData.getFilteringData());
|
||||
ownedRawTextures.add(texture);
|
||||
return texture;
|
||||
} else if (textureData instanceof CustomTextureData.ResourceData resourceData) {
|
||||
final String namespace = resourceData.getNamespace();
|
||||
String location = resourceData.getLocation();
|
||||
|
||||
String withoutExtension;
|
||||
int extensionIndex = FilenameUtils.indexOfExtension(location);
|
||||
final String withoutExtension;
|
||||
final int extensionIndex = FilenameUtils.indexOfExtension(location);
|
||||
if (extensionIndex != -1) {
|
||||
withoutExtension = location.substring(0, extensionIndex);
|
||||
} else {
|
||||
withoutExtension = location;
|
||||
}
|
||||
PBRType pbrType = PBRType.fromFileLocation(withoutExtension);
|
||||
final PBRType pbrType = PBRType.fromFileLocation(withoutExtension);
|
||||
|
||||
TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||
final TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
|
||||
|
||||
if (pbrType == null) {
|
||||
ResourceLocation textureLocation = new ResourceLocation(namespace, location);
|
||||
final ResourceLocation textureLocation = new ResourceLocation(namespace, location);
|
||||
|
||||
// NB: We have to re-query the TextureManager for the texture object every time. This is because the
|
||||
// AbstractTexture object could be removed / deleted from the TextureManager on resource reloads,
|
||||
// and we could end up holding on to a deleted texture unless we added special code to handle resource
|
||||
// reloads. Re-fetching the texture from the TextureManager every time is the most robust approach for
|
||||
// now.
|
||||
return () -> {
|
||||
ITextureObject texture = textureManager.getTexture(textureLocation);
|
||||
|
||||
// TODO: Should we give something else if the texture isn't there? This will need some thought
|
||||
return new TextureWrapper(() -> {
|
||||
final ITextureObject texture = textureManager.getTexture(textureLocation);
|
||||
return texture != null ? texture.getGlTextureId() : TextureUtil.missingTexture.getGlTextureId();
|
||||
};
|
||||
}, TextureType.TEXTURE_2D);
|
||||
} else {
|
||||
location = location.substring(0, extensionIndex - pbrType.getSuffix().length()) + location.substring(extensionIndex);
|
||||
ResourceLocation textureLocation = new ResourceLocation(namespace, location);
|
||||
final ResourceLocation textureLocation = new ResourceLocation(namespace, location);
|
||||
|
||||
return () -> {
|
||||
ITextureObject texture = textureManager.getTexture(textureLocation);
|
||||
return new TextureWrapper(() -> {
|
||||
final ITextureObject texture = textureManager.getTexture(textureLocation);
|
||||
|
||||
if (texture != null) {
|
||||
int id = texture.getGlTextureId();
|
||||
PBRTextureHolder pbrHolder = PBRTextureManager.INSTANCE.getOrLoadHolder(id);
|
||||
AbstractTexture pbrTexture = switch (pbrType) {
|
||||
final int id = texture.getGlTextureId();
|
||||
final PBRTextureHolder pbrHolder = PBRTextureManager.INSTANCE.getOrLoadHolder(id);
|
||||
final AbstractTexture pbrTexture = switch (pbrType) {
|
||||
case NORMAL -> pbrHolder.getNormalTexture();
|
||||
case SPECULAR -> pbrHolder.getSpecularTexture();
|
||||
default -> throw new Error("Unknown PBRType '" + pbrType + "'");
|
||||
default -> throw new IllegalArgumentException("Unknown PBRType '" + pbrType + "'");
|
||||
};
|
||||
|
||||
TextureFormat textureFormat = TextureFormatLoader.getFormat();
|
||||
final TextureFormat textureFormat = TextureFormatLoader.getFormat();
|
||||
if (textureFormat != null) {
|
||||
int previousBinding = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
final int previousBinding = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, pbrTexture.getGlTextureId());
|
||||
textureFormat.setupTextureParameters(pbrType, pbrTexture);
|
||||
GLStateManager.glBindTexture(GL11.GL_TEXTURE_2D, previousBinding);
|
||||
@@ -148,29 +173,26 @@ public class CustomTextureManager {
|
||||
return pbrTexture.getGlTextureId();
|
||||
}
|
||||
|
||||
// return MissingTextureAtlasSprite.getTexture().getId();
|
||||
return TextureUtil.missingTexture.getGlTextureId();
|
||||
};
|
||||
}, TextureType.TEXTURE_2D);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unable to handle custom texture data " + textureData);
|
||||
}
|
||||
throw new IllegalArgumentException("Unable to handle custom texture data " + textureData);
|
||||
}
|
||||
|
||||
public EnumMap<TextureStage, Object2ObjectMap<String, IntSupplier>> getCustomTextureIdMap() {
|
||||
return customTextureIdMap;
|
||||
}
|
||||
|
||||
public Object2ObjectMap<String, IntSupplier> getCustomTextureIdMap(TextureStage stage) {
|
||||
public Object2ObjectMap<String, TextureAccess> getCustomTextureIdMap(TextureStage stage) {
|
||||
return customTextureIdMap.getOrDefault(stage, Object2ObjectMaps.emptyMap());
|
||||
}
|
||||
|
||||
public IntSupplier getNoiseTexture() {
|
||||
public TextureAccess getNoiseTexture() {
|
||||
return noise;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
// TODO :Iris
|
||||
// ownedTextures.forEach(AbstractTexture::close);
|
||||
public void destroy() {
|
||||
ownedTextures.forEach(AbstractTexture::deleteGlTexture);
|
||||
ownedTextures.clear();
|
||||
|
||||
ownedRawTextures.forEach(GlTexture::destroy);
|
||||
ownedRawTextures.clear();
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,18 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import com.gtnewhorizons.angelica.glsm.texture.TextureInfoCache;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
|
||||
import net.coderbot.iris.gl.buffer.ShaderStorageBufferHolder;
|
||||
import net.coderbot.iris.gl.buffer.ShaderStorageInfo;
|
||||
import net.coderbot.iris.gl.image.GlImage;
|
||||
import net.coderbot.iris.gl.image.ImageInformation;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.block_rendering.BlockMaterialMapping;
|
||||
import net.coderbot.iris.celeritas.CeleritasTerrainPipeline;
|
||||
import net.coderbot.iris.compat.dh.DHCompat;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.ProgramTable;
|
||||
@@ -59,6 +66,7 @@ import net.coderbot.iris.texture.pbr.PBRTextureManager;
|
||||
import net.coderbot.iris.texture.pbr.PBRType;
|
||||
import net.coderbot.iris.uniforms.CommonUniforms;
|
||||
import net.coderbot.iris.uniforms.FrameUpdateNotifier;
|
||||
import net.coderbot.iris.uniforms.ItemMaterialHelper;
|
||||
import net.coderbot.iris.uniforms.custom.CustomUniforms;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
@@ -130,6 +138,13 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
private final ImmutableSet<Integer> flippedAfterTranslucent;
|
||||
|
||||
private final CeleritasTerrainPipeline celeritasTerrainPipeline;
|
||||
private final DHCompat dhCompat;
|
||||
|
||||
// Custom images and SSBOs
|
||||
private final Set<GlImage> customImages;
|
||||
private final GlImage[] imagesToClear;
|
||||
@Nullable
|
||||
private final ShaderStorageBufferHolder ssboHolder;
|
||||
|
||||
private final Map<Pair<String, InputAvailability>, Map<PatchShaderType, String>> attributeTransforms;
|
||||
|
||||
@@ -193,7 +208,9 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
this.shouldRenderSun = programs.getPackDirectives().shouldRenderSun();
|
||||
this.shouldRenderMoon = programs.getPackDirectives().shouldRenderMoon();
|
||||
this.shouldWriteRainAndSnowToDepthBuffer = programs.getPackDirectives().rainDepth();
|
||||
this.shouldRenderParticlesBeforeDeferred = programs.getPackDirectives().areParticlesBeforeDeferred();
|
||||
this.shouldRenderParticlesBeforeDeferred = programs.getPackDirectives().getParticleRenderingSettings()
|
||||
.map(s -> s == net.coderbot.iris.shaderpack.ParticleRenderingSettings.BEFORE || s == net.coderbot.iris.shaderpack.ParticleRenderingSettings.MIXED)
|
||||
.orElse(false);
|
||||
this.allowConcurrentCompute = programs.getPackDirectives().getConcurrentCompute();
|
||||
this.shouldRenderPrepareBeforeShadow = programs.getPackDirectives().isPrepareBeforeShadow();
|
||||
this.oldLighting = programs.getPackDirectives().isOldLighting();
|
||||
@@ -230,11 +247,13 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
holder -> CommonUniforms.addNonDynamicUniforms(holder, programs.getPack().getIdMap(), programs.getPackDirectives(), this.updateNotifier)
|
||||
);
|
||||
|
||||
// TODO: BlockStateIdMap
|
||||
BlockRenderingSettings.INSTANCE.setBlockMatches(BlockMaterialMapping.createBlockStateIdMap(programs.getPack().getIdMap().getBlockProperties()));
|
||||
BlockRenderingSettings.INSTANCE.setBlockMetaMatches(BlockMaterialMapping.createBlockMetaIdMap(programs.getPack().getIdMap().getBlockProperties()));
|
||||
BlockRenderingSettings.INSTANCE.setBlockTypeIds(BlockMaterialMapping.createBlockTypeMap(programs.getPack().getIdMap().getBlockRenderTypeMap()));
|
||||
|
||||
BlockRenderingSettings.INSTANCE.setEntityIds(programs.getPack().getIdMap().getEntityIdMap());
|
||||
|
||||
ItemMaterialHelper.clearCache();
|
||||
BlockRenderingSettings.INSTANCE.setItemIds(programs.getPack().getIdMap().getItemIdMap());
|
||||
BlockRenderingSettings.INSTANCE.setAmbientOcclusionLevel(programs.getPackDirectives().getAmbientOcclusionLevel());
|
||||
BlockRenderingSettings.INSTANCE.setDisableDirectionalShading(shouldDisableDirectionalShading());
|
||||
BlockRenderingSettings.INSTANCE.setUseSeparateAo(programs.getPackDirectives().shouldUseSeparateAo());
|
||||
@@ -243,10 +262,46 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
// Don't clobber anything in texture unit 0. It probably won't cause issues, but we're just being cautious here.
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE2);
|
||||
|
||||
customTextureManager = new CustomTextureManager(programs.getPackDirectives(), programs.getPack().getCustomTextureDataMap(), programs.getPack().getCustomNoiseTexture());
|
||||
customTextureManager = new CustomTextureManager(programs.getPackDirectives(), programs.getPack().getCustomTextureDataMap(), programs.getPack().getIrisCustomTextureDataMap(), programs.getPack().getCustomNoiseTexture());
|
||||
|
||||
whitePixel = new NativeImageBackedSingleColorTexture(255, 255, 255, 255);
|
||||
|
||||
// Initialize custom images
|
||||
this.customImages = new HashSet<>();
|
||||
final var customImageInfos = programs.getPack().getCustomImages();
|
||||
Iris.logger.debug("[CustomImages] Found {} custom image definitions from shader pack", customImageInfos.size());
|
||||
final List<GlImage> clearList = new ArrayList<>();
|
||||
for (var entry : customImageInfos.object2ObjectEntrySet()) {
|
||||
ImageInformation info = entry.getValue();
|
||||
Iris.logger.debug("[CustomImages] Creating GlImage: {} with info: {}", entry.getKey(), info);
|
||||
GlImage image;
|
||||
if (info.isRelative()) {
|
||||
image = new GlImage.Relative(info.name(), info.samplerName(), info.format(), info.internalTextureFormat(),
|
||||
info.type(), info.clear(), info.relativeWidth(), info.relativeHeight(),
|
||||
main.framebufferWidth, main.framebufferHeight);
|
||||
} else {
|
||||
image = new GlImage(info.name(), info.samplerName(), info.target(), info.format(), info.internalTextureFormat(),
|
||||
info.type(), info.clear(), info.width(), info.height(), info.depth());
|
||||
}
|
||||
Iris.logger.debug("[CustomImages] Created GlImage: {} with texture ID: {}", entry.getKey(), image.getId());
|
||||
customImages.add(image);
|
||||
if (image.shouldClear()) {
|
||||
clearList.add(image);
|
||||
}
|
||||
}
|
||||
this.imagesToClear = clearList.toArray(new GlImage[0]);
|
||||
Iris.logger.debug("[CustomImages] Total GlImages created: {}, images to clear: {}", customImages.size(), imagesToClear.length);
|
||||
|
||||
// Initialize SSBOs
|
||||
final var bufferObjectInfos = programs.getPack().getBufferObjects();
|
||||
if (!bufferObjectInfos.isEmpty() && RenderSystem.supportsSSBO()) {
|
||||
Int2ObjectArrayMap<ShaderStorageInfo> ssboOverrides = new Int2ObjectArrayMap<>();
|
||||
bufferObjectInfos.forEach(ssboOverrides::put);
|
||||
this.ssboHolder = new ShaderStorageBufferHolder(ssboOverrides, main.framebufferWidth, main.framebufferHeight);
|
||||
} else {
|
||||
this.ssboHolder = null;
|
||||
}
|
||||
|
||||
GLStateManager.glActiveTexture(GL13.GL_TEXTURE0);
|
||||
|
||||
this.flippedBeforeShadow = ImmutableSet.of();
|
||||
@@ -267,9 +322,9 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
|
||||
PatchedShaderPrinter.resetPrintState();
|
||||
|
||||
final ProgramBuildContext prepareBuildContext = new ProgramBuildContext(renderTargets, customTextureManager.getNoiseTexture(), updateNotifier, centerDepthSampler, shadowTargetsSupplier, customTextureManager.getCustomTextureIdMap(TextureStage.PREPARE), customUniforms);
|
||||
final ProgramBuildContext deferredBuildContext = new ProgramBuildContext(renderTargets, customTextureManager.getNoiseTexture(), updateNotifier, centerDepthSampler, shadowTargetsSupplier, customTextureManager.getCustomTextureIdMap(TextureStage.DEFERRED), customUniforms);
|
||||
final ProgramBuildContext compositeBuildContext = new ProgramBuildContext(renderTargets, customTextureManager.getNoiseTexture(), updateNotifier, centerDepthSampler, shadowTargetsSupplier, customTextureManager.getCustomTextureIdMap(TextureStage.COMPOSITE_AND_FINAL), customUniforms);
|
||||
final ProgramBuildContext prepareBuildContext = new ProgramBuildContext(renderTargets, customTextureManager.getNoiseTexture(), updateNotifier, centerDepthSampler, shadowTargetsSupplier, customTextureManager.getCustomTextureIdMap(TextureStage.PREPARE), customUniforms, customImages, customTextureManager.getIrisCustomTextures(), this);
|
||||
final ProgramBuildContext deferredBuildContext = new ProgramBuildContext(renderTargets, customTextureManager.getNoiseTexture(), updateNotifier, centerDepthSampler, shadowTargetsSupplier, customTextureManager.getCustomTextureIdMap(TextureStage.DEFERRED), customUniforms, customImages, customTextureManager.getIrisCustomTextures(), this);
|
||||
final ProgramBuildContext compositeBuildContext = new ProgramBuildContext(renderTargets, customTextureManager.getNoiseTexture(), updateNotifier, centerDepthSampler, shadowTargetsSupplier, customTextureManager.getCustomTextureIdMap(TextureStage.COMPOSITE_AND_FINAL), customUniforms, customImages, customTextureManager.getIrisCustomTextures(), this);
|
||||
this.prepareRenderer = new CompositeRenderer(programs.getPrepare(), programs.getPrepareCompute(), flipper, prepareBuildContext, programs.getPackDirectives().getExplicitFlips("prepare_pre"), prepareTransformFutures, "prepare");
|
||||
|
||||
flippedAfterPrepare = flipper.snapshot();
|
||||
@@ -402,13 +457,18 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
ProgramSamplers.Builder builder = ProgramSamplers.builder(programId, IrisSamplers.WORLD_RESERVED_TEXTURE_UNITS);
|
||||
ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureManager.getCustomTextureIdMap(TextureStage.GBUFFERS_AND_SHADOW));
|
||||
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, flipped, renderTargets, false);
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, flipped, renderTargets, false, this);
|
||||
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true));
|
||||
IrisSamplers.addWorldDepthSamplers(customTextureSamplerInterceptor, renderTargets);
|
||||
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, customTextureManager.getNoiseTexture());
|
||||
|
||||
// Bind custom images as samplers (for texture() access to voxel_sampler, floodfill_sampler, etc.)
|
||||
IrisSamplers.addCustomImages(customTextureSamplerInterceptor, customImages);
|
||||
// Bind custom textures (PNG files from shader pack)
|
||||
IrisSamplers.addCustomTextures(customTextureSamplerInterceptor, customTextureManager.getIrisCustomTextures());
|
||||
|
||||
if (IrisSamplers.hasShadowSamplers(customTextureSamplerInterceptor)) {
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, Objects.requireNonNull(shadowRenderTargets));
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, Objects.requireNonNull(shadowRenderTargets), null, true);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
@@ -418,9 +478,11 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
ProgramImages.Builder builder = ProgramImages.builder(programId);
|
||||
|
||||
IrisImages.addRenderTargetImages(builder, flipped, renderTargets);
|
||||
// Bind custom images as image units (for imageLoad/imageStore)
|
||||
IrisImages.addCustomImages(builder, customImages);
|
||||
|
||||
if (IrisImages.hasShadowImages(builder)) {
|
||||
IrisImages.addShadowColorImages(builder, Objects.requireNonNull(shadowRenderTargets));
|
||||
IrisImages.addShadowColorImages(builder, Objects.requireNonNull(shadowRenderTargets), null);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
@@ -430,13 +492,18 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
ProgramSamplers.Builder builder = ProgramSamplers.builder(programId, IrisSamplers.WORLD_RESERVED_TEXTURE_UNITS);
|
||||
ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureManager.getCustomTextureIdMap(TextureStage.GBUFFERS_AND_SHADOW));
|
||||
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flippedAfterPrepare, renderTargets, false);
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flippedAfterPrepare, renderTargets, false, this);
|
||||
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true));
|
||||
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, customTextureManager.getNoiseTexture());
|
||||
|
||||
// Bind custom images as samplers (for texture() access to voxel_sampler, floodfill_sampler, etc.)
|
||||
IrisSamplers.addCustomImages(customTextureSamplerInterceptor, customImages);
|
||||
// Bind custom textures (PNG files from shader pack)
|
||||
IrisSamplers.addCustomTextures(customTextureSamplerInterceptor, customTextureManager.getIrisCustomTextures());
|
||||
|
||||
// Only initialize these samplers if the shadow map renderer exists. Otherwise, this program shouldn't be used at all?
|
||||
if (IrisSamplers.hasShadowSamplers(customTextureSamplerInterceptor)) {
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, Objects.requireNonNull(shadowRenderTargets));
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, Objects.requireNonNull(shadowRenderTargets), null, true);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
@@ -445,9 +512,11 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
ProgramImages.Builder builder = ProgramImages.builder(programId);
|
||||
|
||||
IrisImages.addRenderTargetImages(builder, () -> flippedAfterPrepare, renderTargets);
|
||||
// Bind custom images as image units (for imageLoad/imageStore - voxelization uses this in shadow pass)
|
||||
IrisImages.addCustomImages(builder, customImages);
|
||||
|
||||
if (IrisImages.hasShadowImages(builder)) {
|
||||
IrisImages.addShadowColorImages(builder, Objects.requireNonNull(shadowRenderTargets));
|
||||
IrisImages.addShadowColorImages(builder, Objects.requireNonNull(shadowRenderTargets), null);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
@@ -468,6 +537,8 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
celeritasTerrainFuture, celeritasTranslucentFuture, celeritasShadowFuture,
|
||||
renderTargets, flippedAfterPrepare, flippedAfterTranslucent,
|
||||
celeritasShadowFb, celeritasTerrainDrawBuffers);
|
||||
|
||||
this.dhCompat = new DHCompat();
|
||||
}
|
||||
|
||||
private RenderTargets getRenderTargets() {
|
||||
@@ -671,7 +742,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
ProgramSamplers.customTextureSamplerInterceptor(builder,
|
||||
customTextureManager.getCustomTextureIdMap(textureStage));
|
||||
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, flipped, renderTargets, false);
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, flipped, renderTargets, false, this);
|
||||
IrisImages.addRenderTargetImages(builder, flipped, renderTargets);
|
||||
|
||||
if (!shouldBindPBR) {
|
||||
@@ -692,8 +763,8 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
}
|
||||
|
||||
if (shadowRenderTargets != null) {
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowRenderTargets);
|
||||
IrisImages.addShadowColorImages(builder, shadowRenderTargets);
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowRenderTargets, null, true);
|
||||
IrisImages.addShadowColorImages(builder, shadowRenderTargets, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -887,6 +958,17 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
// Destroy custom textures and the static samplers (normals, specular, and noise)
|
||||
customTextureManager.destroy();
|
||||
// whitePixel.releaseId();
|
||||
|
||||
// Destroy custom images
|
||||
for (GlImage image : customImages) {
|
||||
image.destroy();
|
||||
}
|
||||
customImages.clear();
|
||||
|
||||
// Destroy SSBOs
|
||||
if (ssboHolder != null) {
|
||||
ssboHolder.destroyBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
private static void destroyPasses(ProgramTable<Pass> table) {
|
||||
@@ -971,6 +1053,16 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
|
||||
this.clearPassesFull = ClearPassCreator.createClearPasses(renderTargets, true, packDirectives.getRenderTargetDirectives());
|
||||
this.clearPasses = ClearPassCreator.createClearPasses(renderTargets, false, packDirectives.getRenderTargetDirectives());
|
||||
|
||||
// Resize custom images if needed
|
||||
for (GlImage image : customImages) {
|
||||
image.updateNewSize(main.framebufferWidth, main.framebufferHeight);
|
||||
}
|
||||
|
||||
// Resize SSBOs if needed
|
||||
if (ssboHolder != null) {
|
||||
ssboHolder.hasResizedScreen(main.framebufferWidth, main.framebufferHeight);
|
||||
}
|
||||
}
|
||||
|
||||
final ImmutableList<ClearPass> passes;
|
||||
@@ -1024,7 +1116,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor =
|
||||
ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureManager.getCustomTextureIdMap(textureStage));
|
||||
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, flipped, renderTargets, false);
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, flipped, renderTargets, false, this);
|
||||
IrisImages.addRenderTargetImages(builder, flipped, renderTargets);
|
||||
|
||||
IrisSamplers.addLevelSamplers(customTextureSamplerInterceptor, this, whitePixel, new InputAvailability(true, true));
|
||||
@@ -1033,8 +1125,8 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
|
||||
if (IrisSamplers.hasShadowSamplers(customTextureSamplerInterceptor)) {
|
||||
if (shadowRenderTargets != null) {
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowRenderTargets);
|
||||
IrisImages.addShadowColorImages(builder, shadowRenderTargets);
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowRenderTargets, null, true);
|
||||
IrisImages.addShadowColorImages(builder, shadowRenderTargets, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1042,7 +1134,7 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
|
||||
this.customUniforms.mapholderToPass(builder, programs[i]);
|
||||
|
||||
programs[i].setWorkGroupInfo(source.getWorkGroupRelative(), source.getWorkGroups());
|
||||
programs[i].setWorkGroupInfo(source.getWorkGroupRelative(), source.getWorkGroups(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1167,6 +1259,11 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
// Get ready for world rendering
|
||||
prepareRenderTargets();
|
||||
|
||||
// Clear custom images that need clearing each frame
|
||||
for (GlImage image : imagesToClear) {
|
||||
image.clear();
|
||||
}
|
||||
|
||||
setPhase(WorldRenderingPhase.SKY);
|
||||
|
||||
// Render our horizon box before actual sky rendering to avoid being broken by mods that do weird things
|
||||
@@ -1224,6 +1321,11 @@ public class DeferredWorldRenderingPipeline implements WorldRenderingPipeline, R
|
||||
return updateNotifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DHCompat getDHCompat() {
|
||||
return dhCompat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldRenderingPhase getPhase() {
|
||||
if (overridePhase != null) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.coderbot.iris.pipeline;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.celeritas.CeleritasTerrainPipeline;
|
||||
import net.coderbot.iris.compat.dh.DHCompat;
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
|
||||
import net.coderbot.iris.gbuffer_overrides.state.RenderTargetStateListener;
|
||||
@@ -123,6 +124,13 @@ public class FixedFunctionWorldRenderingPipeline implements WorldRenderingPipeli
|
||||
return new FrameUpdateNotifier();
|
||||
}
|
||||
|
||||
private static final DHCompat DH_COMPAT = new DHCompat();
|
||||
|
||||
@Override
|
||||
public DHCompat getDHCompat() {
|
||||
return DH_COMPAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldDisableVanillaEntityShadows() {
|
||||
return false;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.layer.GbufferPrograms;
|
||||
import net.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -114,6 +115,8 @@ public class HandRenderer {
|
||||
|
||||
setupGlState(gameRenderer, camera, tickDelta);
|
||||
|
||||
GbufferPrograms.setBlockEntityDefaults();
|
||||
|
||||
renderingSolid = true;
|
||||
mc.entityRenderer.enableLightmap(tickDelta);
|
||||
mc.entityRenderer.itemRenderer.renderItemInFirstPerson(tickDelta);
|
||||
@@ -151,6 +154,8 @@ public class HandRenderer {
|
||||
|
||||
setupGlState(gameRenderer, camera, tickDelta);
|
||||
|
||||
GbufferPrograms.setBlockEntityDefaults();
|
||||
|
||||
mc.entityRenderer.enableLightmap(tickDelta);
|
||||
mc.entityRenderer.itemRenderer.renderItemInFirstPerson(tickDelta);
|
||||
mc.entityRenderer.disableLightmap(tickDelta);
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.coderbot.iris.pipeline;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.shaderpack.DimensionId;
|
||||
import net.coderbot.iris.uniforms.SystemTimeUniforms;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -16,21 +15,21 @@ import java.util.function.Function;
|
||||
|
||||
public class PipelineManager {
|
||||
|
||||
private final Function<DimensionId, WorldRenderingPipeline> pipelineFactory;
|
||||
private final Map<DimensionId, WorldRenderingPipeline> pipelinesPerDimension = new HashMap<>();
|
||||
private final Function<String, WorldRenderingPipeline> pipelineFactory;
|
||||
private final Map<String, WorldRenderingPipeline> pipelinesPerDimension = new HashMap<>();
|
||||
private WorldRenderingPipeline pipeline = new FixedFunctionWorldRenderingPipeline();
|
||||
private DimensionId lastPreparedDimension = null;
|
||||
private String lastPreparedDimension = null;
|
||||
@Getter
|
||||
private int versionCounterForSodiumShaderReload = 0;
|
||||
|
||||
public PipelineManager(Function<DimensionId, WorldRenderingPipeline> pipelineFactory) {
|
||||
public PipelineManager(Function<String, WorldRenderingPipeline> pipelineFactory) {
|
||||
this.pipelineFactory = pipelineFactory;
|
||||
}
|
||||
|
||||
public WorldRenderingPipeline preparePipeline(DimensionId currentDimension) {
|
||||
public WorldRenderingPipeline preparePipeline(String currentDimension) {
|
||||
// Detect dimension change and do full teardown/recreation
|
||||
if (lastPreparedDimension != null && lastPreparedDimension != currentDimension) {
|
||||
Iris.logger.info("Dimension changed from {} to {}, reloading pipeline", lastPreparedDimension, currentDimension);
|
||||
if (lastPreparedDimension != null && !lastPreparedDimension.equals(currentDimension)) {
|
||||
Iris.logger.info("Dimension changed from '{}' to '{}', reloading pipeline", lastPreparedDimension, currentDimension);
|
||||
destroyPipeline();
|
||||
}
|
||||
lastPreparedDimension = currentDimension;
|
||||
@@ -39,7 +38,7 @@ public class PipelineManager {
|
||||
SystemTimeUniforms.COUNTER.reset();
|
||||
SystemTimeUniforms.TIMER.reset();
|
||||
|
||||
Iris.logger.info("Creating pipeline for dimension {}", currentDimension);
|
||||
Iris.logger.info("Creating pipeline for dimension '{}'", currentDimension);
|
||||
pipeline = pipelineFactory.apply(currentDimension);
|
||||
pipelinesPerDimension.put(currentDimension, pipeline);
|
||||
} else {
|
||||
@@ -71,8 +70,8 @@ public class PipelineManager {
|
||||
* @see <a href="https://github.com/IrisShaders/Iris/issues/1330">this GitHub issue</a>
|
||||
*/
|
||||
public void destroyPipeline() {
|
||||
pipelinesPerDimension.forEach((dimensionId, pipeline) -> {
|
||||
Iris.logger.info("Destroying pipeline {}", dimensionId);
|
||||
pipelinesPerDimension.forEach((dimensionName, pipeline) -> {
|
||||
Iris.logger.info("Destroying pipeline for dimension '{}'", dimensionName);
|
||||
resetTextureState();
|
||||
pipeline.destroy();
|
||||
});
|
||||
|
||||
@@ -17,8 +17,8 @@ import java.util.Objects;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.layer.GbufferPrograms;
|
||||
import net.coderbot.iris.gui.option.IrisVideoSettings;
|
||||
import net.coderbot.iris.shaderpack.OptionalBoolean;
|
||||
import net.coderbot.iris.shaderpack.PackDirectives;
|
||||
import net.coderbot.iris.shaderpack.ShadowCullState;
|
||||
import net.coderbot.iris.shaderpack.PackShadowDirectives;
|
||||
import net.coderbot.iris.shaderpack.ProgramSource;
|
||||
import net.coderbot.iris.shadow.ShadowMatrices;
|
||||
@@ -79,7 +79,7 @@ public class ShadowRenderer {
|
||||
private final float intervalSize;
|
||||
private final Float fov;
|
||||
private final ShadowRenderTargets targets;
|
||||
private final OptionalBoolean packCullingState;
|
||||
private final ShadowCullState packCullingState;
|
||||
private boolean packHasVoxelization;
|
||||
private final boolean shouldRenderTerrain;
|
||||
private final boolean shouldRenderTranslucent;
|
||||
@@ -141,7 +141,7 @@ public class ShadowRenderer {
|
||||
this.packCullingState = shadowDirectives.getCullingState();
|
||||
} else {
|
||||
this.packHasVoxelization = false;
|
||||
this.packCullingState = OptionalBoolean.DEFAULT;
|
||||
this.packCullingState = ShadowCullState.DEFAULT;
|
||||
}
|
||||
|
||||
this.sunPathRotation = directives.getSunPathRotation();
|
||||
@@ -286,12 +286,12 @@ public class ShadowRenderer {
|
||||
// TODO: Cull entities / block entities with Advanced Frustum Culling even if voxelization is detected.
|
||||
String distanceInfo;
|
||||
String cullingInfo;
|
||||
if ((packCullingState == OptionalBoolean.FALSE || packHasVoxelization) && packCullingState != OptionalBoolean.TRUE) {
|
||||
if ((packCullingState == ShadowCullState.DISTANCE || packHasVoxelization) && packCullingState != ShadowCullState.ADVANCED) {
|
||||
double distance = halfPlaneLength * renderMultiplier;
|
||||
|
||||
String reason;
|
||||
|
||||
if (packCullingState == OptionalBoolean.FALSE) {
|
||||
if (packCullingState == ShadowCullState.DISTANCE) {
|
||||
reason = "(set by shader pack)";
|
||||
} else /*if (packHasVoxelization)*/ {
|
||||
reason = "(voxelization detected)";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.coderbot.iris.pipeline;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import net.coderbot.iris.compat.dh.DHCompat;
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.SpecialCondition;
|
||||
import net.coderbot.iris.gbuffer_overrides.state.RenderTargetStateListener;
|
||||
@@ -39,6 +40,7 @@ public interface WorldRenderingPipeline {
|
||||
|
||||
CeleritasTerrainPipeline getCeleritasTerrainPipeline();
|
||||
FrameUpdateNotifier getFrameUpdateNotifier();
|
||||
DHCompat getDHCompat();
|
||||
|
||||
boolean shouldDisableVanillaEntityShadows();
|
||||
boolean shouldDisableDirectionalShading();
|
||||
|
||||
@@ -204,8 +204,12 @@ public class ShaderTransformer {
|
||||
hacky120Patches.add(transformer);
|
||||
}
|
||||
|
||||
// Extract extensions from the pre-parsed content (version + extensions before main code)
|
||||
// This preserves #extension directives that the shader pack declares
|
||||
var extensions = versionPattern.matcher(getFormattedShader(parsedShader.pre(), "")).replaceFirst("").trim();
|
||||
|
||||
types.put(type, transformer);
|
||||
prepatched.put(type, profileString);
|
||||
prepatched.put(type, profileString + (extensions.isEmpty() ? "" : "\n" + extensions));
|
||||
}
|
||||
CompatibilityTransformer.transformGrouped(types, parameters);
|
||||
for (var entry : types.entrySet()) {
|
||||
@@ -394,8 +398,10 @@ public class ShaderTransformer {
|
||||
stringBuilder.deleteCharAt(stringBuilder.length() - 2);
|
||||
}
|
||||
tabHolder[0] = "";
|
||||
stringBuilder.append(" \n");
|
||||
} else {
|
||||
stringBuilder.append(text.equals(";") ? " \n" + tabHolder[0] : " ");
|
||||
}
|
||||
stringBuilder.append(text.equals(";") ? " \n" + tabHolder[0] : " ");
|
||||
} else {
|
||||
for (int i = 0; i < tree.getChildCount(); ++i) {
|
||||
getFormattedShader(tree.getChild(i), stringBuilder, tabHolder);
|
||||
|
||||
@@ -8,13 +8,17 @@ import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import lombok.Getter;
|
||||
import net.coderbot.iris.gl.framebuffer.GlFramebuffer;
|
||||
import net.coderbot.iris.gl.framebuffer.ViewportData;
|
||||
import net.coderbot.iris.gl.image.GlImage;
|
||||
import net.coderbot.iris.gl.program.ComputeProgram;
|
||||
import net.coderbot.iris.gl.program.Program;
|
||||
import net.coderbot.iris.gl.program.ProgramBuilder;
|
||||
import net.coderbot.iris.gl.program.ProgramSamplers;
|
||||
import net.coderbot.iris.gl.program.ProgramUniforms;
|
||||
import net.coderbot.iris.gl.sampler.SamplerLimits;
|
||||
import net.coderbot.iris.gl.texture.TextureAccess;
|
||||
import net.coderbot.iris.pipeline.PatchedShaderPrinter;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.pipeline.transform.PatchShaderType;
|
||||
import net.coderbot.iris.pipeline.transform.TransformPatcher;
|
||||
import net.coderbot.iris.rendertarget.RenderTarget;
|
||||
@@ -32,6 +36,7 @@ import net.coderbot.iris.uniforms.custom.CustomUniforms;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.shader.Framebuffer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
@@ -39,31 +44,34 @@ import org.lwjgl.opengl.GL30;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class CompositeRenderer {
|
||||
private final RenderTargets renderTargets;
|
||||
|
||||
private final ImmutableList<Pass> passes;
|
||||
private final IntSupplier noiseTexture;
|
||||
private final TextureAccess noiseTexture;
|
||||
private final FrameUpdateNotifier updateNotifier;
|
||||
private final CenterDepthSampler centerDepthSampler;
|
||||
private final CustomUniforms customUniforms;
|
||||
private final Object2ObjectMap<String, IntSupplier> customTextureIds;
|
||||
private final Object2ObjectMap<String, TextureAccess> customTextureIds;
|
||||
@Nullable private final Set<GlImage> customImages;
|
||||
@Nullable private final Object2ObjectMap<String, TextureAccess> irisCustomTextures;
|
||||
@Nullable private final WorldRenderingPipeline pipeline;
|
||||
@Getter
|
||||
private final ImmutableSet<Integer> flippedAtLeastOnceFinal;
|
||||
|
||||
public CompositeRenderer(PackDirectives packDirectives, ProgramSource[] sources, ComputeSource[][] computes, RenderTargets renderTargets,
|
||||
IntSupplier noiseTexture, FrameUpdateNotifier updateNotifier,
|
||||
TextureAccess noiseTexture, FrameUpdateNotifier updateNotifier,
|
||||
CenterDepthSampler centerDepthSampler, BufferFlipper bufferFlipper,
|
||||
Supplier<ShadowRenderTargets> shadowTargetsSupplier,
|
||||
Object2ObjectMap<String, IntSupplier> customTextureIds, ImmutableMap<Integer, Boolean> explicitPreFlips,
|
||||
Object2ObjectMap<String, TextureAccess> customTextureIds, ImmutableMap<Integer, Boolean> explicitPreFlips,
|
||||
CustomUniforms customUniforms,
|
||||
Map<Integer, CompletableFuture<Map<PatchShaderType, String>>> precomputedTransformFutures) {
|
||||
this(sources, computes, bufferFlipper, new ProgramBuildContext(renderTargets, noiseTexture, updateNotifier, centerDepthSampler, shadowTargetsSupplier, customTextureIds, customUniforms), explicitPreFlips, precomputedTransformFutures, "unknown");
|
||||
this(sources, computes, bufferFlipper, new ProgramBuildContext(renderTargets, noiseTexture, updateNotifier, centerDepthSampler, shadowTargetsSupplier, customTextureIds, customUniforms, null, null, null), explicitPreFlips, precomputedTransformFutures, "unknown");
|
||||
}
|
||||
|
||||
public CompositeRenderer(ProgramSource[] sources, ComputeSource[][] computes, BufferFlipper bufferFlipper, ProgramBuildContext context, ImmutableMap<Integer, Boolean> explicitPreFlips, Map<Integer, CompletableFuture<Map<PatchShaderType, String>>> precomputedTransformFutures, String stageName) {
|
||||
@@ -73,6 +81,9 @@ public class CompositeRenderer {
|
||||
this.renderTargets = context.renderTargets();
|
||||
this.customTextureIds = context.customTextureIds();
|
||||
this.customUniforms = context.customUniforms();
|
||||
this.customImages = context.customImages();
|
||||
this.irisCustomTextures = context.irisCustomTextures();
|
||||
this.pipeline = context.pipeline();
|
||||
|
||||
final ImmutableList.Builder<Pass> passes = ImmutableList.builder();
|
||||
final ImmutableSet.Builder<Integer> flippedAtLeastOnce = new ImmutableSet.Builder<>();
|
||||
@@ -205,7 +216,7 @@ public class CompositeRenderer {
|
||||
GlFramebuffer framebuffer;
|
||||
ImmutableSet<Integer> stageReadsFromAlt;
|
||||
ImmutableSet<Integer> mipmappedBuffers;
|
||||
float viewportScale;
|
||||
ViewportData viewportScale;
|
||||
|
||||
protected void destroy() {
|
||||
this.program.destroy();
|
||||
@@ -264,9 +275,11 @@ public class CompositeRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
final float scaledWidth = renderPass.viewWidth * renderPass.viewportScale;
|
||||
final float scaledHeight = renderPass.viewHeight * renderPass.viewportScale;
|
||||
GL11.glViewport(0, 0, (int) scaledWidth, (int) scaledHeight);
|
||||
final float scaledWidth = renderPass.viewWidth * renderPass.viewportScale.scale();
|
||||
final float scaledHeight = renderPass.viewHeight * renderPass.viewportScale.scale();
|
||||
final float viewportX = renderPass.viewWidth * renderPass.viewportScale.viewportX();
|
||||
final float viewportY = renderPass.viewHeight * renderPass.viewportScale.viewportY();
|
||||
GL11.glViewport((int) viewportX, (int) viewportY, (int) scaledWidth, (int) scaledHeight);
|
||||
|
||||
renderPass.framebuffer.bind();
|
||||
renderPass.program.use();
|
||||
@@ -345,15 +358,19 @@ public class CompositeRenderer {
|
||||
|
||||
ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureIds, flippedAtLeastOnceSnapshot);
|
||||
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flipped, renderTargets, true);
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flipped, renderTargets, true, pipeline);
|
||||
IrisSamplers.addCustomImages(customTextureSamplerInterceptor, customImages);
|
||||
IrisSamplers.addCustomTextures(customTextureSamplerInterceptor, irisCustomTextures);
|
||||
|
||||
IrisImages.addRenderTargetImages(builder, () -> flipped, renderTargets);
|
||||
IrisImages.addCustomImages(builder, customImages);
|
||||
|
||||
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, noiseTexture);
|
||||
IrisSamplers.addCompositeSamplers(customTextureSamplerInterceptor, renderTargets);
|
||||
|
||||
if (IrisSamplers.hasShadowSamplers(customTextureSamplerInterceptor)) {
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowTargetsSupplier.get());
|
||||
IrisImages.addShadowColorImages(builder, shadowTargetsSupplier.get());
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowTargetsSupplier.get(), null, false);
|
||||
IrisImages.addShadowColorImages(builder, shadowTargetsSupplier.get(), null);
|
||||
}
|
||||
|
||||
// TODO: Don't duplicate this with FinalPassRenderer
|
||||
@@ -390,15 +407,19 @@ public class CompositeRenderer {
|
||||
|
||||
this.customUniforms.assignTo(builder);
|
||||
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flipped, renderTargets, true);
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flipped, renderTargets, true, pipeline);
|
||||
IrisSamplers.addCustomImages(customTextureSamplerInterceptor, customImages);
|
||||
IrisSamplers.addCustomTextures(customTextureSamplerInterceptor, irisCustomTextures);
|
||||
|
||||
IrisImages.addRenderTargetImages(builder, () -> flipped, renderTargets);
|
||||
IrisImages.addCustomImages(builder, customImages);
|
||||
|
||||
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, noiseTexture);
|
||||
IrisSamplers.addCompositeSamplers(customTextureSamplerInterceptor, renderTargets);
|
||||
|
||||
if (IrisSamplers.hasShadowSamplers(customTextureSamplerInterceptor)) {
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowTargetsSupplier.get());
|
||||
IrisImages.addShadowColorImages(builder, shadowTargetsSupplier.get());
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowTargetsSupplier.get(), null, false);
|
||||
IrisImages.addShadowColorImages(builder, shadowTargetsSupplier.get(), null);
|
||||
}
|
||||
|
||||
// TODO: Don't duplicate this with FinalPassRenderer
|
||||
@@ -408,7 +429,7 @@ public class CompositeRenderer {
|
||||
|
||||
customUniforms.mapholderToPass(builder, programs[i]);
|
||||
|
||||
programs[i].setWorkGroupInfo(source.getWorkGroupRelative(), source.getWorkGroups());
|
||||
programs[i].setWorkGroupInfo(source.getWorkGroupRelative(), source.getWorkGroups(), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,16 @@ import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import net.coderbot.iris.gl.framebuffer.GlFramebuffer;
|
||||
import net.coderbot.iris.gl.image.GlImage;
|
||||
import net.coderbot.iris.gl.program.ComputeProgram;
|
||||
import net.coderbot.iris.gl.program.Program;
|
||||
import net.coderbot.iris.gl.program.ProgramBuilder;
|
||||
import net.coderbot.iris.gl.program.ProgramSamplers;
|
||||
import net.coderbot.iris.gl.program.ProgramUniforms;
|
||||
import net.coderbot.iris.gl.sampler.SamplerLimits;
|
||||
import net.coderbot.iris.gl.texture.TextureAccess;
|
||||
import net.coderbot.iris.pipeline.PatchedShaderPrinter;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.pipeline.transform.PatchShaderType;
|
||||
import net.coderbot.iris.pipeline.transform.TransformPatcher;
|
||||
import net.coderbot.iris.rendertarget.IRenderTargetExt;
|
||||
@@ -40,9 +43,9 @@ import org.lwjgl.opengl.GL30;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FinalPassRenderer {
|
||||
@@ -55,20 +58,23 @@ public class FinalPassRenderer {
|
||||
private final GlFramebuffer colorHolder;
|
||||
private int lastColorTextureId;
|
||||
private int lastColorTextureVersion;
|
||||
private final IntSupplier noiseTexture;
|
||||
private final TextureAccess noiseTexture;
|
||||
private final FrameUpdateNotifier updateNotifier;
|
||||
private final CenterDepthSampler centerDepthSampler;
|
||||
private final Object2ObjectMap<String, IntSupplier> customTextureIds;
|
||||
private final Object2ObjectMap<String, TextureAccess> customTextureIds;
|
||||
private final CustomUniforms customUniforms;
|
||||
@Nullable private final Set<GlImage> customImages;
|
||||
@Nullable private final Object2ObjectMap<String, TextureAccess> irisCustomTextures;
|
||||
@Nullable private final WorldRenderingPipeline pipeline;
|
||||
|
||||
public FinalPassRenderer(ProgramSet pack, RenderTargets renderTargets, IntSupplier noiseTexture,
|
||||
public FinalPassRenderer(ProgramSet pack, RenderTargets renderTargets, TextureAccess noiseTexture,
|
||||
FrameUpdateNotifier updateNotifier, ImmutableSet<Integer> flippedBuffers,
|
||||
CenterDepthSampler centerDepthSampler,
|
||||
Supplier<ShadowRenderTargets> shadowTargetsSupplier,
|
||||
Object2ObjectMap<String, IntSupplier> customTextureIds,
|
||||
Object2ObjectMap<String, TextureAccess> customTextureIds,
|
||||
ImmutableSet<Integer> flippedAtLeastOnce, CustomUniforms customUniforms,
|
||||
CompletableFuture<Map<PatchShaderType, String>> precomputedTransformFuture) {
|
||||
this(pack, new ProgramBuildContext(renderTargets, noiseTexture, updateNotifier, centerDepthSampler, shadowTargetsSupplier, customTextureIds, customUniforms), flippedBuffers, flippedAtLeastOnce, precomputedTransformFuture, "final");
|
||||
this(pack, new ProgramBuildContext(renderTargets, noiseTexture, updateNotifier, centerDepthSampler, shadowTargetsSupplier, customTextureIds, customUniforms, null, null, null), flippedBuffers, flippedAtLeastOnce, precomputedTransformFuture, "final");
|
||||
}
|
||||
|
||||
public FinalPassRenderer(ProgramSet pack, ProgramBuildContext context, ImmutableSet<Integer> flippedBuffers, ImmutableSet<Integer> flippedAtLeastOnce, CompletableFuture<Map<PatchShaderType, String>> precomputedTransformFuture, String stageName) {
|
||||
@@ -79,6 +85,9 @@ public class FinalPassRenderer {
|
||||
this.noiseTexture = context.noiseTexture();
|
||||
this.renderTargets = context.renderTargets();
|
||||
this.customUniforms = context.customUniforms();
|
||||
this.customImages = context.customImages();
|
||||
this.irisCustomTextures = context.irisCustomTextures();
|
||||
this.pipeline = context.pipeline();
|
||||
this.finalPass = pack.getCompositeFinal().filter(ProgramSource::isValid).map(source -> {
|
||||
final Pass pass = new Pass();
|
||||
final ProgramDirectives directives = source.getDirectives();
|
||||
@@ -359,14 +368,22 @@ public class FinalPassRenderer {
|
||||
final ProgramSamplers.CustomTextureSamplerInterceptor customTextureSamplerInterceptor = ProgramSamplers.customTextureSamplerInterceptor(builder, customTextureIds, flippedAtLeastOnceSnapshot);
|
||||
|
||||
CommonUniforms.addDynamicUniforms(builder);
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flipped, renderTargets, true);
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flipped, renderTargets, true, pipeline);
|
||||
// Bind custom images as samplers BEFORE render target images
|
||||
IrisSamplers.addCustomImages(customTextureSamplerInterceptor, customImages);
|
||||
// Bind custom textures (PNG files from shader pack)
|
||||
IrisSamplers.addCustomTextures(customTextureSamplerInterceptor, irisCustomTextures);
|
||||
|
||||
IrisImages.addRenderTargetImages(builder, () -> flipped, renderTargets);
|
||||
// Bind custom images as image units AFTER render target images
|
||||
IrisImages.addCustomImages(builder, customImages);
|
||||
|
||||
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, noiseTexture);
|
||||
IrisSamplers.addCompositeSamplers(customTextureSamplerInterceptor, renderTargets);
|
||||
|
||||
if (IrisSamplers.hasShadowSamplers(customTextureSamplerInterceptor)) {
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowTargetsSupplier.get());
|
||||
IrisImages.addShadowColorImages(builder, shadowTargetsSupplier.get());
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowTargetsSupplier.get(), null, false);
|
||||
IrisImages.addShadowColorImages(builder, shadowTargetsSupplier.get(), null);
|
||||
}
|
||||
|
||||
// TODO: Don't duplicate this with CompositeRenderer
|
||||
@@ -402,15 +419,19 @@ public class FinalPassRenderer {
|
||||
customUniforms.assignTo(builder);
|
||||
|
||||
CommonUniforms.addDynamicUniforms(builder);
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flipped, renderTargets, true);
|
||||
IrisSamplers.addRenderTargetSamplers(customTextureSamplerInterceptor, () -> flipped, renderTargets, true, pipeline);
|
||||
IrisSamplers.addCustomImages(customTextureSamplerInterceptor, customImages);
|
||||
IrisSamplers.addCustomTextures(customTextureSamplerInterceptor, irisCustomTextures);
|
||||
|
||||
IrisImages.addRenderTargetImages(builder, () -> flipped, renderTargets);
|
||||
IrisImages.addCustomImages(builder, customImages);
|
||||
|
||||
IrisSamplers.addNoiseSampler(customTextureSamplerInterceptor, noiseTexture);
|
||||
IrisSamplers.addCompositeSamplers(customTextureSamplerInterceptor, renderTargets);
|
||||
|
||||
if (IrisSamplers.hasShadowSamplers(customTextureSamplerInterceptor)) {
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowTargetsSupplier.get());
|
||||
IrisImages.addShadowColorImages(builder, shadowTargetsSupplier.get());
|
||||
IrisSamplers.addShadowSamplers(customTextureSamplerInterceptor, shadowTargetsSupplier.get(), null, false);
|
||||
IrisImages.addShadowColorImages(builder, shadowTargetsSupplier.get(), null);
|
||||
}
|
||||
|
||||
// TODO: Don't duplicate this with FinalPassRenderer
|
||||
@@ -420,7 +441,7 @@ public class FinalPassRenderer {
|
||||
|
||||
this.customUniforms.mapholderToPass(builder, programs[i]);
|
||||
|
||||
programs[i].setWorkGroupInfo(source.getWorkGroupRelative(), source.getWorkGroups());
|
||||
programs[i].setWorkGroupInfo(source.getWorkGroupRelative(), source.getWorkGroups(), null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,22 +2,29 @@ package net.coderbot.iris.postprocess;
|
||||
|
||||
import com.github.bsideup.jabel.Desugar;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import net.coderbot.iris.gl.image.GlImage;
|
||||
import net.coderbot.iris.gl.texture.TextureAccess;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.rendertarget.RenderTargets;
|
||||
import net.coderbot.iris.shadows.ShadowRenderTargets;
|
||||
import net.coderbot.iris.uniforms.FrameUpdateNotifier;
|
||||
import net.coderbot.iris.uniforms.custom.CustomUniforms;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Desugar
|
||||
public record ProgramBuildContext(
|
||||
@NotNull RenderTargets renderTargets,
|
||||
@NotNull IntSupplier noiseTexture,
|
||||
@NotNull TextureAccess noiseTexture,
|
||||
@NotNull FrameUpdateNotifier updateNotifier,
|
||||
@NotNull CenterDepthSampler centerDepthSampler,
|
||||
@NotNull Supplier<ShadowRenderTargets> shadowTargetsSupplier,
|
||||
@NotNull Object2ObjectMap<String, IntSupplier> customTextureIds,
|
||||
@NotNull CustomUniforms customUniforms
|
||||
@NotNull Object2ObjectMap<String, TextureAccess> customTextureIds,
|
||||
@NotNull CustomUniforms customUniforms,
|
||||
@Nullable Set<GlImage> customImages,
|
||||
@Nullable Object2ObjectMap<String, TextureAccess> irisCustomTextures,
|
||||
@Nullable WorldRenderingPipeline pipeline
|
||||
) {}
|
||||
@@ -1,12 +1,14 @@
|
||||
package net.coderbot.iris.samplers;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import net.coderbot.iris.gl.image.GlImage;
|
||||
import net.coderbot.iris.gl.image.ImageHolder;
|
||||
import net.coderbot.iris.gl.texture.InternalTextureFormat;
|
||||
import net.coderbot.iris.rendertarget.RenderTarget;
|
||||
import net.coderbot.iris.rendertarget.RenderTargets;
|
||||
import net.coderbot.iris.shadows.ShadowRenderTargets;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -16,10 +18,14 @@ public class IrisImages {
|
||||
for (int i = 0; i < renderTargets.getRenderTargetCount(); i++) {
|
||||
final int index = i;
|
||||
|
||||
final String name = "colorimg" + i;
|
||||
|
||||
if (!images.hasImage(name)) continue;
|
||||
|
||||
// Note: image bindings *are* impacted by buffer flips.
|
||||
IntSupplier textureID = () -> {
|
||||
ImmutableSet<Integer> flippedBuffers = flipped.get();
|
||||
RenderTarget target = renderTargets.get(index);
|
||||
final IntSupplier textureID = () -> {
|
||||
final ImmutableSet<Integer> flippedBuffers = flipped.get();
|
||||
final RenderTarget target = renderTargets.get(index);
|
||||
|
||||
if (flippedBuffers.contains(index)) {
|
||||
return target.getAltTexture();
|
||||
@@ -29,7 +35,6 @@ public class IrisImages {
|
||||
};
|
||||
|
||||
final InternalTextureFormat internalFormat = renderTargets.get(i).getInternalFormat();
|
||||
final String name = "colorimg" + i;
|
||||
|
||||
images.addTextureImage(textureID, internalFormat, name);
|
||||
}
|
||||
@@ -37,17 +42,43 @@ public class IrisImages {
|
||||
|
||||
public static boolean hasShadowImages(ImageHolder images) {
|
||||
// TODO: Generalize
|
||||
if (images == null) {
|
||||
return false;
|
||||
}
|
||||
return images.hasImage("shadowcolorimg0") || images.hasImage("shadowcolorimg1");
|
||||
}
|
||||
|
||||
public static void addShadowColorImages(ImageHolder images, ShadowRenderTargets shadowRenderTargets) {
|
||||
public static boolean hasRenderTargetImages(ImageHolder images, RenderTargets targets) {
|
||||
for (int i = 0; i < targets.getRenderTargetCount(); i++) {
|
||||
if (images != null && images.hasImage("colorimg" + i)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void addShadowColorImages(ImageHolder images, ShadowRenderTargets shadowRenderTargets, ImmutableSet<Integer> flipped) {
|
||||
if (images == null) {
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < shadowRenderTargets.getNumColorTextures(); i++) {
|
||||
final int index = i;
|
||||
|
||||
IntSupplier textureID = () -> shadowRenderTargets.getColorTextureId(index);
|
||||
IntSupplier textureID;
|
||||
if (flipped == null) {
|
||||
textureID = () -> shadowRenderTargets.getColorTextureId(index);
|
||||
} else {
|
||||
textureID = () -> flipped.contains(index) ? shadowRenderTargets.get(index).getAltTexture() : shadowRenderTargets.get(index).getMainTexture();
|
||||
}
|
||||
InternalTextureFormat format = shadowRenderTargets.getColorTextureFormat(index);
|
||||
|
||||
images.addTextureImage(textureID, format, "shadowcolorimg" + i);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addCustomImages(ImageHolder images, Set<GlImage> customImages) {
|
||||
customImages.forEach(image -> {
|
||||
images.addTextureImage(image::getId, image.getInternalFormat(), image.getName());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,16 +2,24 @@ package net.coderbot.iris.samplers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
|
||||
import net.coderbot.iris.gl.image.GlImage;
|
||||
import net.coderbot.iris.gl.sampler.GlSampler;
|
||||
import net.coderbot.iris.gl.sampler.SamplerHolder;
|
||||
import net.coderbot.iris.gl.state.StateUpdateNotifiers;
|
||||
import net.coderbot.iris.gl.texture.TextureAccess;
|
||||
import net.coderbot.iris.gl.texture.TextureType;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPipeline;
|
||||
import net.coderbot.iris.rendertarget.RenderTarget;
|
||||
import net.coderbot.iris.rendertarget.RenderTargets;
|
||||
import net.coderbot.iris.shaderpack.PackRenderTargetDirectives;
|
||||
import net.coderbot.iris.shaderpack.PackShadowDirectives;
|
||||
import net.coderbot.iris.shadows.ShadowRenderTargets;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.IntSupplier;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -25,22 +33,35 @@ public class IrisSamplers {
|
||||
// We need a way to restore these texture bindings.
|
||||
public static final ImmutableSet<Integer> COMPOSITE_RESERVED_TEXTURE_UNITS = ImmutableSet.of(1);
|
||||
|
||||
private static GlSampler SHADOW_SAMPLER_NEAREST;
|
||||
private static GlSampler SHADOW_SAMPLER_LINEAR;
|
||||
|
||||
private IrisSamplers() {
|
||||
// no construction allowed
|
||||
}
|
||||
|
||||
public static void initRenderer() {
|
||||
if (!RenderSystem.supportsSamplerObjects()) {
|
||||
// Leave as null - callers handle null gracefully
|
||||
return;
|
||||
}
|
||||
SHADOW_SAMPLER_NEAREST = new GlSampler(false, false, true, true);
|
||||
SHADOW_SAMPLER_LINEAR = new GlSampler(true, false, true, true);
|
||||
}
|
||||
|
||||
public static void addRenderTargetSamplers(SamplerHolder samplers, Supplier<ImmutableSet<Integer>> flipped,
|
||||
RenderTargets renderTargets, boolean isFullscreenPass) {
|
||||
RenderTargets renderTargets, boolean isFullscreenPass,
|
||||
WorldRenderingPipeline pipeline) {
|
||||
// colortex0,1,2,3 are only able to be sampled from fullscreen passes.
|
||||
// Iris could lift this restriction, though I'm not sure if it could cause issues.
|
||||
int startIndex = isFullscreenPass ? 0 : 4;
|
||||
final int startIndex = isFullscreenPass ? 0 : 4;
|
||||
|
||||
for (int i = startIndex; i < renderTargets.getRenderTargetCount(); i++) {
|
||||
final int index = i;
|
||||
|
||||
IntSupplier sampler = () -> {
|
||||
ImmutableSet<Integer> flippedBuffers = flipped.get();
|
||||
RenderTarget target = renderTargets.get(index);
|
||||
final IntSupplier texture = () -> {
|
||||
final ImmutableSet<Integer> flippedBuffers = flipped.get();
|
||||
final RenderTarget target = renderTargets.get(index);
|
||||
|
||||
if (flippedBuffers.contains(index)) {
|
||||
return target.getAltTexture();
|
||||
@@ -54,32 +75,43 @@ public class IrisSamplers {
|
||||
// TODO: How do custom textures interact with aliases?
|
||||
|
||||
if (i < PackRenderTargetDirectives.LEGACY_RENDER_TARGETS.size()) {
|
||||
String legacyName = PackRenderTargetDirectives.LEGACY_RENDER_TARGETS.get(i);
|
||||
final String legacyName = PackRenderTargetDirectives.LEGACY_RENDER_TARGETS.get(i);
|
||||
|
||||
// colortex0 is the default sampler in fullscreen passes
|
||||
if (i == 0 && isFullscreenPass) {
|
||||
samplers.addDefaultSampler(sampler, name, legacyName);
|
||||
samplers.addDefaultSampler(texture, name, legacyName);
|
||||
} else {
|
||||
samplers.addDynamicSampler(sampler, name, legacyName);
|
||||
samplers.addDynamicSampler(texture, name, legacyName);
|
||||
}
|
||||
} else {
|
||||
samplers.addDynamicSampler(sampler, name);
|
||||
samplers.addDynamicSampler(texture, name);
|
||||
}
|
||||
}
|
||||
|
||||
// Add the DH depth textures (stub implementation returns 0 until DH is integrated)
|
||||
if (pipeline != null) {
|
||||
samplers.addDynamicSampler(TextureType.TEXTURE_2D, () -> pipeline.getDHCompat().getDepthTex(), (GlSampler) null, "dhDepthTex", "dhDepthTex0");
|
||||
samplers.addDynamicSampler(TextureType.TEXTURE_2D, () -> pipeline.getDHCompat().getDepthTexNoTranslucent(), (GlSampler) null, "dhDepthTex1");
|
||||
}
|
||||
}
|
||||
|
||||
public static void addNoiseSampler(SamplerHolder samplers, IntSupplier sampler) {
|
||||
samplers.addDynamicSampler(sampler, "noisetex");
|
||||
public static void addNoiseSampler(SamplerHolder samplers, TextureAccess sampler) {
|
||||
samplers.addDynamicSampler(sampler.getTextureId(), "noisetex");
|
||||
}
|
||||
|
||||
public static boolean hasShadowSamplers(SamplerHolder samplers) {
|
||||
// TODO: Keep this up to date with the actual definitions.
|
||||
// TODO: Don't query image presence using the sampler interface even though the current underlying implementation
|
||||
// is the same.
|
||||
ImmutableList<String> shadowSamplers = ImmutableList.of("shadowtex0", "shadowtex0HW", "shadowtex1", "shadowtex1HW", "shadow", "watershadow",
|
||||
"shadowcolor", "shadowcolor0", "shadowcolor1", "shadowcolorimg0", "shadowcolorimg1");
|
||||
final ImmutableList.Builder<String> shadowSamplers = ImmutableList.<String>builder()
|
||||
.add("shadowtex0", "shadowtex0HW", "shadowtex0DH", "shadowtex1", "shadowtex1HW", "shadowtex1DH", "shadow", "watershadow", "shadowcolor");
|
||||
|
||||
for (String samplerName : shadowSamplers) {
|
||||
for (int i = 0; i < PackShadowDirectives.MAX_SHADOW_COLOR_BUFFERS; i++) {
|
||||
shadowSamplers.add("shadowcolor" + i);
|
||||
shadowSamplers.add("shadowcolorimg" + i);
|
||||
}
|
||||
|
||||
for (String samplerName : shadowSamplers.build()) {
|
||||
if (samplers.hasSampler(samplerName)) {
|
||||
return true;
|
||||
}
|
||||
@@ -88,31 +120,61 @@ public class IrisSamplers {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean addShadowSamplers(SamplerHolder samplers, ShadowRenderTargets shadowRenderTargets) {
|
||||
public static boolean addShadowSamplers(SamplerHolder samplers, ShadowRenderTargets shadowRenderTargets, ImmutableSet<Integer> flipped, boolean separateHardwareSamplers) {
|
||||
boolean usesShadows;
|
||||
|
||||
// TODO: figure this out from parsing the shader source code to be 100% compatible with the legacy
|
||||
// shader packs that rely on this behavior.
|
||||
boolean waterShadowEnabled = samplers.hasSampler("watershadow");
|
||||
final boolean waterShadowEnabled = samplers.hasSampler("watershadow");
|
||||
|
||||
// Get the appropriate sampler for hardware filtering
|
||||
// If separateHardwareSamplers is true, we don't apply HW filtering to the main samplers
|
||||
final GlSampler sampler0 = separateHardwareSamplers ? null : (shadowRenderTargets.isHardwareFiltered(0) ? (shadowRenderTargets.isLinearFiltered(0) ? SHADOW_SAMPLER_LINEAR : SHADOW_SAMPLER_NEAREST) : null);
|
||||
final GlSampler sampler1 = separateHardwareSamplers ? null : (shadowRenderTargets.isHardwareFiltered(1) ? (shadowRenderTargets.isLinearFiltered(1) ? SHADOW_SAMPLER_LINEAR : SHADOW_SAMPLER_NEAREST) : null);
|
||||
|
||||
if (waterShadowEnabled) {
|
||||
usesShadows = true;
|
||||
samplers.addDynamicSampler(shadowRenderTargets.getDepthTexture()::getTextureId, "shadowtex0", "watershadow");
|
||||
samplers.addDynamicSampler(shadowRenderTargets.getDepthTextureNoTranslucents()::getTextureId, "shadowtex1", "shadow");
|
||||
samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTexture()::getTextureId, sampler0, "shadowtex0", "watershadow");
|
||||
samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTextureNoTranslucents()::getTextureId, sampler1, "shadowtex1", "shadow");
|
||||
} else {
|
||||
usesShadows = samplers.addDynamicSampler(shadowRenderTargets.getDepthTexture()::getTextureId, "shadowtex0", "shadow");
|
||||
usesShadows |= samplers.addDynamicSampler(shadowRenderTargets.getDepthTextureNoTranslucents()::getTextureId, "shadowtex1");
|
||||
usesShadows = samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTexture()::getTextureId, sampler0, "shadowtex0", "shadow");
|
||||
usesShadows |= samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTextureNoTranslucents()::getTextureId, sampler1, "shadowtex1");
|
||||
}
|
||||
|
||||
samplers.addDynamicSampler(() -> shadowRenderTargets.getColorTextureId(0), "shadowcolor", "shadowcolor0");
|
||||
samplers.addDynamicSampler(() -> shadowRenderTargets.getColorTextureId(1), "shadowcolor1");
|
||||
|
||||
if (shadowRenderTargets.isHardwareFiltered(0)) {
|
||||
samplers.addDynamicSampler(shadowRenderTargets.getDepthTexture()::getTextureId, "shadowtex0HW");
|
||||
// Shadow color textures with flip support
|
||||
if (flipped == null) {
|
||||
// No flip tracking - use getColorTextureId which handles internal flip state
|
||||
if (samplers.addDynamicSampler(() -> shadowRenderTargets.getColorTextureId(0), "shadowcolor")) {
|
||||
shadowRenderTargets.createIfEmpty(0);
|
||||
}
|
||||
for (int i = 0; i < shadowRenderTargets.getRenderTargetCount(); i++) {
|
||||
final int finalI = i;
|
||||
if (samplers.addDynamicSampler(() -> shadowRenderTargets.getColorTextureId(finalI), "shadowcolor" + i)) {
|
||||
shadowRenderTargets.createIfEmpty(finalI);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// With flip tracking - check provided flipped set
|
||||
if (samplers.addDynamicSampler(() -> flipped.contains(0) ? shadowRenderTargets.get(0).getAltTexture() : shadowRenderTargets.get(0).getMainTexture(), "shadowcolor")) {
|
||||
shadowRenderTargets.createIfEmpty(0);
|
||||
}
|
||||
for (int i = 0; i < shadowRenderTargets.getRenderTargetCount(); i++) {
|
||||
final int finalI = i;
|
||||
if (samplers.addDynamicSampler(() -> flipped.contains(finalI) ? shadowRenderTargets.get(finalI).getAltTexture() : shadowRenderTargets.get(finalI).getMainTexture(), "shadowcolor" + finalI)) {
|
||||
shadowRenderTargets.createIfEmpty(finalI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shadowRenderTargets.isHardwareFiltered(1)) {
|
||||
samplers.addDynamicSampler(shadowRenderTargets.getDepthTextureNoTranslucents()::getTextureId, "shadowtex1HW");
|
||||
// Hardware-filtered shadow samplers for separate HW sampler access
|
||||
if (shadowRenderTargets.isHardwareFiltered(0) && separateHardwareSamplers) {
|
||||
final GlSampler hwSampler0 = shadowRenderTargets.isLinearFiltered(0) ? SHADOW_SAMPLER_LINEAR : SHADOW_SAMPLER_NEAREST;
|
||||
samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTexture()::getTextureId, hwSampler0, "shadowtex0HW");
|
||||
}
|
||||
|
||||
if (shadowRenderTargets.isHardwareFiltered(1) && separateHardwareSamplers) {
|
||||
final GlSampler hwSampler1 = shadowRenderTargets.isLinearFiltered(1) ? SHADOW_SAMPLER_LINEAR : SHADOW_SAMPLER_NEAREST;
|
||||
samplers.addDynamicSampler(TextureType.TEXTURE_2D, shadowRenderTargets.getDepthTextureNoTranslucents()::getTextureId, hwSampler1, "shadowtex1HW");
|
||||
}
|
||||
|
||||
return usesShadows;
|
||||
@@ -151,4 +213,18 @@ public class IrisSamplers {
|
||||
samplers.addDynamicSampler(renderTargets.getDepthTextureNoTranslucents()::getTextureId, "depthtex1");
|
||||
samplers.addDynamicSampler(renderTargets.getDepthTextureNoHand()::getTextureId, "depthtex2");
|
||||
}
|
||||
|
||||
public static void addCustomTextures(SamplerHolder samplers, Object2ObjectMap<String, TextureAccess> irisCustomTextures) {
|
||||
irisCustomTextures.forEach((name, texture) -> {
|
||||
samplers.addDynamicSampler(texture.getType(), texture.getTextureId(), name);
|
||||
});
|
||||
}
|
||||
|
||||
public static void addCustomImages(SamplerHolder images, Set<GlImage> customImages) {
|
||||
customImages.forEach(image -> {
|
||||
if (image.getSamplerName() != null) {
|
||||
images.addDynamicSampler(image.getTarget(), image::getId, image.getSamplerName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,56 +1,40 @@
|
||||
package net.coderbot.iris.shaderpack;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.joml.Vector2f;
|
||||
import org.joml.Vector3i;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class ComputeSource {
|
||||
private final String name;
|
||||
@Getter private final String name;
|
||||
private final String source;
|
||||
private final ProgramSet parent;
|
||||
private Vector3i workGroups;
|
||||
private Vector2f workGroupRelative;
|
||||
@Getter private final ProgramSet parent;
|
||||
@Getter private final IndirectPointer indirectPointer;
|
||||
@Getter @Setter private Vector3i workGroups;
|
||||
@Getter @Setter private Vector2f workGroupRelative;
|
||||
|
||||
public ComputeSource(String name, String source, ProgramSet parent) {
|
||||
this(name, source, parent, null);
|
||||
}
|
||||
|
||||
public ComputeSource(String name, String source, ProgramSet parent, ShaderProperties properties) {
|
||||
this.name = name;
|
||||
this.source = source;
|
||||
this.parent = parent;
|
||||
this.indirectPointer = properties != null ? properties.getIndirectPointers().get(name) : null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Optional<String> getSource() {
|
||||
public Optional<String> getSource() {
|
||||
return Optional.ofNullable(source);
|
||||
}
|
||||
|
||||
public ProgramSet getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
public boolean isValid() {
|
||||
return source != null;
|
||||
}
|
||||
|
||||
public void setWorkGroups(Vector3i workGroups) {
|
||||
this.workGroups = workGroups;
|
||||
}
|
||||
|
||||
public void setWorkGroupRelative(Vector2f workGroupRelative) {
|
||||
this.workGroupRelative = workGroupRelative;
|
||||
}
|
||||
|
||||
public Vector2f getWorkGroupRelative() {
|
||||
return workGroupRelative;
|
||||
}
|
||||
|
||||
public Vector3i getWorkGroups() {
|
||||
return workGroups;
|
||||
}
|
||||
|
||||
public Optional<ComputeSource> requireValid() {
|
||||
public Optional<ComputeSource> requireValid() {
|
||||
if (this.isValid()) {
|
||||
return Optional.of(this);
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.coderbot.iris.shaderpack;
|
||||
|
||||
import net.coderbot.iris.gl.buffer.ShaderStorageBufferHolder;
|
||||
|
||||
public record FilledIndirectPointer(int buffer, long offset) {
|
||||
public static FilledIndirectPointer basedOff(ShaderStorageBufferHolder holder, IndirectPointer pointer) {
|
||||
if (pointer == null || holder == null) return null;
|
||||
|
||||
return new FilledIndirectPointer(holder.getBufferIndex(pointer.buffer()), pointer.offset());
|
||||
}
|
||||
}
|
||||
@@ -132,6 +132,82 @@ public class IdMap {
|
||||
return parseIdMap(properties, "entity.", "entity.properties");
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a space-delimited list of identifiers.
|
||||
* Identifiers with spaces or special characters can be enclosed in double quotes.
|
||||
* Use backslash to escape quotes or backslashes within quoted strings.
|
||||
*
|
||||
* Examples (input -> parsed result):
|
||||
* minecraft:stone natura:berry
|
||||
* -> minecraft:stone, natura:berry
|
||||
*
|
||||
* minecraft:stone "Natura:N Crops"
|
||||
* -> minecraft:stone, Natura:N Crops
|
||||
*
|
||||
* "SomeDumbMod:Foo\\ \"Bar\":3"
|
||||
* -> SomeDumbMod:Foo\ "Bar":3
|
||||
*
|
||||
* @param value The space-delimited string to parse
|
||||
* @param fileName The name of the properties file (for error messages)
|
||||
* @param key The property key being parsed (for error messages)
|
||||
* @return List of parsed identifiers
|
||||
*/
|
||||
static List<String> parseIdentifierList(String value, String fileName, String key) {
|
||||
if (value.indexOf('"') == -1) {
|
||||
String[] parts = value.split("\\s+");
|
||||
List<String> result = new ArrayList<>(parts.length);
|
||||
for (String part : parts) {
|
||||
if (!part.isEmpty()) {
|
||||
result.add(part);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Found quote, start of a dumb block ID
|
||||
List<String> result = new ArrayList<>();
|
||||
StringBuilder current = new StringBuilder();
|
||||
boolean inQuotes = false;
|
||||
boolean escaped = false;
|
||||
|
||||
for (int i = 0; i < value.length(); i++) {
|
||||
char c = value.charAt(i);
|
||||
|
||||
if (escaped) {
|
||||
current.append(c);
|
||||
escaped = false;
|
||||
} else if (c == '\\') {
|
||||
escaped = true;
|
||||
} else if (c == '"') {
|
||||
inQuotes = !inQuotes;
|
||||
} else if (Character.isWhitespace(c) && !inQuotes) {
|
||||
if (current.length() > 0) {
|
||||
result.add(current.toString());
|
||||
current.setLength(0);
|
||||
}
|
||||
} else {
|
||||
current.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
// Didn't close a quote, warn
|
||||
if (inQuotes) {
|
||||
Iris.logger.warn(fileName + " [" + key + "]: Unclosed quote");
|
||||
}
|
||||
|
||||
// Trailing backslash, warn
|
||||
if (escaped) {
|
||||
Iris.logger.warn(fileName + " [" + key + "]: Trailing backslash");
|
||||
}
|
||||
|
||||
// Add final token
|
||||
if (current.length() > 0) {
|
||||
result.add(current.toString());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a NamespacedId map in OptiFine format
|
||||
*/
|
||||
@@ -158,8 +234,8 @@ public class IdMap {
|
||||
return;
|
||||
}
|
||||
|
||||
// Split on any whitespace
|
||||
for (String part : value.split("\\s+")) {
|
||||
// Parse identifiers
|
||||
for (String part : parseIdentifierList(value, fileName, key)) {
|
||||
if (part.contains("=")) {
|
||||
// Avoid tons of logspam for now
|
||||
Iris.logger.warn("Failed to parse an ResourceLocation in " + fileName + " for the key " + key + ": state properties are currently not supported: " + part);
|
||||
@@ -209,8 +285,8 @@ public class IdMap {
|
||||
}
|
||||
}
|
||||
|
||||
// Split on whitespace groups, not just single spaces
|
||||
for (String part : value.toString().split("\\s+")) {
|
||||
// Parse identifiers
|
||||
for (String part : parseIdentifierList(value.toString(), fileName, key)) {
|
||||
if (part.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
@@ -255,7 +331,7 @@ public class IdMap {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String part : value.split("\\s+")) {
|
||||
for (String part : parseIdentifierList(value, fileName, key)) {
|
||||
// Note: NamespacedId performs no validation on the content. That will need to be done by whatever is
|
||||
// converting these things to ResourceLocations.
|
||||
overrides.put(new NamespacedId(part), renderType);
|
||||
|
||||
Loaded 100 of 132 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user