mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-26 07:03:02 +00:00
The Mergening (#13)
* ThreadedTessellator -> RenderBlocks instance Tessellator * Plus a CME workaround until I can figure out why it's happening * One inject with multiple methods instead of two injects * Add AF's Tessellator#reset mixin Fixes screen flashing when chunks are being built * Thread Saftey * Make each tesselator use its own ByteBuffer * Don't make RecyclingList a static variable 🤦 * Add some additions via ITessellatorInstance * Stop using builtin updateRenderers * Remove a few unused things in MixinTessellator * Remove useless casting due to implementing the interface * Overwrite some more rendering methods to ensure they're not used * Implement IBlockAccess on WorldSlice * Currently just proxies to the World... need to get it to use the local cache * Make WorldSlice use its copied values instead of using the world * block, meta, and light. Still need TODO biome * Finish making WorldSlice thread safe * Remove last unsafe this.world accesses * Copy biomeData * Implement getTileEntity(), and getBiomeGenForCoords() * Remove unused 1.16+ classes - Biome, Colorizer, and ColorBlender related * Cache worldHeight instead of asking the provider every time * Debug Screen updates * Disable Culling for now (until it works) * Tessellator Updates * Use one instance on the main thread, and individual instances on every other thread * Prevent draw() and buffer.reset() on non singleton instance * Misc cleanup, maybe better growBuffer? * Fixing splash screen and GUI issues by excluding SplashProgress from GLStateManager transformer * Update docs * Fixing a one line in SodiumWorldRenderer that allows the game setting for the distance at which entities will render. Hope it's not too bad mitch :) * TileEntites now render * Less silly transparency * Removing clamp implementation because I missed the one in mathhelper * Initial sodium entity smooth lighting * Fix entity smooth lighting * Fix lerp uses and use render layers properly (#17) * Remove some uses of blockstate + patch FluidState * Fix lerp * Enable Sodium fluid rendering * Update FluidRenderer.java * Rewind buffers when copying * Fix multidraw * Force cutout on all non-translucent blocks * Let vanilla handle render pass state * Rewrite render layer check to use Forge 1.7 hook * Fix skylight handling * Fix flickering * Clone TEs correctly * Fixing entityDistMulti (I think) * Fix TEs rendering on the wrong pass * Buff max render distance to 32 Pretty useless since the integrated server stalls instantly, but our renderer supports it * Fix fog * Fix render distance changes being ignored * Implement entity culling * Block face culling * Re-enable occlusion culling * Fix x/z coordinate mixup when indexing biome arrays Partially fixes wrong biome colors, but at chunk edges it's still wrong because neighboring chunks aren't accessed * Make a copy of biome data The old code seemed to work fine but this should be safer * Make CompatMemoryUtil#memReallocDirect preserve buffer position LWJGL3's MemoryUtil#memRealloc does this, see its javadoc. Fixes screen flashing and this error getting printed when indirect buffer grows: GL_INVALID_OPERATION error generated. Bound draw indirect buffer is not large enough. * Use biome data of neighboring chunk sections Fixes wrong colors at chunk edges * Re-enable fog culling * Tile entity culling * Remove some unneeded Sodium code * Massive code cleanup * Avoids errors when usin lwjglxdebug * Bump hodgepodge dep * Add AngelicaConfig * Add Mixin to disable MC's builtin checkGLError * Add configs for iris/sodium * Iris work * Move some StateNotifiers to GLStateManager * Remove some redundant mixins based on sodium/angelica work and rendering state captures * Add Iris DebugScreenHandler * rm archaicfix's occlusion renderer and threaded updates * Implemented Sodium's GUI and a couple of setting fixes (#20) * Ported Sodium's GUI * Correct AO * Fixed Vignette * Re-enable DirectMemoryAccess * Adds some code from lwjgl3 in CompatMemoryUtil.java * Re-add *Unsafe classes * Remove MixinWorldRenderer * Add NEID (mixin pr) support * Only shadow runtime module of antlr4 Reduces jar size by 11 mb * Update NotFine * Make LongHashMap actually perform like a hash map * Options GUI Fixes and some option implementations (#22) * Correct useNoErrorGLContext option * Added translucency sorting option * Implemented Particle Culling gives real fps boost, however, it's not as big as i thought * Begin implementing animateOnlyVisibleTextures * Correct Donation page opening * Fixed Shift + P Now it uses NotFine's GUI, but it think that NotFine's GUI should be rewrited for using other config options * Correct URL's for Linux * second code cleanup in particle culling * Fix incorrect TE map population * Add optional assertMainThread behind `-Dangelica.assertMainThread=true` * Add back air optimization, but only apply to vanilla air * Implement more options (#23) * Combine free regions in GlBufferArena * Clear global block entity list when initializing renderer * AF, CompileStubs, and SplashProgress Remove most of ArchaicFix * Move a few mixins over to angelica * Disable if org.lwjgl.util.Debug is set * Only enable Iris/lwjgl debug callbacks if org.lwjgl.util.Debug is set * Rewrite Tessellator hacks - now using a ThreadLocal instead of only patching RenderBlocks * Reenable AF mixins, switch to cached debug var, disable incompatible mixins * Remove AF deps and a late mixin that was missed * Add Iris Sodium Compat impl * Fix Sodium GLProgram to use ResourceLocation instead of Identifier * Start applying Iris -> Sodium Mixins * Make NotFine menu open if holding shift * Fixed Tessellators in production env * Finish Sodium Fluid Renderer (#24) * Init and pass Sodium LightPipelines * Remove registry lookup and refactor WorldUtil * Hook up lighting pipeline * Patch fluid velocity * It's alive! Sodium Fluid Renderer is alive! * Fix face culling not taking third person camera offset into account * rewrite ACTEntityRenderer to stop transforming ALL the classes * use ClassConstantPoolParser in TessellatorTransformer to speed up search for Tessellator references * use ClassConstantPoolParser in GLStateManagerTransformer to speed up search for class references * rewrite GLStateManagerTransformer and TessellatorTransformer * merge GLStateManagerTransfor and TessellatorTransformer into one Transformer * Fixed smooth lighting rendering * Iris block_id Mixins & BlockStateIdMap initial impl for 1.7.10 * Fix running with lwjgl debug flag & Cleanup old ShadersMod transformers * Initialize GLStateManager via Mixins instead of all in the static block * Clean up chunk load/unload tracking, fix chunks rendering without neighbors sometimes * Fix occlusion culler not re-running after important uploads Backport of https://github.com/CaffeineMC/sodium-fabric/pull/755 * Add chunks to queues without going through occlusion culler Partially reverts the previous chunk tracking commit, because that logic will reintroduce https://github.com/CaffeineMC/sodium-fabric/issues/605 As long as we only rebuild with neighbors present, we shouldn't see the visual seams * Extremely primitive synchronization approach for ISBRH * Use factory for Spdium menu createElement outputs This will allow NotFine to use Sodium menu elements and vice versa in a future commit. * Splash Screen Compat * Separate remaining NamedState enums * NotFine but it loads Sodium pages * Hook up NotFine optimizations * Hook up some NotFine features * copy over hud caching code from hodgepodge * backport glstatemanager mixin * Track thread that currently owns the GL Context in addition to the main thread. * First pass over FontRenderer, 1300->1400 FPS on my GPU when showing F3 Done: - A batching vertex buffer builder for font output - Reduction in drawcalls from 1-3 per character to 1 per font atlas switch - Mixin to draw the entire F3 screen in one batch, instead of separate batches per line TODO: - Switch drawing to a VBO - Cache string meshes across frames - Cache string width calculations used for layouts - Multidraw to reduce draw calls even further * Add JVM flag to bypass GL state caching * Push/Pop Attrib Hacks -- to be evolved later * Fix FontRenderer+SplashScreen combo * HUDCaching tweaks * Add license * Jabba Compat, and reset tesselator state even if the chunk render thread blows up * Initial Xaero's World Map + Minimap Support * Disable Fastcraft & Optifine if present * Iris Progress * Wire up more Iris mixins, informing pipeline stages. Still not rendering anything visible. * Don't try to transform the server * Avoid running biome generator on client in singleplayer * Call world biome retrieval methods instead of copying array directly (#25) * Shaders now do something! * Shadow Pass work * First shadow pass renders; however it moves all around when moving the camera... * Second shadow pass not running because it makes everything very very dark instead of just rendering translucents * Actually use the ShadowRenderer Model View when running the shadow pass... * Enable Sodium SmoothLightPipeline & Iris useSeparateAo * Avoid repeatedly copying biome data on each Y level (#27) * Celestial Rotation fixes * Water progress * Uniforms audit * Lightmap workaround * PBR compiling, stuck on Normal and Specular textures being added in * Shaderpack selection "works"; ShaderOptions TODO * Hud caching angelica (#28) * Potential hud-caching fix * Shader Options almost working ** Clicking on everything doesn't yet work, and the visuals are slightly off * Entity shadows seem to be working * Move glint fix to Mixin * Rework mouse handling for ShaderPackConfig * Stop centering shader options vertically * Angelica pbr (#31) * Only use Sodium light pipeline if useSeparateAo is on Sodium pipeline is still very buggy, so isolate it to Iris-only for now * Fix region sorting for translucency * Open Shaderpack now works on Linux * RM Shadersmod * Initial iris scrollbar clicking * Punt unsupported ISBRHs to the main thread * Delete the ISBRH lock, shouldn't be needed anymore * Render GT blocks on main thread * Require CCC 1.2.0+ * Depend on CCC 1.2 * Fix TESRs not being tracked for blocks rendered on main thread * Cut down number of runtime dependencies, enable CoreTweaks in dev by default * Add modern F3 background * Pull over some hodgepodge mixins --------- Co-authored-by: makamys <[email protected]> Co-authored-by: embeddedt <[email protected]> Co-authored-by: rjnasers <[email protected]> Co-authored-by: ah-OOG-ah <[email protected]> Co-authored-by: Ryan Nasers <[email protected]> Co-authored-by: Rad <[email protected]> Co-authored-by: Bogdan <[email protected]> Co-authored-by: Caedis <[email protected]> Co-authored-by: jss2a98aj <[email protected]> Co-authored-by: Alexdoru <[email protected]> Co-authored-by: Raven Szewczyk <[email protected]> Co-authored-by: mist475 <[email protected]> Co-authored-by: Ryan Nasers <[email protected]>
This commit is contained in:
942 files changed
+65828
-8640
No files matched your search
@@ -0,0 +1,623 @@
|
||||
package net.coderbot.iris.shaderpack;
|
||||
|
||||
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
|
||||
import it.unimi.dsi.fastutil.objects.Object2BooleanMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gl.IrisRenderSystem;
|
||||
import net.coderbot.iris.gl.blending.AlphaTest;
|
||||
import net.coderbot.iris.gl.blending.AlphaTestFunction;
|
||||
import net.coderbot.iris.gl.blending.AlphaTestOverride;
|
||||
import net.coderbot.iris.gl.blending.BlendMode;
|
||||
import net.coderbot.iris.gl.blending.BlendModeFunction;
|
||||
import net.coderbot.iris.gl.blending.BlendModeOverride;
|
||||
import net.coderbot.iris.gl.blending.BufferBlendInformation;
|
||||
import net.coderbot.iris.gl.texture.TextureScaleOverride;
|
||||
import net.coderbot.iris.shaderpack.option.ShaderPackOptions;
|
||||
import net.coderbot.iris.shaderpack.preprocessor.PropertiesPreprocessor;
|
||||
import net.coderbot.iris.shaderpack.texture.TextureStage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* The parsed representation of the shaders.properties file. This class is not meant to be stored permanently, rather
|
||||
* it merely exists as an intermediate step until we build up PackDirectives and ProgramDirectives objects from the
|
||||
* values in here & the values parsed from shader source code.
|
||||
*/
|
||||
public class ShaderProperties {
|
||||
private CloudSetting cloudSetting = CloudSetting.DEFAULT;
|
||||
private OptionalBoolean oldHandLight = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean dynamicHandLight = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean oldLighting = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean shadowTerrain = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean shadowTranslucent = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean shadowEntities = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean shadowPlayer = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean shadowBlockEntities = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean underwaterOverlay = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean sun = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean moon = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean vignette = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean backFaceSolid = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean backFaceCutout = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean backFaceCutoutMipped = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean backFaceTranslucent = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean rainDepth = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean concurrentCompute = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean beaconBeamDepth = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean separateAo = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean frustumCulling = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean shadowCulling = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean shadowEnabled = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean particlesBeforeDeferred = OptionalBoolean.DEFAULT;
|
||||
private OptionalBoolean prepareBeforeShadow = OptionalBoolean.DEFAULT;
|
||||
private List<String> sliderOptions = new ArrayList<>();
|
||||
private final Map<String, List<String>> profiles = new LinkedHashMap<>();
|
||||
private List<String> mainScreenOptions = null;
|
||||
private final Map<String, List<String>> subScreenOptions = new HashMap<>();
|
||||
private Integer mainScreenColumnCount = null;
|
||||
private final Map<String, Integer> subScreenColumnCount = new HashMap<>();
|
||||
// TODO: private Map<String, String> optifineVersionRequirements;
|
||||
// TODO: Parse custom uniforms / variables
|
||||
private final Object2ObjectMap<String, AlphaTestOverride> alphaTestOverrides = new Object2ObjectOpenHashMap<>();
|
||||
private final Object2FloatMap<String> viewportScaleOverrides = new Object2FloatOpenHashMap<>();
|
||||
private final Object2ObjectMap<String, TextureScaleOverride> textureScaleOverrides = new Object2ObjectOpenHashMap<>();
|
||||
private final Object2ObjectMap<String, BlendModeOverride> blendModeOverrides = new Object2ObjectOpenHashMap<>();
|
||||
private final Object2ObjectMap<String, ArrayList<BufferBlendInformation>> bufferBlendOverrides = new Object2ObjectOpenHashMap<>();
|
||||
private final EnumMap<TextureStage, Object2ObjectMap<String, String>> customTextures = new EnumMap<>(TextureStage.class);
|
||||
private final Object2ObjectMap<String, Object2BooleanMap<String>> explicitFlips = new Object2ObjectOpenHashMap<>();
|
||||
private String noiseTexturePath = null;
|
||||
private Object2ObjectMap<String, String> conditionallyEnabledPrograms = new Object2ObjectOpenHashMap<>();
|
||||
private List<String> requiredFeatureFlags = new ArrayList<>();
|
||||
private List<String> optionalFeatureFlags = new ArrayList<>();
|
||||
|
||||
private ShaderProperties() {
|
||||
// empty
|
||||
}
|
||||
|
||||
// TODO: Is there a better solution than having ShaderPack pass a root path to ShaderProperties to be able to read textures?
|
||||
public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, Iterable<StringPair> environmentDefines) {
|
||||
String preprocessedContents = PropertiesPreprocessor.preprocessSource(contents, shaderPackOptions, environmentDefines);
|
||||
|
||||
Properties preprocessed = new OrderBackedProperties();
|
||||
Properties original = new OrderBackedProperties();
|
||||
try {
|
||||
preprocessed.load(new StringReader(preprocessedContents));
|
||||
original.load(new StringReader(contents));
|
||||
} catch (IOException e) {
|
||||
Iris.logger.error("Error loading shaders.properties!", e);
|
||||
}
|
||||
|
||||
preprocessed.forEach((keyObject, valueObject) -> {
|
||||
String key = (String) keyObject;
|
||||
String value = (String) valueObject;
|
||||
|
||||
if ("texture.noise".equals(key)) {
|
||||
noiseTexturePath = value;
|
||||
return;
|
||||
}
|
||||
|
||||
if ("clouds".equals(key)) {
|
||||
if ("off".equals(value)) {
|
||||
cloudSetting = CloudSetting.OFF;
|
||||
} else if ("fast".equals(value)) {
|
||||
cloudSetting = CloudSetting.FAST;
|
||||
} else if ("fancy".equals(value)) {
|
||||
cloudSetting = CloudSetting.FANCY;
|
||||
} else {
|
||||
Iris.logger.error("Unrecognized clouds setting: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
handleBooleanDirective(key, value, "oldHandLight", bool -> oldHandLight = bool);
|
||||
handleBooleanDirective(key, value, "dynamicHandLight", bool -> dynamicHandLight = bool);
|
||||
handleBooleanDirective(key, value, "oldLighting", bool -> oldLighting = bool);
|
||||
handleBooleanDirective(key, value, "shadowTerrain", bool -> shadowTerrain = bool);
|
||||
handleBooleanDirective(key, value, "shadowTranslucent", bool -> shadowTranslucent = bool);
|
||||
handleBooleanDirective(key, value, "shadowEntities", bool -> shadowEntities = bool);
|
||||
handleBooleanDirective(key, value, "shadowPlayer", bool -> shadowPlayer = bool);
|
||||
handleBooleanDirective(key, value, "shadowBlockEntities", bool -> shadowBlockEntities = bool);
|
||||
handleBooleanDirective(key, value, "underwaterOverlay", bool -> underwaterOverlay = bool);
|
||||
handleBooleanDirective(key, value, "sun", bool -> sun = bool);
|
||||
handleBooleanDirective(key, value, "moon", bool -> moon = bool);
|
||||
handleBooleanDirective(key, value, "vignette", bool -> vignette = bool);
|
||||
handleBooleanDirective(key, value, "backFace.solid", bool -> backFaceSolid = bool);
|
||||
handleBooleanDirective(key, value, "backFace.cutout", bool -> backFaceCutout = bool);
|
||||
handleBooleanDirective(key, value, "backFace.cutoutMipped", bool -> backFaceCutoutMipped = bool);
|
||||
handleBooleanDirective(key, value, "backFace.translucent", bool -> backFaceTranslucent = bool);
|
||||
handleBooleanDirective(key, value, "rain.depth", bool -> rainDepth = bool);
|
||||
handleBooleanDirective(key, value, "allowConcurrentCompute", bool -> concurrentCompute = bool);
|
||||
handleBooleanDirective(key, value, "beacon.beam.depth", bool -> beaconBeamDepth = bool);
|
||||
handleBooleanDirective(key, value, "separateAo", bool -> separateAo = bool);
|
||||
handleBooleanDirective(key, value, "frustum.culling", bool -> frustumCulling = bool);
|
||||
handleBooleanDirective(key, value, "shadow.culling", bool -> shadowCulling = bool);
|
||||
handleBooleanDirective(key, value, "particles.before.deferred", bool -> particlesBeforeDeferred = bool);
|
||||
handleBooleanDirective(key, value, "prepareBeforeShadow", bool -> prepareBeforeShadow = bool);
|
||||
|
||||
// TODO: Min optifine versions, shader options layout / appearance / profiles
|
||||
// TODO: Custom uniforms
|
||||
|
||||
handlePassDirective("scale.", key, value, pass -> {
|
||||
float scale;
|
||||
|
||||
try {
|
||||
scale = Float.parseFloat(value);
|
||||
} catch (NumberFormatException e) {
|
||||
Iris.logger.error("Unable to parse scale directive for " + pass + ": " + value, e);
|
||||
return;
|
||||
}
|
||||
|
||||
viewportScaleOverrides.put(pass, scale);
|
||||
});
|
||||
|
||||
handlePassDirective("size.buffer.", key, value, pass -> {
|
||||
String[] parts = value.split(" ");
|
||||
|
||||
if (parts.length != 2) {
|
||||
Iris.logger.error("Unable to parse size.buffer directive for " + pass + ": " + value);
|
||||
return;
|
||||
}
|
||||
|
||||
textureScaleOverrides.put(pass, new TextureScaleOverride(parts[0], parts[1]));
|
||||
});
|
||||
|
||||
handlePassDirective("alphaTest.", key, value, pass -> {
|
||||
if ("off".equals(value)) {
|
||||
alphaTestOverrides.put(pass, AlphaTestOverride.OFF);
|
||||
return;
|
||||
}
|
||||
|
||||
String[] parts = value.split(" ");
|
||||
|
||||
if (parts.length > 2) {
|
||||
Iris.logger.warn("Weird alpha test directive for " + pass + " contains more parts than we expected: " + value);
|
||||
} else if (parts.length < 2) {
|
||||
Iris.logger.error("Invalid alpha test directive for " + pass + ": " + value);
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<AlphaTestFunction> function = AlphaTestFunction.fromString(parts[0]);
|
||||
|
||||
if (!function.isPresent()) {
|
||||
Iris.logger.error("Unable to parse alpha test directive for " + pass + ", unknown alpha test function " + parts[0] + ": " + value);
|
||||
return;
|
||||
}
|
||||
|
||||
float reference;
|
||||
|
||||
try {
|
||||
reference = Float.parseFloat(parts[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
Iris.logger.error("Unable to parse alpha test directive for " + pass + ": " + value, e);
|
||||
return;
|
||||
}
|
||||
|
||||
alphaTestOverrides.put(pass, new AlphaTestOverride(new AlphaTest(function.get(), reference)));
|
||||
});
|
||||
|
||||
handlePassDirective("blend.", key, value, pass -> {
|
||||
if (pass.contains(".")) {
|
||||
|
||||
if (!IrisRenderSystem.supportsBufferBlending()) {
|
||||
throw new RuntimeException("Buffer blending is not supported on this platform, however it was attempted to be used!");
|
||||
}
|
||||
|
||||
String[] parts = pass.split("\\.");
|
||||
int index = PackRenderTargetDirectives.LEGACY_RENDER_TARGETS.indexOf(parts[1]);
|
||||
|
||||
if (index == -1 && parts[1].startsWith("colortex")) {
|
||||
String id = parts[1].substring("colortex".length());
|
||||
|
||||
try {
|
||||
index = Integer.parseInt(id);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new RuntimeException("Failed to parse buffer blend!", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1) {
|
||||
throw new RuntimeException("Failed to parse buffer blend! index = " + index);
|
||||
}
|
||||
|
||||
if ("off".equals(value)) {
|
||||
bufferBlendOverrides.computeIfAbsent(parts[0], list -> new ArrayList<>()).add(new BufferBlendInformation(index, null));
|
||||
return;
|
||||
}
|
||||
|
||||
String[] modeArray = value.split(" ");
|
||||
int[] modes = new int[modeArray.length];
|
||||
|
||||
int i = 0;
|
||||
for (String modeName : modeArray) {
|
||||
modes[i] = BlendModeFunction.fromString(modeName).get().getGlId();
|
||||
i++;
|
||||
}
|
||||
|
||||
bufferBlendOverrides.computeIfAbsent(parts[0], list -> new ArrayList<>()).add(new BufferBlendInformation(index, new BlendMode(modes[0], modes[1], modes[2], modes[3])));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ("off".equals(value)) {
|
||||
blendModeOverrides.put(pass, BlendModeOverride.OFF);
|
||||
return;
|
||||
}
|
||||
|
||||
String[] modeArray = value.split(" ");
|
||||
int[] modes = new int[modeArray.length];
|
||||
|
||||
int i = 0;
|
||||
for (String modeName : modeArray) {
|
||||
modes[i] = BlendModeFunction.fromString(modeName).get().getGlId();
|
||||
i++;
|
||||
}
|
||||
|
||||
blendModeOverrides.put(pass, new BlendModeOverride(new BlendMode(modes[0], modes[1], modes[2], modes[3])));
|
||||
});
|
||||
|
||||
handleProgramEnabledDirective("program.", key, value, program -> {
|
||||
conditionallyEnabledPrograms.put(program, value);
|
||||
});
|
||||
|
||||
handleTwoArgDirective("texture.", key, value, (stageName, samplerName) -> {
|
||||
String[] parts = value.split(" ");
|
||||
|
||||
// TODO: Support raw textures
|
||||
if (parts.length > 1) {
|
||||
Iris.logger.warn("Custom texture directive for stage " + stageName + ", sampler " + samplerName + " contains more parts than we expected: " + value);
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<TextureStage> optionalTextureStage = TextureStage.parse(stageName);
|
||||
|
||||
if (!optionalTextureStage.isPresent()) {
|
||||
Iris.logger.warn("Unknown texture stage " + "\"" + stageName + "\"," + " ignoring custom texture directive for " + key);
|
||||
return;
|
||||
}
|
||||
|
||||
TextureStage stage = optionalTextureStage.get();
|
||||
|
||||
customTextures.computeIfAbsent(stage, _stage -> new Object2ObjectOpenHashMap<>())
|
||||
.put(samplerName, value);
|
||||
});
|
||||
|
||||
handleTwoArgDirective("flip.", key, value, (pass, buffer) -> {
|
||||
handleBooleanValue(key, value, shouldFlip -> {
|
||||
explicitFlips.computeIfAbsent(pass, _pass -> new Object2BooleanOpenHashMap<>())
|
||||
.put(buffer, shouldFlip);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
handleWhitespacedListDirective(key, value, "iris.features.required", options -> requiredFeatureFlags = options);
|
||||
handleWhitespacedListDirective(key, value, "iris.features.optional", options -> optionalFeatureFlags = options);
|
||||
|
||||
// TODO: Buffer size directives
|
||||
// TODO: Conditional program enabling directives
|
||||
});
|
||||
|
||||
// We need to use a non-preprocessed property file here since we don't want any weird preprocessor changes to be applied to the screen/value layout.
|
||||
original.forEach((keyObject, valueObject) -> {
|
||||
String key = (String) keyObject;
|
||||
String value = (String) valueObject;
|
||||
|
||||
// Defining "sliders" multiple times in the properties file will only result in
|
||||
// the last definition being used, should be tested if behavior matches OptiFine
|
||||
handleWhitespacedListDirective(key, value, "sliders", sliders -> sliderOptions = sliders);
|
||||
handlePrefixedWhitespacedListDirective("profile.", key, value, profiles::put);
|
||||
|
||||
if (handleIntDirective(key, value, "screen.columns", columns -> mainScreenColumnCount = columns)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (handleAffixedIntDirective("screen.", ".columns", key, value, subScreenColumnCount::put)) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleWhitespacedListDirective(key, value, "screen", options -> mainScreenOptions = options);
|
||||
handlePrefixedWhitespacedListDirective("screen.", key, value, subScreenOptions::put);
|
||||
});
|
||||
}
|
||||
|
||||
private static void handleBooleanValue(String key, String value, BooleanConsumer handler) {
|
||||
if ("true".equals(value)) {
|
||||
handler.accept(true);
|
||||
} else if ("false".equals(value)) {
|
||||
handler.accept(false);
|
||||
} else {
|
||||
Iris.logger.warn("Unexpected value for boolean key " + key + " in shaders.properties: got " + value + ", but expected either true or false");
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleBooleanDirective(String key, String value, String expectedKey, Consumer<OptionalBoolean> handler) {
|
||||
if (!expectedKey.equals(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ("true".equals(value)) {
|
||||
handler.accept(OptionalBoolean.TRUE);
|
||||
} else if ("false".equals(value)) {
|
||||
handler.accept(OptionalBoolean.FALSE);
|
||||
} else {
|
||||
Iris.logger.warn("Unexpected value for boolean key " + key + " in shaders.properties: got " + value + ", but expected either true or false");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean handleIntDirective(String key, String value, String expectedKey, Consumer<Integer> handler) {
|
||||
if (!expectedKey.equals(key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
int result = Integer.parseInt(value);
|
||||
|
||||
handler.accept(result);
|
||||
} catch (NumberFormatException nex) {
|
||||
Iris.logger.warn("Unexpected value for integer key " + key + " in shaders.properties: got " + value + ", but expected an integer");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean handleAffixedIntDirective(String prefix, String suffix, String key, String value, BiConsumer<String, Integer> handler) {
|
||||
if (key.startsWith(prefix) && key.endsWith(suffix)) {
|
||||
int substrBegin = prefix.length();
|
||||
int substrEnd = key.length() - suffix.length();
|
||||
|
||||
if (substrEnd <= substrBegin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String affixStrippedKey = key.substring(substrBegin, substrEnd);
|
||||
|
||||
try {
|
||||
int result = Integer.parseInt(value);
|
||||
|
||||
handler.accept(affixStrippedKey, result);
|
||||
} catch (NumberFormatException nex) {
|
||||
Iris.logger.warn("Unexpected value for integer key " + key + " in shaders.properties: got " + value + ", but expected an integer");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void handlePassDirective(String prefix, String key, String value, Consumer<String> handler) {
|
||||
if (key.startsWith(prefix)) {
|
||||
String pass = key.substring(prefix.length());
|
||||
|
||||
handler.accept(pass);
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleProgramEnabledDirective(String prefix, String key, String value, Consumer<String> handler) {
|
||||
if (key.startsWith(prefix)) {
|
||||
String program = key.substring(prefix.length(), key.indexOf(".", prefix.length()));
|
||||
|
||||
handler.accept(program);
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleWhitespacedListDirective(String key, String value, String expectedKey, Consumer<List<String>> handler) {
|
||||
if (!expectedKey.equals(key)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String[] elements = value.split(" +");
|
||||
|
||||
handler.accept(Arrays.asList(elements));
|
||||
}
|
||||
|
||||
private static void handlePrefixedWhitespacedListDirective(String prefix, String key, String value, BiConsumer<String, List<String>> handler) {
|
||||
if (key.startsWith(prefix)) {
|
||||
String prefixStrippedKey = key.substring(prefix.length());
|
||||
String[] elements = value.split(" +");
|
||||
|
||||
handler.accept(prefixStrippedKey, Arrays.asList(elements));
|
||||
}
|
||||
}
|
||||
|
||||
private static void handleTwoArgDirective(String prefix, String key, String value, BiConsumer<String, String> handler) {
|
||||
if (key.startsWith(prefix)) {
|
||||
int endOfPassIndex = key.indexOf(".", prefix.length());
|
||||
String stage = key.substring(prefix.length(), endOfPassIndex);
|
||||
String sampler = key.substring(endOfPassIndex + 1);
|
||||
|
||||
handler.accept(stage, sampler);
|
||||
}
|
||||
}
|
||||
|
||||
public static ShaderProperties empty() {
|
||||
return new ShaderProperties();
|
||||
}
|
||||
|
||||
public CloudSetting getCloudSetting() {
|
||||
return cloudSetting;
|
||||
}
|
||||
|
||||
public OptionalBoolean getOldHandLight() {
|
||||
return oldHandLight;
|
||||
}
|
||||
|
||||
public OptionalBoolean getDynamicHandLight() {
|
||||
return dynamicHandLight;
|
||||
}
|
||||
|
||||
public OptionalBoolean getOldLighting() {
|
||||
return oldLighting;
|
||||
}
|
||||
|
||||
public OptionalBoolean getShadowTerrain() {
|
||||
return shadowTerrain;
|
||||
}
|
||||
|
||||
public OptionalBoolean getShadowTranslucent() {
|
||||
return shadowTranslucent;
|
||||
}
|
||||
|
||||
public OptionalBoolean getShadowEntities() {
|
||||
return shadowEntities;
|
||||
}
|
||||
|
||||
public OptionalBoolean getShadowPlayer() {
|
||||
return shadowPlayer;
|
||||
}
|
||||
|
||||
public OptionalBoolean getShadowBlockEntities() {
|
||||
return shadowBlockEntities;
|
||||
}
|
||||
|
||||
public OptionalBoolean getUnderwaterOverlay() {
|
||||
return underwaterOverlay;
|
||||
}
|
||||
|
||||
public OptionalBoolean getSun() {
|
||||
return sun;
|
||||
}
|
||||
|
||||
public OptionalBoolean getMoon() {
|
||||
return moon;
|
||||
}
|
||||
|
||||
public OptionalBoolean getVignette() {
|
||||
return vignette;
|
||||
}
|
||||
|
||||
public OptionalBoolean getBackFaceSolid() {
|
||||
return backFaceSolid;
|
||||
}
|
||||
|
||||
public OptionalBoolean getBackFaceCutout() {
|
||||
return backFaceCutout;
|
||||
}
|
||||
|
||||
public OptionalBoolean getBackFaceCutoutMipped() {
|
||||
return backFaceCutoutMipped;
|
||||
}
|
||||
|
||||
public OptionalBoolean getBackFaceTranslucent() {
|
||||
return backFaceTranslucent;
|
||||
}
|
||||
|
||||
public OptionalBoolean getRainDepth() {
|
||||
return rainDepth;
|
||||
}
|
||||
|
||||
public OptionalBoolean getBeaconBeamDepth() {
|
||||
return beaconBeamDepth;
|
||||
}
|
||||
|
||||
public OptionalBoolean getSeparateAo() {
|
||||
return separateAo;
|
||||
}
|
||||
|
||||
public OptionalBoolean getFrustumCulling() {
|
||||
return frustumCulling;
|
||||
}
|
||||
|
||||
public OptionalBoolean getShadowCulling() {
|
||||
return shadowCulling;
|
||||
}
|
||||
|
||||
public OptionalBoolean getShadowEnabled() {
|
||||
return shadowEnabled;
|
||||
}
|
||||
|
||||
public OptionalBoolean getParticlesBeforeDeferred() {
|
||||
return particlesBeforeDeferred;
|
||||
}
|
||||
|
||||
public OptionalBoolean getConcurrentCompute() {
|
||||
return concurrentCompute;
|
||||
}
|
||||
|
||||
public OptionalBoolean getPrepareBeforeShadow() {
|
||||
return prepareBeforeShadow;
|
||||
}
|
||||
|
||||
public Object2ObjectMap<String, AlphaTestOverride> getAlphaTestOverrides() {
|
||||
return alphaTestOverrides;
|
||||
}
|
||||
|
||||
public Object2FloatMap<String> getViewportScaleOverrides() {
|
||||
return viewportScaleOverrides;
|
||||
}
|
||||
|
||||
public Object2ObjectMap<String, TextureScaleOverride> getTextureScaleOverrides() {
|
||||
return textureScaleOverrides;
|
||||
}
|
||||
|
||||
public Object2ObjectMap<String, BlendModeOverride> getBlendModeOverrides() {
|
||||
return blendModeOverrides;
|
||||
}
|
||||
|
||||
public Object2ObjectMap<String, ArrayList<BufferBlendInformation>> getBufferBlendOverrides() {
|
||||
return bufferBlendOverrides;
|
||||
}
|
||||
|
||||
public EnumMap<TextureStage, Object2ObjectMap<String, String>> getCustomTextures() {
|
||||
return customTextures;
|
||||
}
|
||||
|
||||
public Optional<String> getNoiseTexturePath() {
|
||||
return Optional.ofNullable(noiseTexturePath);
|
||||
}
|
||||
|
||||
public Object2ObjectMap<String, String> getConditionallyEnabledPrograms() {
|
||||
return conditionallyEnabledPrograms;
|
||||
}
|
||||
|
||||
public List<String> getSliderOptions() {
|
||||
return sliderOptions;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getProfiles() {
|
||||
return profiles;
|
||||
}
|
||||
|
||||
public Optional<List<String>> getMainScreenOptions() {
|
||||
return Optional.ofNullable(mainScreenOptions);
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getSubScreenOptions() {
|
||||
return subScreenOptions;
|
||||
}
|
||||
|
||||
public Optional<Integer> getMainScreenColumnCount() {
|
||||
return Optional.ofNullable(mainScreenColumnCount);
|
||||
}
|
||||
|
||||
public Map<String, Integer> getSubScreenColumnCount() {
|
||||
return subScreenColumnCount;
|
||||
}
|
||||
|
||||
public Object2ObjectMap<String, Object2BooleanMap<String>> getExplicitFlips() {
|
||||
return explicitFlips;
|
||||
}
|
||||
|
||||
public List<String> getRequiredFeatureFlags() {
|
||||
return requiredFeatureFlags;
|
||||
}
|
||||
|
||||
public List<String> getOptionalFeatureFlags() {
|
||||
return optionalFeatureFlags;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user