mirror of
https://github.com/GTNewHorizons/Angelica.git
synced 2026-11-18 19:39:09 +00:00
Compare commits
55
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55c1786811 | ||
|
|
356d826387 | ||
|
|
c34d8548a5 | ||
|
|
81a000af75 | ||
|
|
711c23c722 | ||
|
|
5aa1d504b0 | ||
|
|
60ab3b7900 | ||
|
|
912e0e83b8 | ||
|
|
104eda0b51 | ||
|
|
7fb8cde66d | ||
|
|
0e4421f2ce | ||
|
|
3cf3d096fd | ||
|
|
ffa1193dd2 | ||
|
|
d180023469 | ||
|
|
762275a6da | ||
|
|
0e66bcf42f | ||
|
|
979ad344a1 | ||
|
|
5f328e9b57 | ||
|
|
2dba62bf20 | ||
|
|
0fd4d457e2 | ||
|
|
b56e803622 | ||
|
|
3ab965ded7 | ||
|
|
538b38898c | ||
|
|
e43cd6f18e | ||
|
|
38285087c9 | ||
|
|
deb6c2b6e5 | ||
|
|
e11985a913 | ||
|
|
4bbf39eb4d | ||
|
|
8c90f79c17 | ||
|
|
e4e657846d | ||
|
|
2dace708b4 | ||
|
|
1df1ec3530 | ||
|
|
d96ac28043 | ||
|
|
72c13cff67 | ||
|
|
f233ba65e3 | ||
|
|
c0d636d4f7 | ||
|
|
bd5cd350c3 | ||
|
|
88936d3713 | ||
|
|
cf5bf2e2e7 | ||
|
|
cfd2388c85 | ||
|
|
fd78f63f12 | ||
|
|
6cf119dfee | ||
|
|
8c5f4d2543 | ||
|
|
9e1fa7b80f | ||
|
|
6c99872459 | ||
|
|
f0809410ee | ||
|
|
98299b69d2 | ||
|
|
fed0aa77c5 | ||
|
|
f7fb3186c8 | ||
|
|
ab243bb936 | ||
|
|
60cce7ea1d | ||
|
|
b837b0571d | ||
|
|
7abc6213f5 | ||
|
|
b46643ae8c | ||
|
|
e3d1fedd48 |
No files matched your search
@@ -18,6 +18,14 @@ body:
|
||||
placeholder: "Example: 1.0.0-alpha1"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: report
|
||||
attributes:
|
||||
label: Bug Report
|
||||
description: "Relevant information, as well as relevant logs attached such as `logs/fml-client-latest.log."
|
||||
placeholder: "Example: https://mclo.gs/ OR submit the file to github by dragging it to this textbox."
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: java
|
||||
attributes:
|
||||
@@ -48,12 +56,25 @@ body:
|
||||
- Mesa/Software
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: report
|
||||
- type: dropdown
|
||||
id: shaders
|
||||
attributes:
|
||||
label: Bug Report
|
||||
description: "Relevant information, as well as relevant logs attached such as `logs/fml-client-latest.log."
|
||||
placeholder: "Example: https://mclo.gs/ OR submit the file to github by dragging it to this textbox."
|
||||
label: Shaders
|
||||
description: Do you have a shaderpack enabled?
|
||||
options:
|
||||
- "No"
|
||||
- "Yes: Please put relevant information about shaderpack in the report(what shaderpack, any special settings of note, etc)"
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: mcpf
|
||||
attributes:
|
||||
label: MCPF or other features disabled by default
|
||||
description: Do you have MCPF or any other features that are disabled by default enabled?
|
||||
options:
|
||||
- "No: Go ahead and create an issue"
|
||||
- "Yes: I will not create an issue"
|
||||
- "Yes: I don't read and shouldn't be creating an issue"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
@@ -76,6 +97,5 @@ body:
|
||||
required: true
|
||||
- label: "I am running an officially released version. (Or, if I've compiled it myself I plan to fix the issue)"
|
||||
required: true
|
||||
- label: "This issue is not related to a feature that is disabed by default - Shaders, MCPF, etc. [They'll be enabled when they're ready for testing]"
|
||||
required: true
|
||||
|
||||
|
||||
|
||||
@@ -29,5 +29,5 @@ body:
|
||||
required: true
|
||||
- label: "I have read the known incompatibilities and this is not related to one of those."
|
||||
required: true
|
||||
- label: "This issue is not related to a feature that is disabed by default - Shaders, MCPF, etc. [They'll be enabled when they're ready for testing]"
|
||||
required: true
|
||||
- label: "This issue is not related to a feature that is disabed by default - MCPF, etc. [They'll be enabled when they're ready for testing]"
|
||||
required: true
|
||||
@@ -5,8 +5,9 @@
|
||||
* The little Angle [sic] that supports shaders while saving your fps from a certain death -boubou
|
||||
* Is it obtuse, or accute? -Caedis
|
||||
* It's a cute angle -mitchej123
|
||||
* It's the angel that pulls you out of OptiFine's hell -Roadhog360
|
||||
|
||||
## **Beta Quality - Here there be Dragons**
|
||||
## **Beta Quality - Here there be Dragons**
|
||||
* Shaders sneak preview - Please don't report issues yet, but please do submit fixes
|
||||
* Complementary & BSL mostly function, but have some bugs
|
||||
* Sildurs, Seus, and any other shader probably doesn't work
|
||||
@@ -33,10 +34,11 @@
|
||||
* OptiFine [Disabled, won't fix]
|
||||
* FastCraft [Disabled, won't fix]
|
||||
* BetterFPS [Disabled, won't fix]
|
||||
* OptimizationsAndTweaks [Disabled, won't fix]
|
||||
* [Amazing Trophies 1.2.1 and below](https://github.com/GTNewHorizons/Amazing-Trophies/releases) - use 1.2.2+
|
||||
* [LWJGL3ify 1.5.4 and below](https://github.com/GTNewHorizons/lwjgl3ify/releases/) - Use the latest version available, 1.5.7+
|
||||
* [ArchaicFix 0.6.2 and below](https://www.curseforge.com/minecraft/mc-mods/archaicfix/files/all?page=1&pageSize=20) - Use 0.7.0 or above
|
||||
* [Hodgepodge 2.4.3 and below](https://github.com/GTNewHorizons/Hodgepodge/releases) - Use 2.4.4 or above
|
||||
* [Hodgepodge 2.4.3 and below](https://github.com/GTNewHorizons/Hodgepodge/releases) - Use 0.4.5 or above
|
||||
* CodeChicken[Core](https://github.com/GTNewHorizons/CodeChickenCore/releases)/[Lib](https://github.com/GTNewHorizons/CodeChickenLib/releases) <1.2.0 - Threading issues, use 1.3.0+
|
||||
* Neodymium - Untested, but unlikely to be compatible. (Chunk Meshing is definitely incompatible, other features might work depending on config)
|
||||
|
||||
@@ -66,7 +68,7 @@
|
||||
* HUDCaching
|
||||
* Created by [Moulberry](https://github.com/Moulberry/MCHUDCaching), backported from [Patcher](https://github.com/Sk1erLLC/Patcher) mod by Alexdoru under the CC-BY-SA-NC 4.0 license
|
||||
* Angelica
|
||||
* mitchej123, Omni, Makamys, Embeddedt, NanoLive, Caedis, Cardinalstar, Alexdoru, Eigenraven, mist475, Clepto for helping get Angelica up and running!
|
||||
* mitchej123, Omni, Makamys, Embeddedt, NanoLive, Caedis, Cardinalstar, Alexdoru, Eigenraven, mist475, Clepto, kurrycat for helping get Angelica up and running!
|
||||
* IMS, jss2a98aj, || dbp ||, roadhog360 for advice and moral support
|
||||
* Forge 1.12+
|
||||
* Some files have been taken from Minecraft Forge under the LGPL 2.1 license and are marked as such
|
||||
@@ -75,4 +77,8 @@
|
||||
license, see LICENSE in `com.gtnewhorizons.angelica.models`
|
||||
* Dynamic Lights
|
||||
* LambdAurora for [LambDynamicLights](https://github.com/LambdAurora/LambDynamicLights) under the MIT license, and the Forge port anthxnymc for [DynamicLightsReforged](https://github.com/anthxnymc/DynamicLightsReforged), also under the MIT license
|
||||
|
||||
* Embeddedt and Ferri_Arnus for [glsl-transformation-lib](https://github.com/TauMC/glsl-transformation-lib)
|
||||
* Also for work on [Monocle](https://github.com/ferriarnus/Monocle) which was used as a reference for implementing glsl-transformation-lib
|
||||
* Code from both glsl-transformation-lib and Monocle taken under their respective LGPL 3.0 licenses
|
||||
* FalseTweaks
|
||||
* FalsePattern for [FalseTweaks](https://github.com/falsepattern/falsetweaks) - Item Rendering Optimizations taken from FalseTweaks under the LGPL 3.0 license
|
||||
+14
-20
@@ -49,7 +49,7 @@ configurations {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.4.31")
|
||||
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.5.78")
|
||||
|
||||
compileOnly("com.gtnewhorizons.retrofuturabootstrap:RetroFuturaBootstrap:0.4.0") { transitive = false }
|
||||
|
||||
@@ -57,36 +57,33 @@ dependencies {
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.22")
|
||||
|
||||
// Use modern models+textures to inject QuadProviders
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:TX-Loader:1.7.1:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:TX-Loader:1.7.2:dev')
|
||||
|
||||
// Iris Shaders
|
||||
compileOnly('org.jetbrains:annotations:24.0.1')
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.4.2:dev")
|
||||
api("com.github.GTNewHorizons:GTNHLib:0.5.20:dev")
|
||||
shadowImplementation("org.anarres:jcpp:1.4.14") // Apache 2.0
|
||||
implementation("io.github.douira:glsl-transformer:1.0.0")
|
||||
shadowImplementation("io.github.douira:glsl-transformer:1.0.0") { // glsl-transformer Noncommercial License 1.0.0
|
||||
shadowImplementation("org.taumc:glsl-transformation-lib:0.2.0-4.g6b42bca") {
|
||||
exclude module: "antlr4" // we only want to shadow the runtime module
|
||||
}
|
||||
shadowImplementation("org.antlr:antlr4-runtime:4.13.2")
|
||||
compileOnly "org.apache.ant:ant:1.8.2"
|
||||
|
||||
// Because who doesn't want NEI
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.4.9-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:CodeChickenCore:1.2.0:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:NotEnoughItems:2.6.45-GTNH:dev')
|
||||
devOnlyNonPublishable('com.github.GTNewHorizons:CodeChickenCore:1.3.10:dev')
|
||||
|
||||
// Notfine Deps
|
||||
compileOnly("thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev")
|
||||
devOnlyNonPublishable("com.github.GTNewHorizons:Baubles:1.0.4:dev")
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.5.16:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:twilightforest:2.6.35:dev") { transitive = false }
|
||||
compileOnly(rfg.deobf('curse.maven:witchery-69673:2234410'))
|
||||
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.12.0-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Natura:2.6.1:dev")
|
||||
compileOnly("com.github.GTNewHorizons:TinkersConstruct:1.12.14-GTNH:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Natura:2.7.5:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.6.1:dev")
|
||||
compileOnly("com.github.GTNewHorizons:ThaumicHorizons:1.6.4:dev")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.0:dev") { transitive = false }
|
||||
compileOnly(rfg.deobf('maven.modrinth:backhand:1.4.1')) { transitive = false }
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.0:dev") { transitive = false }
|
||||
compileOnly("com.github.GTNewHorizons:Battlegear2:1.4.1:dev") { transitive = false }
|
||||
compileOnly(rfg.deobf('maven.modrinth:backhand:1.4.1')) { transitive = false }
|
||||
|
||||
compileOnly("com.falsepattern:chunkapi-mc1.7.10:0.5.1:api") { transitive = false }
|
||||
@@ -97,15 +94,13 @@ dependencies {
|
||||
|
||||
compileOnly("curse.maven:minefactory-reloaded-66672:2277486")
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds:2.0.3:dev") // Mixin Version
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds:2.1.6:dev") // Mixin Version
|
||||
compileOnly("com.github.GTNewHorizons:NotEnoughIds-Legacy:1.4.7:dev") // ASM Version
|
||||
|
||||
compileOnly(rfg.deobf("curse.maven:campfirebackport-387444:4611675"))
|
||||
// HMMMMM
|
||||
compileOnly(rfg.deobf("curse.maven:journeymap-32274:2367915"))
|
||||
compileOnly(rfg.deobf("curse.maven:xaeros-minimap-263420:5060684"))
|
||||
|
||||
compileOnly("com.github.GTNewHorizons:HoloInventory:2.4.4-GTNH:dev")
|
||||
compileOnly("com.github.GTNewHorizons:HoloInventory:2.4.13-GTNH:dev")
|
||||
|
||||
runtimeOnlyNonPublishable(rfg.deobf("CoreTweaks:CoreTweaks:0.3.3.2"))
|
||||
|
||||
@@ -115,7 +110,6 @@ dependencies {
|
||||
// Better Crashes
|
||||
compileOnly("com.github.GTNewHorizons:BetterCrashes:1.4.0-GTNH:dev")
|
||||
|
||||
|
||||
// Tests
|
||||
testImplementation(platform('org.junit:junit-bom:5.9.2'))
|
||||
testImplementation('org.junit.jupiter:junit-jupiter')
|
||||
|
||||
+7
-1
@@ -122,9 +122,15 @@ minimizeShadowedDependencies = true
|
||||
# If disabled, won't rename the shadowed classes.
|
||||
relocateShadowedDependencies = true
|
||||
|
||||
# Adds the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
|
||||
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
|
||||
includeWellKnownRepositories = true
|
||||
|
||||
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
|
||||
# list of strings, with the acceptable keys being(case does not matter):
|
||||
# cursemaven
|
||||
# modrinth
|
||||
excludeWellKnownRepositories =
|
||||
|
||||
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
|
||||
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
|
||||
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -84,7 +86,8 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
Vendored
+2
@@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
|
||||
@@ -25,5 +25,12 @@ repositories {
|
||||
includeGroup('CoreTweaks')
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = 'taumc'
|
||||
url = 'https://maven.taumc.org/releases'
|
||||
content {
|
||||
includeGroup 'org.taumc'
|
||||
}
|
||||
}
|
||||
mavenLocal()
|
||||
}
|
||||
+1
-1
@@ -16,5 +16,5 @@ pluginManagement {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.26'
|
||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.29'
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.gtnewhorizons.angelica;
|
||||
|
||||
import com.gtnewhorizons.angelica.common.BlockError;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.proxy.CommonProxy;
|
||||
import com.gtnewhorizons.angelica.utils.AnimationMode;
|
||||
@@ -27,10 +28,13 @@ public class AngelicaMod {
|
||||
|
||||
public static final ManagedEnum<AnimationMode> animationsMode = new ManagedEnum<>(AnimationMode.VISIBLE_ONLY);
|
||||
|
||||
public static BlockError blockError;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
ModStatus.preInit();
|
||||
proxy.preInit(event);
|
||||
blockError = new BlockError();
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
|
||||
@@ -357,7 +357,7 @@ public class BatchingFontRenderer {
|
||||
final float underlineY = anchorY + underlying.FONT_HEIGHT - 1.0f;
|
||||
float underlineStartX = 0.0f;
|
||||
float underlineEndX = 0.0f;
|
||||
final float strikethroughY = anchorY + (float) (underlying.FONT_HEIGHT / 2);
|
||||
final float strikethroughY = anchorY + (float) (underlying.FONT_HEIGHT / 2) - 1.0F;
|
||||
float strikethroughStartX = 0.0f;
|
||||
float strikethroughEndX = 0.0f;
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.gtnewhorizons.angelica.common;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
/**
|
||||
* This Block is not actually getting registered. A static instance is created in AngelicaMod.
|
||||
* Actually registering the block on the client but not the server can cause block IDs to
|
||||
* different between client/server, which is not good.
|
||||
|
||||
* We're essentially injecting the block's texture, so that we may use this block as if it were
|
||||
* any normal block for rendering purposes with RenderBlocks and such, but not have to actually
|
||||
* register it as a block.
|
||||
*/
|
||||
|
||||
public class BlockError extends Block {
|
||||
|
||||
public static final IIcon[] icons = new IIcon[2];
|
||||
|
||||
public BlockError() {
|
||||
super(Material.rock);
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void onTextureStitch(TextureStitchEvent.Pre event) {
|
||||
if (event.map.getTextureType() == 0) {
|
||||
for (int i = 0; i < icons.length; i++) {
|
||||
icons[i] = event.map.registerIcon("angelica:error_block_" + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return meta >= 0 && meta < icons.length ? icons[meta] : null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.gtnewhorizons.angelica.helpers.LoadControllerHelper;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.versioning.ArtifactVersion;
|
||||
import cpw.mods.fml.common.versioning.DefaultArtifactVersion;
|
||||
import mods.battlegear2.Battlegear;
|
||||
import net.dries007.holoInventory.HoloInventory;
|
||||
import xonin.backhand.Backhand;
|
||||
|
||||
@@ -52,6 +53,14 @@ public class ModStatus {
|
||||
) <= 0;
|
||||
}
|
||||
|
||||
// remove compat with original release of BG2
|
||||
if (isBattlegearLoaded){
|
||||
isBattlegearLoaded = new DefaultArtifactVersion("1.2.0")
|
||||
.compareTo(
|
||||
LoadControllerHelper.getOwningMod(Battlegear.class).getProcessedVersion()
|
||||
) <= 0;
|
||||
}
|
||||
|
||||
if (isBackhandLoaded){
|
||||
isBackhandLoaded = new DefaultArtifactVersion("1.4.1")
|
||||
.compareTo(
|
||||
|
||||
@@ -33,7 +33,7 @@ public class AngelicaConfig {
|
||||
public static boolean enableTestBlocks;
|
||||
|
||||
@Config.Comment("Enable Iris Shaders [Requires Sodium]")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableIris;
|
||||
|
||||
@@ -107,28 +107,45 @@ public class AngelicaConfig {
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean optimizeTextureLoading;
|
||||
|
||||
@Config.Comment("Fix thread-safety in lotrs rendering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixLotrSodiumCompat;
|
||||
|
||||
@Config.Comment("Fix thread-safety in Extra Utilities rendering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixExtraUtilsSodiumCompat;
|
||||
|
||||
@Config.Comment("Fix thread-safety issues in MineFactory Reloaded")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixMineFactoryReloadedSodiumCompat;
|
||||
|
||||
@Config.Comment("Fix RenderBlockFluid reading the block type from the world access multiple times")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixFluidRendererCheckingBlockAgain;
|
||||
|
||||
@Config.Comment("Dynamically modifies the render distance of dropped items entities to preserve performance."
|
||||
+ " It starts reducing the render distance when exceeding the threshold set below.")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean dynamicItemRenderDistance;
|
||||
|
||||
@Config.Comment("Max amount of dropped item rendered")
|
||||
@Config.DefaultInt(256)
|
||||
@Config.RangeInt(min = 32, max = 2048)
|
||||
public static int droppedItemLimit;
|
||||
|
||||
@Config.Comment("Use total world time instead of normal world time. Allows most shader animations to play when "
|
||||
+ "doDaylightCycle is off, but causes shader animations to desync from time of day.")
|
||||
@Config.DefaultBoolean(false)
|
||||
public static boolean useTotalWorldTime;
|
||||
|
||||
@Config.Comment("Enable Debug Logging")
|
||||
@Config.DefaultBoolean(false)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableDebugLogging;
|
||||
|
||||
@Config.Comment("Enable Zoom")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean enableZoom;
|
||||
|
||||
@Config.Comment("Optimizes in-world item rendering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean optimizeInWorldItemRendering;
|
||||
|
||||
@Config.Comment("Max amount of display lists to cache for optimized item rendering. Higher number will use more VRAM")
|
||||
@Config.DefaultInt(256)
|
||||
@Config.RangeInt(min = 64, max = 1024)
|
||||
public static int itemRendererDisplayListCacheSize;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gtnewhorizons.angelica.config;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.Config;
|
||||
|
||||
@Config(modid = "angelica", filename = "angelica-compat")
|
||||
public class CompatConfig {
|
||||
|
||||
@Config.Comment("Apply fixes to the LOTR mod")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixLotr;
|
||||
|
||||
@Config.Comment("Apply fixes to Extra Utilities")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixExtraUtils;
|
||||
|
||||
@Config.Comment("Apply fixes to Stacks on Stacks")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixStacksOnStacks;
|
||||
|
||||
@Config.Comment("Apply fixes to Minefactory Reloaded")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixMinefactoryReloaded;
|
||||
|
||||
@Config.Comment("Apply fixes to Thaumcraft")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixThaumcraft;
|
||||
|
||||
@Config.Comment("Apply fixes to ThaumicHorizons")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixThaumicHorizons;
|
||||
|
||||
@Config.Comment("Apply fixes to Immersive Engineering")
|
||||
@Config.DefaultBoolean(true)
|
||||
@Config.RequiresMcRestart
|
||||
public static boolean fixImmersiveEngineering;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.gtnewhorizons.angelica.debug;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraftforge.client.event.RenderGameOverlayEvent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class F3Direction {
|
||||
public static void renderWorldDirectionsEvent(Minecraft mc, RenderGameOverlayEvent.Pre event) {
|
||||
if (mc.gameSettings.showDebugInfo && mc.gameSettings.thirdPersonView == 0) {
|
||||
ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
int width = scaledresolution.getScaledWidth();
|
||||
int height = scaledresolution.getScaledHeight();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
|
||||
GL11.glTranslatef((float) (width / 2), (float) (height / 2), -90);
|
||||
|
||||
Entity entity = mc.renderViewEntity;
|
||||
GL11.glRotatef(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * event.partialTicks, -1.0F, 0.0F, 0.0F);
|
||||
GL11.glRotatef(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * event.partialTicks, 0.0F, 1.0F, 0.0F);
|
||||
|
||||
GL11.glScalef(-1.0F, -1.0F, -1.0F);
|
||||
|
||||
renderWorldDirections();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
public static void renderWorldDirections() {
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
GL11.glDepthMask(false);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
GL11.glLineWidth(2.0F);
|
||||
tessellator.startDrawing(GL11.GL_LINES);
|
||||
|
||||
//X
|
||||
tessellator.setColorRGBA_F(255, 0, 0, 1);
|
||||
tessellator.addVertex(0.0D, 0.0D, 0.0D);
|
||||
tessellator.addVertex(10, 0.0D, 0.0D);
|
||||
|
||||
//Z
|
||||
tessellator.setColorRGBA_F(0, 0, 255, 1);
|
||||
tessellator.addVertex(0.0D, 0.0D, 0.0D);
|
||||
tessellator.addVertex(0.0D, 0.0D, 10);
|
||||
|
||||
//Y
|
||||
tessellator.setColorRGBA_F(0, 255, 0, 1);
|
||||
tessellator.addVertex(0.0D, 0.0D, 0.0D);
|
||||
tessellator.addVertex(0.0D, 10, 0.0D);
|
||||
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glLineWidth(1.0F);
|
||||
GL11.glDepthMask(true);
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
package com.gtnewhorizons.angelica.debug;
|
||||
|
||||
import static org.lwjgl.opengl.GL11.GL_ALPHA_TEST;
|
||||
import static org.lwjgl.opengl.GL11.GL_BLEND;
|
||||
import static org.lwjgl.opengl.GL11.GL_CULL_FACE;
|
||||
import static org.lwjgl.opengl.GL11.GL_DEPTH_TEST;
|
||||
import static org.lwjgl.opengl.GL11.GL_FLOAT;
|
||||
import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA;
|
||||
import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA;
|
||||
import static org.lwjgl.opengl.GL11.GL_TEXTURE_2D;
|
||||
import static org.lwjgl.opengl.GL11.GL_TRIANGLE_STRIP;
|
||||
import static org.lwjgl.opengl.GL11.GL_VERTEX_ARRAY;
|
||||
import static org.lwjgl.opengl.GL11.glBlendFunc;
|
||||
import static org.lwjgl.opengl.GL11.glColor4f;
|
||||
import static org.lwjgl.opengl.GL11.glDisable;
|
||||
import static org.lwjgl.opengl.GL11.glDisableClientState;
|
||||
import static org.lwjgl.opengl.GL11.glDrawArrays;
|
||||
import static org.lwjgl.opengl.GL11.glEnable;
|
||||
import static org.lwjgl.opengl.GL11.glEnableClientState;
|
||||
import static org.lwjgl.opengl.GL15.GL_ARRAY_BUFFER;
|
||||
import static org.lwjgl.opengl.GL15.GL_STATIC_DRAW;
|
||||
import static org.lwjgl.opengl.GL15.glBindBuffer;
|
||||
import static org.lwjgl.opengl.GL15.glBufferData;
|
||||
import static org.lwjgl.opengl.GL15.glGenBuffers;
|
||||
import static org.lwjgl.opengl.GL20.glDisableVertexAttribArray;
|
||||
import static org.lwjgl.opengl.GL20.glEnableVertexAttribArray;
|
||||
import static org.lwjgl.opengl.GL20.glUniform1;
|
||||
import static org.lwjgl.opengl.GL20.glUniform1f;
|
||||
import static org.lwjgl.opengl.GL20.glUniform1i;
|
||||
import static org.lwjgl.opengl.GL20.glVertexAttribPointer;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.shader.ShaderProgram;
|
||||
import java.nio.FloatBuffer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import org.lwjgl.BufferUtils;
|
||||
|
||||
public abstract class F3Graph {
|
||||
private static final int NUM_SAMPLES = 240;
|
||||
// Two floats (x,y)
|
||||
private static final int VERT_FLOATS = 2;
|
||||
private static final int VERT_COUNT = 4;
|
||||
private static final int BORDER = 1;
|
||||
private static final int HEIGHT = 60;
|
||||
private static final int WIDTH = NUM_SAMPLES;
|
||||
private static final int FONT_COLOR = 0xFFE0E0E0;
|
||||
// Due to GLSL 120 limitations, it's just easier to use floats
|
||||
private final FloatBuffer sampleBuf = BufferUtils.createFloatBuffer(NUM_SAMPLES);
|
||||
private final long[] samples = new long[NUM_SAMPLES]; // CPU-side copy for reads
|
||||
// Circular buffer holding the last 240 samples, in nanoseconds
|
||||
private int samplesHead = 0; // one ahead of the position of the last sample
|
||||
private boolean initialized = false;
|
||||
private ShaderProgram shader;
|
||||
private int aPos;
|
||||
private int uFBWidth;
|
||||
private int uFBHeight;
|
||||
private int uScaleFactor;
|
||||
private int uHeadIdx;
|
||||
private int uSamples;
|
||||
private int vertBuf;
|
||||
private final ResourceLocation texture;
|
||||
private final float pxPerNs;
|
||||
private final boolean left;
|
||||
private long sum;
|
||||
|
||||
protected F3Graph(ResourceLocation texture, float pxPerNs, boolean left) {
|
||||
this.texture = texture;
|
||||
this.pxPerNs = pxPerNs;
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
public void putSample(long time) {
|
||||
// Manage running trackers
|
||||
sum -= samples[samplesHead];
|
||||
sum += time;
|
||||
samples[samplesHead] = time;
|
||||
|
||||
sampleBuf.put(samplesHead, (float) time);
|
||||
samplesHead = (samplesHead + 1) % NUM_SAMPLES;
|
||||
}
|
||||
|
||||
private int getVertX(ScaledResolution sres, int idx) {
|
||||
if (left) {
|
||||
return switch (idx) {
|
||||
case 0, 3 -> WIDTH + BORDER * 2;
|
||||
case 1, 2 -> 0;
|
||||
default -> throw new RuntimeException("Tried to get out-of-bounds vertex for graph!");
|
||||
};
|
||||
}
|
||||
|
||||
final int displayWidth = sres.getScaledWidth();
|
||||
return switch (idx) {
|
||||
case 0, 3 -> displayWidth;
|
||||
case 1, 2 -> displayWidth - WIDTH - BORDER * 2;
|
||||
default -> throw new RuntimeException("Tried to get out-of-bounds vertex for graph!");
|
||||
};
|
||||
}
|
||||
|
||||
private int getVertY(ScaledResolution sres, int idx) {
|
||||
final int displayHeight = sres.getScaledHeight();
|
||||
return switch (idx) {
|
||||
case 0, 1 -> displayHeight - HEIGHT - BORDER * 2;
|
||||
case 2, 3 -> displayHeight;
|
||||
default -> throw new RuntimeException("Tried to get out-of-bounds vertex for graph!");
|
||||
};
|
||||
}
|
||||
|
||||
private void init() {
|
||||
shader = new ShaderProgram(
|
||||
"angelica",
|
||||
"shaders/debug_graph.vert.glsl",
|
||||
"shaders/debug_graph.frag.glsl");
|
||||
shader.use();
|
||||
|
||||
// Register attributes
|
||||
aPos = shader.getAttribLocation("pos");
|
||||
|
||||
// Register uniforms
|
||||
uFBWidth = shader.getUniformLocation("fbWidth");
|
||||
uFBHeight = shader.getUniformLocation("fbHeight");
|
||||
uScaleFactor = shader.getUniformLocation("scaleFactor");
|
||||
uSamples = shader.getUniformLocation("samples");
|
||||
uHeadIdx = shader.getUniformLocation("headIdx");
|
||||
final int uPxPerNs = shader.getUniformLocation("pxPerNs");
|
||||
final int uLeft = shader.getUniformLocation("left");
|
||||
|
||||
// Load vertex buffer
|
||||
vertBuf = glGenBuffers();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertBuf);
|
||||
final FloatBuffer vertices = BufferUtils.createFloatBuffer(VERT_COUNT * VERT_FLOATS);
|
||||
// Since we use a triangle strip, we only need 4 vertices. The quad extends to the top of the screen so spikes
|
||||
// don't get truncated. The max height is replaced in the vert shader, no need to be precise.
|
||||
vertices.put(new float[]{
|
||||
BORDER, BORDER,
|
||||
WIDTH + BORDER, BORDER,
|
||||
BORDER, Float.MAX_VALUE,
|
||||
WIDTH + BORDER, Float.MAX_VALUE
|
||||
});
|
||||
vertices.rewind();
|
||||
|
||||
glBufferData(GL_ARRAY_BUFFER, vertices, GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
final ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
|
||||
// Load initial value for uniforms
|
||||
glUniform1f(uFBWidth, mc.displayWidth);
|
||||
glUniform1f(uFBHeight, mc.displayHeight);
|
||||
glUniform1f(uScaleFactor, sr.getScaleFactor());
|
||||
glUniform1i(uHeadIdx, samplesHead);
|
||||
glUniform1(uSamples, sampleBuf);
|
||||
glUniform1f(uPxPerNs, pxPerNs);
|
||||
glUniform1i(uLeft, left ? 1 : 0); // this is how you load bool uniforms
|
||||
|
||||
ShaderProgram.clear();
|
||||
}
|
||||
|
||||
public void render() {
|
||||
if (!initialized) {
|
||||
init();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* We try to copy modern vanilla's tracker.
|
||||
* It is 240 (FRAME_TIMES) wide by 60 tall, including the 1px borders.
|
||||
* We instead make it 242x62 including borders to prevent the borders from overlapping the samples.
|
||||
* The background is ARGB 90505050, the borders FFFFFFFF, and the text FFE0E0E0.
|
||||
* First the background is rendered, then the samples, then the foreground texture and the text.
|
||||
* The background is drawn via a 242x62 translucent rect.
|
||||
* Next, the samples are rendered by a shader on a transparent 240x60 rect.
|
||||
* Finally, the foreground texture and the text is rendered on top.
|
||||
* The shader pipeline is only needed for the sample draw.
|
||||
*/
|
||||
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
final ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
|
||||
// Setup GL state
|
||||
final Tessellator tess = Tessellator.instance;
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
// Draw background
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
glColor4f(0x50 / 255.0F, 0x50 / 255.0F, 0x50 / 255.0F, 0x90 / 255.0F);
|
||||
tess.startDrawingQuads();
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
tess.addVertex(getVertX(sr, i), getVertY(sr, i), 0);
|
||||
}
|
||||
tess.draw();
|
||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
|
||||
// Draw samples
|
||||
shader.use();
|
||||
|
||||
// Load uniforms
|
||||
glUniform1f(uFBWidth, mc.displayWidth);
|
||||
glUniform1f(uFBHeight, mc.displayHeight);
|
||||
glUniform1f(uScaleFactor, sr.getScaleFactor());
|
||||
glUniform1i(uHeadIdx, samplesHead);
|
||||
glUniform1(uSamples, sampleBuf);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertBuf);
|
||||
glEnableVertexAttribArray(aPos);
|
||||
glVertexAttribPointer(aPos, VERT_FLOATS, GL_FLOAT, false, VERT_FLOATS * 4, 0);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
// Left side graphs are inverted, so temporarily disable culling
|
||||
if (!left) glDisable(GL_CULL_FACE);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, VERT_COUNT);
|
||||
|
||||
if (!left) glEnable(GL_CULL_FACE);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableVertexAttribArray(aPos);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
ShaderProgram.clear();
|
||||
|
||||
// Draw foreground
|
||||
|
||||
mc.getTextureManager().bindTexture(texture);
|
||||
tess.startDrawingQuads();
|
||||
tess.addVertexWithUV(getVertX(sr, 0), getVertY(sr, 0), 0.0D, 1, 0);
|
||||
tess.addVertexWithUV(getVertX(sr, 1), getVertY(sr, 1), 0.0D, 0, 0);
|
||||
tess.addVertexWithUV(getVertX(sr, 2), getVertY(sr, 2), 0.0D, 0, 1);
|
||||
tess.addVertexWithUV(getVertX(sr, 3), getVertY(sr, 3), 0.0D, 1, 1);
|
||||
tess.draw();
|
||||
|
||||
// Reset GL state
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
|
||||
// Draw text
|
||||
// Ensure running counters are reset on first sample
|
||||
long min = Long.MAX_VALUE;
|
||||
long max = Long.MIN_VALUE;
|
||||
for (int i = 0; i < NUM_SAMPLES; ++i) {
|
||||
min = Math.min(min, samples[i]);
|
||||
max = Math.max(max, samples[i]);
|
||||
}
|
||||
String minStr = String.format("%.1f ms min", min / 1_000_000D);
|
||||
String avgStr = String.format("%.1f ms avg", sum / 1_000_000 / (double) NUM_SAMPLES);
|
||||
String maxStr = String.format("%.1f ms max", max / 1_000_000D);
|
||||
final FontRenderer fr = mc.fontRenderer;
|
||||
final int top = sr.getScaledHeight() - HEIGHT - BORDER * 2 - fr.FONT_HEIGHT;
|
||||
final int scaledWidth = sr.getScaledWidth();
|
||||
|
||||
if (left) {
|
||||
fr.drawString(minStr, BORDER * 2, top, FONT_COLOR, true);
|
||||
fr.drawString(avgStr, BORDER + WIDTH / 2 - fr.getStringWidth(avgStr) / 2, top, FONT_COLOR, true);
|
||||
fr.drawString(maxStr, BORDER * 2 + WIDTH - fr.getStringWidth(maxStr), top, FONT_COLOR, true);
|
||||
} else {
|
||||
fr.drawString(minStr, scaledWidth - (BORDER * 2 + WIDTH), top, FONT_COLOR, true);
|
||||
fr.drawString(avgStr, scaledWidth - (BORDER + WIDTH / 2 + fr.getStringWidth(avgStr) / 2), top, FONT_COLOR, true);
|
||||
fr.drawString(maxStr, scaledWidth - (BORDER * 2 + fr.getStringWidth(maxStr)), top, FONT_COLOR, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.gtnewhorizons.angelica.debug;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class FrametimeGraph extends F3Graph {
|
||||
public FrametimeGraph() {
|
||||
// At 1x scale, 30 FPS should be 60 px. 30 FPS = 33_333_333ns per frame, 60px/33_333_333ns = 0.0000018f px/ns
|
||||
super(
|
||||
new ResourceLocation("angelica:textures/frametimes_fg.png"),
|
||||
0.0000018f,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.gtnewhorizons.angelica.debug;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class TPSGraph extends F3Graph {
|
||||
public TPSGraph() {
|
||||
// At 1x scale, 20 TPS should be 60 px. 20 FPS = 50_000_000ns per frame, 60px/50_000_000ns = 0.0000012 px/ns
|
||||
super(
|
||||
new ResourceLocation("angelica:textures/tps_fg.png"),
|
||||
0.0000012f,
|
||||
false
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import java.util.function.Predicate;
|
||||
public class DynamicLights {
|
||||
private static DynamicLights instance;
|
||||
public static DynamicLightsMode Mode = DynamicLightsMode.OFF;
|
||||
public static boolean ShaderForce = false;
|
||||
|
||||
private static final double MAX_RADIUS = 7.75;
|
||||
private static final double MAX_RADIUS_SQUARED = MAX_RADIUS * MAX_RADIUS;
|
||||
@@ -52,7 +53,11 @@ public class DynamicLights {
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
return AngelicaConfig.enableDynamicLights && Mode.isEnabled() && !IrisApi.getInstance().isShaderPackInUse();
|
||||
return AngelicaConfig.enableDynamicLights &&
|
||||
Mode.isEnabled() &&
|
||||
// if shader force is enabled then true
|
||||
// if not, then true when shaders are not in use
|
||||
(ShaderForce || !IrisApi.getInstance().isShaderPackInUse());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +70,7 @@ public class DynamicLights {
|
||||
return;
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
if (now >= this.lastUpdate + 50) {
|
||||
if (now >= this.lastUpdate + Mode.getDelay()) {
|
||||
this.lastUpdate = now;
|
||||
this.lastUpdateCount = 0;
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ public enum DynamicLightsMode
|
||||
OFF("Off", 0),
|
||||
FASTEST("Fastest", 500),
|
||||
FAST("Fast", 250),
|
||||
FANCY("Fancy", 0);
|
||||
FANCY("Fancy", 50),
|
||||
REALTIME("Realtime", 0);
|
||||
|
||||
private final String name;
|
||||
private final int delay;
|
||||
|
||||
@@ -73,13 +73,6 @@ public interface IDynamicLightSource {
|
||||
*/
|
||||
void angelica$dynamicLightTick();
|
||||
|
||||
/**
|
||||
* Returns whether this dynamic light source should update.
|
||||
*
|
||||
* @return {@code true} if this dynamic light source should update, else {@code false}
|
||||
*/
|
||||
boolean angelica$shouldUpdateDynamicLight();
|
||||
|
||||
boolean angelica$updateDynamicLight(@NotNull SodiumWorldRenderer renderer);
|
||||
|
||||
void angelica$scheduleTrackedChunksRebuild(@NotNull SodiumWorldRenderer renderer);
|
||||
|
||||
@@ -971,6 +971,20 @@ public class GLStateManager {
|
||||
GL11.glDrawBuffer(mode);
|
||||
}
|
||||
|
||||
public static void glDrawElements(int mode, IntBuffer indices) {
|
||||
if(AngelicaConfig.enableIris) {
|
||||
Iris.getPipelineManager().getPipeline().ifPresent(WorldRenderingPipeline::syncProgram);
|
||||
}
|
||||
GL11.glDrawElements(mode, indices);
|
||||
}
|
||||
|
||||
public static void glBegin(int mode) {
|
||||
if (AngelicaConfig.enableIris) {
|
||||
Iris.getPipelineManager().getPipeline().ifPresent(WorldRenderingPipeline::syncProgram);
|
||||
}
|
||||
GL11.glBegin(mode);
|
||||
}
|
||||
|
||||
public static void glLogicOp(int opcode) {
|
||||
GL11.glLogicOp(opcode);
|
||||
}
|
||||
|
||||
@@ -19,9 +19,7 @@ import org.lwjgl.opengl.GL30;
|
||||
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.gui.GuiIngame;
|
||||
@@ -29,9 +27,7 @@ import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.client.shader.Framebuffer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraftforge.client.GuiIngameForge;
|
||||
import thaumcraft.common.Thaumcraft;
|
||||
import xaero.common.core.XaeroMinimapCore;
|
||||
@@ -70,31 +66,6 @@ public class HUDCaching {
|
||||
|
||||
private HUDCaching() {}
|
||||
|
||||
/* TODO START REMOVE DEBUG STUFF */
|
||||
|
||||
private final List<Long> updateTimeList = new ArrayList<>(21);
|
||||
private static boolean isEnabled = true;
|
||||
|
||||
// moved initialization to when its registered to avoid an empty Debug category, which can cause crashes when
|
||||
// opening the controls menu and hudcaching is disabled in the config
|
||||
private static KeyBinding toggle;
|
||||
|
||||
public static void registerKeyBindings() {
|
||||
toggle = new KeyBinding("Toggle HUDCaching", 0, "Debug");
|
||||
ClientRegistry.registerKeyBinding(toggle);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeypress(InputEvent.KeyInputEvent event) {
|
||||
if (toggle != null && toggle.isPressed()) {
|
||||
isEnabled = !isEnabled;
|
||||
final String msg = isEnabled ? "Enabled HUDCaching" : "Disabled HUDCaching";
|
||||
if (mc.thePlayer != null) mc.thePlayer.addChatMessage(new ChatComponentText(msg));
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO END REMOVE DEBUG STUFF */
|
||||
|
||||
// highest so it runs before the GLSM load event
|
||||
@SubscribeEvent(priority = EventPriority.HIGH)
|
||||
public void onJoinWorld(WorldEvent.Load event) {
|
||||
@@ -112,7 +83,7 @@ public class HUDCaching {
|
||||
XaeroMinimapCore.beforeIngameGuiRender(partialTicks);
|
||||
}
|
||||
|
||||
if (!OpenGlHelper.isFramebufferEnabled() || !isEnabled || framebuffer == null) {
|
||||
if (!OpenGlHelper.isFramebufferEnabled() || framebuffer == null) {
|
||||
ingame.renderGameOverlay(partialTicks, hasScreen, mouseX, mouseY);
|
||||
return;
|
||||
}
|
||||
@@ -244,13 +215,14 @@ public class HUDCaching {
|
||||
|
||||
// moved to here due to the method being called from a mixin
|
||||
public static void disableHoloInventory() {
|
||||
if (ModStatus.isHoloInventoryLoaded){
|
||||
Renderer.INSTANCE.angelicaOverride = isEnabled;
|
||||
if (ModStatus.isHoloInventoryLoaded) {
|
||||
Renderer.INSTANCE.angelicaOverride = true;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") // called via ASM
|
||||
public static class HUDCachingHooks {
|
||||
public static boolean shouldReturnEarly(){
|
||||
public static boolean shouldReturnEarly() {
|
||||
return renderingCacheOverride;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.gtnewhorizons.angelica.loading;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.gtnewhorizon.gtnhlib.asm.ASMUtil;
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigException;
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
|
||||
import com.gtnewhorizon.gtnhmixins.IEarlyMixinLoader;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.Mixins;
|
||||
import com.gtnewhorizons.angelica.mixins.TargetedMod;
|
||||
import com.gtnewhorizons.angelica.transform.compat.CompatASMTransformers;
|
||||
import com.gtnewhorizons.angelica.transform.compat.GenericCompatTransformer;
|
||||
import com.gtnewhorizons.angelica.transform.compat.handlers.CompatHandler;
|
||||
import com.gtnewhorizons.angelica.transform.compat.handlers.CompatHandlers;
|
||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
||||
import jss.notfine.asm.AsmTransformers;
|
||||
import jss.notfine.asm.mappings.Namer;
|
||||
@@ -21,22 +25,28 @@ import org.spongepowered.asm.launch.GlobalProperties;
|
||||
import org.spongepowered.asm.service.mojang.MixinServiceLaunchWrapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
// ================== Important ==================
|
||||
// Due to a bug caused by this class both implementing
|
||||
// IFMLLoadingPlugin and IEarlyMixinLoader,
|
||||
// the IClassTransformer registered in this class
|
||||
// will not respect the sorting index defined.
|
||||
// They will instead use default index 0 which means they will see
|
||||
// obfuscated mappings and not SRG mappings when running outside of dev env.
|
||||
// ===============================================
|
||||
//@IFMLLoadingPlugin.SortingIndex(Integer.MAX_VALUE - 5)
|
||||
@IFMLLoadingPlugin.MCVersion("1.7.10")
|
||||
@IFMLLoadingPlugin.TransformerExclusions(
|
||||
{
|
||||
@IFMLLoadingPlugin.TransformerExclusions({
|
||||
"com.gtnewhorizons.angelica.transform.RedirectorTransformer",
|
||||
"com.gtnewhorizons.angelica.glsm.GLStateManager"
|
||||
}
|
||||
)
|
||||
@IFMLLoadingPlugin.SortingIndex(Integer.MAX_VALUE - 5)
|
||||
"com.gtnewhorizons.angelica.glsm.GLStateManager"})
|
||||
public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
|
||||
private static final boolean DUMP_CLASSES = Boolean.parseBoolean(System.getProperty("angelica.dumpClass", "false"));
|
||||
private static boolean OBF_ENV;
|
||||
public static final Logger LOGGER = LogManager.getLogger("Angelica");
|
||||
|
||||
private String[] transformerClasses;
|
||||
@@ -45,6 +55,7 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
try {
|
||||
// Angelica Config
|
||||
ConfigurationManager.registerConfig(AngelicaConfig.class);
|
||||
ConfigurationManager.registerConfig(CompatConfig.class);
|
||||
final LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
|
||||
final Configuration config = ctx.getConfiguration();
|
||||
final LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
|
||||
@@ -68,17 +79,24 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
if (mixinTweakClasses != null) {
|
||||
mixinTweakClasses.add(MixinCompatHackTweaker.class.getName());
|
||||
}
|
||||
|
||||
// Return any others here
|
||||
if (transformerClasses == null) {
|
||||
|
||||
//Mod Compat transformers
|
||||
final List<String> transformers = new ArrayList<>();
|
||||
transformers.addAll(CompatASMTransformers.getTransformers());
|
||||
|
||||
//NotFine transformers
|
||||
Namer.initNames();
|
||||
transformers.addAll(Arrays.asList(AsmTransformers.getTransformers()));
|
||||
// Regsiter compat handlers, and add extra specific transformers, then build and register the generic transformer
|
||||
for (CompatHandler handler : CompatHandlers.getHandlers()) {
|
||||
GenericCompatTransformer.register(handler);
|
||||
if (handler.extraTransformers() != null) {
|
||||
transformers.addAll(handler.extraTransformers());
|
||||
}
|
||||
}
|
||||
|
||||
GenericCompatTransformer.build();
|
||||
transformers.add(GenericCompatTransformer.class.getName());
|
||||
|
||||
// Add NotFine transformers
|
||||
final List<String> notFineTransformers = AsmTransformers.getTransformers();
|
||||
if (!notFineTransformers.isEmpty()) Namer.initNames();
|
||||
transformers.addAll(notFineTransformers);
|
||||
|
||||
transformerClasses = transformers.toArray(new String[0]);
|
||||
}
|
||||
@@ -97,7 +115,7 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
|
||||
@Override
|
||||
public void injectData(Map<String, Object> data) {
|
||||
// no-op
|
||||
OBF_ENV = (boolean) data.get("runtimeDeobfuscationEnabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -115,6 +133,24 @@ public class AngelicaTweaker implements IFMLLoadingPlugin, IEarlyMixinLoader {
|
||||
return Mixins.getEarlyMixins(loadedCoreMods);
|
||||
}
|
||||
|
||||
public static boolean DUMP_CLASSES() {
|
||||
return DUMP_CLASSES || !OBF_ENV;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if we are in an obfuscated environment, returns false in dev environment.
|
||||
*/
|
||||
public static boolean isObfEnv() {
|
||||
return OBF_ENV;
|
||||
}
|
||||
|
||||
public static void dumpClass(String className, byte[] originalBytes, byte[] transformedBytes, Object transformer) {
|
||||
if (AngelicaTweaker.DUMP_CLASSES()) {
|
||||
ASMUtil.saveAsRawClassFile(originalBytes, className + "_PRE", transformer);
|
||||
ASMUtil.saveAsRawClassFile(transformedBytes, className + "_POST", transformer);
|
||||
}
|
||||
}
|
||||
|
||||
private static final ImmutableMap<String, TargetedMod> MODS_BY_CLASS = ImmutableMap.<String, TargetedMod>builder()
|
||||
.put("optifine.OptiFineForgeTweaker", TargetedMod.OPTIFINE)
|
||||
.put("fastcraft.Tweaker", TargetedMod.FASTCRAFT)
|
||||
|
||||
@@ -4,15 +4,24 @@ import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.transform.BlockTransformer;
|
||||
import com.gtnewhorizons.angelica.transform.RedirectorTransformer;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.relauncher.CoreModManager;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.ITweaker;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
import org.spongepowered.asm.launch.platform.MixinContainer;
|
||||
import org.spongepowered.asm.launch.platform.MixinPlatformManager;
|
||||
import org.spongepowered.asm.launch.platform.container.IContainerHandle;
|
||||
import org.spongepowered.asm.mixin.transformer.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
@@ -23,8 +32,8 @@ public class MixinCompatHackTweaker implements ITweaker {
|
||||
verifyDependencies();
|
||||
|
||||
if(DISABLE_OPTIFINE_FASTCRAFT_BETTERFPS) {
|
||||
LOGGER.info("Disabling Optifine, Fastcraft, and BetterFPS (if present)");
|
||||
disableOptifineFastcraftAndBetterFPS();
|
||||
LOGGER.info("Disabling Optifine, Fastcraft, BetterFPS, and other incompatible mods (if present)");
|
||||
disableIncompatibleMods();
|
||||
}
|
||||
|
||||
if (AngelicaConfig.enableHudCaching){
|
||||
@@ -40,8 +49,8 @@ public class MixinCompatHackTweaker implements ITweaker {
|
||||
|
||||
private void disableXaerosMinimapWaypointTransformer(){
|
||||
try {
|
||||
LaunchClassLoader lcl = Launch.classLoader;
|
||||
Field xformersField = lcl.getClass().getDeclaredField("transformers");
|
||||
final LaunchClassLoader lcl = Launch.classLoader;
|
||||
final Field xformersField = lcl.getClass().getDeclaredField("transformers");
|
||||
xformersField.setAccessible(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IClassTransformer> xformers = (List<IClassTransformer>) xformersField.get(lcl);
|
||||
@@ -57,14 +66,14 @@ public class MixinCompatHackTweaker implements ITweaker {
|
||||
}
|
||||
}
|
||||
|
||||
private void disableOptifineFastcraftAndBetterFPS() {
|
||||
// Remove Optifine, Fastcraft, and BetterFPS transformers & Mod Containers
|
||||
@SuppressWarnings("unchecked")
|
||||
private void disableIncompatibleMods() {
|
||||
// Remove transformers, Mod Containers, and mixins for Optifine, Fastcraft, BetterFPS and other incompatible mods
|
||||
try {
|
||||
LaunchClassLoader lcl = Launch.classLoader;
|
||||
Field xformersField = lcl.getClass().getDeclaredField("transformers");
|
||||
final LaunchClassLoader lcl = Launch.classLoader;
|
||||
final Field xformersField = lcl.getClass().getDeclaredField("transformers");
|
||||
xformersField.setAccessible(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<IClassTransformer> xformers = (List<IClassTransformer>) xformersField.get(lcl);
|
||||
final List<IClassTransformer> xformers = (List<IClassTransformer>) xformersField.get(lcl);
|
||||
for (int idx = xformers.size() - 1; idx >= 0; idx--) {
|
||||
final String name = xformers.get(idx).getClass().getName();
|
||||
if (name.startsWith("optifine") || name.startsWith("fastcraft") || name.startsWith("me.guichaguri.betterfps")) {
|
||||
@@ -76,17 +85,72 @@ public class MixinCompatHackTweaker implements ITweaker {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
Field injectedContainersField = Loader.class.getDeclaredField("injectedContainers");
|
||||
final Field injectedContainersField = Loader.class.getDeclaredField("injectedContainers");
|
||||
injectedContainersField.setAccessible(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> containers = (List<String> ) injectedContainersField.get(Loader.class);
|
||||
final List<String> containers = (List<String> ) injectedContainersField.get(Loader.class);
|
||||
for (int idx = containers.size() - 1; idx >= 0; idx--) {
|
||||
final String name = containers.get(idx);
|
||||
final String name = containers.get(idx);
|
||||
if (name.startsWith("optifine") || name.startsWith("fastcraft")) {
|
||||
LOGGER.info("Removing mod container " + name);
|
||||
containers.remove(idx);
|
||||
}
|
||||
}
|
||||
|
||||
final Field reparsedCoremodsField = CoreModManager.class.getDeclaredField("reparsedCoremods");
|
||||
final Field loadedCoremodsField = CoreModManager.class.getDeclaredField("loadedCoremods");
|
||||
reparsedCoremodsField.setAccessible(true);
|
||||
loadedCoremodsField.setAccessible(true);
|
||||
final ArrayList<String> reparsedCoremods = (ArrayList<String>) reparsedCoremodsField.get(CoreModManager.class);
|
||||
final ArrayList<String> loadedCoremods = (ArrayList<String>) loadedCoremodsField.get(CoreModManager.class);
|
||||
for (int idx = reparsedCoremods.size() - 1; idx >= 0; idx--) {
|
||||
final String coreMod = reparsedCoremods.get(idx);
|
||||
if (coreMod.startsWith("optimizationsandtweaks")) {
|
||||
LOGGER.info("Removing reparsed coremod " + coreMod);
|
||||
// Fool the CoreModManager into not checking for a mod container again later
|
||||
loadedCoremods.add(reparsedCoremods.remove(idx));
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
final ArrayList<String> mixinConfigsDefault = (ArrayList<String>) Launch.blackboard.get("mixin.configs.default");
|
||||
if (mixinConfigsDefault != null) {
|
||||
for (int idx = mixinConfigsDefault.size() - 1; idx >= 0; idx--) {
|
||||
final String name = mixinConfigsDefault.get(idx);
|
||||
if (name != null && name.contains("optimizationsandtweaks")) {
|
||||
LOGGER.info("Removing mixin config " + name);
|
||||
mixinConfigsDefault.remove(idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
final Set<Config> mixinConfigs = (Set<Config>) Launch.blackboard.get("mixin.configs.queue");
|
||||
final Set<Config> toRemove = new HashSet<>();
|
||||
if (mixinConfigs != null) {
|
||||
for (Config config : mixinConfigs) {
|
||||
final String name = config.getName();
|
||||
if (name != null && name.contains("optimizationsandtweaks")) {
|
||||
LOGGER.info("Removing queued mixin config " + config.getName());
|
||||
toRemove.add(config);
|
||||
}
|
||||
}
|
||||
mixinConfigs.removeAll(toRemove);
|
||||
}
|
||||
final MixinPlatformManager platformManager = (MixinPlatformManager) Launch.blackboard.get("mixin.platform");
|
||||
if (platformManager != null) {
|
||||
final Field containersField = platformManager.getClass().getDeclaredField("containers");
|
||||
containersField.setAccessible(true);
|
||||
final Map<IContainerHandle, MixinContainer> containers = (Map<IContainerHandle, MixinContainer>) containersField.get(platformManager);
|
||||
for (Map.Entry<IContainerHandle, MixinContainer> entry : containers.entrySet()) {
|
||||
final String attribute = entry.getKey().getAttribute("MixinConfigs");
|
||||
if(attribute != null && attribute.contains("optimizationsandtweaks")) {
|
||||
LOGGER.info("Removing mixin container " + entry.getKey().toString());
|
||||
containers.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gtnewhorizons.angelica.mixins;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
import jss.notfine.config.MCPatcherForgeConfig;
|
||||
@@ -26,9 +27,12 @@ public enum Mixins {
|
||||
.setPhase(Phase.EARLY).addMixinClasses(
|
||||
"angelica.MixinActiveRenderInfo"
|
||||
,"angelica.MixinEntityRenderer"
|
||||
,"angelica.MixinGameSettings"
|
||||
,"angelica.MixinMinecraft"
|
||||
,"angelica.MixinMinecraftServer"
|
||||
,"angelica.optimizations.MixinRendererLivingEntity"
|
||||
,"angelica.MixinFMLClientHandler"
|
||||
,"angelica.bugfixes.MixinRenderGlobal_DestroyBlock"
|
||||
)
|
||||
),
|
||||
ANGELICA_VBO(
|
||||
@@ -69,6 +73,16 @@ public enum Mixins {
|
||||
.setApplyIf(() -> AngelicaConfig.fixFluidRendererCheckingBlockAgain)
|
||||
.addTargetedMod(TargetedMod.VANILLA)),
|
||||
|
||||
ANGELICA_LIMIT_DROPPED_ITEM_ENTITIES(new Builder("Dynamically modifies the render distance of dropped items entities to preserve performance")
|
||||
.setPhase(Phase.EARLY).addMixinClasses("angelica.optimizations.MixinRenderGlobal_ItemRenderDist").setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> AngelicaConfig.dynamicItemRenderDistance)
|
||||
.addTargetedMod(TargetedMod.VANILLA)),
|
||||
|
||||
ANGELICA_ITEM_DISPLAY_LIST_OPTIMIZATION(new Builder("Optimized item rendering by wrapping them with display lists")
|
||||
.setPhase(Phase.EARLY).addMixinClasses("angelica.itemrenderer.MixinItemRenderer").setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> AngelicaConfig.optimizeInWorldItemRendering)
|
||||
.addTargetedMod(TargetedMod.VANILLA)),
|
||||
|
||||
// Not compatible with the lwjgl debug callbacks, so disable if that's enabled
|
||||
ARCHAIC_SPLASH(new Builder("ArchaicFix Splash").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.showSplashMemoryBar && !AngelicaMod.lwjglDebug).addMixinClasses(
|
||||
@@ -100,15 +114,15 @@ public enum Mixins {
|
||||
|
||||
SODIUM(new Builder("Sodium").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableSodium).addMixinClasses(
|
||||
"sodium.MixinChunkProviderClient"
|
||||
,"sodium.MixinBlock"
|
||||
"sodium.MixinBlock"
|
||||
,"sodium.MixinBlockFluidBase"
|
||||
,"sodium.AccessorBiomeColorEvent"
|
||||
,"sodium.MixinBiomeGenBase"
|
||||
,"sodium.MixinChunk"
|
||||
,"sodium.MixinChunkProviderServer"
|
||||
,"sodium.MixinClientRegistry"
|
||||
,"sodium.MixinEntity"
|
||||
,"sodium.MixinEntity_RenderDist"
|
||||
,"sodium.MixinEntityItem_RenderDist"
|
||||
,"sodium.MixinRenderManager"
|
||||
,"sodium.MixinExtendedBlockStorage"
|
||||
,"sodium.MixinEntityRenderer"
|
||||
@@ -131,25 +145,18 @@ public enum Mixins {
|
||||
)
|
||||
),
|
||||
|
||||
// Required for Sodium's FluidRenderer, so it treats vanilla liquids as IFluidBlocks
|
||||
SODIUM_WISHLIST(new Builder("Sodiumer").addTargetedMod(TargetedMod.VANILLA).setSide(Side.BOTH)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableSodiumFluidRendering).addMixinClasses(
|
||||
"sodium.MixinBlockLiquid")),
|
||||
|
||||
IRIS_RENDERING(new Builder("Iris Shaders").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableIris).addMixinClasses(
|
||||
"shaders.MixinEntityRenderer"
|
||||
,"shaders.MixinGuiIngameForge"
|
||||
,"shaders.MixinFramebuffer"
|
||||
,"shaders.MixinItem"
|
||||
,"shaders.MixinItemRenderer"
|
||||
,"shaders.MixinLocale"
|
||||
,"shaders.MixinOpenGlHelper"
|
||||
,"shaders.MixinRender"
|
||||
,"shaders.MixinRenderDragon"
|
||||
,"shaders.MixinRenderEnderman"
|
||||
,"shaders.MixinRendererLivingEntity"
|
||||
,"shaders.MixinRenderGlobal"
|
||||
,"shaders.MixinRenderSpider"
|
||||
,"shaders.MixinTileEntityBeaconRenderer"
|
||||
)
|
||||
),
|
||||
@@ -171,6 +178,14 @@ public enum Mixins {
|
||||
,"angelica.textures.MixinTextureUtil"
|
||||
)),
|
||||
|
||||
ANGELICA_ZOOM(new Builder("Zoom").addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT)
|
||||
.setPhase(Phase.EARLY).setApplyIf(() -> AngelicaConfig.enableZoom)
|
||||
.addMixinClasses(
|
||||
"angelica.zoom.MixinEntityRenderer_Zoom",
|
||||
"angelica.zoom.MixinMinecraft_Zoom",
|
||||
"angelica.zoom.MixinMouseFilter"
|
||||
)),
|
||||
|
||||
HUD_CACHING(new Builder("Renders the HUD elements 20 times per second maximum to improve performance")
|
||||
.addTargetedMod(TargetedMod.VANILLA).setSide(Side.CLIENT).setPhase(Phase.EARLY)
|
||||
.setApplyIf(() -> AngelicaConfig.enableHudCaching).addMixinClasses(
|
||||
@@ -205,7 +220,7 @@ public enum Mixins {
|
||||
|
||||
EXTRA_UTILITIES_THREAD_SAFETY(new Builder("Enable thread safety fixes in Extra Utilities").setPhase(Phase.LATE)
|
||||
.addTargetedMod(TargetedMod.EXTRAUTILS).setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> AngelicaConfig.fixExtraUtilsSodiumCompat)
|
||||
.setApplyIf(() -> CompatConfig.fixExtraUtils)
|
||||
.addMixinClasses(
|
||||
"client.extrautils.MixinRenderBlockConnectedTextures",
|
||||
"client.extrautils.MixinRenderBlockConnectedTexturesEthereal",
|
||||
@@ -213,7 +228,7 @@ public enum Mixins {
|
||||
|
||||
MFR_THREAD_SAFETY(new Builder("Enable thread safety fixes for MineFactory Reloaded").setPhase(Phase.LATE)
|
||||
.addTargetedMod(TargetedMod.MINEFACTORY_RELOADED).setSide(Side.CLIENT)
|
||||
.setApplyIf(() -> AngelicaConfig.fixMineFactoryReloadedSodiumCompat)
|
||||
.setApplyIf(() -> CompatConfig.fixMinefactoryReloaded)
|
||||
.addMixinClasses("client.minefactoryreloaded.MixinRedNetCableRenderer")),
|
||||
|
||||
SPEEDUP_CAMPFIRE_BACKPORT_ANIMATIONS(new Builder("Add animation speedup support to Campfire Backport").setPhase(Phase.LATE)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.gtnewhorizons.angelica.mixins.interfaces;
|
||||
|
||||
public interface IGameSettingsExt {
|
||||
boolean angelica$showFpsGraph();
|
||||
void angelica$setShowFpsGraph(boolean renderFpsGraph);
|
||||
}
|
||||
@@ -1,11 +1,18 @@
|
||||
package com.gtnewhorizons.angelica.proxy;
|
||||
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.vertex.VertexFormat;
|
||||
import com.gtnewhorizons.angelica.compat.ModStatus;
|
||||
import com.gtnewhorizons.angelica.compat.bettercrashes.BetterCrashesCompat;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import com.gtnewhorizons.angelica.debug.F3Direction;
|
||||
import com.gtnewhorizons.angelica.debug.FrametimeGraph;
|
||||
import com.gtnewhorizons.angelica.debug.TPSGraph;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IGameSettingsExt;
|
||||
import com.gtnewhorizons.angelica.dynamiclights.DynamicLights;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.debug.OpenGLDebugging;
|
||||
@@ -14,6 +21,7 @@ import com.gtnewhorizons.angelica.models.VanillaModels;
|
||||
import com.gtnewhorizons.angelica.render.CloudRenderer;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
import com.gtnewhorizons.angelica.utils.AssetLoader;
|
||||
import com.gtnewhorizons.angelica.zoom.Zoom;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
@@ -24,6 +32,9 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import jss.notfine.core.Settings;
|
||||
import me.jellysquid.mods.sodium.client.SodiumDebugScreenHandler;
|
||||
import net.coderbot.iris.Iris;
|
||||
@@ -51,15 +62,11 @@ import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static com.gtnewhorizons.angelica.loading.AngelicaTweaker.LOGGER;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
final FrametimeGraph frametimeGraph = new FrametimeGraph();
|
||||
final TPSGraph tpsGraph = new TPSGraph();
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
@@ -95,8 +102,7 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
if (AngelicaConfig.enableHudCaching) {
|
||||
FMLCommonHandler.instance().bus().register(HUDCaching.INSTANCE);
|
||||
MinecraftForge.EVENT_BUS.register(HUDCaching.INSTANCE); // TODO remove debug stuff, unused registration}
|
||||
HUDCaching.registerKeyBindings();
|
||||
MinecraftForge.EVENT_BUS.register(HUDCaching.INSTANCE);
|
||||
}
|
||||
if (AngelicaConfig.enableSodium) {
|
||||
MinecraftForge.EVENT_BUS.register(SodiumDebugScreenHandler.INSTANCE);
|
||||
@@ -129,7 +135,7 @@ public class ClientProxy extends CommonProxy {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
glsmKeyBinding = new KeyBinding("Print GLSM Debug", Keyboard.KEY_NONE, "Angelica Keybinds");
|
||||
glsmKeyBinding = new KeyBinding("Print GLSM Debug", Keyboard.KEY_NONE, "Angelica");
|
||||
ClientRegistry.registerKeyBinding(glsmKeyBinding);
|
||||
|
||||
VanillaModels.init();
|
||||
@@ -137,6 +143,9 @@ public class ClientProxy extends CommonProxy {
|
||||
if (ModStatus.isBetterCrashesLoaded) {
|
||||
BetterCrashesCompat.init();
|
||||
}
|
||||
if (AngelicaConfig.enableZoom) {
|
||||
Zoom.init();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean wasGLSMKeyPressed;
|
||||
@@ -154,7 +163,7 @@ public class ClientProxy extends CommonProxy {
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
super.postInit(event);
|
||||
|
||||
if (ModStatus.isLotrLoaded && AngelicaConfig.enableSodium && AngelicaConfig.fixLotrSodiumCompat) {
|
||||
if (ModStatus.isLotrLoaded && AngelicaConfig.enableSodium && CompatConfig.fixLotr) {
|
||||
try {
|
||||
Class<?> lotrRendering = Class.forName("lotr.common.coremod.LOTRReplacedMethods$BlockRendering");
|
||||
ReflectionHelper.setPrivateValue(lotrRendering, null, new ConcurrentHashMap<>(), "naturalBlockClassTable");
|
||||
@@ -179,19 +188,30 @@ public class ClientProxy extends CommonProxy {
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onRenderOverlay(RenderGameOverlayEvent.Pre event) {
|
||||
if (event.isCanceled() || !mc.gameSettings.showDebugInfo) return;
|
||||
if (AngelicaConfig.modernizeF3Screen && event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS) {
|
||||
F3Direction.renderWorldDirectionsEvent(mc, event);
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onRenderOverlay(RenderGameOverlayEvent.Text event) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (event.isCanceled() || !mc.gameSettings.showDebugInfo || event.left.isEmpty()) return;
|
||||
|
||||
NetHandlerPlayClient cl = mc.getNetHandler();
|
||||
if (cl != null) {
|
||||
IntegratedServer srv = mc.getIntegratedServer();
|
||||
|
||||
if (srv != null) {
|
||||
String s = String.format("Integrated server @ %.0f ms ticks", lastIntegratedTickTime);
|
||||
event.left.add(1, s);
|
||||
event.left.add(Math.min(event.left.size(), 1), s);
|
||||
}
|
||||
}
|
||||
|
||||
if (AngelicaConfig.showBlockDebugInfo && mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
if (!event.right.isEmpty() && !Objects.firstNonNull(event.right.get(event.right.size() - 1), "").isEmpty()) event.right.add("");
|
||||
Block block = mc.theWorld.getBlock(mc.objectMouseOver.blockX, mc.objectMouseOver.blockY, mc.objectMouseOver.blockZ);
|
||||
@@ -199,6 +219,7 @@ public class ClientProxy extends CommonProxy {
|
||||
event.right.add(Block.blockRegistry.getNameForObject(block));
|
||||
event.right.add("meta: " + meta);
|
||||
}
|
||||
|
||||
if (DynamicLights.isEnabled()) {
|
||||
var builder = new StringBuilder("Dynamic Light Sources: ");
|
||||
DynamicLights dl = DynamicLights.get();
|
||||
@@ -206,6 +227,7 @@ public class ClientProxy extends CommonProxy {
|
||||
|
||||
event.right.add(builder.toString());
|
||||
}
|
||||
|
||||
if (AngelicaConfig.modernizeF3Screen) {
|
||||
boolean hasReplacedXYZ = false;
|
||||
for (int i = 0; i < event.left.size() - 3; i++) {
|
||||
@@ -246,6 +268,8 @@ public class ClientProxy extends CommonProxy {
|
||||
}
|
||||
}
|
||||
event.setCanceled(true);
|
||||
// TODO don't cancel the event and render here,
|
||||
// instead mixin into the vanilla code and add a background to it
|
||||
/* render ourselves for modern background */
|
||||
FontRenderer fontrenderer = mc.fontRenderer;
|
||||
int fontColor = 0xe0e0e0;
|
||||
@@ -268,6 +292,14 @@ public class ClientProxy extends CommonProxy {
|
||||
Gui.drawRect(strX - 1, strY - 1, strX + w + 1, strY + fontrenderer.FONT_HEIGHT - 1, rectColor);
|
||||
fontrenderer.drawString(msg, strX, strY, fontColor);
|
||||
}
|
||||
|
||||
// Draw a frametime graph
|
||||
if (((IGameSettingsExt)mc.gameSettings).angelica$showFpsGraph()) {
|
||||
frametimeGraph.render();
|
||||
if (Minecraft.getMinecraft().isSingleplayer()) {
|
||||
tpsGraph.render();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,4 +335,14 @@ public class ClientProxy extends CommonProxy {
|
||||
event.newfov = 1.0F;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putFrametime(long time) {
|
||||
frametimeGraph.putSample(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putTicktime(long time) {
|
||||
tpsGraph.putSample(time);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.gtnewhorizons.angelica.proxy;
|
||||
|
||||
import com.gtnewhorizons.angelica.common.BlockTest;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.utils.AssetLoader;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
@@ -20,4 +19,9 @@ public class CommonProxy {
|
||||
public void init(FMLInitializationEvent event) {}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent event) {}
|
||||
|
||||
// Only present on the client!
|
||||
public void putFrametime(long time) { throw new UnsupportedOperationException(); }
|
||||
|
||||
public void putTicktime(long time) { throw new UnsupportedOperationException(); }
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* This file is part of FalseTweaks.
|
||||
*
|
||||
* Copyright (C) 2022-2024 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* Modifications by Angelica in accordance with LGPL v3.0
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalseTweaks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* FalseTweaks is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalseTweaks. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.gtnewhorizons.angelica.rendering;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.val;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.resources.IResourceManager;
|
||||
import net.minecraft.client.resources.IResourceManagerReloadListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class ItemRenderListManager implements IResourceManagerReloadListener {
|
||||
public static final ItemRenderListManager INSTANCE = new ItemRenderListManager();
|
||||
|
||||
private final Map<ItemProp, Integer> theMap = new HashMap<>();
|
||||
private final List<ItemProp> propList = new ArrayList<>();
|
||||
private final ItemProp prop = new ItemProp();
|
||||
private int list = 0;
|
||||
|
||||
public boolean pre(float a, float b, float c, float d, int e, int f, float g) {
|
||||
prop.set(a, b, c, d, e, f, g);
|
||||
if (theMap.containsKey(prop)) {
|
||||
val list = theMap.get(prop);
|
||||
propList.add(propList.remove(propList.indexOf(prop)));
|
||||
GL11.glCallList(list);
|
||||
return true;
|
||||
} else {
|
||||
if (propList.size() >= AngelicaConfig.itemRendererDisplayListCacheSize) {
|
||||
val oldProp = propList.remove(0);
|
||||
GLAllocation.deleteDisplayLists(theMap.remove(oldProp));
|
||||
}
|
||||
list = GLAllocation.generateDisplayLists(1);
|
||||
val newProp = new ItemProp(prop);
|
||||
theMap.put(newProp, list);
|
||||
propList.add(newProp);
|
||||
GL11.glNewList(list, GL11.GL_COMPILE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void post() {
|
||||
GL11.glEndList();
|
||||
GL11.glCallList(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager p_110549_1_) {
|
||||
propList.clear();
|
||||
theMap.forEach((key, value) -> GLAllocation.deleteDisplayLists(value));
|
||||
theMap.clear();
|
||||
}
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class ItemProp {
|
||||
private float a;
|
||||
private float b;
|
||||
private float c;
|
||||
private float d;
|
||||
private int e;
|
||||
private int f;
|
||||
private float g;
|
||||
|
||||
public ItemProp(ItemProp old) {
|
||||
set(old.a, old.b, old.c, old.d, old.e, old.f, old.g);
|
||||
}
|
||||
|
||||
public void set(float a, float b, float c, float d, int e, int f, float g) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
this.d = d;
|
||||
this.e = e;
|
||||
this.f = f;
|
||||
this.g = g;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.gtnewhorizons.angelica.transform;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
|
||||
public class AsmUtil {
|
||||
|
||||
public static String obf(String deobf, String obf) {
|
||||
if (AngelicaTweaker.isObfEnv()) {
|
||||
return obf;
|
||||
}
|
||||
return deobf;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gtnewhorizons.angelica.transform;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
@@ -10,9 +11,8 @@ import org.objectweb.asm.tree.ClassNode;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockTransformer implements IClassTransformer {
|
||||
public static final String BlockClass = "net/minecraft/block/Block";
|
||||
public static final String BlockPackage = BlockClass.substring(0, BlockClass.lastIndexOf('/') + 1);
|
||||
private static final String BlockClassFriendly = BlockClass.replace('/', '.');
|
||||
|
||||
private static final String BlockClassFriendly = "net.minecraft.block.Block";
|
||||
public static final List<Pair<String, String>> BlockBoundsFields = ImmutableList.of(
|
||||
Pair.of("minX", "field_149759_B"),
|
||||
Pair.of("minY", "field_149760_C"),
|
||||
@@ -28,18 +28,18 @@ public class BlockTransformer implements IClassTransformer {
|
||||
*/
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if(basicClass != null && transformedName.equals(BlockClassFriendly)) {
|
||||
if (basicClass != null && BlockClassFriendly.equals(transformedName)) {
|
||||
final ClassReader cr = new ClassReader(basicClass);
|
||||
final ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
|
||||
cn.fields.removeIf(node -> BlockBoundsFields.stream().anyMatch(pair -> node.name.equals(pair.getLeft()) || node.name.equals(pair.getRight())));
|
||||
|
||||
cn.fields.removeIf(field -> BlockBoundsFields.stream().anyMatch(pair -> field.name.equals(pair.getLeft()) || field.name.equals(pair.getRight())));
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
cn.accept(cw);
|
||||
basicClass = cw.toByteArray();
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.transform;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.spongepowered.asm.lib.ClassReader;
|
||||
import org.spongepowered.asm.lib.ClassWriter;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.lib.tree.InsnList;
|
||||
import org.spongepowered.asm.lib.tree.InsnNode;
|
||||
import org.spongepowered.asm.lib.tree.JumpInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.LabelNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.transformers.MixinClassWriter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class HUDCachingTransformer implements IClassTransformer, Opcodes {
|
||||
static final String HUDCaching = "com/gtnewhorizons/angelica/hudcaching/HUDCaching$HUDCachingHooks";
|
||||
private static final boolean DUMP_CLASSES = Boolean.parseBoolean(System.getProperty("angelica.dumpClass", "false"));
|
||||
|
||||
static final Map<String, List<String>> ReturnEarlyMethods = ImmutableMap.of(
|
||||
"thaumcraft.client.lib.RenderEventHandler", ImmutableList.of("renderOverlay"),
|
||||
"com.kentington.thaumichorizons.client.lib.RenderEventHandler", ImmutableList.of("renderOverlay")
|
||||
);
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null) return null;
|
||||
|
||||
if (ReturnEarlyMethods.containsKey(transformedName)) {
|
||||
ClassReader cr = new ClassReader(basicClass);
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
|
||||
for (String targetMethod : ReturnEarlyMethods.get(transformedName)) {
|
||||
for (MethodNode method : cn.methods) {
|
||||
if (!method.name.equals(targetMethod)) continue;
|
||||
|
||||
InsnList list = new InsnList();
|
||||
LabelNode exitLabel = new LabelNode();
|
||||
AngelicaTweaker.LOGGER.info("Injecting HUDCaching Conditional Return: " + transformedName + "#" + method.name);
|
||||
list.add(new MethodInsnNode(INVOKESTATIC, HUDCaching, "shouldReturnEarly", "()Z", false));
|
||||
list.add(new JumpInsnNode(IFEQ, exitLabel));
|
||||
if (method.desc.endsWith("Z") || method.desc.endsWith("I")) {
|
||||
list.add(new InsnNode(ICONST_0));
|
||||
list.add(new InsnNode(IRETURN));
|
||||
} else if (method.desc.endsWith("V")) {
|
||||
list.add(new InsnNode(RETURN));
|
||||
} else {
|
||||
AngelicaTweaker.LOGGER.warn("HUDCaching Conditional Return - Unknown return type: " + transformedName + "#" + method.name + ":" + method.desc);
|
||||
return basicClass;
|
||||
}
|
||||
list.add(exitLabel);
|
||||
method.instructions.insert(list);
|
||||
}
|
||||
}
|
||||
|
||||
MixinClassWriter cw = new MixinClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
saveTransformedClass(bytes, transformedName);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
private File outputDir = null;
|
||||
private void saveTransformedClass(final byte[] data, final String transformedName) {
|
||||
if (!DUMP_CLASSES) {
|
||||
return;
|
||||
}
|
||||
if (outputDir == null) {
|
||||
outputDir = new File(Launch.minecraftHome, "ASM_HUD_CACHING");
|
||||
try {
|
||||
FileUtils.deleteDirectory(outputDir);
|
||||
} catch (IOException ignored) {}
|
||||
if (!outputDir.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
outputDir.mkdirs();
|
||||
}
|
||||
}
|
||||
final String fileName = transformedName.replace('.', File.separatorChar);
|
||||
final File classFile = new File(outputDir, fileName + ".class");
|
||||
final File outDir = classFile.getParentFile();
|
||||
if (!outDir.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
outDir.mkdirs();
|
||||
}
|
||||
if (classFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
classFile.delete();
|
||||
}
|
||||
try (final OutputStream output = Files.newOutputStream(classFile.toPath())) {
|
||||
output.write(data);
|
||||
} catch (IOException e) {
|
||||
AngelicaTweaker.LOGGER.error("Could not save transformed class (byte[]) " + transformedName, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,10 @@ package com.gtnewhorizons.angelica.transform;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.gtnewhorizon.gtnhlib.asm.ClassConstantPoolParser;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.coderbot.iris.IrisLogging;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
@@ -23,12 +20,8 @@ import org.objectweb.asm.tree.LdcInsnNode;
|
||||
import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -38,17 +31,12 @@ import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.gtnewhorizons.angelica.transform.BlockTransformer.BlockBoundsFields;
|
||||
import static com.gtnewhorizons.angelica.transform.BlockTransformer.BlockClass;
|
||||
import static com.gtnewhorizons.angelica.transform.BlockTransformer.BlockPackage;
|
||||
|
||||
/**
|
||||
* This transformer redirects many GL calls to our custom GLStateManager
|
||||
*/
|
||||
public class RedirectorTransformer implements IClassTransformer {
|
||||
|
||||
private static final boolean ASSERT_MAIN_THREAD = Boolean.parseBoolean(System.getProperty("angelica.assertMainThread", "false"));
|
||||
private static final boolean DUMP_CLASSES = Boolean.parseBoolean(System.getProperty("angelica.dumpClass", "false"));
|
||||
private static final String Drawable = "org/lwjgl/opengl/Drawable";
|
||||
private static final String GLStateManager = "com/gtnewhorizons/angelica/glsm/GLStateManager";
|
||||
private static final String GL11 = "org/lwjgl/opengl/GL11";
|
||||
@@ -57,6 +45,9 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
private static final String GL20 = "org/lwjgl/opengl/GL20";
|
||||
private static final String Project = "org/lwjgl/util/glu/Project";
|
||||
|
||||
private static final String BlockClass = "net/minecraft/block/Block";
|
||||
private static final String BlockPackage = "net/minecraft/block/Block";
|
||||
|
||||
private static final String OpenGlHelper = "net/minecraft/client/renderer/OpenGlHelper";
|
||||
private static final String EXTBlendFunc = "org/lwjgl/opengl/EXTBlendFuncSeparate";
|
||||
private static final String ARBMultiTexture = "org/lwjgl/opengl/ARBMultitexture";
|
||||
@@ -106,6 +97,7 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
glCapRedirects.put(org.lwjgl.opengl.GL11.GL_SCISSOR_TEST, "ScissorTest");
|
||||
methodRedirects.put(GL11, RedirectMap.newMap()
|
||||
.add("glAlphaFunc")
|
||||
.add("glBegin")
|
||||
.add("glBindTexture")
|
||||
.add("glBlendFunc")
|
||||
.add("glCallList")
|
||||
@@ -128,6 +120,7 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
.add("glDepthRange")
|
||||
.add("glDrawArrays")
|
||||
.add("glDrawBuffer")
|
||||
.add("glDrawElements")
|
||||
.add("glEdgeFlag")
|
||||
.add("glEndList")
|
||||
.add("glFog")
|
||||
@@ -233,9 +226,9 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
}
|
||||
|
||||
private boolean isVanillaBlockSubclass(String className) {
|
||||
if(className.startsWith(BlockTransformer.BlockPackage)) {
|
||||
for(String exclusion : VanillaBlockExclusions) {
|
||||
if(className.startsWith(exclusion)) {
|
||||
if (className.startsWith(BlockPackage)) {
|
||||
for (String exclusion : VanillaBlockExclusions) {
|
||||
if (className.startsWith(exclusion)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -281,7 +274,7 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
saveTransformedClass(bytes, transformedName);
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
return basicClass;
|
||||
@@ -309,9 +302,9 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
} else {
|
||||
// Check if we declare any known field names
|
||||
Set<String> fieldsDeclaredByClass = cn.fields.stream().map(f -> f.name).collect(Collectors.toSet());
|
||||
doWeShadow = BlockBoundsFields.stream().anyMatch(pair -> fieldsDeclaredByClass.contains(pair.getLeft()) || fieldsDeclaredByClass.contains(pair.getRight()));
|
||||
doWeShadow = BlockTransformer.BlockBoundsFields.stream().anyMatch(pair -> fieldsDeclaredByClass.contains(pair.getLeft()) || fieldsDeclaredByClass.contains(pair.getRight()));
|
||||
}
|
||||
if(doWeShadow) {
|
||||
if (doWeShadow) {
|
||||
AngelicaTweaker.LOGGER.info("Class '{}' shadows one or more block bounds fields, these accesses won't be redirected!", cn.name);
|
||||
blockOwnerExclusions.add(cn.name);
|
||||
}
|
||||
@@ -383,13 +376,13 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
else if ((node.getOpcode() == Opcodes.GETFIELD || node.getOpcode() == Opcodes.PUTFIELD) && node instanceof FieldInsnNode fNode) {
|
||||
if(!blockOwnerExclusions.contains(fNode.owner) && isBlockSubclass(fNode.owner) && isSodiumEnabled()) {
|
||||
Pair<String, String> fieldToRedirect = null;
|
||||
for(Pair<String, String> blockPairs : BlockBoundsFields) {
|
||||
for(Pair<String, String> blockPairs : BlockTransformer.BlockBoundsFields) {
|
||||
if(fNode.name.equals(blockPairs.getLeft()) || fNode.name.equals(blockPairs.getRight())) {
|
||||
fieldToRedirect = blockPairs;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(fieldToRedirect != null) {
|
||||
if (fieldToRedirect != null) {
|
||||
if (IrisLogging.ENABLE_SPAM) {
|
||||
AngelicaTweaker.LOGGER.info("Redirecting Block.{} in {} to thread-safe wrapper", fNode.name, transformedName);
|
||||
}
|
||||
@@ -398,9 +391,9 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
fNode.owner = ThreadedBlockData;
|
||||
// Inject getter before the field access, to turn Block -> ThreadedBlockData
|
||||
final MethodInsnNode getter = new MethodInsnNode(Opcodes.INVOKESTATIC, ThreadedBlockData, "get", "(L" + BlockClass + ";)L" + ThreadedBlockData + ";", false);
|
||||
if(node.getOpcode() == Opcodes.GETFIELD) {
|
||||
if (node.getOpcode() == Opcodes.GETFIELD) {
|
||||
mn.instructions.insertBefore(fNode, getter);
|
||||
} else if(node.getOpcode() == Opcodes.PUTFIELD) {
|
||||
} else if (node.getOpcode() == Opcodes.PUTFIELD) {
|
||||
// FIXME: this code assumes doubles
|
||||
// Stack: Block, double
|
||||
final InsnList beforePut = new InsnList();
|
||||
@@ -418,7 +411,6 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -430,40 +422,6 @@ public class RedirectorTransformer implements IClassTransformer {
|
||||
return changed;
|
||||
}
|
||||
|
||||
private File outputDir = null;
|
||||
|
||||
private void saveTransformedClass(final byte[] data, final String transformedName) {
|
||||
if (!DUMP_CLASSES) {
|
||||
return;
|
||||
}
|
||||
if (outputDir == null) {
|
||||
outputDir = new File(Launch.minecraftHome, "ASM_REDIRECTOR");
|
||||
try {
|
||||
FileUtils.deleteDirectory(outputDir);
|
||||
} catch (IOException ignored) {}
|
||||
if (!outputDir.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
outputDir.mkdirs();
|
||||
}
|
||||
}
|
||||
final String fileName = transformedName.replace('.', File.separatorChar);
|
||||
final File classFile = new File(outputDir, fileName + ".class");
|
||||
final File outDir = classFile.getParentFile();
|
||||
if (!outDir.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
outDir.mkdirs();
|
||||
}
|
||||
if (classFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
classFile.delete();
|
||||
}
|
||||
try (final OutputStream output = Files.newOutputStream(classFile.toPath())) {
|
||||
output.write(data);
|
||||
} catch (IOException e) {
|
||||
AngelicaTweaker.LOGGER.error("Could not save transformed class (byte[]) " + transformedName, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static class RedirectMap<K> extends HashMap<K, K> {
|
||||
public static RedirectMap<String> newMap() {
|
||||
return new RedirectMap<>();
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public enum CompatASMTransformers {
|
||||
|
||||
EXTRA_UTILITIES_ISBRH("RenderBlockColor Transformer", () -> AngelicaConfig.fixExtraUtilsSodiumCompat, Side.CLIENT,
|
||||
"com.gtnewhorizons.angelica.transform.compat.ExtraUtilsTransformer"
|
||||
),
|
||||
HUD_CACHING("HUDCaching Early Return Transformer", () -> AngelicaConfig.enableHudCaching && AngelicaConfig.enableHudCachingEventTransformer, Side.CLIENT,
|
||||
"com.gtnewhorizons.angelica.transform.HUDCachingTransformer")
|
||||
;
|
||||
|
||||
private final Supplier<Boolean> applyIf;
|
||||
private final Side side;
|
||||
private final String[] transformerClasses;
|
||||
|
||||
CompatASMTransformers(String description, Supplier<Boolean> applyIf, Side side, String... transformers) {
|
||||
this.applyIf = applyIf;
|
||||
this.side = side;
|
||||
this.transformerClasses = transformers;
|
||||
}
|
||||
|
||||
private boolean shouldBeLoaded() { return applyIf.get() && shouldLoadSide(); }
|
||||
|
||||
private boolean shouldLoadSide() {
|
||||
return side == Side.BOTH || (side == Side.SERVER && FMLLaunchHandler.side()
|
||||
.isServer())
|
||||
|| (side == Side.CLIENT && FMLLaunchHandler.side()
|
||||
.isClient());
|
||||
}
|
||||
|
||||
public static List<String> getTransformers() {
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (CompatASMTransformers transformer : values()) {
|
||||
if (transformer.shouldBeLoaded()) {
|
||||
AngelicaTweaker.LOGGER.info("Loading transformer {}", (Object[]) transformer.transformerClasses);
|
||||
list.addAll(Arrays.asList(transformer.transformerClasses));
|
||||
} else {
|
||||
AngelicaTweaker.LOGGER.info("Not loading transformer {}", (Object[]) transformer.transformerClasses);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private enum Side {
|
||||
BOTH,
|
||||
CLIENT,
|
||||
SERVER
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.AnnotationNode;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExtraUtilsTransformer implements IClassTransformer {
|
||||
|
||||
private static final String RenderBlockColor = "com.rwtema.extrautils.block.render.RenderBlockColor";
|
||||
private static final String RenderBlockConnectedTextures = "com.rwtema.extrautils.block.render.RenderBlockConnectedTextures";
|
||||
private static final String RenderBlockConnectedTexturesEthereal = "com.rwtema.extrautils.block.render.RenderBlockConnectedTexturesEthereal";
|
||||
private static final String RenderBlockFullBright = "com.rwtema.extrautils.block.render.RenderBlockFullBright";
|
||||
private static final String RenderBlockSpike = "com.rwtema.extrautils.block.render.RenderBlockSpike";
|
||||
|
||||
private static final List<String> transformedClasses = Arrays.asList(RenderBlockColor, RenderBlockConnectedTextures, RenderBlockConnectedTexturesEthereal, RenderBlockFullBright, RenderBlockSpike);
|
||||
|
||||
private static final Map<String, Boolean> perThreadMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
perThreadMap.put(RenderBlockColor, false);
|
||||
perThreadMap.put(RenderBlockConnectedTextures, true);
|
||||
perThreadMap.put(RenderBlockConnectedTexturesEthereal, true);
|
||||
perThreadMap.put(RenderBlockFullBright, false);
|
||||
perThreadMap.put(RenderBlockSpike, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(final String className, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null) return null;
|
||||
|
||||
if (!transformedClasses.contains(transformedName)) {
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
AngelicaTweaker.LOGGER.info("Adding ThreadSafeISBRH for Extra Utilities to: {}", transformedName);
|
||||
|
||||
final ClassReader cr = new ClassReader(basicClass);
|
||||
final ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
|
||||
addThreadSafeISBRHAnnotation(transformedName, cn);
|
||||
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
||||
cn.accept(cw);
|
||||
return cw.toByteArray();
|
||||
}
|
||||
|
||||
public void addThreadSafeISBRHAnnotation(String transformedName, ClassNode cn) {
|
||||
|
||||
AnnotationNode isbrhAnnotation = new AnnotationNode("Lcom/gtnewhorizons/angelica/api/ThreadSafeISBRH;");
|
||||
|
||||
Boolean perThread = perThreadMap.get(transformedName);
|
||||
if (perThread == null) {
|
||||
perThread = false;
|
||||
AngelicaTweaker.LOGGER.info("Tried to add ThreadSafeISBRH annotation to {} which is missing from perThreadMap. Using false for perThread.", transformedName);
|
||||
}
|
||||
isbrhAnnotation.values = Arrays.asList("perThread", perThread);
|
||||
|
||||
if (cn.visibleAnnotations == null) {
|
||||
cn.visibleAnnotations = new ArrayList<>();
|
||||
}
|
||||
cn.visibleAnnotations.add(isbrhAnnotation);
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.transform.compat.handlers.CompatHandler;
|
||||
import com.gtnewhorizons.angelica.transform.compat.transformers.generic.FieldLevelTessellatorTransformer;
|
||||
import com.gtnewhorizons.angelica.transform.compat.transformers.generic.HUDCachingEarlyReturnTransformer;
|
||||
import com.gtnewhorizons.angelica.transform.compat.transformers.generic.ThreadSafeISBRHAnnotationTransformer;
|
||||
import com.gtnewhorizons.angelica.transform.compat.transformers.generic.TileEntityNullGuardTransformer;
|
||||
import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.spongepowered.asm.lib.ClassReader;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.transformers.MixinClassWriter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class GenericCompatTransformer implements IClassTransformer {
|
||||
|
||||
private static final Map<String, List<String>> fieldLevelTessellator = new Object2ObjectOpenHashMap<>();
|
||||
private static final Map<String, List<String>> tileEntityNullGuard = new Object2ObjectOpenHashMap<>();
|
||||
private static final Map<String, Boolean> threadSafeIBSRH = new Object2BooleanOpenHashMap<>();
|
||||
private static final Map<String, List<String>> hudCachingEarlyReturn = new Object2ObjectOpenHashMap<>();
|
||||
|
||||
private static final Set<String> transformedClasses = new ObjectOpenHashSet<>();
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null) return null;
|
||||
|
||||
if (!transformedClasses.contains(transformedName)) return basicClass;
|
||||
|
||||
ClassReader cr = new ClassReader(basicClass);
|
||||
ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
|
||||
if (fieldLevelTessellator.containsKey(transformedName)) {
|
||||
FieldLevelTessellatorTransformer.transform(cn, fieldLevelTessellator.get(transformedName));
|
||||
}
|
||||
|
||||
if (tileEntityNullGuard.containsKey(transformedName)) {
|
||||
TileEntityNullGuardTransformer.transform(cn, tileEntityNullGuard.get(transformedName));
|
||||
}
|
||||
|
||||
if (threadSafeIBSRH.containsKey(transformedName)) {
|
||||
ThreadSafeISBRHAnnotationTransformer.transform(cn, threadSafeIBSRH.get(transformedName));
|
||||
}
|
||||
|
||||
if (hudCachingEarlyReturn.containsKey(transformedName)) {
|
||||
HUDCachingEarlyReturnTransformer.transform(cn, hudCachingEarlyReturn.get(transformedName));
|
||||
}
|
||||
|
||||
MixinClassWriter cw = new MixinClassWriter(MixinClassWriter.COMPUTE_MAXS | MixinClassWriter.COMPUTE_FRAMES);
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static void register(CompatHandler handler) {
|
||||
if (handler.getFieldLevelTessellator() != null)
|
||||
fieldLevelTessellator.putAll(handler.getFieldLevelTessellator());
|
||||
if (handler.getTileEntityNullGuard() != null)
|
||||
tileEntityNullGuard.putAll(handler.getTileEntityNullGuard());
|
||||
if (handler.getThreadSafeISBRHAnnotations() != null)
|
||||
threadSafeIBSRH.putAll(handler.getThreadSafeISBRHAnnotations());
|
||||
if (handler.getHUDCachingEarlyReturn() != null)
|
||||
hudCachingEarlyReturn.putAll(handler.getHUDCachingEarlyReturn());
|
||||
}
|
||||
|
||||
public static void build() {
|
||||
transformedClasses.addAll(fieldLevelTessellator.keySet());
|
||||
transformedClasses.addAll(tileEntityNullGuard.keySet());
|
||||
transformedClasses.addAll(threadSafeIBSRH.keySet());
|
||||
transformedClasses.addAll(hudCachingEarlyReturn.keySet());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface CompatHandler {
|
||||
|
||||
default Map<String, List<String>> getFieldLevelTessellator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default Map<String, List<String>> getTileEntityNullGuard() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default Map<String, Boolean> getThreadSafeISBRHAnnotations() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default Map<String, List<String>> getHUDCachingEarlyReturn() {
|
||||
return null;
|
||||
}
|
||||
|
||||
default List<String> extraTransformers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.CompatConfig;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public enum CompatHandlers {
|
||||
|
||||
STACKS_ON_STACKS(() -> CompatConfig.fixStacksOnStacks, new StacksOnStacksCompatHandler()),
|
||||
EXTRA_UTILS(() -> CompatConfig.fixExtraUtils, new ExtraUtilsCompatHandler()),
|
||||
IMMERSIVE_ENGINEERING(() -> CompatConfig.fixImmersiveEngineering, new ImmersiveEngineeringCompatHandler()),
|
||||
THAUMCRAFT(() -> CompatConfig.fixThaumcraft, new ThaumcraftCompatHandler()),
|
||||
THAUMIC_HORIZONS(() -> CompatConfig.fixThaumicHorizons, new ThaumicHorizonsCompatHandler());
|
||||
|
||||
private final Supplier<Boolean> applyIf;
|
||||
private final CompatHandler handler;
|
||||
|
||||
CompatHandlers(Supplier<Boolean> applyIf, CompatHandler handler) {
|
||||
this.applyIf = applyIf;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
private static List<CompatHandler> compatHandlers = null;
|
||||
|
||||
public static List<CompatHandler> getHandlers() {
|
||||
if (compatHandlers != null) {
|
||||
return compatHandlers;
|
||||
}
|
||||
compatHandlers = new ArrayList<>();
|
||||
for (CompatHandlers value : values()) {
|
||||
if (value.applyIf.get()) {
|
||||
compatHandlers.add(value.handler);
|
||||
}
|
||||
}
|
||||
return compatHandlers;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ExtraUtilsCompatHandler implements CompatHandler {
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getThreadSafeISBRHAnnotations() {
|
||||
return ImmutableMap.of(
|
||||
"com.rwtema.extrautils.block.render.RenderBlockColor",
|
||||
false,
|
||||
"com.rwtema.extrautils.block.render.RenderBlockConnectedTextures",
|
||||
true,
|
||||
"com.rwtema.extrautils.block.render.RenderBlockConnectedTexturesEthereal",
|
||||
true,
|
||||
"com.rwtema.extrautils.block.render.RenderBlockFullBright",
|
||||
false,
|
||||
"com.rwtema.extrautils.block.render.RenderBlockSpike",
|
||||
false);
|
||||
}
|
||||
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.gtnewhorizons.angelica.transform.compat.transformers.specific.ImmersiveEngineeringTransformer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImmersiveEngineeringCompatHandler implements CompatHandler {
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getTileEntityNullGuard() {
|
||||
final List<String> renderWorldBlockExclusive = ImmutableList.of("renderWorldBlock");
|
||||
return ImmutableMap.<String, List<String>>builder()
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderClothDevices", renderWorldBlockExclusive)
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderMetalDecoration", renderWorldBlockExclusive)
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderMetalDevices", renderWorldBlockExclusive)
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderMetalDevices2", renderWorldBlockExclusive)
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderWoodenDecoration", renderWorldBlockExclusive)
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderWoodenDevices", renderWorldBlockExclusive)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getThreadSafeISBRHAnnotations() {
|
||||
return ImmutableMap.<String, Boolean>builder()
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderClothDevices", false)
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderMetalDecoration", false)
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderMetalDevices", false)
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderMetalDevices2", false)
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderMetalMultiblocks", false)
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderStoneDevices", false)
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderWoodenDecoration", false)
|
||||
.put("blusunrize.immersiveengineering.client.render.BlockRenderWoodenDevices", false)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> extraTransformers() {
|
||||
return ImmutableList.of(ImmersiveEngineeringTransformer.class.getName());
|
||||
}
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.gtnewhorizons.angelica.transform.compat.transformers.specific.StacksOnStacksTransformer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StacksOnStacksCompatHandler implements CompatHandler {
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getFieldLevelTessellator() {
|
||||
return ImmutableMap
|
||||
.of("com.tierzero.stacksonstacks.util.ClientUtils", ImmutableList.of("drawQuad", "drawRectangularPrism"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getTileEntityNullGuard() {
|
||||
return ImmutableMap
|
||||
.of("com.tierzero.stacksonstacks.client.render.RenderTilePile", ImmutableList.of("renderWorldBlock"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Boolean> getThreadSafeISBRHAnnotations() {
|
||||
return ImmutableMap.of("com.tierzero.stacksonstacks.client.render.RenderTilePile", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> extraTransformers() {
|
||||
return ImmutableList.of(StacksOnStacksTransformer.class.getName());
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ThaumcraftCompatHandler implements CompatHandler {
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getHUDCachingEarlyReturn() {
|
||||
return ImmutableMap.of("thaumcraft.client.lib.RenderEventHandler", ImmutableList.of("renderOverlay"));
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.handlers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ThaumicHorizonsCompatHandler implements CompatHandler {
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getHUDCachingEarlyReturn() {
|
||||
return ImmutableMap
|
||||
.of("com.kentington.thaumichorizons.client.lib.RenderEventHandler", ImmutableList.of("renderOverlay"));
|
||||
}
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.transformers.generic;
|
||||
|
||||
import com.gtnewhorizons.angelica.transform.AsmUtil;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.tree.AbstractInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.lib.tree.FieldInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.InsnList;
|
||||
import org.spongepowered.asm.lib.tree.LabelNode;
|
||||
import org.spongepowered.asm.lib.tree.LocalVariableNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.lib.tree.VarInsnNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FieldLevelTessellatorTransformer {
|
||||
|
||||
public static void transform(ClassNode cn, List<String> patchMethods) {
|
||||
for (MethodNode method : cn.methods) {
|
||||
if (patchMethods.contains(method.name)) {
|
||||
injectLocalTessellatorAndReplaceFieldUsage(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void injectLocalTessellatorAndReplaceFieldUsage(MethodNode mn) {
|
||||
// This part searches the instructions to see if there is any usage of a Tessellator field
|
||||
// which is NOT owned by Minecraft itself. This means anyone that caches it into a field will get caught
|
||||
// but not direct usage of Tessellator.instance.whatever()
|
||||
List<String> fields = new ArrayList<>();
|
||||
for (int i = 0; i < mn.instructions.size(); i++) {
|
||||
AbstractInsnNode in = mn.instructions.get(i);
|
||||
if (in instanceof FieldInsnNode fin) {
|
||||
if ((fin.getOpcode() == Opcodes.GETSTATIC || fin.getOpcode() == Opcodes.GETFIELD)
|
||||
&& fin.desc.equals("Lnet/minecraft/client/renderer/Tessellator;")
|
||||
&& !fin.owner.equals("net/minecraft/client/renderer/Tessellator")) {
|
||||
fields.add(fin.owner + ";" + fin.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fields.isEmpty()) return;
|
||||
|
||||
// Injects a new local to store our new local Tessellator in
|
||||
int localIndex = mn.maxLocals;
|
||||
LabelNode startLabel = new LabelNode();
|
||||
LabelNode endLabel = new LabelNode();
|
||||
LocalVariableNode tesNode = new LocalVariableNode(
|
||||
"tes",
|
||||
"Lnet/minecraft/client/renderer/Tessellator;",
|
||||
null,
|
||||
startLabel,
|
||||
endLabel,
|
||||
localIndex);
|
||||
mn.localVariables.add(tesNode);
|
||||
|
||||
// Actually initialize the new local Tessellator
|
||||
InsnList list = new InsnList();
|
||||
list.add(startLabel);
|
||||
list.add(
|
||||
new FieldInsnNode(
|
||||
Opcodes.GETSTATIC,
|
||||
"net/minecraft/client/renderer/Tessellator",
|
||||
AsmUtil.obf("instance", "field_78398_a"),
|
||||
"Lnet/minecraft/client/renderer/Tessellator;"));
|
||||
list.add(new VarInsnNode(Opcodes.ASTORE, localIndex));
|
||||
mn.instructions.insert(list);
|
||||
|
||||
// This searches through all the instructions and finds usage of the previously discovered fields, then it
|
||||
// replaces them
|
||||
// with an ALOAD for our new local instead of the GETSTATIC/GETFIELD
|
||||
for (int i = 0; i < mn.instructions.size(); i++) {
|
||||
AbstractInsnNode in = mn.instructions.get(i);
|
||||
if (in instanceof FieldInsnNode fin) {
|
||||
String hash = fin.owner + ";" + fin.name;
|
||||
if ((fin.getOpcode() == Opcodes.GETSTATIC || fin.getOpcode() == Opcodes.GETFIELD)
|
||||
&& fin.desc.equals("Lnet/minecraft/client/renderer/Tessellator;")
|
||||
&& fields.contains(hash)) {
|
||||
mn.instructions.insertBefore(in, new VarInsnNode(Opcodes.ALOAD, localIndex));
|
||||
mn.instructions.remove(in);
|
||||
}
|
||||
}
|
||||
}
|
||||
mn.instructions.add(endLabel);
|
||||
}
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.transformers.generic;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.lib.tree.InsnList;
|
||||
import org.spongepowered.asm.lib.tree.InsnNode;
|
||||
import org.spongepowered.asm.lib.tree.JumpInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.LabelNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class HUDCachingEarlyReturnTransformer {
|
||||
|
||||
private static final String HUDCaching = "com/gtnewhorizons/angelica/hudcaching/HUDCaching$HUDCachingHooks";
|
||||
|
||||
public static void transform(ClassNode cn, List<String> patchMethods) {
|
||||
for (MethodNode method : cn.methods) {
|
||||
if (patchMethods.contains(method.name)) {
|
||||
InsnList list = new InsnList();
|
||||
LabelNode exitLabel = new LabelNode();
|
||||
list.add(new MethodInsnNode(Opcodes.INVOKESTATIC, HUDCaching, "shouldReturnEarly", "()Z", false));
|
||||
list.add(new JumpInsnNode(Opcodes.IFEQ, exitLabel));
|
||||
if (method.desc.endsWith("Z") || method.desc.endsWith("I")) {
|
||||
list.add(new InsnNode(Opcodes.ICONST_0));
|
||||
list.add(new InsnNode(Opcodes.IRETURN));
|
||||
} else if (method.desc.endsWith("V")) {
|
||||
list.add(new InsnNode(Opcodes.RETURN));
|
||||
} else {
|
||||
AngelicaTweaker.LOGGER.warn(
|
||||
"HUDCaching Conditional Return - Unknown return type: {}#{}:{}", cn.name, method.name, method.desc
|
||||
);
|
||||
return;
|
||||
}
|
||||
list.add(exitLabel);
|
||||
method.instructions.insert(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.transformers.generic;
|
||||
|
||||
import org.spongepowered.asm.lib.tree.AnnotationNode;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class ThreadSafeISBRHAnnotationTransformer {
|
||||
|
||||
public static void transform(ClassNode cn, boolean perThread) {
|
||||
if (cn.visibleAnnotations == null) {
|
||||
cn.visibleAnnotations = new ArrayList<>();
|
||||
}
|
||||
|
||||
AnnotationNode isbrhAnnotation = new AnnotationNode("Lcom/gtnewhorizons/angelica/api/ThreadSafeISBRH;");
|
||||
isbrhAnnotation.values = Arrays.asList("perThread", perThread);
|
||||
cn.visibleAnnotations.add(isbrhAnnotation);
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.transformers.generic;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import com.gtnewhorizons.angelica.transform.AsmUtil;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.tree.AbstractInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.lib.tree.InsnList;
|
||||
import org.spongepowered.asm.lib.tree.InsnNode;
|
||||
import org.spongepowered.asm.lib.tree.JumpInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.LabelNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.lib.tree.TypeInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.VarInsnNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityNullGuardTransformer {
|
||||
|
||||
public static void transform(ClassNode cn, List<String> patchMethods) {
|
||||
for (MethodNode method : cn.methods) {
|
||||
if (patchMethods.contains(method.name)) {
|
||||
injectGetTileEntityNullGuard(method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void injectGetTileEntityNullGuard(MethodNode mn) {
|
||||
/*
|
||||
* Searching for the following pattern:
|
||||
* L0 {
|
||||
* ...
|
||||
* INVOKEINTERFACE net/minecraft/world/IBlockAccess.getTileEntity(III)Lnet/minecraft/tileentity/TileEntity;
|
||||
* CHECKCAST *
|
||||
* ASTORE x
|
||||
* }
|
||||
* L1 {...
|
||||
* Then injecting the following after the ASTORE such that we get
|
||||
* L0 {
|
||||
* ASTORE x
|
||||
* ALOAD x
|
||||
* IFNONNULL L1
|
||||
* ICONST_0
|
||||
* IRETURN
|
||||
* }
|
||||
* L1 {...
|
||||
* Ultimately this converts:
|
||||
* MyTileEntity tile = (MyTileEntity) world.getTileEntity(x, y, z);
|
||||
* doSomethingWithTileEntity(tile);
|
||||
* into:
|
||||
* MyTileEntity tile = (MyTileEntity) world.getTileEntity(x, y, z);
|
||||
* if (tile == null) {
|
||||
* return false;
|
||||
* } else {
|
||||
* doSomethingWithTileEntity(tile);
|
||||
* }
|
||||
*/
|
||||
for (int i = 0; i < mn.instructions.size(); i++) {
|
||||
AbstractInsnNode in = mn.instructions.get(i);
|
||||
if (in instanceof MethodInsnNode min) {
|
||||
if (min.getOpcode() == Opcodes.INVOKEINTERFACE
|
||||
&& min.name.equals(AsmUtil.obf("getTileEntity", "func_147438_o"))
|
||||
&& min.owner.equals("net/minecraft/world/IBlockAccess")) {
|
||||
AbstractInsnNode castNodeAbstract = min.getNext();
|
||||
if (castNodeAbstract instanceof TypeInsnNode castNodeType) {
|
||||
if (castNodeType.getOpcode() == Opcodes.CHECKCAST) {
|
||||
AbstractInsnNode astoreNodeAbstract = castNodeType.getNext();
|
||||
if (astoreNodeAbstract instanceof VarInsnNode astoreNodeVar) {
|
||||
if (astoreNodeVar.getOpcode() == Opcodes.ASTORE) {
|
||||
InsnList list = new InsnList();
|
||||
LabelNode exit = new LabelNode();
|
||||
list.add(new VarInsnNode(Opcodes.ALOAD, astoreNodeVar.var));
|
||||
list.add(new JumpInsnNode(Opcodes.IFNONNULL, exit));
|
||||
if (mn.desc.endsWith("Z") || mn.desc.endsWith("I")) {
|
||||
list.add(new InsnNode(Opcodes.ICONST_0));
|
||||
list.add(new InsnNode(Opcodes.IRETURN));
|
||||
} else if (mn.desc.endsWith("V")) {
|
||||
list.add(new InsnNode(Opcodes.RETURN));
|
||||
} else {
|
||||
AngelicaTweaker.LOGGER.warn("TileEntityNullGuard - Unknown Return Type: {}:{}", mn.name, mn.desc);
|
||||
return;
|
||||
}
|
||||
list.add(exit);
|
||||
mn.instructions.insert(astoreNodeVar, list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.transformers.specific;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.spongepowered.asm.lib.ClassReader;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.tree.AbstractInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.lib.tree.FieldInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.InsnNode;
|
||||
import org.spongepowered.asm.lib.tree.JumpInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.transformers.MixinClassWriter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ImmersiveEngineeringTransformer implements IClassTransformer {
|
||||
|
||||
private static final String BlockRenderClothDevices = "blusunrize.immersiveengineering.client.render.BlockRenderClothDevices";
|
||||
private static final String BlockRenderMetalDevices2 = "blusunrize.immersiveengineering.client.render.BlockRenderMetalDevices2";
|
||||
private static final String BlockRenderStoneDevices = "blusunrize.immersiveengineering.client.render.BlockRenderStoneDevices";
|
||||
private static final String ClientUtils = "blusunrize.immersiveengineering.client.ClientUtils";
|
||||
|
||||
private static final List<String> transformedClasses = new ArrayList<>();
|
||||
|
||||
private static final List<String> staticRenderPassPatches = new ArrayList<>();
|
||||
|
||||
static {
|
||||
transformedClasses.add(BlockRenderClothDevices);
|
||||
transformedClasses.add(BlockRenderMetalDevices2);
|
||||
transformedClasses.add(BlockRenderStoneDevices);
|
||||
transformedClasses.add(ClientUtils);
|
||||
|
||||
staticRenderPassPatches.add(BlockRenderClothDevices);
|
||||
staticRenderPassPatches.add(BlockRenderMetalDevices2);
|
||||
staticRenderPassPatches.add(BlockRenderStoneDevices);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null) return null;
|
||||
|
||||
if (!transformedClasses.contains(transformedName)) return basicClass;
|
||||
|
||||
final ClassReader cr = new ClassReader(basicClass);
|
||||
final ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
|
||||
if (transformedName.equals(ClientUtils)) {
|
||||
transformClientUtils(cn);
|
||||
}
|
||||
|
||||
if (staticRenderPassPatches.contains(transformedName)) {
|
||||
staticRenderPassPatcher(cn);
|
||||
}
|
||||
|
||||
MixinClassWriter cw = new MixinClassWriter(MixinClassWriter.COMPUTE_FRAMES);
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaTweaker.LOGGER.info("[AngelicaCompat]Extra Transformers: Applied ImmersiveEngineeringTransformer");
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
private void staticRenderPassPatcher(ClassNode cn) {
|
||||
for (MethodNode mn : cn.methods) {
|
||||
if (mn.name.equals("renderWorldBlock")) {
|
||||
for (int i = 0; i < mn.instructions.size(); i++) {
|
||||
AbstractInsnNode ain = mn.instructions.get(i);
|
||||
// So far every one of these has been named renderPass, eventually might need to make the name dynamic and possibly care about owner?
|
||||
// Maybe this is common in other mods, possibly could generalize this transformation further if it comes up more.
|
||||
if (ain instanceof FieldInsnNode fin && fin.getOpcode() == Opcodes.GETSTATIC && fin.name.equals("renderPass")) {
|
||||
MethodInsnNode getRenderPass = new MethodInsnNode(Opcodes.INVOKESTATIC, "net/minecraftforge/client/ForgeHooksClient", "getWorldRenderPass", "()I");
|
||||
mn.instructions.insert(fin, getRenderPass);
|
||||
mn.instructions.remove(fin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void transformClientUtils(ClassNode cn) {
|
||||
for (MethodNode mn : cn.methods) {
|
||||
// This patches an if (world != null) check to just be if (false) in order to make the block of code not run
|
||||
// The block of code in question calls OpenGL to update the lightmap texture coordinates, which is illegal from an ISBRH
|
||||
// in Angelica. It doesn't seem to make anything not work by causing this to not happen.
|
||||
if (mn.name.equals("renderStaticWavefrontModelWithIcon") || mn.name.equals("renderStaticWavefrontModel")) {
|
||||
if (
|
||||
mn.desc.equals("(Lnet/minecraft/world/IBlockAccess;IIILnet/minecraftforge/client/model/obj/WavefrontObject;Lnet/minecraft/util/IIcon;Lnet/minecraft/client/renderer/Tessellator;Lblusunrize/immersiveengineering/common/util/chickenbones/Matrix4;Lblusunrize/immersiveengineering/common/util/chickenbones/Matrix4;IZFFF[Ljava/lang/String;)V")
|
||||
|| mn.desc.equals("(Lnet/minecraft/world/IBlockAccess;IIILnet/minecraftforge/client/model/obj/WavefrontObject;Lnet/minecraft/client/renderer/Tessellator;Lblusunrize/immersiveengineering/common/util/chickenbones/Matrix4;Lblusunrize/immersiveengineering/common/util/chickenbones/Matrix4;IZFFF[Ljava/lang/String;)V")
|
||||
) {
|
||||
for (int i = 0; i < mn.instructions.size(); i++) {
|
||||
AbstractInsnNode ain = mn.instructions.get(i);
|
||||
if (ain instanceof JumpInsnNode jump && jump.getOpcode() == Opcodes.IFNULL) {
|
||||
InsnNode iconst = new InsnNode(Opcodes.ICONST_0);
|
||||
jump.setOpcode(Opcodes.IFEQ);
|
||||
mn.instructions.insertBefore(jump, iconst);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
package com.gtnewhorizons.angelica.transform.compat.transformers.specific;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import org.spongepowered.asm.lib.ClassReader;
|
||||
import org.spongepowered.asm.lib.ClassWriter;
|
||||
import org.spongepowered.asm.lib.Opcodes;
|
||||
import org.spongepowered.asm.lib.tree.AbstractInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.lib.tree.FieldInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.FieldNode;
|
||||
import org.spongepowered.asm.lib.tree.InsnList;
|
||||
import org.spongepowered.asm.lib.tree.InsnNode;
|
||||
import org.spongepowered.asm.lib.tree.LabelNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.MethodNode;
|
||||
import org.spongepowered.asm.lib.tree.TypeInsnNode;
|
||||
import org.spongepowered.asm.lib.tree.VarInsnNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class StacksOnStacksTransformer implements IClassTransformer {
|
||||
|
||||
private static final String RenderTilePile = "com.tierzero.stacksonstacks.client.render.RenderTilePile";
|
||||
private static final List<String> staticRemovers = ImmutableList.of("ingotRender", "gemRender", "dustRender");
|
||||
|
||||
private static final String ClientUtils = "com.tierzero.stacksonstacks.util.ClientUtils";
|
||||
|
||||
@Override
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if (basicClass == null) return null;
|
||||
|
||||
if (!transformedName.equals(RenderTilePile) && !transformedName.equals(ClientUtils)) return basicClass;
|
||||
|
||||
final ClassReader cr = new ClassReader(basicClass);
|
||||
final ClassNode cn = new ClassNode();
|
||||
cr.accept(cn, 0);
|
||||
|
||||
if (transformedName.equals(RenderTilePile)) {
|
||||
transformRenderTilePile(cn);
|
||||
} else {
|
||||
transformClientUtils(cn);
|
||||
}
|
||||
|
||||
ClassWriter cw = new ClassWriter(0);
|
||||
cn.accept(cw);
|
||||
final byte[] bytes = cw.toByteArray();
|
||||
AngelicaTweaker.LOGGER.info("[AngelicaCompat]Extra Transformers: Applied StacksOnStacksTransformer");
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Injects initializers for the field level PileRender objects which used to be static into the <init>
|
||||
*/
|
||||
private static InsnList buildPilerRenderInitializer(String type) {
|
||||
LabelNode start = new LabelNode();
|
||||
LabelNode end = new LabelNode();
|
||||
InsnList list = new InsnList();
|
||||
list.add(start);
|
||||
list.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
list.add(new TypeInsnNode(Opcodes.NEW, "com/tierzero/stacksonstacks/client/render/PileRender" + type));
|
||||
list.add(new InsnNode(Opcodes.DUP));
|
||||
list.add(
|
||||
new MethodInsnNode(
|
||||
Opcodes.INVOKESPECIAL,
|
||||
"com/tierzero/stacksonstacks/client/render/PileRender" + type,
|
||||
"<init>",
|
||||
"()V"));
|
||||
list.add(
|
||||
new FieldInsnNode(
|
||||
Opcodes.PUTFIELD,
|
||||
"com/tierzero/stacksonstacks/client/render/RenderTilePile",
|
||||
type.toLowerCase() + "Render",
|
||||
"Lcom/tierzero/stacksonstacks/client/render/PileRender;"));
|
||||
list.add(end);
|
||||
return list;
|
||||
}
|
||||
|
||||
private static void transformRenderTilePile(ClassNode cn) {
|
||||
MethodNode clinit = null;
|
||||
for (MethodNode mn : cn.methods) {
|
||||
// Handles injecting field initializers for the various PileRender fields which used to be static
|
||||
// but we're removing <clinit> entirely and doing the initialization in <init>
|
||||
if (mn.name.equals("<init>")) {
|
||||
AbstractInsnNode objectInsn = null;
|
||||
// This removes the early return, and gets a reference to the self initialization so we can insert after
|
||||
for (int i = 0; i < mn.instructions.size(); i++) {
|
||||
AbstractInsnNode ain = mn.instructions.get(i);
|
||||
if (ain.getOpcode() == Opcodes.RETURN) mn.instructions.remove(ain);
|
||||
if (ain.getOpcode() == Opcodes.INVOKESPECIAL) objectInsn = mn.instructions.get(i);
|
||||
}
|
||||
// Build the initializer InsnLists and then insert them in reverse order, such that the dustRender comes
|
||||
// last
|
||||
// because we are adding the return opcode back in as part of that one's InsnList
|
||||
InsnList ingotRender = buildPilerRenderInitializer("Ingot");
|
||||
InsnList gemRender = buildPilerRenderInitializer("Gem");
|
||||
InsnList dustRender = buildPilerRenderInitializer("Dust");
|
||||
dustRender.add(new InsnNode(Opcodes.RETURN));
|
||||
mn.instructions.insert(objectInsn, dustRender);
|
||||
mn.instructions.insert(objectInsn, gemRender);
|
||||
mn.instructions.insert(objectInsn, ingotRender);
|
||||
}
|
||||
// Just catching the MethodNode for <clinit> so we can remove it later after we're done iterating
|
||||
if (mn.name.equals("<clinit>")) {
|
||||
clinit = mn;
|
||||
}
|
||||
if (mn.name.equals("renderWorldBlock")) {
|
||||
for (int i = 0; i < mn.instructions.size(); i++) {
|
||||
AbstractInsnNode in = mn.instructions.get(i);
|
||||
// This part removes the GETSTATIC for the field level PileRender objects which used to be static,
|
||||
// and replaces them with
|
||||
// a non-static GETFIELD
|
||||
if (in instanceof FieldInsnNode fin) {
|
||||
if (fin.getOpcode() == Opcodes.GETSTATIC && staticRemovers.contains(fin.name)) {
|
||||
FieldInsnNode nonStatic = new FieldInsnNode(
|
||||
Opcodes.GETFIELD,
|
||||
"com/tierzero/stacksonstacks/client/render/RenderTilePile",
|
||||
fin.name,
|
||||
"Lcom/tierzero/stacksonstacks/client/render/PileRender;");
|
||||
mn.instructions.insertBefore(fin, new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
mn.instructions.insertBefore(fin, nonStatic);
|
||||
mn.instructions.remove(fin);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove clinit after iterating. Nothing else happens in here besides the field initialization, so no reason to
|
||||
// drill down
|
||||
// into the instructions
|
||||
if (clinit != null) cn.methods.remove(clinit);
|
||||
|
||||
// Remove the static access bits from the desired field names
|
||||
for (FieldNode fn : cn.fields) {
|
||||
if (staticRemovers.contains(fn.name)) {
|
||||
fn.access = fn.access & (~Opcodes.ACC_STATIC);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void transformClientUtils(ClassNode cn) {
|
||||
// Various things throughout the ISBRH call these functions which in turn call GL11.glPush/PopMatrix
|
||||
// Upon checking, these aren't called anywhere but in the ISBRH, and they're entirely unnecessary in there.
|
||||
// This just makes the methods no-op, since they aren't required by any other part of the mod to be working.
|
||||
for (MethodNode mn : cn.methods) {
|
||||
if (mn.name.equals("pushMatrix")) {
|
||||
for (int i = 0; i < mn.instructions.size(); i++) {
|
||||
AbstractInsnNode in = mn.instructions.get(i);
|
||||
if (in.getOpcode() == Opcodes.INVOKESTATIC) {
|
||||
mn.instructions.remove(in);
|
||||
}
|
||||
}
|
||||
} else if (mn.name.equals("popMatrix")) {
|
||||
for (int i = 0; i < mn.instructions.size(); i++) {
|
||||
AbstractInsnNode in = mn.instructions.get(i);
|
||||
if (in.getOpcode() == Opcodes.INVOKESTATIC) {
|
||||
mn.instructions.remove(in);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.gtnewhorizons.angelica.zoom;
|
||||
|
||||
public interface IMouseFilterExt {
|
||||
void angelica$reset();
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.gtnewhorizons.angelica.zoom;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.InputEvent;
|
||||
import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
public class Zoom {
|
||||
|
||||
@Getter
|
||||
private static float zoom = 4.0F;
|
||||
@Getter
|
||||
private static final KeyBinding zoomKey = new KeyBinding("Zoom", 0, "key.categories.misc");
|
||||
|
||||
public static final float ZOOM_MIN = 1.0F;
|
||||
public static final float ZOOM_MAX = 64.0F;
|
||||
public static final float ZOOM_STEP = 1.2F;
|
||||
|
||||
private static boolean lastSmoothCameraState = false;
|
||||
|
||||
public static void init() {
|
||||
ClientRegistry.registerKeyBinding(zoomKey);
|
||||
FMLCommonHandler.instance().bus().register(new Zoom());
|
||||
}
|
||||
|
||||
public static void modifyZoom(int eventDWheel) {
|
||||
if (eventDWheel == 0) return;
|
||||
zoom = MathHelper.clamp_float((float) (zoom * Math.pow(ZOOM_STEP, Integer.signum(eventDWheel))), ZOOM_MIN, ZOOM_MAX);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onKeyPress(InputEvent.KeyInputEvent e) {
|
||||
final int keyCode = zoomKey.getKeyCode();
|
||||
if (keyCode == 0 || Keyboard.getEventKey() != keyCode || Keyboard.isRepeatEvent()) return;
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (Keyboard.getEventKeyState()) {
|
||||
lastSmoothCameraState = mc.gameSettings.smoothCamera;
|
||||
mc.gameSettings.smoothCamera = true;
|
||||
} else {
|
||||
zoom = 4.0F;
|
||||
if (mc.gameSettings.smoothCamera != lastSmoothCameraState) {
|
||||
((IMouseFilterExt) mc.entityRenderer.mouseFilterXAxis).angelica$reset();
|
||||
((IMouseFilterExt) mc.entityRenderer.mouseFilterYAxis).angelica$reset();
|
||||
}
|
||||
mc.gameSettings.smoothCamera = lastSmoothCameraState;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ public enum AsmTransformers {
|
||||
.isClient());
|
||||
}
|
||||
|
||||
public static String[] getTransformers() {
|
||||
public static List<String> getTransformers() {
|
||||
final List<String> list = new ArrayList<>();
|
||||
for (AsmTransformers transformer : values()) {
|
||||
if (transformer.shouldBeLoaded()) {
|
||||
@@ -55,7 +55,7 @@ public enum AsmTransformers {
|
||||
AngelicaTweaker.LOGGER.info("Not loading transformer {}", (Object[]) transformer.transformerClasses);
|
||||
}
|
||||
}
|
||||
return list.toArray(new String[0]);
|
||||
return list;
|
||||
}
|
||||
|
||||
private enum Side {
|
||||
|
||||
@@ -2,6 +2,7 @@ package jss.notfine.asm;
|
||||
|
||||
import static jss.notfine.asm.ASMUtils.matchesNodeSequence;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
@@ -32,9 +33,10 @@ public class RenderBlocksTransformer implements IClassTransformer {
|
||||
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if ("net.minecraft.client.renderer.RenderBlocks".equals(transformedName)) {
|
||||
return patchRenderBlocks(basicClass);
|
||||
final byte[] bytes = patchRenderBlocks(basicClass);
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package jss.notfine.asm;
|
||||
|
||||
import static jss.notfine.asm.ASMUtils.matchesNodeSequence;
|
||||
|
||||
import com.gtnewhorizons.angelica.loading.AngelicaTweaker;
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -26,9 +27,10 @@ public class WorldRendererTransformer implements IClassTransformer {
|
||||
|
||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||
if ("net.minecraft.client.renderer.WorldRenderer".equals(transformedName)) {
|
||||
return patchWorldRenderer(basicClass);
|
||||
final byte[] bytes = patchWorldRenderer(basicClass);
|
||||
AngelicaTweaker.dumpClass(transformedName, basicClass, bytes, this);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
return basicClass;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,9 +50,6 @@ public class Namer {
|
||||
final boolean obfuscated = !(Boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
|
||||
AngelicaTweaker.LOGGER.info("Environment obfuscated: {}", obfuscated);
|
||||
if (obfuscated) {
|
||||
// due to mixin bug we can't use sortingIndex meaning we will run too early to use srg
|
||||
// new NamerSrg().setNames();
|
||||
//TODO: check if this is still the case in Angelica
|
||||
new NamerObf().setNames();
|
||||
} else {
|
||||
new NamerMcp().setNames();
|
||||
|
||||
@@ -51,7 +51,13 @@ public enum Settings {
|
||||
DYNAMIC_LIGHTS(new NotFineOptionCycling(DynamicLightsMode.FANCY, OptionImpact.VARIES)){
|
||||
@Override
|
||||
public void applyChanges() {
|
||||
DynamicLights.Mode = (DynamicLightsMode) DYNAMIC_LIGHTS.option.getStore();
|
||||
DynamicLights.Mode = (DynamicLightsMode) this.option.getStore();
|
||||
}
|
||||
},
|
||||
DYNAMIC_LIGHTS_SHADER_FORCE(new NotFineOptionTickBox(false, OptionImpact.VARIES)){
|
||||
@Override
|
||||
public void applyChanges() {
|
||||
DynamicLights.ShaderForce = (boolean) this.option.getStore();
|
||||
}
|
||||
},
|
||||
FOG_NEAR_DISTANCE(new NotFineOptionSliderPercentage(75, 1, 100, 1, OptionImpact.LOW)),
|
||||
|
||||
@@ -191,6 +191,7 @@ public class NotFineGameOptionPages {
|
||||
.add(Settings.DOWNFALL_DISTANCE.option)
|
||||
.add(Settings.MODE_VIGNETTE.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS.option, AngelicaConfig.enableDynamicLights)
|
||||
.add(Settings.DYNAMIC_LIGHTS_SHADER_FORCE.option, AngelicaConfig.enableDynamicLights)
|
||||
.add(Settings.MODE_SHADOWS.option)
|
||||
.add(Settings.VOID_FOG.option)
|
||||
.add(Settings.MODE_DROPPED_ITEMS.option)
|
||||
|
||||
@@ -17,7 +17,7 @@ public class SodiumDebugScreenHandler {
|
||||
public void onRenderGameOverlayTextEvent(RenderGameOverlayEvent.Text event) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.gameSettings.showDebugInfo) {
|
||||
event.right.add(2, "Off-Heap: +" + ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getUsed() / 1024L / 1024L + "MB");
|
||||
event.right.add(Math.min(event.right.size(), 2), "Off-Heap: +" + ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage().getUsed() / 1024L / 1024L + "MB");
|
||||
|
||||
event.right.add("");
|
||||
event.right.add("Sodium (Embeddium) Renderer");
|
||||
|
||||
@@ -19,6 +19,7 @@ import me.jellysquid.mods.sodium.client.gui.options.named.GraphicsMode;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.named.GraphicsQuality;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.named.LightingQuality;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.named.ParticleMode;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.storage.AngelicaOptionsStorage;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.storage.MinecraftOptionsStorage;
|
||||
import me.jellysquid.mods.sodium.client.gui.options.storage.SodiumOptionsStorage;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw.MultidrawChunkRenderBackend;
|
||||
@@ -36,6 +37,7 @@ import java.util.List;
|
||||
public class SodiumGameOptionPages {
|
||||
private static final SodiumOptionsStorage sodiumOpts = new SodiumOptionsStorage();
|
||||
private static final MinecraftOptionsStorage vanillaOpts = new MinecraftOptionsStorage();
|
||||
private static final AngelicaOptionsStorage angelicaOpts = new AngelicaOptionsStorage();
|
||||
|
||||
public static OptionPage general() {
|
||||
final List<OptionGroup> groups = new ArrayList<>();
|
||||
@@ -153,6 +155,15 @@ public class SodiumGameOptionPages {
|
||||
.add(Settings.DYNAMIC_FOV.option)
|
||||
.add(Settings.MODE_WATER.option)
|
||||
.add(Settings.MODE_DROPPED_ITEMS.option)
|
||||
.add(
|
||||
OptionImpl.createBuilder(int.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.droppedItemLimit"))
|
||||
.setTooltip(I18n.format("options.angelica.droppedItemLimit.tooltip"))
|
||||
.setControl(option -> new SliderControl(option, 32, 2048, 32, ControlValueFormatter.droppedItemLimitLimit()))
|
||||
.setBinding((options, value) -> AngelicaConfig.droppedItemLimit = value, options -> AngelicaConfig.droppedItemLimit)
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.build()
|
||||
)
|
||||
.build());
|
||||
|
||||
return new OptionPage(I18n.format("stat.generalButton"), ImmutableList.copyOf(groups));
|
||||
@@ -232,6 +243,7 @@ public class SodiumGameOptionPages {
|
||||
.add(Settings.MODE_SHADOWS.option)
|
||||
.add(Settings.MODE_VIGNETTE.option)
|
||||
.add(Settings.DYNAMIC_LIGHTS.option, AngelicaConfig.enableDynamicLights)
|
||||
.add(Settings.DYNAMIC_LIGHTS_SHADER_FORCE.option, AngelicaConfig.enableDynamicLights)
|
||||
.build());
|
||||
|
||||
|
||||
@@ -246,7 +258,7 @@ public class SodiumGameOptionPages {
|
||||
.build())
|
||||
.build());
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.MODE_GLINT_INV.option)
|
||||
.add(Settings.MODE_GLINT_INV.option)
|
||||
.add(Settings.MODE_GLINT_WORLD.option)
|
||||
.build());
|
||||
|
||||
@@ -360,6 +372,17 @@ public class SodiumGameOptionPages {
|
||||
)
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(OptionImpl.createBuilder(int.class, angelicaOpts)
|
||||
.setName(I18n.format("options.angelica.itemdisplaylistcount"))
|
||||
.setTooltip(I18n.format("options.angelica.itemdisplaylistcount.tooltip"))
|
||||
.setControl(o -> new SliderControl(o, 0, 1024, 1, ControlValueFormatter.number()))
|
||||
.setImpact(OptionImpact.MEDIUM)
|
||||
.setBinding((opts, value) -> AngelicaConfig.itemRendererDisplayListCacheSize = value, options -> AngelicaConfig.itemRendererDisplayListCacheSize)
|
||||
.build()
|
||||
)
|
||||
.build());
|
||||
|
||||
groups.add(OptionGroup.createBuilder()
|
||||
.add(Settings.MODE_GUI_BACKGROUND.option)
|
||||
.add(Settings.GUI_BACKGROUND.option)
|
||||
|
||||
+3
@@ -10,6 +10,9 @@ public interface ControlValueFormatter {
|
||||
static ControlValueFormatter fpsLimit() {
|
||||
return (v) -> (v == 260) ? I18n.format("options.framerateLimit.max") : I18n.format("options.framerate", v);
|
||||
}
|
||||
static ControlValueFormatter droppedItemLimitLimit() {
|
||||
return (v) -> (v == 2048) ? I18n.format("options.droppedItems.max") : I18n.format("options.droppedItems", v);
|
||||
}
|
||||
|
||||
static ControlValueFormatter brightness() {
|
||||
return (v) -> {
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package me.jellysquid.mods.sodium.client.gui.options.storage;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import me.jellysquid.mods.sodium.client.SodiumClientMod;
|
||||
|
||||
public class AngelicaOptionsStorage implements OptionStorage<AngelicaConfig> {
|
||||
|
||||
public AngelicaOptionsStorage() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AngelicaConfig getData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
ConfigurationManager.save(AngelicaConfig.class);
|
||||
SodiumClientMod.logger().info("Flushed changes to Angelica configuration");
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -25,6 +25,6 @@ public class SodiumOptionsStorage implements OptionStorage<SodiumGameOptions> {
|
||||
throw new RuntimeException("Couldn't save configuration changes", e);
|
||||
}
|
||||
|
||||
SodiumClientMod.logger().info("Flushed changes to Rubidium configuration");
|
||||
SodiumClientMod.logger().info("Flushed changes to Angelica configuration");
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@ import me.jellysquid.mods.sodium.client.render.chunk.backends.multidraw.Multidra
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.backends.oneshot.ChunkRenderBackendOneshot;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderData;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.format.DefaultModelVertexFormats;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.map.ChunkTracker;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.map.ChunkTrackerHolder;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import me.jellysquid.mods.sodium.client.render.pipeline.context.ChunkRenderCacheShared;
|
||||
import me.jellysquid.mods.sodium.client.util.math.FrustumExtended;
|
||||
@@ -59,7 +61,7 @@ import java.util.Set;
|
||||
/**
|
||||
* Provides an extension to vanilla's {@link WorldRenderer}.
|
||||
*/
|
||||
public class SodiumWorldRenderer implements ChunkStatusListener {
|
||||
public class SodiumWorldRenderer {
|
||||
private static SodiumWorldRenderer instance;
|
||||
|
||||
private final Minecraft client;
|
||||
@@ -155,7 +157,6 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
|
||||
this.chunkRenderBackend = null;
|
||||
}
|
||||
|
||||
this.loadedChunkPositions.clear();
|
||||
this.globalTileEntities.clear();
|
||||
|
||||
this.world = null;
|
||||
@@ -194,6 +195,8 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
|
||||
public void updateChunks(Camera camera, Frustrum frustum, boolean hasForcedFrustum, int frame, boolean spectator) {
|
||||
this.frustum = frustum;
|
||||
|
||||
this.processChunkEvents();
|
||||
|
||||
this.useEntityCulling = SodiumClientMod.options().advanced.useEntityCulling;
|
||||
|
||||
if (this.client.gameSettings.renderDistanceChunks != this.renderDistance) {
|
||||
@@ -265,6 +268,11 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void processChunkEvents() {
|
||||
var tracker = ChunkTrackerHolder.get(this.world);
|
||||
tracker.forEachEvent(this.chunkRenderManager::onChunkAdded, this.chunkRenderManager::onChunkRemoved);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a render pass for the given {@link RenderLayer} and draws all visible chunks for it.
|
||||
*/
|
||||
@@ -324,7 +332,9 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
|
||||
this.chunkRenderBackend.createShaders(device);
|
||||
|
||||
this.chunkRenderManager = new ChunkRenderManager<>(this, this.chunkRenderBackend, this.world, this.renderDistance);
|
||||
this.chunkRenderManager.restoreChunks(this.loadedChunkPositions);
|
||||
|
||||
var tracker = ChunkTrackerHolder.get(this.world);
|
||||
ChunkTracker.forEachChunk(tracker.getReadyChunks(), this.chunkRenderManager::onChunkAdded);
|
||||
}
|
||||
|
||||
private static ChunkRenderBackend<?> createChunkRenderBackend(RenderDevice device, SodiumGameOptions options, ChunkVertexType vertexFormat) {
|
||||
@@ -379,18 +389,6 @@ public class SodiumWorldRenderer implements ChunkStatusListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkAdded(int x, int z) {
|
||||
this.loadedChunkPositions.add(ChunkPos.toLong(x, z));
|
||||
this.chunkRenderManager.onChunkAdded(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkRemoved(int x, int z) {
|
||||
this.loadedChunkPositions.remove(ChunkPos.toLong(x, z));
|
||||
this.chunkRenderManager.onChunkRemoved(x, z);
|
||||
}
|
||||
|
||||
public void onChunkRenderUpdated(int x, int y, int z, ChunkRenderData meshBefore, ChunkRenderData meshAfter) {
|
||||
ListUtil.updateList(this.globalTileEntities, meshBefore.getGlobalTileEntities(), meshAfter.getGlobalTileEntities());
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.map;
|
||||
|
||||
public class ChunkStatus {
|
||||
public static final int FLAG_HAS_BLOCK_DATA = 1;
|
||||
public static final int FLAG_HAS_LIGHT_DATA = 2;
|
||||
public static final int FLAG_ALL = FLAG_HAS_BLOCK_DATA | FLAG_HAS_LIGHT_DATA;
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.map;
|
||||
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongCollection;
|
||||
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||
import it.unimi.dsi.fastutil.longs.LongSets;
|
||||
import net.minecraft.world.ChunkCoordIntPair;
|
||||
|
||||
public class ChunkTracker implements ClientChunkEventListener {
|
||||
private final Long2IntOpenHashMap chunkStatus = new Long2IntOpenHashMap();
|
||||
private final LongOpenHashSet chunkReady = new LongOpenHashSet();
|
||||
|
||||
private final LongSet unloadQueue = new LongOpenHashSet();
|
||||
private final LongSet loadQueue = new LongOpenHashSet();
|
||||
|
||||
public ChunkTracker() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateMapCenter(int chunkX, int chunkZ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLoadDistance(int loadDistance) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkStatusAdded(int x, int z, int flags) {
|
||||
var key = ChunkCoordIntPair.chunkXZ2Int(x, z);
|
||||
|
||||
var prev = this.chunkStatus.get(key);
|
||||
var cur = prev | flags;
|
||||
|
||||
if (prev == cur) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.chunkStatus.put(key, cur);
|
||||
|
||||
this.updateNeighbors(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkStatusRemoved(int x, int z, int flags) {
|
||||
var key = ChunkCoordIntPair.chunkXZ2Int(x, z);
|
||||
|
||||
var prev = this.chunkStatus.get(key);
|
||||
int cur = prev & ~flags;
|
||||
|
||||
if (prev == cur) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cur == this.chunkStatus.defaultReturnValue()) {
|
||||
this.chunkStatus.remove(key);
|
||||
} else {
|
||||
this.chunkStatus.put(key, cur);
|
||||
}
|
||||
|
||||
this.updateNeighbors(x, z);
|
||||
}
|
||||
|
||||
private void updateNeighbors(int x, int z) {
|
||||
for (int ox = -1; ox <= 1; ox++) {
|
||||
for (int oz = -1; oz <= 1; oz++) {
|
||||
this.updateMerged(ox + x, oz + z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMerged(int x, int z) {
|
||||
long key = ChunkCoordIntPair.chunkXZ2Int(x, z);
|
||||
|
||||
int flags = this.chunkStatus.get(key);
|
||||
|
||||
for (int ox = -1; ox <= 1; ox++) {
|
||||
for (int oz = -1; oz <= 1; oz++) {
|
||||
flags &= this.chunkStatus.get(ChunkCoordIntPair.chunkXZ2Int(ox + x, oz + z));
|
||||
}
|
||||
}
|
||||
|
||||
if (flags == ChunkStatus.FLAG_ALL) {
|
||||
if (this.chunkReady.add(key) && !this.unloadQueue.remove(key)) {
|
||||
this.loadQueue.add(key);
|
||||
}
|
||||
} else {
|
||||
if (this.chunkReady.remove(key) && !this.loadQueue.remove(key)) {
|
||||
this.unloadQueue.add(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public LongCollection getReadyChunks() {
|
||||
return LongSets.unmodifiable(this.chunkReady);
|
||||
}
|
||||
|
||||
public void forEachEvent(ChunkEventHandler loadEventHandler, ChunkEventHandler unloadEventHandler) {
|
||||
forEachChunk(this.unloadQueue, unloadEventHandler);
|
||||
this.unloadQueue.clear();
|
||||
|
||||
forEachChunk(this.loadQueue, loadEventHandler);
|
||||
this.loadQueue.clear();
|
||||
}
|
||||
|
||||
public static void forEachChunk(LongCollection queue, ChunkEventHandler handler) {
|
||||
var iterator = queue.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
var pos = iterator.nextLong();
|
||||
|
||||
var x = (int)(pos & 4294967295L);
|
||||
var z = (int)((pos >> 32L) & 4294967295L);
|
||||
|
||||
handler.apply(x, z);
|
||||
}
|
||||
}
|
||||
|
||||
public interface ChunkEventHandler {
|
||||
void apply(int x, int z);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.map;
|
||||
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
|
||||
public interface ChunkTrackerHolder {
|
||||
static ChunkTracker get(WorldClient world) {
|
||||
return ((ChunkTrackerHolder) world).sodium$getTracker();
|
||||
}
|
||||
|
||||
ChunkTracker sodium$getTracker();
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.map;
|
||||
|
||||
public interface ClientChunkEventListener {
|
||||
void updateMapCenter(int chunkX, int chunkZ);
|
||||
|
||||
void updateLoadDistance(int loadDistance);
|
||||
|
||||
void onChunkStatusAdded(int x, int z, int flags);
|
||||
void onChunkStatusRemoved(int x, int z, int flags);
|
||||
}
|
||||
+25
-5
@@ -1,7 +1,9 @@
|
||||
package me.jellysquid.mods.sodium.client.render.chunk.tasks;
|
||||
|
||||
import com.gtnewhorizon.gtnhlib.blockpos.BlockPos;
|
||||
import com.gtnewhorizon.gtnhlib.client.renderer.util.WorldUtil;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.ChunkOcclusionDataBuilder;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.RenderLayer;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache;
|
||||
import com.gtnewhorizons.angelica.rendering.AngelicaBlockSafetyRegistry;
|
||||
@@ -22,6 +24,7 @@ import me.jellysquid.mods.sodium.client.util.MathUtil;
|
||||
import me.jellysquid.mods.sodium.client.util.task.CancellationSource;
|
||||
import me.jellysquid.mods.sodium.client.world.WorldSlice;
|
||||
import me.jellysquid.mods.sodium.client.world.cloned.ChunkRenderContext;
|
||||
import net.coderbot.iris.block_rendering.BlockRenderingSettings;
|
||||
import net.coderbot.iris.vertices.ExtendedDataHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
@@ -32,9 +35,9 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@@ -104,6 +107,19 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canRenderInPass(Block block, BlockRenderPass pass) {
|
||||
boolean canRender = block.canRenderInPass(pass.ordinal());
|
||||
Map<Block, RenderLayer> blockTypeIds = BlockRenderingSettings.INSTANCE.getBlockTypeIds();
|
||||
RenderLayer renderLayer;
|
||||
if (blockTypeIds != null && (renderLayer = blockTypeIds.get(block)) != null) {
|
||||
canRender = switch (pass) {
|
||||
case CUTOUT_MIPPED -> renderLayer == RenderLayer.cutout();
|
||||
case TRANSLUCENT -> renderLayer == RenderLayer.translucent();
|
||||
};
|
||||
}
|
||||
return canRender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkBuildResult<T> performBuild(ChunkRenderCacheLocal cache, ChunkBuildBuffers buffers, CancellationSource cancellationSource) {
|
||||
final ChunkRenderData.Builder renderData = new ChunkRenderData.Builder();
|
||||
@@ -153,7 +169,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
if (rendersOffThread(block)) {
|
||||
// Do regular block rendering
|
||||
for (BlockRenderPass pass : BlockRenderPass.VALUES) {
|
||||
if (block.canRenderInPass(pass.ordinal()) && (!AngelicaConfig.enableSodiumFluidRendering || !(block instanceof IFluidBlock))) {
|
||||
if (canRenderInPass(block, pass) && !shouldUseSodiumFluidRendering(block)) {
|
||||
ChunkRenderManager.setWorldRenderPass(pass);
|
||||
final long seed = MathUtil.hashPos(pos.x, pos.y, pos.z);
|
||||
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(block, ExtendedDataHelper.BLOCK_RENDER_TYPE);
|
||||
@@ -169,9 +185,9 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
}
|
||||
|
||||
// Do fluid rendering without RenderBlocks
|
||||
if (AngelicaConfig.enableSodiumFluidRendering && block instanceof IFluidBlock) {
|
||||
if (shouldUseSodiumFluidRendering(block)) {
|
||||
for (BlockRenderPass pass : BlockRenderPass.VALUES) {
|
||||
if (block.canRenderInPass(pass.ordinal())) {
|
||||
if (canRenderInPass(block, pass)) {
|
||||
ChunkRenderManager.setWorldRenderPass(pass);
|
||||
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(block, ExtendedDataHelper.FLUID_RENDER_TYPE);
|
||||
|
||||
@@ -273,7 +289,7 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
|
||||
// Do regular block rendering
|
||||
for (BlockRenderPass pass : BlockRenderPass.VALUES) {
|
||||
if (block.canRenderInPass(pass.ordinal()) && (!AngelicaConfig.enableSodiumFluidRendering || !(block instanceof IFluidBlock))) {
|
||||
if (canRenderInPass(block, pass) && !shouldUseSodiumFluidRendering(block)) {
|
||||
ChunkRenderManager.setWorldRenderPass(pass);
|
||||
final long seed = MathUtil.hashPos(pos.x, pos.y, pos.z);
|
||||
if(AngelicaConfig.enableIris) buffers.iris$setMaterialId(block, ExtendedDataHelper.BLOCK_RENDER_TYPE);
|
||||
@@ -306,4 +322,8 @@ public class ChunkRenderRebuildTask<T extends ChunkGraphicsState> extends ChunkR
|
||||
+ translucencySorting
|
||||
+ '}';
|
||||
}
|
||||
|
||||
private static boolean shouldUseSodiumFluidRendering(Block block) {
|
||||
return AngelicaConfig.enableSodiumFluidRendering && WorldUtil.isFluidBlock(block);
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -96,7 +95,8 @@ public class FluidRenderer {
|
||||
int posY = pos.y;
|
||||
int posZ = pos.z;
|
||||
|
||||
Fluid fluid = ((IFluidBlock) block).getFluid();
|
||||
|
||||
Fluid fluid = WorldUtil.getFluid(block);
|
||||
if (fluid == null) return false;
|
||||
|
||||
// Check for occluded sides; if everything is occluded, don't render
|
||||
@@ -437,7 +437,7 @@ public class FluidRenderer {
|
||||
|
||||
Block block = world.getBlock(x2, y + 1, z2);
|
||||
|
||||
if (block instanceof IFluidBlock && ((IFluidBlock) block).getFluid() == fluid) {
|
||||
if (WorldUtil.getFluid(block) == fluid) {
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
@@ -445,7 +445,7 @@ public class FluidRenderer {
|
||||
|
||||
block = world.getBlock(pos.x, pos.y, pos.z);
|
||||
int meta = world.getBlockMetadata(pos.x, pos.y, pos.z);
|
||||
Fluid fluid2 = block instanceof IFluidBlock ? ((IFluidBlock) world.getBlock(pos.x, pos.y, pos.z)).getFluid() : null;
|
||||
Fluid fluid2 = WorldUtil.getFluid(block);
|
||||
|
||||
if (fluid2 == fluid) {
|
||||
float height = WorldUtil.getFluidHeight(fluid2, meta);
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.coderbot.iris.client;
|
||||
|
||||
import com.gtnewhorizons.angelica.AngelicaMod;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.mitchej123.hodgepodge.client.HodgepodgeClient;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.coderbot.iris.Iris;
|
||||
@@ -39,7 +38,7 @@ public class IrisDebugScreenHandler {
|
||||
public void onRenderGameOverlayTextEvent(RenderGameOverlayEvent.Text event) {
|
||||
final Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.gameSettings.showDebugInfo) {
|
||||
event.right.add(2, "Direct Buffers: +" + iris$humanReadableByteCountBin(iris$directPool.getMemoryUsed()));
|
||||
event.right.add(Math.min(event.right.size(), 2), "Direct Buffers: +" + iris$humanReadableByteCountBin(iris$directPool.getMemoryUsed()));
|
||||
|
||||
event.right.add("");
|
||||
|
||||
@@ -49,8 +48,8 @@ public class IrisDebugScreenHandler {
|
||||
} else {
|
||||
event.right.add("[" + Iris.MODNAME + "] Shaders are disabled");
|
||||
}
|
||||
if(AngelicaConfig.speedupAnimations) {
|
||||
event.right.add(9, "animationsMode: " + AngelicaMod.animationsMode);
|
||||
if (AngelicaConfig.speedupAnimations) {
|
||||
event.right.add(Math.min(event.right.size(), 9), "animationsMode: " + AngelicaMod.animationsMode);
|
||||
}
|
||||
|
||||
Iris.getPipelineManager().getPipeline().ifPresent(pipeline -> pipeline.addDebugText(event.left));
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
package net.coderbot.iris.gl.program;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.OptionalInt;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gl.state.ValueUpdateNotifier;
|
||||
import net.coderbot.iris.gl.uniform.DynamicLocationalUniformHolder;
|
||||
@@ -11,20 +19,13 @@ import net.coderbot.iris.gl.uniform.UniformType;
|
||||
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
|
||||
import net.coderbot.iris.uniforms.SystemTimeUniforms;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.ARBShaderImageLoadStore;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
import org.lwjgl.opengl.GL30;
|
||||
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.OptionalInt;
|
||||
|
||||
public class ProgramUniforms {
|
||||
private static ProgramUniforms active;
|
||||
private final ImmutableList<Uniform> perTick;
|
||||
@@ -52,8 +53,11 @@ public class ProgramUniforms {
|
||||
}
|
||||
|
||||
private static long getCurrentTick() {
|
||||
if (Minecraft.getMinecraft().theWorld != null) {
|
||||
return Minecraft.getMinecraft().theWorld.getWorldTime();
|
||||
final WorldClient world = Minecraft.getMinecraft().theWorld;
|
||||
if (world != null) {
|
||||
return AngelicaConfig.useTotalWorldTime
|
||||
? world.getTotalWorldTime()
|
||||
: world.getWorldTime();
|
||||
} else {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.coderbot.iris.gl.shader;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.gtnewhorizons.angelica.Tags;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import net.coderbot.iris.pipeline.HandRenderer;
|
||||
import net.coderbot.iris.pipeline.WorldRenderingPhase;
|
||||
@@ -52,6 +53,8 @@ public class StandardMacros {
|
||||
define(standardDefines, "MC_SPECULAR_MAP");
|
||||
define(standardDefines, "MC_RENDER_QUALITY", "1.0");
|
||||
define(standardDefines, "MC_SHADOW_QUALITY", "1.0");
|
||||
define(standardDefines, "IS_ANGELICA");
|
||||
define(standardDefines, "ANGELICA_VERSION", Tags.VERSION);
|
||||
define(standardDefines, "MC_HAND_DEPTH", Float.toString(HandRenderer.DEPTH));
|
||||
|
||||
TextureFormat textureFormat = TextureFormatLoader.getFormat();
|
||||
|
||||
@@ -108,8 +108,11 @@ public abstract class IrisGuiSlot extends GuiSlot {
|
||||
if (scrolling) {
|
||||
this.amountScrolled += ((float) mouseY - this.initialClickY);
|
||||
this.initialClickY = mouseY;
|
||||
} else {
|
||||
for (; !this.mc.gameSettings.touchscreen && Mouse.next(); this.mc.currentScreen.handleMouseInput()) {
|
||||
} else if (this.mc.currentScreen != null ){
|
||||
while (!this.mc.gameSettings.touchscreen && Mouse.next()) {
|
||||
if(this.mc.currentScreen != null) {
|
||||
this.mc.currentScreen.handleMouseInput();
|
||||
}
|
||||
int dWheel = Mouse.getEventDWheel();
|
||||
|
||||
if (dWheel != 0) {
|
||||
|
||||
@@ -111,6 +111,12 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
}
|
||||
}
|
||||
|
||||
if (hoveredElement != null) {
|
||||
hoveredElementCommentTimer++;
|
||||
} else {
|
||||
hoveredElementCommentTimer = 0;
|
||||
}
|
||||
|
||||
final float previousHoverTimer = this.guiButtonHoverTimer;
|
||||
super.drawScreen(mouseX, mouseY, delta);
|
||||
if (previousHoverTimer == this.guiButtonHoverTimer) {
|
||||
@@ -134,8 +140,10 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
if (this.isDisplayingComment()) {
|
||||
// Determine panel height and position
|
||||
final int panelHeight = Math.max(50, 18 + (this.hoveredElementCommentBody.size() * 10));
|
||||
final int x = (int) (0.5 * this.width) - 157;
|
||||
final int y = this.height - (panelHeight + 4);
|
||||
int x = mouseX + 5;
|
||||
if (x + 314 >= (this.width - 4)) x = this.width - (318);
|
||||
int y = mouseY + 8;
|
||||
if (y + panelHeight >= (this.height - 4)) y = this.height - (panelHeight + 4);
|
||||
// Draw panel
|
||||
GuiUtil.drawPanel(x, y, COMMENT_PANEL_WIDTH, panelHeight);
|
||||
// Draw text
|
||||
@@ -374,6 +382,8 @@ public class ShaderPackScreen extends GuiScreen implements HudHideable {
|
||||
public void applyChanges() {
|
||||
final ShaderPackEntry entry = this.shaderPackList.getSelected();
|
||||
|
||||
if (entry == null) return;
|
||||
|
||||
this.shaderPackList.setApplied(entry);
|
||||
|
||||
final String name = entry.getPackName();
|
||||
|
||||
@@ -2,157 +2,183 @@ package net.coderbot.iris.pipeline;
|
||||
|
||||
import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import com.gtnewhorizons.angelica.compat.mojang.InteractionHand;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
|
||||
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.irisshaders.iris.api.v0.IrisApi;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.glu.Project;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import java.util.Map;
|
||||
|
||||
public class HandRenderer {
|
||||
public static final HandRenderer INSTANCE = new HandRenderer();
|
||||
public static final HandRenderer INSTANCE = new HandRenderer();
|
||||
|
||||
private boolean ACTIVE;
|
||||
private boolean renderingSolid;
|
||||
public static final float DEPTH = 0.125F;
|
||||
private boolean ACTIVE;
|
||||
private boolean renderingSolid;
|
||||
public static final float DEPTH = 0.125F;
|
||||
|
||||
private void setupGlState(RenderGlobal gameRenderer, Camera camera, MatrixStack poseStack, float tickDelta) {
|
||||
// final MatrixStack.Entry pose = poseStack.peek();
|
||||
private void setupGlState(RenderGlobal gameRenderer, Camera camera, float tickDelta) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
// We need to scale the matrix by 0.125 so the hand doesn't clip through blocks.
|
||||
// Matrix4f scaleMatrix = new Matrix4f().scale(1F, 1F, DEPTH);
|
||||
// TODO: ProjectionMatrix
|
||||
// scaleMatrix.multiply(gameRenderer.getProjectionMatrix(camera, tickDelta, false));
|
||||
// scaleMatrix.mul(projectionMatrix);
|
||||
// RenderSystem.matrixMode(5889);
|
||||
// RenderSystem.loadIdentity();
|
||||
// RenderSystem.multMatrix(arg);
|
||||
// RenderSystem.matrixMode(5888);
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glLoadIdentity();
|
||||
// We need to scale the matrix by 0.125 so the hand doesn't clip through blocks.
|
||||
GL11.glScalef(1.0F, 1.0F, DEPTH);
|
||||
|
||||
// pose.getModel().identity();
|
||||
// pose.getNormal().identity();
|
||||
// TODO: Anaglyph
|
||||
/*if (this.mc.gameSettings.anaglyph) {
|
||||
GL11.glTranslatef((float) (-(anaglyphChannel * 2 - 1)) * 0.07F, 0.0F, 0.0F);
|
||||
}*/
|
||||
|
||||
// gameRenderer.invokeBobHurt(poseStack, tickDelta);
|
||||
//
|
||||
// if (Minecraft.getMinecraft().gameSettings.viewBobbing) {
|
||||
//// gameRenderer.invokeBobView(poseStack, tickDelta);
|
||||
// }
|
||||
}
|
||||
if (mc.entityRenderer.cameraZoom != 1.0D) {
|
||||
GL11.glTranslatef((float) mc.entityRenderer.cameraYaw, (float) (-mc.entityRenderer.cameraPitch), 0.0F);
|
||||
GL11.glScaled(mc.entityRenderer.cameraZoom, mc.entityRenderer.cameraZoom, 1.0D);
|
||||
}
|
||||
|
||||
private boolean canRender(Camera camera, RenderGlobal gameRenderer) {
|
||||
return (camera.isThirdPerson() || !(camera.getEntity() instanceof EntityPlayer) || Minecraft.getMinecraft().gameSettings.hideGUI || (camera.getEntity() instanceof EntityLiving && ((EntityLiving)camera.getEntity()).isPlayerSleeping()));
|
||||
Project.gluPerspective(mc.entityRenderer.getFOVModifier(tickDelta, false), (float) mc.displayWidth / (float) mc.displayHeight, 0.05F, mc.entityRenderer.farPlaneDistance * 2.0F);
|
||||
|
||||
// return !(!gameRenderer.getRenderHand()
|
||||
// || camera.isThirdPerson()
|
||||
// || !(camera.getEntity() instanceof EntityPlayer)
|
||||
// || gameRenderer.getPanoramicMode()
|
||||
// || Minecraft.getMinecraft().gameSettings.hideGUI
|
||||
// || (camera.getEntity() instanceof EntityLiving && ((EntityLiving)camera.getEntity()).isPlayerSleeping())
|
||||
// // TODO: SPECTATOR
|
||||
// /*|| Minecraft.getMinecraft().gameMode.getPlayerMode() == GameType.SPECTATOR*/);
|
||||
}
|
||||
|
||||
public boolean isHandTranslucent(InteractionHand hand) {
|
||||
if (mc.playerController.enableEverythingIsScrewedUpMode()) {
|
||||
GL11.glScalef(1.0F, 2 / 3f, 1.0F);
|
||||
}
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
GL11.glLoadIdentity();
|
||||
|
||||
// TODO: Anaglyph
|
||||
/*if (mc.gameSettings.anaglyph) {
|
||||
GL11.glTranslatef((float) (anaglyphChannel * 2 - 1) * 0.1F, 0.0F, 0.0F);
|
||||
}*/
|
||||
|
||||
mc.entityRenderer.hurtCameraEffect(tickDelta);
|
||||
|
||||
if (mc.gameSettings.viewBobbing) {
|
||||
mc.entityRenderer.setupViewBobbing(tickDelta);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canRender(Camera camera, RenderGlobal gameRenderer) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
return mc.entityRenderer.debugViewDirection <= 0 &&
|
||||
mc.gameSettings.thirdPersonView == 0 &&
|
||||
!camera.getEntity().isPlayerSleeping() &&
|
||||
!mc.gameSettings.hideGUI &&
|
||||
// TODO: SPECTATOR
|
||||
// mc.playerController.currentGameType
|
||||
!mc.playerController.enableEverythingIsScrewedUpMode();
|
||||
}
|
||||
|
||||
public boolean isHandTranslucent(InteractionHand hand) {
|
||||
// TODO: Offhand
|
||||
// Item item = Minecraft.getMinecraft().thePlayer.getItemBySlot(hand == InteractionHand.OFF_HAND ? EquipmentSlot.OFFHAND : EquipmentSlot.MAINHAND).getItem();
|
||||
ItemStack heldItem = Minecraft.getMinecraft().thePlayer.getHeldItem();
|
||||
if (heldItem == null) {
|
||||
return false;
|
||||
}
|
||||
Item item = heldItem.getItem();
|
||||
|
||||
if (item instanceof ItemBlock itemBlock) {
|
||||
// TODO: RenderType
|
||||
// return ItemBlockRenderTypes.getChunkRenderType(itemBlock.getBlock().defaultBlockState()) == RenderType.translucent();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Item item = heldItem.getItem();
|
||||
|
||||
return false;
|
||||
}
|
||||
if (item instanceof ItemBlock itemBlock) {
|
||||
Map<Block, RenderLayer> blockTypeIds = BlockRenderingSettings.INSTANCE.getBlockTypeIds();
|
||||
return blockTypeIds != null && blockTypeIds.get(itemBlock.field_150939_a) == RenderLayer.translucent();
|
||||
}
|
||||
|
||||
public boolean isAnyHandTranslucent() {
|
||||
return isHandTranslucent(InteractionHand.MAIN_HAND) || isHandTranslucent(InteractionHand.OFF_HAND);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void renderSolid(MatrixStack poseStack, float tickDelta, Camera camera, RenderGlobal gameRenderer, WorldRenderingPipeline pipeline) {
|
||||
if (!canRender(camera, gameRenderer) || !IrisApi.getInstance().isShaderPackInUse()) {
|
||||
return;
|
||||
}
|
||||
public boolean isAnyHandTranslucent() {
|
||||
return isHandTranslucent(InteractionHand.MAIN_HAND) || isHandTranslucent(InteractionHand.OFF_HAND);
|
||||
}
|
||||
|
||||
ACTIVE = true;
|
||||
public void renderSolid(float tickDelta, Camera camera, RenderGlobal gameRenderer, WorldRenderingPipeline pipeline) {
|
||||
if (!canRender(camera, gameRenderer) || !IrisApi.getInstance().isShaderPackInUse()) {
|
||||
return;
|
||||
}
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
pipeline.setPhase(WorldRenderingPhase.HAND_SOLID);
|
||||
ACTIVE = true;
|
||||
|
||||
// poseStack.push();
|
||||
pipeline.setPhase(WorldRenderingPhase.HAND_SOLID);
|
||||
|
||||
Minecraft.getMinecraft().mcProfiler.startSection("iris_hand");
|
||||
GL11.glPushMatrix();
|
||||
GL11.glDepthMask(true); // actually write to the depth buffer, it's normally disabled at this point
|
||||
|
||||
// TODO: Iris
|
||||
// setupGlState(gameRenderer, camera, poseStack, tickDelta);
|
||||
mc.mcProfiler.startSection("iris_hand");
|
||||
|
||||
renderingSolid = true;
|
||||
// TODO: Hand
|
||||
// Minecraft.getMinecraft().getItemInHandRenderer().renderHandsWithItems(tickDelta, poseStack, bufferSource, Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().getEntityRenderDispatcher().getPackedLightCoords(camera.getEntity(), tickDelta));
|
||||
setupGlState(gameRenderer, camera, tickDelta);
|
||||
|
||||
Minecraft.getMinecraft().mcProfiler.endSection();
|
||||
renderingSolid = true;
|
||||
mc.entityRenderer.enableLightmap(tickDelta);
|
||||
mc.entityRenderer.itemRenderer.renderItemInFirstPerson(tickDelta);
|
||||
mc.entityRenderer.disableLightmap(tickDelta);
|
||||
|
||||
// TODO: ProjectionMatrix
|
||||
// gameRenderer.resetProjectionMatrix(CapturedRenderingState.INSTANCE.getGbufferProjection());
|
||||
GLStateManager.defaultBlendFunc();
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
// poseStack.pop();
|
||||
mc.mcProfiler.endSection();
|
||||
|
||||
// bufferSource.endBatch();
|
||||
resetProjectionMatrix();
|
||||
|
||||
renderingSolid = false;
|
||||
renderingSolid = false;
|
||||
|
||||
pipeline.setPhase(WorldRenderingPhase.NONE);
|
||||
pipeline.setPhase(WorldRenderingPhase.NONE);
|
||||
|
||||
ACTIVE = false;
|
||||
}
|
||||
ACTIVE = false;
|
||||
}
|
||||
|
||||
public void renderTranslucent(MatrixStack poseStack, float tickDelta, Camera camera, RenderGlobal gameRenderer, WorldRenderingPipeline pipeline) {
|
||||
if (!canRender(camera, gameRenderer) || !isAnyHandTranslucent() || !IrisApi.getInstance().isShaderPackInUse()) {
|
||||
return;
|
||||
}
|
||||
// TODO: RenderType
|
||||
public void renderTranslucent(float tickDelta, Camera camera, RenderGlobal gameRenderer, WorldRenderingPipeline pipeline) {
|
||||
if (!canRender(camera, gameRenderer) || !isAnyHandTranslucent() || !IrisApi.getInstance().isShaderPackInUse()) {
|
||||
return;
|
||||
}
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
ACTIVE = true;
|
||||
ACTIVE = true;
|
||||
|
||||
pipeline.setPhase(WorldRenderingPhase.HAND_TRANSLUCENT);
|
||||
pipeline.setPhase(WorldRenderingPhase.HAND_TRANSLUCENT);
|
||||
|
||||
poseStack.push();
|
||||
GL11.glPushMatrix();
|
||||
|
||||
Minecraft.getMinecraft().mcProfiler.startSection("iris_hand_translucent");
|
||||
mc.mcProfiler.startSection("iris_hand_translucent");
|
||||
|
||||
setupGlState(gameRenderer, camera, poseStack, tickDelta);
|
||||
setupGlState(gameRenderer, camera, tickDelta);
|
||||
|
||||
// TODO: Hand
|
||||
// Minecraft.getMinecraft().getItemInHandRenderer().renderHandsWithItems(tickDelta, poseStack, bufferSource, Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().getEntityRenderDispatcher().getPackedLightCoords(camera.getEntity(), tickDelta));
|
||||
mc.entityRenderer.enableLightmap(tickDelta);
|
||||
mc.entityRenderer.itemRenderer.renderItemInFirstPerson(tickDelta);
|
||||
mc.entityRenderer.disableLightmap(tickDelta);
|
||||
|
||||
poseStack.pop();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
Minecraft.getMinecraft().mcProfiler.endSection();
|
||||
resetProjectionMatrix();
|
||||
|
||||
// TODO: ProjectionMatrix
|
||||
// gameRenderer.resetProjectionMatrix(CapturedRenderingState.INSTANCE.getGbufferProjection());
|
||||
Minecraft.getMinecraft().mcProfiler.endSection();
|
||||
|
||||
// bufferSource.endBatch();
|
||||
pipeline.setPhase(WorldRenderingPhase.NONE);
|
||||
|
||||
pipeline.setPhase(WorldRenderingPhase.NONE);
|
||||
ACTIVE = false;
|
||||
}
|
||||
|
||||
ACTIVE = false;
|
||||
}
|
||||
private void resetProjectionMatrix() {
|
||||
GL11.glMatrixMode(GL11.GL_PROJECTION);
|
||||
GL11.glLoadIdentity();
|
||||
GL11.glMultMatrix(RenderingState.INSTANCE.getProjectionBuffer());
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return ACTIVE;
|
||||
}
|
||||
|
||||
public boolean isRenderingSolid() {
|
||||
return renderingSolid;
|
||||
}
|
||||
public boolean isActive() {
|
||||
return ACTIVE;
|
||||
}
|
||||
|
||||
public boolean isRenderingSolid() {
|
||||
return renderingSolid;
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,12 @@ import com.gtnewhorizons.angelica.compat.mojang.Camera;
|
||||
import com.gtnewhorizons.angelica.compat.toremove.MatrixStack;
|
||||
import com.gtnewhorizons.angelica.glsm.GLStateManager;
|
||||
import com.gtnewhorizons.angelica.glsm.RenderSystem;
|
||||
import com.gtnewhorizons.angelica.mixins.interfaces.IRenderGlobalExt;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||
import me.jellysquid.mods.sodium.client.gl.device.RenderDevice;
|
||||
import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer;
|
||||
import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.shaderpack.OptionalBoolean;
|
||||
import net.coderbot.iris.shaderpack.PackDirectives;
|
||||
@@ -27,9 +31,12 @@ import net.coderbot.iris.uniforms.CelestialUniforms;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.client.renderer.EntityRenderer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.culling.Frustrum;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.profiler.Profiler;
|
||||
@@ -349,17 +356,13 @@ public class ShadowRenderer {
|
||||
}
|
||||
|
||||
private void renderEntities(EntityRenderer levelRenderer, Frustrum frustum, Object bufferSource, MatrixStack modelView, double cameraX, double cameraY, double cameraZ, float tickDelta) {
|
||||
// TODO: Render
|
||||
// EntityRenderDispatcher dispatcher = levelRenderer.getEntityRenderDispatcher();
|
||||
|
||||
int shadowEntities = 0;
|
||||
int shadowEntities = 0;
|
||||
|
||||
profiler.startSection("cull");
|
||||
|
||||
List<Entity> renderedEntities = new ArrayList<>(32);
|
||||
|
||||
// TODO: I'm sure that this can be improved / optimized.
|
||||
// TODO: Render
|
||||
// TODO: Entity culling
|
||||
for (Entity entity : getLevel().loadedEntityList) {
|
||||
if (false/*!dispatcher.shouldRender(entity, frustum, cameraX, cameraY, cameraZ) || entity.isSpectator()*/) {
|
||||
@@ -383,7 +386,7 @@ public class ShadowRenderer {
|
||||
modelView.peek().getModel().get(MODELVIEW_BUFFER);
|
||||
GL11.glLoadMatrix(MODELVIEW_BUFFER);
|
||||
for (Entity entity : renderedEntities) {
|
||||
RenderManager.instance.renderEntitySimple(entity, tickDelta);//(entity, cameraX, cameraY, cameraZ, tickDelta, modelView, bufferSource);
|
||||
RenderManager.instance.renderEntitySimple(entity, tickDelta);
|
||||
shadowEntities++;
|
||||
}
|
||||
GL11.glPopMatrix();
|
||||
@@ -394,13 +397,11 @@ public class ShadowRenderer {
|
||||
}
|
||||
|
||||
private void renderPlayerEntity(EntityRenderer levelRenderer, Frustrum frustum, Object bufferSource, MatrixStack modelView, double cameraX, double cameraY, double cameraZ, float tickDelta) {
|
||||
// TODO: Render
|
||||
// EntityRenderDispatcher dispatcher = levelRenderer.getEntityRenderDispatcher();
|
||||
|
||||
profiler.startSection("cull");
|
||||
|
||||
Entity player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
// TODO: Entity culling
|
||||
// if (!dispatcher.shouldRender(player, frustum, cameraX, cameraY, cameraZ) || player.isSpectator()) {
|
||||
// return;
|
||||
// }
|
||||
@@ -409,19 +410,24 @@ public class ShadowRenderer {
|
||||
|
||||
int shadowEntities = 0;
|
||||
|
||||
// if (!player.getPassengers().isEmpty()) {
|
||||
// for (int i = 0; i < player.getPassengers().size(); i++) {
|
||||
// levelRenderer.invokeRenderEntity(player.getPassengers().get(i), cameraX, cameraY, cameraZ, tickDelta, modelView, bufferSource);
|
||||
// shadowEntities++;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (player.getVehicle() != null) {
|
||||
// levelRenderer.invokeRenderEntity(player.getVehicle(), cameraX, cameraY, cameraZ, tickDelta, modelView, bufferSource);
|
||||
// shadowEntities++;
|
||||
// }
|
||||
//
|
||||
// levelRenderer.invokeRenderEntity(player, cameraX, cameraY, cameraZ, tickDelta, modelView, bufferSource);
|
||||
GL11.glPushMatrix();
|
||||
MODELVIEW_BUFFER.clear().rewind();
|
||||
modelView.peek().getModel().get(MODELVIEW_BUFFER);
|
||||
GL11.glLoadMatrix(MODELVIEW_BUFFER);
|
||||
|
||||
if (player.riddenByEntity != null) {
|
||||
RenderManager.instance.renderEntitySimple(player.riddenByEntity, tickDelta);
|
||||
shadowEntities++;
|
||||
}
|
||||
|
||||
if (player.ridingEntity != null) {
|
||||
RenderManager.instance.renderEntitySimple(player.ridingEntity, tickDelta);
|
||||
shadowEntities++;
|
||||
}
|
||||
|
||||
RenderManager.instance.renderEntitySimple(player, tickDelta);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
shadowEntities++;
|
||||
|
||||
@@ -430,6 +436,21 @@ public class ShadowRenderer {
|
||||
profiler.endSection();
|
||||
}
|
||||
|
||||
private void renderTileEntity(TileEntity tile, double cameraX, double cameraY, double cameraZ, float partialTicks) {
|
||||
if (tile.getDistanceFrom(cameraX, cameraY, cameraZ) >= tile.getMaxRenderDistanceSquared()) {
|
||||
return;
|
||||
}
|
||||
int brightness = tile.getWorldObj().getLightBrightnessForSkyBlocks(tile.xCoord, tile.yCoord, tile.zCoord, 0);
|
||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) brightness % 65536, (float) brightness / 65536);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
TileEntityRendererDispatcher.instance.renderTileEntityAt(tile,
|
||||
(double)tile.xCoord - cameraX,
|
||||
(double)tile.yCoord - cameraY,
|
||||
(double)tile.zCoord - cameraZ,
|
||||
partialTicks
|
||||
);
|
||||
}
|
||||
|
||||
private void renderTileEntities(Object bufferSource, MatrixStack modelView, double cameraX, double cameraY, double cameraZ, float partialTicks, boolean hasEntityFrustum) {
|
||||
profiler.startSection("build blockentities");
|
||||
|
||||
@@ -440,17 +461,19 @@ public class ShadowRenderer {
|
||||
culler.setPosition(cameraX, cameraY, cameraZ);
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
MODELVIEW_BUFFER.clear().rewind();
|
||||
modelView.peek().getModel().get(MODELVIEW_BUFFER);
|
||||
GL11.glLoadMatrix(MODELVIEW_BUFFER);
|
||||
for (TileEntity tileEntity : visibleTileEntities) {
|
||||
if (hasEntityFrustum && (culler.isCulled(tileEntity.xCoord - 1, tileEntity.yCoord - 1, tileEntity.zCoord - 1, tileEntity.xCoord + 1, tileEntity.yCoord + 1, tileEntity.zCoord + 1))) {
|
||||
continue;
|
||||
}
|
||||
modelView.push();
|
||||
modelView.translate(tileEntity.xCoord - cameraX, tileEntity.yCoord - cameraY, tileEntity.zCoord - cameraZ);
|
||||
TileEntityRendererDispatcher.instance.renderTileEntity(tileEntity, partialTicks);
|
||||
modelView.pop();
|
||||
renderTileEntity(tileEntity, cameraX, cameraY, cameraZ, partialTicks);
|
||||
|
||||
shadowTileEntities++;
|
||||
}
|
||||
GLStateManager.glPopMatrix();
|
||||
|
||||
renderedShadowTileEntities = shadowTileEntities;
|
||||
|
||||
@@ -465,8 +488,6 @@ public class ShadowRenderer {
|
||||
// If the profiler is inactive, it will return InactiveProfiler.INSTANCE
|
||||
this.profiler = Minecraft.getMinecraft().mcProfiler;
|
||||
|
||||
Minecraft client = Minecraft.getMinecraft();
|
||||
|
||||
profiler.endStartSection("shadows");
|
||||
ACTIVE = true;
|
||||
|
||||
@@ -523,7 +544,6 @@ public class ShadowRenderer {
|
||||
|
||||
// Execute the vanilla terrain setup / culling routines using our shadow frustum.
|
||||
mc.renderGlobal.clipRenderersByFrustum(terrainFrustumHolder.getFrustum(), playerCamera.getPartialTicks());
|
||||
// levelRenderer.invokeSetupRender(playerCamera, terrainFrustumHolder.getFrustum(), false, levelRenderer.getFrameId(), false);
|
||||
|
||||
// Don't forget to increment the frame counter! This variable is arbitrary and only used in terrain setup,
|
||||
// and if it's not incremented, the vanilla culling code will get confused and think that it's already seen
|
||||
@@ -536,11 +556,8 @@ public class ShadowRenderer {
|
||||
|
||||
// Render all opaque terrain unless pack requests not to
|
||||
if (shouldRenderTerrain) {
|
||||
mc.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
|
||||
rg.sortAndRender(mc.thePlayer, 0, playerCamera.getPartialTicks());
|
||||
|
||||
// levelRenderer.invokeRenderChunkLayer(RenderLayer.solid(), modelView, cameraX, cameraY, cameraZ);
|
||||
// levelRenderer.invokeRenderChunkLayer(RenderLayer.cutout(), modelView, cameraX, cameraY, cameraZ);
|
||||
// levelRenderer.invokeRenderChunkLayer(RenderLayer.cutoutMipped(), modelView, cameraX, cameraY, cameraZ);
|
||||
}
|
||||
|
||||
profiler.endStartSection("entities");
|
||||
@@ -564,27 +581,15 @@ public class ShadowRenderer {
|
||||
entityShadowFrustum.setPosition(cameraX, cameraY, cameraZ);
|
||||
|
||||
// Render nearby entities
|
||||
//
|
||||
// Note: We must use a separate BuilderBufferStorage object here, or else very weird things will happen during
|
||||
// rendering.
|
||||
// if (renderBuffersExt != null) {
|
||||
// renderBuffersExt.beginLevelRendering();
|
||||
// }
|
||||
|
||||
// if (buffers instanceof DrawCallTrackingRenderBuffers) {
|
||||
// ((DrawCallTrackingRenderBuffers) buffers).resetDrawCounts();
|
||||
// }
|
||||
|
||||
// BufferSource bufferSource = buffers.bufferSource();
|
||||
|
||||
if (shouldRenderEntities) {
|
||||
renderEntities(levelRenderer, entityShadowFrustum, null, modelView, cameraX, cameraY, cameraZ, tickDelta);
|
||||
} else if (shouldRenderPlayer) {
|
||||
// renderPlayerEntity(levelRenderer, entityShadowFrustum, bufferSource, modelView, cameraX, cameraY, cameraZ, tickDelta);
|
||||
renderPlayerEntity(levelRenderer, entityShadowFrustum, null, modelView, cameraX, cameraY, cameraZ, tickDelta);
|
||||
}
|
||||
|
||||
if (shouldRenderBlockEntities) {
|
||||
// renderTileEntities(bufferSource, modelView, cameraX, cameraY, cameraZ, tickDelta, hasEntityFrustum);
|
||||
renderTileEntities(null, modelView, cameraX, cameraY, cameraZ, tickDelta, hasEntityFrustum);
|
||||
}
|
||||
|
||||
profiler.endStartSection("draw entities");
|
||||
@@ -592,21 +597,16 @@ public class ShadowRenderer {
|
||||
// NB: Don't try to draw the translucent parts of entities afterwards. It'll cause problems since some
|
||||
// shader packs assume that everything drawn afterwards is actually translucent and should cast a colored
|
||||
// shadow...
|
||||
// bufferSource.endBatch();
|
||||
|
||||
copyPreTranslucentDepth();
|
||||
|
||||
profiler.endStartSection("translucent terrain");
|
||||
|
||||
// TODO: Prevent these calls from scheduling translucent sorting...
|
||||
// TODO (Iris): Prevent these calls from scheduling translucent sorting...
|
||||
// It doesn't matter a ton, since this just means that they won't be sorted in the getNormal rendering pass.
|
||||
// Just something to watch out for, however...
|
||||
if (shouldRenderTranslucent) {
|
||||
// TODO: Render
|
||||
// TODO -- This makes everything look... weird
|
||||
// rg.sortAndRender(mc.thePlayer, 1, playerCamera.getPartialTicks());
|
||||
|
||||
// levelRenderer.invokeRenderChunkLayer(RenderLayer.translucent(), modelView, cameraX, cameraY, cameraZ);
|
||||
rg.sortAndRender(mc.thePlayer, 1, playerCamera.getPartialTicks());
|
||||
}
|
||||
|
||||
// Note: Apparently tripwire isn't rendered in the shadow pass.
|
||||
@@ -616,7 +616,6 @@ public class ShadowRenderer {
|
||||
// renderBuffersExt.endLevelRendering();
|
||||
// }
|
||||
|
||||
// TODO: Render
|
||||
debugStringTerrain = SodiumWorldRenderer.getInstance().getChunksDebugString();
|
||||
|
||||
profiler.endStartSection("generate mipmaps");
|
||||
@@ -631,9 +630,6 @@ public class ShadowRenderer {
|
||||
((CullingDataCache) levelRenderer).restoreState();
|
||||
}
|
||||
|
||||
// TODO: Render
|
||||
// levelRenderer.setRenderBuffers(playerBuffers);
|
||||
|
||||
ACTIVE = false;
|
||||
profiler.endSection();
|
||||
profiler.endStartSection("updatechunks");
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package net.coderbot.iris.pipeline.transform;
|
||||
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
|
||||
|
||||
class AttributeParameters extends Parameters {
|
||||
public final boolean hasGeometry;
|
||||
public final InputAvailability inputs;
|
||||
|
||||
public AttributeParameters(Patch patch, boolean hasGeometry, InputAvailability inputs) {
|
||||
super(patch);
|
||||
this.hasGeometry = hasGeometry;
|
||||
this.inputs = inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + (hasGeometry ? 1231 : 1237);
|
||||
result = prime * result + ((inputs == null) ? 0 : inputs.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
AttributeParameters other = (AttributeParameters) obj;
|
||||
if (hasGeometry != other.hasGeometry)
|
||||
return false;
|
||||
if (inputs == null) {
|
||||
if (other.inputs != null)
|
||||
return false;
|
||||
} else if (!inputs.equals(other.inputs))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,17 @@
|
||||
package net.coderbot.iris.pipeline.transform;
|
||||
|
||||
import io.github.douira.glsl_transformer.ast.node.Identifier;
|
||||
import io.github.douira.glsl_transformer.ast.node.Profile;
|
||||
import io.github.douira.glsl_transformer.ast.node.TranslationUnit;
|
||||
import io.github.douira.glsl_transformer.ast.node.basic.ASTNode;
|
||||
import io.github.douira.glsl_transformer.ast.node.external_declaration.ExternalDeclaration;
|
||||
import io.github.douira.glsl_transformer.ast.query.Root;
|
||||
import io.github.douira.glsl_transformer.ast.query.match.AutoHintedMatcher;
|
||||
import io.github.douira.glsl_transformer.ast.query.match.Matcher;
|
||||
import io.github.douira.glsl_transformer.ast.transform.ASTInjectionPoint;
|
||||
import io.github.douira.glsl_transformer.ast.transform.ASTParser;
|
||||
import net.coderbot.iris.gl.shader.ShaderType;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import net.coderbot.iris.pipeline.transform.parameter.AttributeParameters;
|
||||
import org.taumc.glsl.grammar.GLSLParser;
|
||||
import org.taumc.glsl.Util;
|
||||
|
||||
/**
|
||||
* Implements AttributeShaderTransformer using glsl-transformer AST
|
||||
* transformation methods.
|
||||
*/
|
||||
class AttributeTransformer {
|
||||
public static void transform(
|
||||
ASTParser t,
|
||||
TranslationUnit tree,
|
||||
Root root,
|
||||
AttributeParameters parameters) {
|
||||
boolean isCore = (tree.getVersionStatement().profile == Profile.CORE || (tree.getVersionStatement().profile == null && tree.getVersionStatement().version.number > 140));
|
||||
public static void transform(GLSLParser.Translation_unitContext translationUnit, AttributeParameters parameters, String profile, int version) {
|
||||
boolean isCore = (profile.equals("core") || version > 140);
|
||||
if (isCore) {
|
||||
if (parameters.type == PatchShaderType.VERTEX) {
|
||||
throw new IllegalStateException("Vertex shaders must be in the compatibility profile to run properly!");
|
||||
@@ -36,32 +23,22 @@ class AttributeTransformer {
|
||||
// lightmap texture coordinate.
|
||||
// See https://github.com/IrisShaders/Iris/issues/1149
|
||||
if (parameters.inputs.lightmap) {
|
||||
root.rename("gl_MultiTexCoord2", "gl_MultiTexCoord1");
|
||||
Util.rename(translationUnit, "gl_MultiTexCoord2", "gl_MultiTexCoord1");
|
||||
}
|
||||
|
||||
Stream<Identifier> stream = Stream.empty();
|
||||
boolean hasItems = false;
|
||||
if (!parameters.inputs.lightmap) {
|
||||
stream = Stream.concat(stream,
|
||||
root.identifierIndex.getStream("gl_MultiTexCoord1"));
|
||||
stream = Stream.concat(stream,
|
||||
root.identifierIndex.getStream("gl_MultiTexCoord2"));
|
||||
hasItems = true;
|
||||
}
|
||||
if (!parameters.inputs.texture) {
|
||||
stream = Stream.concat(stream,
|
||||
root.identifierIndex.getStream("gl_MultiTexCoord0"));
|
||||
hasItems = true;
|
||||
}
|
||||
if (hasItems) {
|
||||
root.replaceReferenceExpressions(t, stream, "vec4(240.0, 240.0, 0.0, 1.0)");
|
||||
}
|
||||
if (!parameters.inputs.lightmap) {
|
||||
Util.replaceExpression(translationUnit, "gl_MultiTexCoord1", "vec4(240.0, 240.0, 0.0, 1.0)");
|
||||
Util.replaceExpression(translationUnit, "gl_MultiTexCoord2", "vec4(240.0, 240.0, 0.0, 1.0)");
|
||||
}
|
||||
if (!parameters.inputs.texture) {
|
||||
Util.replaceExpression(translationUnit, "gl_MultiTexCoord0", "vec4(240.0, 240.0, 0.0, 1.0)");
|
||||
}
|
||||
|
||||
patchTextureMatrices(t, tree, root, parameters.inputs.lightmap);
|
||||
patchTextureMatrices(translationUnit, parameters.inputs.lightmap);
|
||||
|
||||
if (parameters.type.glShaderType == ShaderType.VERTEX
|
||||
&& root.identifierIndex.has("gl_MultiTexCoord3")
|
||||
&& !root.identifierIndex.has("mc_midTexCoord")) {
|
||||
&& Util.hasVariable(translationUnit, "gl_MultiTexCoord3")
|
||||
&& !Util.hasVariable(translationUnit, "mc_midTexCoord")) {
|
||||
// TODO: proper type conversion
|
||||
// gl_MultiTexCoord3 is a super legacy alias of mc_midTexCoord. We don't do this
|
||||
// replacement if we think mc_midTexCoord could be defined just we can't handle
|
||||
@@ -69,43 +46,44 @@ class AttributeTransformer {
|
||||
// to define mc_midTexCoord only if it's not defined, and if it is defined,
|
||||
// figure out its type, then replace all occurrences of gl_MultiTexCoord3 with
|
||||
// the correct conversion from mc_midTexCoord's declared type to vec4.
|
||||
root.rename("gl_MultiTexCoord3", "mc_midTexCoord");
|
||||
tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_FUNCTIONS,
|
||||
"attribute vec4 mc_midTexCoord;");
|
||||
Util.rename(translationUnit, "gl_MultiTexCoord3", "mc_midTexCoord");
|
||||
Util.injectVariable(translationUnit, "attribute vec4 mc_midTexCoord;");
|
||||
}
|
||||
}
|
||||
|
||||
private static void patchTextureMatrices(
|
||||
ASTParser t,
|
||||
TranslationUnit tree,
|
||||
Root root,
|
||||
boolean hasLightmap) {
|
||||
root.rename("gl_TextureMatrix", "iris_TextureMatrix");
|
||||
private static void patchTextureMatrices(GLSLParser.Translation_unitContext translationUnit, boolean hasLightmap) {
|
||||
Util.rename(translationUnit, "gl_TextureMatrix", "iris_TextureMatrix");
|
||||
|
||||
tree.parseAndInjectNodes(t, ASTInjectionPoint.BEFORE_FUNCTIONS,
|
||||
"const float iris_ONE_OVER_256 = 0.00390625;",
|
||||
"const float iris_ONE_OVER_32 = iris_ONE_OVER_256 * 8;");
|
||||
if (hasLightmap) {
|
||||
tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_FUNCTIONS,
|
||||
"mat4 iris_LightmapTextureMatrix = gl_TextureMatrix[1];");
|
||||
} else {
|
||||
tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_FUNCTIONS, "mat4 iris_LightmapTextureMatrix =" +
|
||||
"mat4(iris_ONE_OVER_256, 0.0, 0.0, 0.0," +
|
||||
" 0.0, iris_ONE_OVER_256, 0.0, 0.0," +
|
||||
" 0.0, 0.0, iris_ONE_OVER_256, 0.0," +
|
||||
" iris_ONE_OVER_32, iris_ONE_OVER_32, iris_ONE_OVER_32, iris_ONE_OVER_256);");
|
||||
}
|
||||
// TODO: These were originally marked const, but that breaks things
|
||||
// If these are marked const, then using them below in the iris_LightmapTextureMatrix creation
|
||||
// breaks with them being undefined. I suppose the const variables cause them to get defined later than otherwise?
|
||||
// Similarly, if you make them a const, then iris_ONE_OVER_32 breaks because it references iris_ONE_OVER_256.
|
||||
// Not sure if it really matters if these are marked const or not. Alternatively they can be marked const
|
||||
// and the values hardcoded within the places that use them here, that seems to work fine, but this probably
|
||||
// stayed closer to the original way it worked.
|
||||
Util.injectVariable(translationUnit, "float iris_ONE_OVER_256 = 0.00390625;");
|
||||
Util.injectVariable(translationUnit, "float iris_ONE_OVER_32 = iris_ONE_OVER_256 * 8;");
|
||||
|
||||
// column major
|
||||
tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_FUNCTIONS, "mat4 iris_TextureMatrix[8] = mat4[8](" +
|
||||
"gl_TextureMatrix[0]," +
|
||||
"iris_LightmapTextureMatrix," +
|
||||
"mat4(1.0)," +
|
||||
"mat4(1.0)," +
|
||||
"mat4(1.0)," +
|
||||
"mat4(1.0)," +
|
||||
"mat4(1.0)," +
|
||||
"mat4(1.0)" +
|
||||
");");
|
||||
if (hasLightmap) {
|
||||
Util.injectVariable(translationUnit, "mat4 iris_LightmapTextureMatrix = gl_TextureMatrix[1];");
|
||||
} else {
|
||||
Util.injectVariable(translationUnit, "mat4 iris_LightmapTextureMatrix =" +
|
||||
"mat4(iris_ONE_OVER_256, 0.0, 0.0, 0.0," +
|
||||
" 0.0, iris_ONE_OVER_256, 0.0, 0.0," +
|
||||
" 0.0, 0.0, iris_ONE_OVER_256, 0.0," +
|
||||
" iris_ONE_OVER_32, iris_ONE_OVER_32, iris_ONE_OVER_32, iris_ONE_OVER_256);");
|
||||
}
|
||||
|
||||
// column major
|
||||
Util.injectVariable(translationUnit, "mat4 iris_TextureMatrix[8] = mat4[8](" +
|
||||
"gl_TextureMatrix[0]," +
|
||||
"iris_LightmapTextureMatrix," +
|
||||
"mat4(1.0)," +
|
||||
"mat4(1.0)," +
|
||||
"mat4(1.0)," +
|
||||
"mat4(1.0)," +
|
||||
"mat4(1.0)," +
|
||||
"mat4(1.0)" +
|
||||
");");
|
||||
}
|
||||
}
|
||||
@@ -1,310 +1,55 @@
|
||||
package net.coderbot.iris.pipeline.transform;
|
||||
|
||||
import io.github.douira.glsl_transformer.ast.node.Identifier;
|
||||
import io.github.douira.glsl_transformer.ast.node.TranslationUnit;
|
||||
import io.github.douira.glsl_transformer.ast.node.basic.ASTNode;
|
||||
import io.github.douira.glsl_transformer.ast.node.declaration.DeclarationMember;
|
||||
import io.github.douira.glsl_transformer.ast.node.declaration.FunctionParameter;
|
||||
import io.github.douira.glsl_transformer.ast.node.declaration.TypeAndInitDeclaration;
|
||||
import io.github.douira.glsl_transformer.ast.node.expression.Expression;
|
||||
import io.github.douira.glsl_transformer.ast.node.expression.LiteralExpression;
|
||||
import io.github.douira.glsl_transformer.ast.node.expression.ReferenceExpression;
|
||||
import io.github.douira.glsl_transformer.ast.node.expression.unary.FunctionCallExpression;
|
||||
import io.github.douira.glsl_transformer.ast.node.external_declaration.DeclarationExternalDeclaration;
|
||||
import io.github.douira.glsl_transformer.ast.node.external_declaration.EmptyDeclaration;
|
||||
import io.github.douira.glsl_transformer.ast.node.external_declaration.ExternalDeclaration;
|
||||
import io.github.douira.glsl_transformer.ast.node.external_declaration.FunctionDefinition;
|
||||
import io.github.douira.glsl_transformer.ast.node.statement.Statement;
|
||||
import io.github.douira.glsl_transformer.ast.node.type.qualifier.StorageQualifier;
|
||||
import io.github.douira.glsl_transformer.ast.node.type.qualifier.StorageQualifier.StorageType;
|
||||
import io.github.douira.glsl_transformer.ast.node.type.qualifier.TypeQualifier;
|
||||
import io.github.douira.glsl_transformer.ast.node.type.qualifier.TypeQualifierPart;
|
||||
import io.github.douira.glsl_transformer.ast.node.type.specifier.BuiltinNumericTypeSpecifier;
|
||||
import io.github.douira.glsl_transformer.ast.node.type.specifier.FunctionPrototype;
|
||||
import io.github.douira.glsl_transformer.ast.node.type.specifier.TypeSpecifier;
|
||||
import io.github.douira.glsl_transformer.ast.query.Root;
|
||||
import io.github.douira.glsl_transformer.ast.query.match.AutoHintedMatcher;
|
||||
import io.github.douira.glsl_transformer.ast.query.match.Matcher;
|
||||
import io.github.douira.glsl_transformer.ast.transform.ASTInjectionPoint;
|
||||
import io.github.douira.glsl_transformer.ast.transform.ASTParser;
|
||||
import io.github.douira.glsl_transformer.ast.transform.Template;
|
||||
import io.github.douira.glsl_transformer.util.Type;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gl.shader.ShaderType;
|
||||
import net.coderbot.iris.pipeline.PatchedShaderPrinter;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import net.coderbot.iris.pipeline.transform.parameter.Parameters;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.taumc.glsl.Util;
|
||||
import org.taumc.glsl.grammar.GLSLLexer;
|
||||
import org.taumc.glsl.grammar.GLSLParser;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class CompatibilityTransformer {
|
||||
static Logger LOGGER = LogManager.getLogger(CompatibilityTransformer.class);
|
||||
|
||||
private static final AutoHintedMatcher<Expression> sildursWaterFract = new AutoHintedMatcher<>(
|
||||
"fract(worldpos.y + 0.001)", Matcher.expressionPattern);
|
||||
private static final ShaderType[] pipeline = {ShaderType.VERTEX, ShaderType.GEOMETRY, ShaderType.FRAGMENT};
|
||||
|
||||
private static StorageQualifier getConstQualifier(TypeQualifier qualifier) {
|
||||
if (qualifier == null) {
|
||||
return null;
|
||||
}
|
||||
for (TypeQualifierPart constQualifier : qualifier.getChildren()) {
|
||||
if (constQualifier instanceof StorageQualifier) {
|
||||
StorageQualifier storageQualifier = (StorageQualifier) constQualifier;
|
||||
if (storageQualifier.storageType == StorageQualifier.StorageType.CONST) {
|
||||
return storageQualifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void transformEach(ASTParser t, TranslationUnit tree, Root root, Parameters parameters) {
|
||||
if (parameters.type == PatchShaderType.VERTEX) {
|
||||
if (root.replaceExpressionMatches(t, sildursWaterFract, "fract(worldpos.y + 0.01)")) {
|
||||
Iris.logger.warn("Patched fract(worldpos.y + 0.001) to fract(worldpos.y + 0.01) to fix " +
|
||||
"waving water disconnecting from other water blocks; See https://github.com/IrisShaders/Iris/issues/509");
|
||||
}
|
||||
}
|
||||
public static void transformEach(GLSLParser.Translation_unitContext translationUnit, Parameters parameters) {
|
||||
if (parameters.type == PatchShaderType.VERTEX) {
|
||||
;
|
||||
// TODO: sildur's jankness
|
||||
// This is a hacky patch for sildur's shaders that changes the way it does it's waving water to make it work better?
|
||||
// Why is this the GLSL transformation code in Iris, tell sildur to fix it and remove this?
|
||||
// it's still there in current, modern Iris
|
||||
// See https://github.com/IrisShaders/Iris/issues/509
|
||||
Util.replaceExpression(translationUnit, "fract(worldpos.y + 0.001)", "fract(worldpos.y + 0.01)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes const storage qualifier from declarations in functions if they are
|
||||
* initialized with const parameters. Const parameters are immutable parameters
|
||||
* and can't be used to initialize const declarations because they expect
|
||||
* constant, not just immutable, expressions. This varies between drivers and
|
||||
* versions. Also removes the const qualifier from declarations that use the
|
||||
* identifiers from which the declaration was removed previously.
|
||||
* See https://wiki.shaderlabs.org/wiki/Compiler_Behavior_Notes
|
||||
*/
|
||||
Map<FunctionDefinition, Set<String>> constFunctions = new HashMap<>();
|
||||
Set<String> processingSet = new HashSet<>();
|
||||
List<FunctionDefinition> unusedFunctions = new LinkedList<>();
|
||||
for (FunctionDefinition definition : root.nodeIndex.get(FunctionDefinition.class)) {
|
||||
// check if this function is ever used
|
||||
FunctionPrototype prototype = definition.getFunctionPrototype();
|
||||
String functionName = prototype.getName().getName();
|
||||
if (!functionName.equals("main") && root.identifierIndex.getStream(functionName).count() <= 1) {
|
||||
// remove unused functions
|
||||
// unused function removal can be helpful since some drivers don't do some
|
||||
// checks on unused functions. Additionally, sometimes bugs in unused code can
|
||||
// be avoided this way.
|
||||
// TODO: integrate into debug mode (allow user to disable this behavior for
|
||||
// debugging purposes)
|
||||
unusedFunctions.add(definition);
|
||||
if (PatchedShaderPrinter.prettyPrintShaders) {
|
||||
LOGGER.warn("Removing unused function " + functionName);
|
||||
} else if (unusedFunctions.size() == 1) {
|
||||
LOGGER.warn(
|
||||
"Removing unused function " + functionName
|
||||
+ " and omitting further such messages outside of debug mode. See debugging.md for more information.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
/**
|
||||
* Removes const storage qualifier from declarations in functions if they are
|
||||
* initialized with const parameters. Const parameters are immutable parameters
|
||||
* and can't be used to initialize const declarations because they expect
|
||||
* constant, not just immutable, expressions. This varies between drivers and
|
||||
* versions. Also removes the const qualifier from declarations that use the
|
||||
* identifiers from which the declaration was removed previously.
|
||||
* See https://wiki.shaderlabs.org/wiki/Compiler_Behavior_Notes
|
||||
*/
|
||||
Util.removeUnusedFunctions(translationUnit);
|
||||
Util.removeConstAssignment(translationUnit);
|
||||
|
||||
// stop on functions without parameters
|
||||
if (prototype.getChildren().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// find the const parameters
|
||||
Set<String> names = new HashSet<>(prototype.getChildren().size());
|
||||
for (FunctionParameter parameter : prototype.getChildren()) {
|
||||
if (getConstQualifier(parameter.getType().getTypeQualifier()) != null) {
|
||||
String name = parameter.getName().getName();
|
||||
names.add(name);
|
||||
processingSet.add(name);
|
||||
}
|
||||
}
|
||||
if (!names.isEmpty()) {
|
||||
constFunctions.put(definition, names);
|
||||
}
|
||||
}
|
||||
|
||||
// remove collected unused functions
|
||||
for (FunctionDefinition definition : unusedFunctions) {
|
||||
definition.detachAndDelete();
|
||||
}
|
||||
|
||||
// find the reference expressions for the const parameters
|
||||
// and check that they are in the right function and are of the right type
|
||||
boolean constDeclarationHit = false;
|
||||
Deque<String> processingQueue = new ArrayDeque<>(processingSet);
|
||||
while (!processingQueue.isEmpty()) {
|
||||
String name = processingQueue.poll();
|
||||
processingSet.remove(name);
|
||||
for (Identifier id : root.identifierIndex.get(name)) {
|
||||
// since this searches for reference expressions, this won't accidentally find
|
||||
// the name as the name of a declaration member
|
||||
ReferenceExpression reference = id.getAncestor(ReferenceExpression.class);
|
||||
if (reference == null) {
|
||||
continue;
|
||||
}
|
||||
TypeAndInitDeclaration taid = reference.getAncestor(TypeAndInitDeclaration.class);
|
||||
if (taid == null) {
|
||||
continue;
|
||||
}
|
||||
FunctionDefinition inDefinition = taid.getAncestor(FunctionDefinition.class);
|
||||
if (inDefinition == null) {
|
||||
continue;
|
||||
}
|
||||
Set<String> constIdsInFunction = constFunctions.get(inDefinition);
|
||||
if (constIdsInFunction == null) {
|
||||
continue;
|
||||
}
|
||||
if (constIdsInFunction.contains(name)) {
|
||||
// remove the const qualifier from the reference expression
|
||||
TypeQualifier qualifier = taid.getType().getTypeQualifier();
|
||||
StorageQualifier constQualifier = getConstQualifier(qualifier);
|
||||
if (constQualifier == null) {
|
||||
continue;
|
||||
}
|
||||
constQualifier.detachAndDelete();
|
||||
if (qualifier.getChildren().isEmpty()) {
|
||||
qualifier.detachAndDelete();
|
||||
}
|
||||
constDeclarationHit = true;
|
||||
|
||||
// add all members of the declaration to the list of const parameters to process
|
||||
for (DeclarationMember member : taid.getMembers()) {
|
||||
String memberName = member.getName().getName();
|
||||
|
||||
// the name may not be the same as the parameter name
|
||||
if (constIdsInFunction.contains(memberName)) {
|
||||
throw new IllegalStateException("Illegal redefinition of const parameter " + name);
|
||||
}
|
||||
|
||||
constIdsInFunction.add(memberName);
|
||||
|
||||
// don't add to the queue twice if it's already been added by a different scope
|
||||
if (!processingSet.contains(memberName)) {
|
||||
processingQueue.add(memberName);
|
||||
processingSet.add(memberName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (constDeclarationHit) {
|
||||
LOGGER.warn(
|
||||
"Removed the const keyword from declarations that use const parameters. See debugging.md for more information.");
|
||||
}
|
||||
|
||||
// remove empty external declarations
|
||||
boolean emptyDeclarationHit = root.process(
|
||||
root.nodeIndex.getStream(EmptyDeclaration.class),
|
||||
ASTNode::detachAndDelete);
|
||||
if (emptyDeclarationHit) {
|
||||
LOGGER.warn(
|
||||
"Removed empty external declarations (\";\").");
|
||||
}
|
||||
}
|
||||
|
||||
private static class DeclarationMatcher extends AutoHintedMatcher<ExternalDeclaration> {
|
||||
private final StorageType storageType;
|
||||
|
||||
public DeclarationMatcher(StorageType storageType) {
|
||||
super("out float name;", Matcher.externalDeclarationPattern);
|
||||
this.storageType = storageType;
|
||||
markClassWildcard("qualifier", pattern.getRoot().nodeIndex.getOne(TypeQualifier.class));
|
||||
markClassWildcard("type", pattern.getRoot().nodeIndex.getOne(BuiltinNumericTypeSpecifier.class));
|
||||
markClassWildcard("name*", pattern.getRoot().identifierIndex.getOne("name").getAncestor(DeclarationMember.class));
|
||||
}
|
||||
|
||||
public boolean matchesSpecialized(ExternalDeclaration tree, ShaderType shaderType) {
|
||||
boolean result = super.matchesExtract(tree);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
TypeQualifier qualifier = getNodeMatch("qualifier", TypeQualifier.class);
|
||||
for (TypeQualifierPart part : qualifier.getParts()) {
|
||||
if (part instanceof StorageQualifier) {
|
||||
StorageQualifier storageQualifier = (StorageQualifier) part;
|
||||
StorageType qualifierStorageType = storageQualifier.storageType;
|
||||
// TODO: investigate the specified behavior of varying in geometry shaders and
|
||||
// the combination of varying with in or out qualifiers
|
||||
if (qualifierStorageType == storageType ||
|
||||
qualifierStorageType == StorageType.VARYING &&
|
||||
(shaderType == ShaderType.VERTEX && storageType == StorageType.OUT ||
|
||||
shaderType == ShaderType.GEOMETRY && storageType == StorageType.OUT ||
|
||||
shaderType == ShaderType.FRAGMENT && storageType == StorageType.IN)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static final ShaderType[] pipeline = { ShaderType.VERTEX, ShaderType.GEOMETRY, ShaderType.FRAGMENT };
|
||||
private static final DeclarationMatcher outDeclarationMatcher = new DeclarationMatcher(StorageType.OUT);
|
||||
private static final DeclarationMatcher inDeclarationMatcher = new DeclarationMatcher(StorageType.IN);
|
||||
|
||||
private static final String tagPrefix = "iris_template_";
|
||||
private static final Template<ExternalDeclaration> declarationTemplate = Template
|
||||
.withExternalDeclaration("out __type __name;");
|
||||
private static final Template<Statement> initTemplate = Template.withStatement("__decl = __value;");
|
||||
private static final Template<ExternalDeclaration> variableTemplate = Template
|
||||
.withExternalDeclaration("__type __internalDecl;");
|
||||
private static final Template<Statement> statementTemplate = Template
|
||||
.withStatement("__oldDecl = vec3(__internalDecl);");
|
||||
private static final Template<Statement> statementTemplateVector = Template
|
||||
.withStatement("__oldDecl = vec3(__internalDecl, vec4(0));");
|
||||
|
||||
static {
|
||||
declarationTemplate.markLocalReplacement(declarationTemplate.getSourceRoot().nodeIndex.getOne(TypeQualifier.class));
|
||||
declarationTemplate.markLocalReplacement("__type", TypeSpecifier.class);
|
||||
declarationTemplate.markIdentifierReplacement("__name");
|
||||
initTemplate.markIdentifierReplacement("__decl");
|
||||
initTemplate.markLocalReplacement("__value", ReferenceExpression.class);
|
||||
variableTemplate.markLocalReplacement("__type", TypeSpecifier.class);
|
||||
variableTemplate.markIdentifierReplacement("__internalDecl");
|
||||
statementTemplate.markIdentifierReplacement("__oldDecl");
|
||||
statementTemplate.markIdentifierReplacement("__internalDecl");
|
||||
statementTemplate.markLocalReplacement(
|
||||
statementTemplate.getSourceRoot().nodeIndex.getStream(BuiltinNumericTypeSpecifier.class)
|
||||
.filter(specifier -> specifier.type == Type.F32VEC3).findAny().get());
|
||||
statementTemplateVector.markIdentifierReplacement("__oldDecl");
|
||||
statementTemplateVector.markIdentifierReplacement("__internalDecl");
|
||||
statementTemplateVector.markLocalReplacement(
|
||||
statementTemplateVector.getSourceRoot().nodeIndex.getStream(BuiltinNumericTypeSpecifier.class)
|
||||
.filter(specifier -> specifier.type == Type.F32VEC3).findAny().get());
|
||||
}
|
||||
|
||||
private static Statement getInitializer(Root root, String name, Type type) {
|
||||
return initTemplate.getInstanceFor(root,
|
||||
new Identifier(name),
|
||||
type.isScalar()
|
||||
? LiteralExpression.getDefaultValue(type)
|
||||
: Root.indexNodes(root, () -> new FunctionCallExpression(
|
||||
new Identifier(type.getMostCompactName()),
|
||||
Stream.of(LiteralExpression.getDefaultValue(type)))));
|
||||
}
|
||||
|
||||
private static TypeQualifier makeQualifierOut(TypeQualifier typeQualifier) {
|
||||
for (TypeQualifierPart qualifierPart : typeQualifier.getParts()) {
|
||||
if (qualifierPart instanceof StorageQualifier) {
|
||||
StorageQualifier storageQualifier = (StorageQualifier) qualifierPart;
|
||||
if (((StorageQualifier) qualifierPart).storageType == StorageType.IN) {
|
||||
storageQualifier.storageType = StorageType.OUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
return typeQualifier;
|
||||
}
|
||||
// TODO: glsl-transformation-lib doesn't have a way to identify empty declarations
|
||||
// this transformation is not done in current versions of Iris, so not sure it's necessary
|
||||
// boolean emptyDeclarationHit = root.process(
|
||||
// root.nodeIndex.getStream(EmptyDeclaration.class),
|
||||
// ASTNode::detachAndDelete);
|
||||
// if (emptyDeclarationHit) {
|
||||
// LOGGER.warn(
|
||||
// "Removed empty external declarations (\";\").");
|
||||
// }
|
||||
}
|
||||
|
||||
// does transformations that require cross-shader type data
|
||||
public static void transformGrouped(
|
||||
ASTParser t,
|
||||
Map<PatchShaderType, TranslationUnit> trees,
|
||||
Parameters parameters) {
|
||||
public static void transformGrouped(Map<PatchShaderType, GLSLParser.Translation_unitContext> trees, Parameters parameters) {
|
||||
/**
|
||||
* find attributes that are declared as "in" in geometry or fragment but not
|
||||
* declared as "out" in the previous stage. The missing "out" declarations for
|
||||
@@ -320,225 +65,73 @@ public class CompatibilityTransformer {
|
||||
* iris_FogFragCoord if there are geometry shaders present
|
||||
* - improved geometry shader support? They use funky declarations
|
||||
*/
|
||||
ShaderType prevType = null;
|
||||
for (int i = 0; i < pipeline.length; i++) {
|
||||
ShaderType type = pipeline[i];
|
||||
PatchShaderType[] patchTypes = PatchShaderType.fromGlShaderType(type);
|
||||
ShaderType prevType = null;
|
||||
for (ShaderType type : pipeline) {
|
||||
PatchShaderType[] patchTypes = PatchShaderType.fromGlShaderType(type);
|
||||
|
||||
// check if the patch types have sources and continue if not
|
||||
boolean hasAny = false;
|
||||
for (PatchShaderType currentType : patchTypes) {
|
||||
if (trees.get(currentType) != null) {
|
||||
hasAny = true;
|
||||
}
|
||||
}
|
||||
if (!hasAny) {
|
||||
continue;
|
||||
}
|
||||
// check if the patch types have sources and continue if not
|
||||
boolean hasAny = false;
|
||||
for (PatchShaderType currentType : patchTypes) {
|
||||
if (trees.get(currentType) != null) {
|
||||
hasAny = true;
|
||||
}
|
||||
}
|
||||
if (!hasAny) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// if the current type has sources but the previous one doesn't, set the
|
||||
// previous one and continue
|
||||
if (prevType == null) {
|
||||
prevType = type;
|
||||
continue;
|
||||
}
|
||||
// if the current type has sources but the previous one doesn't, set the
|
||||
// previous one and continue
|
||||
if (prevType == null) {
|
||||
prevType = type;
|
||||
continue;
|
||||
}
|
||||
|
||||
PatchShaderType prevPatchTypes = PatchShaderType.fromGlShaderType(prevType)[0];
|
||||
TranslationUnit prevTree = trees.get(prevPatchTypes);
|
||||
Root prevRoot = prevTree.getRoot();
|
||||
PatchShaderType prevPatchTypes = PatchShaderType.fromGlShaderType(prevType)[0];
|
||||
GLSLParser.Translation_unitContext prevTree = trees.get(prevPatchTypes);
|
||||
|
||||
// test if the prefix tag is used for some reason
|
||||
if (prevRoot.identifierIndex.prefixQueryFlat(tagPrefix).findAny().isPresent()) {
|
||||
LOGGER.warn("The prefix tag " + tagPrefix + " is used in the shader, bailing compatibility transformation.");
|
||||
return;
|
||||
}
|
||||
// find out declarations
|
||||
Map<String, GLSLParser.Single_declarationContext> outDec = Util.findQualifiers(prevTree, GLSLLexer.OUT);
|
||||
for (PatchShaderType currentType : patchTypes) {
|
||||
GLSLParser.Translation_unitContext currentTree = trees.get(currentType);
|
||||
|
||||
// find out declarations
|
||||
Map<String, BuiltinNumericTypeSpecifier> outDeclarations = new HashMap<>();
|
||||
for (DeclarationExternalDeclaration declaration : prevRoot.nodeIndex.get(DeclarationExternalDeclaration.class)) {
|
||||
if (outDeclarationMatcher.matchesSpecialized(declaration, prevType)) {
|
||||
BuiltinNumericTypeSpecifier extractedType = outDeclarationMatcher.getNodeMatch("type",
|
||||
BuiltinNumericTypeSpecifier.class);
|
||||
for (DeclarationMember member : outDeclarationMatcher
|
||||
.getNodeMatch("name*", DeclarationMember.class)
|
||||
.getAncestor(TypeAndInitDeclaration.class)
|
||||
.getMembers()) {
|
||||
String name = member.getName().getName();
|
||||
if (!name.startsWith("gl_")) {
|
||||
outDeclarations.put(name, extractedType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentTree == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// add out declarations that are missing for in declarations
|
||||
for (PatchShaderType currentType : patchTypes) {
|
||||
TranslationUnit currentTree = trees.get(currentType);
|
||||
if (currentTree == null) {
|
||||
continue;
|
||||
}
|
||||
Root currentRoot = currentTree.getRoot();
|
||||
Map<String, GLSLParser.Single_declarationContext> inDec = Util.findQualifiers(currentTree, GLSLLexer.IN);
|
||||
for (String in : inDec.keySet()) {
|
||||
if (in.startsWith("gl_")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (ExternalDeclaration declaration : currentRoot.nodeIndex.get(DeclarationExternalDeclaration.class)) {
|
||||
if (!inDeclarationMatcher.matchesSpecialized(declaration, currentType.glShaderType)) {
|
||||
continue;
|
||||
}
|
||||
if (!outDec.containsKey(in)) {
|
||||
if (!Util.containsCall(currentTree, in)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BuiltinNumericTypeSpecifier inTypeSpecifier = inDeclarationMatcher.getNodeMatch("type",
|
||||
BuiltinNumericTypeSpecifier.class);
|
||||
for (DeclarationMember inDeclarationMember : inDeclarationMatcher
|
||||
.getNodeMatch("name*", DeclarationMember.class)
|
||||
.getAncestor(TypeAndInitDeclaration.class)
|
||||
.getMembers()) {
|
||||
String name = inDeclarationMember.getName().getName();
|
||||
if (name.startsWith("gl_")) {
|
||||
continue;
|
||||
}
|
||||
Util.makeOutDeclaration(prevTree, inDec.get(in), in);
|
||||
|
||||
// patch missing declarations with an initialization
|
||||
if (!outDeclarations.containsKey(name)) {
|
||||
// make sure the declared in is actually used
|
||||
if (!currentRoot.identifierIndex.getAncestors(name, ReferenceExpression.class).findAny().isPresent()) {
|
||||
continue;
|
||||
}
|
||||
if (!Util.hasAssigment(prevTree, in)) {
|
||||
Util.initialize(prevTree, inDec.get(in), in);
|
||||
}
|
||||
} else {
|
||||
ParseTree outType = outDec.get(in).fully_specified_type().type_specifier().type_specifier_nonarray().children.get(0);
|
||||
ParseTree inType = inDec.get(in).fully_specified_type().type_specifier().type_specifier_nonarray().children.get(0);
|
||||
|
||||
if (inTypeSpecifier == null) {
|
||||
LOGGER.warn(
|
||||
"The in declaration '" + name + "' in the " + currentType.glShaderType.name()
|
||||
+ " shader that has a missing corresponding out declaration in the previous stage "
|
||||
+ prevType.name() + " has a non-numeric type and could not be compatibility-patched. See debugging.md for more information.");
|
||||
continue;
|
||||
}
|
||||
Type inType = inTypeSpecifier.type;
|
||||
if (outDec.get(in).fully_specified_type().type_specifier().array_specifier() != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// insert the new out declaration but copy over the type qualifiers, except for
|
||||
// the in/out qualifier
|
||||
TypeQualifier outQualifier = (TypeQualifier) inDeclarationMatcher
|
||||
.getNodeMatch("qualifier").cloneInto(prevRoot);
|
||||
makeQualifierOut(outQualifier);
|
||||
prevTree.injectNode(ASTInjectionPoint.BEFORE_DECLARATIONS, declarationTemplate.getInstanceFor(prevRoot,
|
||||
outQualifier,
|
||||
inTypeSpecifier.cloneInto(prevRoot),
|
||||
new Identifier(name)));
|
||||
|
||||
// add the initializer to the main function
|
||||
prevTree.prependMain(getInitializer(prevRoot, name, inType));
|
||||
|
||||
// update out declarations to prevent duplicates
|
||||
outDeclarations.put(name, null);
|
||||
|
||||
LOGGER.warn(
|
||||
"The in declaration '" + name + "' in the " + currentType.glShaderType.name()
|
||||
+ " shader is missing a corresponding out declaration in the previous stage "
|
||||
+ prevType.name() + " and has been compatibility-patched. See debugging.md for more information.");
|
||||
}
|
||||
|
||||
// patch mismatching declaration with a local variable and a cast
|
||||
else {
|
||||
// there is an out declaration for this in declaration, check if the types match
|
||||
BuiltinNumericTypeSpecifier outTypeSpecifier = outDeclarations.get(name);
|
||||
|
||||
// skip newly inserted out declarations
|
||||
if (outTypeSpecifier == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Type inType = inTypeSpecifier.type;
|
||||
Type outType = outTypeSpecifier.type;
|
||||
|
||||
// skip if the type matches, nothing has to be done
|
||||
if (inType == outType) {
|
||||
// if the types match but it's never assigned a value,
|
||||
// an initialization is added
|
||||
if (prevRoot.identifierIndex.get(name).size() > 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// add an initialization statement for this declaration
|
||||
prevTree.prependMain(getInitializer(prevRoot, name, inType));
|
||||
outDeclarations.put(name, null);
|
||||
continue;
|
||||
}
|
||||
|
||||
// bail and warn on mismatching dimensionality
|
||||
if (outType.getDimension() != inType.getDimension()) {
|
||||
LOGGER.warn(
|
||||
"The in declaration '" + name + "' in the " + currentType.glShaderType.name()
|
||||
+ " shader has a mismatching dimensionality (scalar/vector/matrix) with the out declaration in the previous stage "
|
||||
+ prevType.name() + " and could not be compatibility-patched. See debugging.md for more information.");
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean isVector = outType.isVector();
|
||||
|
||||
// rename all references of this out declaration to a new name (iris_)
|
||||
String newName = tagPrefix + name;
|
||||
prevRoot.identifierIndex.rename(name, newName);
|
||||
|
||||
// rename the original out declaration back to the original name
|
||||
TypeAndInitDeclaration outDeclaration = outTypeSpecifier.getAncestor(TypeAndInitDeclaration.class);
|
||||
if (outDeclaration == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<DeclarationMember> outMembers = outDeclaration.getMembers();
|
||||
DeclarationMember outMember = null;
|
||||
for (DeclarationMember member : outMembers) {
|
||||
if (member.getName().getName().equals(newName)) {
|
||||
outMember = member;
|
||||
}
|
||||
}
|
||||
if (outMember == null) {
|
||||
throw new IllegalStateException("The targeted out declaration member is missing!");
|
||||
}
|
||||
outMember.getName().replaceByAndDelete(new Identifier(name));
|
||||
|
||||
// move the declaration member out of the declaration in case there is more than
|
||||
// one member to avoid changing the other member's type as well.
|
||||
if (outMembers.size() > 1) {
|
||||
outMember.detach();
|
||||
outTypeSpecifier = outTypeSpecifier.cloneInto(prevRoot);
|
||||
DeclarationExternalDeclaration singleOutDeclaration = (DeclarationExternalDeclaration) declarationTemplate
|
||||
.getInstanceFor(prevRoot,
|
||||
makeQualifierOut(outDeclaration.getType().getTypeQualifier().cloneInto(prevRoot)),
|
||||
outTypeSpecifier,
|
||||
new Identifier(name));
|
||||
((TypeAndInitDeclaration) singleOutDeclaration.getDeclaration()).getMembers().set(0, outMember);
|
||||
prevTree.injectNode(ASTInjectionPoint.BEFORE_DECLARATIONS, singleOutDeclaration);
|
||||
}
|
||||
|
||||
// add a global variable with the new name and the old type
|
||||
prevTree.injectNode(ASTInjectionPoint.BEFORE_DECLARATIONS, variableTemplate.getInstanceFor(prevRoot,
|
||||
outTypeSpecifier.cloneInto(prevRoot),
|
||||
new Identifier(newName)));
|
||||
|
||||
// insert a statement at the end of the main function that sets the value of the
|
||||
// out declaration to the value of the global variable and does a type cast
|
||||
prevTree.appendMain(
|
||||
(isVector && outType.getDimensions()[0] < inType.getDimensions()[0] ? statementTemplateVector
|
||||
: statementTemplate).getInstanceFor(prevRoot,
|
||||
new Identifier(name),
|
||||
new Identifier(newName),
|
||||
inTypeSpecifier.cloneInto(prevRoot)));
|
||||
|
||||
// make the out declaration use the same type as the fragment shader
|
||||
outTypeSpecifier.replaceByAndDelete(inTypeSpecifier.cloneInto(prevRoot));
|
||||
|
||||
// don't do the patch twice
|
||||
outDeclarations.put(name, null);
|
||||
|
||||
LOGGER.warn(
|
||||
"The out declaration '" + name + "' in the " + prevType.name()
|
||||
+ " shader has a different type " + outType.getMostCompactName()
|
||||
+ " than the corresponding in declaration of type " + inType.getMostCompactName()
|
||||
+ " in the following stage " + currentType.glShaderType.name()
|
||||
+ " and has been compatibility-patched. See debugging.md for more information.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prevType = type;
|
||||
}
|
||||
}
|
||||
if (inType.getText().equals(outType.getText())) {
|
||||
if (!Util.hasAssigment(prevTree, in)) {
|
||||
Util.initialize(prevTree, inDec.get(in), in);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
prevType = type;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,16 @@
|
||||
package net.coderbot.iris.pipeline.transform;
|
||||
|
||||
import io.github.douira.glsl_transformer.ast.node.TranslationUnit;
|
||||
import io.github.douira.glsl_transformer.ast.node.basic.ASTNode;
|
||||
import io.github.douira.glsl_transformer.ast.node.external_declaration.ExternalDeclaration;
|
||||
import io.github.douira.glsl_transformer.ast.query.Root;
|
||||
import io.github.douira.glsl_transformer.ast.query.match.AutoHintedMatcher;
|
||||
import io.github.douira.glsl_transformer.ast.query.match.Matcher;
|
||||
import io.github.douira.glsl_transformer.ast.transform.ASTInjectionPoint;
|
||||
import io.github.douira.glsl_transformer.ast.transform.ASTParser;
|
||||
import org.taumc.glsl.Util;
|
||||
import org.taumc.glsl.grammar.GLSLParser;
|
||||
|
||||
class CompositeDepthTransformer {
|
||||
private static final AutoHintedMatcher<ExternalDeclaration> uniformFloatCenterDepthSmooth = new AutoHintedMatcher<>(
|
||||
"uniform float centerDepthSmooth;", Matcher.externalDeclarationPattern);
|
||||
|
||||
public static void transform(
|
||||
ASTParser t,
|
||||
TranslationUnit tree,
|
||||
Root root) {
|
||||
public static void transform(GLSLParser.Translation_unitContext translationUnit) {
|
||||
// replace original declaration
|
||||
if (root.processMatches(t, uniformFloatCenterDepthSmooth, ASTNode::detachAndDelete)) {
|
||||
tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_DECLARATIONS,
|
||||
"uniform sampler2D iris_centerDepthSmooth;");
|
||||
|
||||
// if centerDepthSmooth is not declared as a uniform, we don't make it available
|
||||
root.replaceReferenceExpressions(t, "centerDepthSmooth",
|
||||
"texture2D(iris_centerDepthSmooth, vec2(0.5)).r");
|
||||
}
|
||||
int type = Util.findType(translationUnit, "centerDepthSmooth");
|
||||
if (type != 0) {
|
||||
Util.injectVariable(translationUnit, "uniform sampler2D iris_centerDepthSmooth;");
|
||||
Util.replaceExpression(translationUnit, "centerDepthSmooth", "texture2D(iris_centerDepthSmooth, vec2(0.5)).r");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package net.coderbot.iris.pipeline.transform;
|
||||
|
||||
import io.github.douira.glsl_transformer.ast.node.TranslationUnit;
|
||||
import io.github.douira.glsl_transformer.ast.node.expression.unary.FunctionCallExpression;
|
||||
import io.github.douira.glsl_transformer.ast.query.Root;
|
||||
import io.github.douira.glsl_transformer.ast.transform.ASTInjectionPoint;
|
||||
import io.github.douira.glsl_transformer.ast.transform.ASTParser;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class CompositeTransformer {
|
||||
public static void transform(
|
||||
ASTParser t,
|
||||
TranslationUnit tree,
|
||||
Root root) {
|
||||
CompositeDepthTransformer.transform(t, tree, root);
|
||||
|
||||
// if using a lod texture sampler and on version 120, patch in the extension
|
||||
// #extension GL_ARB_shader_texture_lod : require
|
||||
if (tree.getVersionStatement().version.number <= 120
|
||||
&& Stream.concat(
|
||||
root.identifierIndex.getStream("texture2DLod"),
|
||||
root.identifierIndex.getStream("texture3DLod"))
|
||||
.filter(id -> id.getParent() instanceof FunctionCallExpression)
|
||||
.findAny().isPresent()) {
|
||||
tree.parseAndInjectNode(t, ASTInjectionPoint.BEFORE_DECLARATIONS,
|
||||
"#extension GL_ARB_shader_texture_lod : require\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package net.coderbot.iris.pipeline.transform;
|
||||
|
||||
import io.github.douira.glsl_transformer.job_parameter.JobParameters;
|
||||
|
||||
class Parameters extends JobParameters {
|
||||
public final Patch patch;
|
||||
public PatchShaderType type;
|
||||
|
||||
public Parameters(Patch patch) {
|
||||
this.patch = patch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((patch == null) ? 0 : patch.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Parameters other = (Parameters) obj;
|
||||
if (patch != other.patch)
|
||||
return false;
|
||||
if (type != other.type)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.coderbot.iris.pipeline.transform;
|
||||
|
||||
enum Patch {
|
||||
public enum Patch {
|
||||
ATTRIBUTES,
|
||||
SODIUM_TERRAIN,
|
||||
COMPOSITE
|
||||
|
||||
@@ -0,0 +1,359 @@
|
||||
package net.coderbot.iris.pipeline.transform;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
import net.coderbot.iris.Iris;
|
||||
import net.coderbot.iris.gl.shader.ShaderType;
|
||||
import net.coderbot.iris.pipeline.transform.parameter.Parameters;
|
||||
import net.coderbot.iris.pipeline.transform.parameter.AttributeParameters;
|
||||
import org.antlr.v4.runtime.BailErrorStrategy;
|
||||
import org.antlr.v4.runtime.CharStreams;
|
||||
import org.antlr.v4.runtime.CommonTokenStream;
|
||||
import org.antlr.v4.runtime.ConsoleErrorListener;
|
||||
import org.antlr.v4.runtime.DefaultErrorStrategy;
|
||||
import org.antlr.v4.runtime.Parser;
|
||||
import org.antlr.v4.runtime.atn.PredictionMode;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.antlr.v4.runtime.tree.TerminalNode;
|
||||
import org.taumc.glsl.Util;
|
||||
import org.taumc.glsl.grammar.GLSLLexer;
|
||||
import org.taumc.glsl.grammar.GLSLParser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ShaderTransformer {
|
||||
static String tab = "";
|
||||
|
||||
private static final Pattern versionPattern = Pattern.compile("#version\\s+(\\d+)(?:\\s+(\\w+))?");
|
||||
|
||||
private static final int CACHE_SIZE = 100;
|
||||
private static final Object2ObjectLinkedOpenHashMap<TransformKey, Map<PatchShaderType, String>> shaderTransformationCache = new Object2ObjectLinkedOpenHashMap<>();
|
||||
private static final boolean useCache = true;
|
||||
|
||||
/**
|
||||
* These are words which need to be renamed by iris if a shader uses them, regardless o the GLSL version.
|
||||
* The words will get caught and renamed to iris_renamed_$WORD
|
||||
*/
|
||||
private static final List<String> fullReservedWords = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* This does the same thing as fullReservedWords, but based on a maximum GLSL version. As an example
|
||||
* if something was register to 400 here, it would get applied on any version below 400.
|
||||
*/
|
||||
private static final Map<Integer, List<String>> versionedReservedWords = new HashMap<>();
|
||||
|
||||
static {
|
||||
// texture seems to be reserved by some drivers but not others, however this is not actually reserved by the GLSL spec
|
||||
fullReservedWords.add("texture");
|
||||
|
||||
// sample was added as a keyword in GLSL 400, many shaders use it
|
||||
versionedReservedWords.put(400, Arrays.asList("sample"));
|
||||
}
|
||||
|
||||
private static final class TransformKey<P extends Parameters> {
|
||||
private final Patch patchType;
|
||||
private final EnumMap<PatchShaderType, String> inputs;
|
||||
private final P params;
|
||||
|
||||
private TransformKey(Patch patchType, EnumMap<PatchShaderType, String> inputs, P params) {
|
||||
this.patchType = patchType;
|
||||
this.inputs = inputs;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
public Patch patchType() {
|
||||
return patchType;
|
||||
}
|
||||
|
||||
public EnumMap<PatchShaderType, String> inputs() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
public P params() {
|
||||
return params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) return true;
|
||||
if (obj == null || obj.getClass() != this.getClass()) return false;
|
||||
var that = (TransformKey) obj;
|
||||
return Objects.equals(this.patchType, that.patchType) &&
|
||||
Objects.equals(this.inputs, that.inputs) &&
|
||||
Objects.equals(this.params, that.params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(patchType, inputs, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TransformKey[" +
|
||||
"patchType=" + patchType + ", " +
|
||||
"inputs=" + inputs + ", " +
|
||||
"params=" + params + ']';
|
||||
}
|
||||
}
|
||||
|
||||
public static <P extends Parameters> Map<PatchShaderType, String> transform(String vertex, String geometry, String fragment, P parameters) {
|
||||
if (vertex == null && geometry == null && fragment == null) {
|
||||
return null;
|
||||
} else {
|
||||
Map<PatchShaderType, String> result;
|
||||
|
||||
var patchType = parameters.patch;
|
||||
|
||||
EnumMap<PatchShaderType, String> inputs = new EnumMap<>(PatchShaderType.class);
|
||||
inputs.put(PatchShaderType.VERTEX, vertex);
|
||||
inputs.put(PatchShaderType.GEOMETRY, geometry);
|
||||
inputs.put(PatchShaderType.FRAGMENT, fragment);
|
||||
|
||||
var key = new TransformKey(patchType, inputs, parameters);
|
||||
|
||||
result = shaderTransformationCache.getAndMoveToFirst(key);
|
||||
if(result == null || !useCache) {
|
||||
result = transformInternal(inputs, patchType, parameters);
|
||||
// Clear this, we don't want whatever random type was last transformed being considered for the key
|
||||
parameters.type = null;
|
||||
if(shaderTransformationCache.size() >= CACHE_SIZE) {
|
||||
shaderTransformationCache.removeLast();
|
||||
}
|
||||
shaderTransformationCache.putAndMoveToLast(key, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private static void configureNoError(Parser parser) {
|
||||
parser.setErrorHandler(new BailErrorStrategy());
|
||||
parser.removeErrorListeners();
|
||||
parser.getInterpreter().setPredictionMode(PredictionMode.SLL);
|
||||
}
|
||||
|
||||
private static void configureError(Parser parser) {
|
||||
parser.setErrorHandler(new DefaultErrorStrategy());
|
||||
parser.addErrorListener(ConsoleErrorListener.INSTANCE);
|
||||
parser.getInterpreter().setPredictionMode(PredictionMode.LL);
|
||||
}
|
||||
|
||||
private static <P extends Parameters> Map<PatchShaderType, String> transformInternal(EnumMap<PatchShaderType, String> inputs, Patch patchType, P parameters) {
|
||||
EnumMap<PatchShaderType, String> result = new EnumMap<>(PatchShaderType.class);
|
||||
EnumMap<PatchShaderType, GLSLParser.Translation_unitContext> types = new EnumMap<>(PatchShaderType.class);
|
||||
EnumMap<PatchShaderType, String> prepatched = new EnumMap<>(PatchShaderType.class);
|
||||
List<GLSLParser.Translation_unitContext> textureLodExtensionPatches = new ArrayList<>();
|
||||
|
||||
Stopwatch watch = Stopwatch.createStarted();
|
||||
|
||||
for (PatchShaderType type : PatchShaderType.values()) {
|
||||
parameters.type = type;
|
||||
if (inputs.get(type) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String input = inputs.get(type);
|
||||
|
||||
Matcher matcher = versionPattern.matcher(input);
|
||||
if (!matcher.find()) {
|
||||
throw new IllegalArgumentException("No #version directive found in source code!");
|
||||
}
|
||||
|
||||
String versionString = matcher.group(1);
|
||||
if (versionString == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String profile = "";
|
||||
int versionInt = Integer.parseInt(versionString);
|
||||
if (versionInt >= 150) {
|
||||
profile = matcher.group(2);
|
||||
if (profile == null) {
|
||||
profile = "core";
|
||||
}
|
||||
}
|
||||
|
||||
String profileString = "#version " + versionString + " " + profile + "\n";
|
||||
|
||||
// The primary reason we rename words here using regex, is because if the words cause invalid
|
||||
// GLSL, regardless of the version being used, it will cause glsl-transformation-lib to fail
|
||||
// so we need to rename them prior to passing the shader input to glsl-transformation-lib.
|
||||
for (String reservedWord : fullReservedWords) {
|
||||
String newName = "iris_renamed_" + reservedWord;
|
||||
input = input.replaceAll("\\b" + reservedWord + "\\b", newName);
|
||||
}
|
||||
for (int version : versionedReservedWords.keySet()) {
|
||||
if (versionInt < version) {
|
||||
for (String reservedWord : versionedReservedWords.get(version)) {
|
||||
String newName = "iris_renamed_" + reservedWord;
|
||||
input = input.replaceAll("\\b" + reservedWord + "\\b", newName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GLSLLexer lexer = new GLSLLexer(CharStreams.fromString(input));
|
||||
GLSLParser parser = new GLSLParser(new CommonTokenStream(lexer));
|
||||
parser.setBuildParseTree(true);
|
||||
configureNoError(parser);
|
||||
|
||||
GLSLParser.Translation_unitContext translationUnit;
|
||||
try {
|
||||
translationUnit = doTransform(parser, patchType, parameters, profile, versionInt);
|
||||
} catch (Exception e) {
|
||||
lexer.reset();
|
||||
parser.reset();
|
||||
configureError(parser);
|
||||
translationUnit = doTransform(parser, patchType, parameters, profile, versionInt);
|
||||
}
|
||||
|
||||
// Check if we need to patch in texture LOD extension enabling
|
||||
if (versionInt <= 120 && (Util.containsCall(translationUnit, "texture2DLod") || Util.containsCall(translationUnit, "texture3DLod"))) {
|
||||
textureLodExtensionPatches.add(translationUnit);
|
||||
}
|
||||
types.put(type, translationUnit);
|
||||
prepatched.put(type, profileString);
|
||||
}
|
||||
CompatibilityTransformer.transformGrouped(types, parameters);
|
||||
for (var entry : types.entrySet()) {
|
||||
// This is a hack to inject an extension declaration when the GLSL version is less than 120
|
||||
// Doing this as a string manipulation on the final shader output since it needs to put this
|
||||
// before variables, didn't see an easy way to do that with glsl-transformation-lib
|
||||
// Eventually this can probably be moved to use glsl-transformation-lib
|
||||
String formattedShader = getFormattedShader(entry.getValue(), prepatched.get(entry.getKey()));
|
||||
if (textureLodExtensionPatches.contains(entry.getValue())) {
|
||||
String[] parts = formattedShader.split("\n", 2);
|
||||
parts[1] = "#extension GL_ARB_shader_texture_lod : require\n" + parts[1];
|
||||
formattedShader = parts[0] + "\n" + parts[1];
|
||||
}
|
||||
result.put(entry.getKey(), formattedShader);
|
||||
}
|
||||
watch.stop();
|
||||
Iris.logger.info("Transformed shader for {} in {}", patchType.name(), watch);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static GLSLParser.Translation_unitContext doTransform(GLSLParser parser, Patch patchType, Parameters parameters, String profile, int versionInt) {
|
||||
GLSLParser.Translation_unitContext translationUnit = parser.translation_unit();
|
||||
switch (patchType) {
|
||||
case SODIUM_TERRAIN:
|
||||
SodiumTransformer.transform(translationUnit, parameters);
|
||||
break;
|
||||
case COMPOSITE:
|
||||
CompositeDepthTransformer.transform(translationUnit);
|
||||
break;
|
||||
case ATTRIBUTES:
|
||||
AttributeTransformer.transform(translationUnit, (AttributeParameters) parameters, profile, versionInt);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown patch type: " + patchType.name());
|
||||
}
|
||||
CompatibilityTransformer.transformEach(translationUnit, parameters);
|
||||
return translationUnit;
|
||||
}
|
||||
|
||||
public static void applyIntelHd4000Workaround(GLSLParser.Translation_unitContext translationUnit) {
|
||||
Util.renameFunctionCall(translationUnit, "ftransform", "iris_ftransform");
|
||||
}
|
||||
|
||||
|
||||
public static void replaceGlMultiTexCoordBounded(GLSLParser.Translation_unitContext translationUnit, int min, int max) {
|
||||
for (int i = min; i <= max; i++) {
|
||||
Util.replaceExpression(translationUnit, "gl_MultiTexCoord" + i, "vec4(0.0, 0.0, 0.0, 1.0)");
|
||||
}
|
||||
}
|
||||
|
||||
public static void patchMultiTexCoord3(GLSLParser.Translation_unitContext translationUnit, Parameters parameters) {
|
||||
if (parameters.type.glShaderType == ShaderType.VERTEX && Util.hasVariable(translationUnit, "gl_MultiTexCoord3") && !Util.hasVariable(translationUnit, "mc_midTexCoord")) {
|
||||
Util.rename(translationUnit, "gl_MultiTexCoord3", "mc_midTexCoord");
|
||||
Util.injectVariable(translationUnit, "attribute vec4 mc_midTexCoord;");
|
||||
}
|
||||
}
|
||||
|
||||
public static void replaceMidTexCoord(GLSLParser.Translation_unitContext translationUnit, float textureScale) {
|
||||
int type = Util.findType(translationUnit, "mc_midTexCoord");
|
||||
if (type != 0) {
|
||||
Util.removeVariable(translationUnit, "mc_midTexCoord");
|
||||
}
|
||||
Util.replaceExpression(translationUnit, "mc_midTexCoord", "iris_MidTex");
|
||||
switch (type) {
|
||||
case 0:
|
||||
return;
|
||||
case GLSLLexer.BOOL:
|
||||
return;
|
||||
case GLSLLexer.FLOAT:
|
||||
Util.injectFunction(translationUnit, "float iris_MidTex = (mc_midTexCoord.x * " + textureScale + ").x;"); //TODO go back to variable if order is fixed
|
||||
break;
|
||||
case GLSLLexer.VEC2:
|
||||
Util.injectFunction(translationUnit, "vec2 iris_MidTex = (mc_midTexCoord.xy * " + textureScale + ").xy;");
|
||||
break;
|
||||
case GLSLLexer.VEC3:
|
||||
Util.injectFunction(translationUnit, "vec3 iris_MidTex = vec3(mc_midTexCoord.xy * " + textureScale + ", 0.0);");
|
||||
break;
|
||||
case GLSLLexer.VEC4:
|
||||
Util.injectFunction(translationUnit, "vec4 iris_MidTex = vec4(mc_midTexCoord.xy * " + textureScale + ", 0.0, 1.0);");
|
||||
break;
|
||||
default:
|
||||
|
||||
}
|
||||
|
||||
Util.injectVariable(translationUnit, "in vec2 mc_midTexCoord;"); //TODO why is this inserted oddly?
|
||||
|
||||
}
|
||||
|
||||
public static void addIfNotExists(GLSLParser.Translation_unitContext translationUnit, String name, String code) {
|
||||
if (!Util.hasVariable(translationUnit, name)) {
|
||||
Util.injectVariable(translationUnit, code);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addIfNotExistsType(GLSLParser.Translation_unitContext translationUnit, String name, String type) {
|
||||
if (!Util.hasVariable(translationUnit, name)) {
|
||||
Util.injectVariable(translationUnit, type + " " + name + ";");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getFormattedShader(ParseTree tree, String string) {
|
||||
StringBuilder sb = new StringBuilder(string + "\n");
|
||||
getFormattedShader(tree, sb);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static void getFormattedShader(ParseTree tree, StringBuilder stringBuilder) {
|
||||
if (tree instanceof TerminalNode) {
|
||||
String text = tree.getText();
|
||||
if (text.equals("<EOF>")) {
|
||||
return;
|
||||
}
|
||||
if (text.equals("#")) {
|
||||
stringBuilder.append("\n#");
|
||||
return;
|
||||
}
|
||||
stringBuilder.append(text);
|
||||
if (text.equals("{")) {
|
||||
stringBuilder.append(" \n\t");
|
||||
tab = "\t";
|
||||
}
|
||||
|
||||
if (text.equals("}")) {
|
||||
stringBuilder.deleteCharAt(stringBuilder.length() - 2);
|
||||
tab = "";
|
||||
}
|
||||
stringBuilder.append(text.equals(";") ? " \n" + tab : " ");
|
||||
} else {
|
||||
for(int i = 0; i < tree.getChildCount(); ++i) {
|
||||
getFormattedShader(tree.getChild(i), stringBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package net.coderbot.iris.pipeline.transform;
|
||||
|
||||
import io.github.douira.glsl_transformer.ast.node.TranslationUnit;
|
||||
import io.github.douira.glsl_transformer.ast.node.expression.Expression;
|
||||
import io.github.douira.glsl_transformer.ast.query.Root;
|
||||
import io.github.douira.glsl_transformer.ast.query.match.AutoHintedMatcher;
|
||||
import io.github.douira.glsl_transformer.ast.query.match.Matcher;
|
||||
import io.github.douira.glsl_transformer.ast.transform.ASTInjectionPoint;
|
||||
import io.github.douira.glsl_transformer.ast.transform.ASTParser;
|
||||
|
||||
/**
|
||||
* Does the sodium terrain transformations using glsl-transformer AST.
|
||||
*/
|
||||
class SodiumTerrainTransformer {
|
||||
public static void transform(
|
||||
ASTParser t,
|
||||
TranslationUnit tree,
|
||||
Root root,
|
||||
Parameters parameters) {
|
||||
switch (parameters.type) {
|
||||
// For Sodium patching, treat fragment and geometry the same
|
||||
case FRAGMENT:
|
||||
case GEOMETRY:
|
||||
transformFragment(t, tree, root, parameters);
|
||||
break;
|
||||
case VERTEX:
|
||||
transformVertex(t, tree, root, parameters);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected Sodium terrain patching shader type: " + parameters.type);
|
||||
}
|
||||
}
|
||||
|
||||
private static final AutoHintedMatcher<Expression> glTextureMatrix0 = new AutoHintedMatcher<>(
|
||||
"gl_TextureMatrix[0]", Matcher.expressionPattern);
|
||||
|
||||
/**
|
||||
* Transforms vertex shaders.
|
||||
*/
|
||||
public static void transformVertex(
|
||||
ASTParser t,
|
||||
TranslationUnit tree,
|
||||
Root root,
|
||||
Parameters parameters) {
|
||||
tree.parseAndInjectNodes(t, ASTInjectionPoint.BEFORE_DECLARATIONS,
|
||||
"attribute vec3 iris_Pos;",
|
||||
"attribute vec4 iris_Color;",
|
||||
"attribute vec2 iris_TexCoord;",
|
||||
"attribute vec2 iris_LightCoord;",
|
||||
"attribute vec3 iris_Normal;", // some are shared
|
||||
"uniform vec3 u_ModelScale;",
|
||||
"uniform vec2 u_TextureScale;",
|
||||
"attribute vec4 iris_ModelOffset;",
|
||||
"vec4 iris_LightTexCoord = vec4(iris_LightCoord, 0, 1);",
|
||||
"vec4 ftransform() { return gl_ModelViewProjectionMatrix * gl_Vertex; }");
|
||||
|
||||
transformShared(t, tree, root, parameters);
|
||||
|
||||
root.replaceReferenceExpressions(t, "gl_Vertex",
|
||||
"vec4((iris_Pos * u_ModelScale) + iris_ModelOffset.xyz, 1.0)");
|
||||
root.replaceReferenceExpressions(t, "gl_MultiTexCoord0",
|
||||
"vec4(iris_TexCoord * u_TextureScale, 0.0, 1.0)");
|
||||
root.replaceReferenceExpressions(t, "gl_MultiTexCoord1",
|
||||
"iris_LightTexCoord");
|
||||
root.replaceReferenceExpressions(t, "gl_MultiTexCoord2",
|
||||
"iris_LightTexCoord");
|
||||
root.rename("gl_Color", "iris_Color");
|
||||
root.rename("gl_Normal", "iris_Normal");
|
||||
root.rename("ftransform", "iris_ftransform");
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms fragment shaders. The fragment shader does only the shared things
|
||||
* from the vertex shader.
|
||||
*/
|
||||
public static void transformFragment(
|
||||
ASTParser t,
|
||||
TranslationUnit tree,
|
||||
Root root,
|
||||
Parameters parameters) {
|
||||
// interestingly there is nothing that isn't shared
|
||||
transformShared(t, tree, root, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the things that transformVertex and transformFragment have in common.
|
||||
*/
|
||||
private static void transformShared(
|
||||
ASTParser t,
|
||||
TranslationUnit tree,
|
||||
Root root,
|
||||
Parameters parameters) {
|
||||
tree.parseAndInjectNodes(t, ASTInjectionPoint.BEFORE_DECLARATIONS,
|
||||
"uniform mat4 iris_ModelViewMatrix;",
|
||||
"uniform mat4 u_ModelViewProjectionMatrix;",
|
||||
"uniform mat4 iris_NormalMatrix;",
|
||||
"uniform mat4 iris_LightmapTextureMatrix;");
|
||||
root.rename("gl_ModelViewMatrix", "iris_ModelViewMatrix");
|
||||
root.rename("gl_ModelViewProjectionMatrix", "u_ModelViewProjectionMatrix");
|
||||
root.replaceReferenceExpressions(t,
|
||||
"gl_NormalMatrix", "mat3(iris_NormalMatrix)");
|
||||
|
||||
root.replaceExpressionMatches(
|
||||
t,
|
||||
glTextureMatrix0,
|
||||
"mat4(1.0)");
|
||||
root.replaceExpressionMatches(t, glTextureMatrix1, "iris_LightmapTextureMatrix");
|
||||
}
|
||||
private static final String lightmapCoordsExpression = "iris_LightCoord";
|
||||
private static final AutoHintedMatcher<Expression> glTextureMatrix1 = new AutoHintedMatcher<>(
|
||||
"gl_TextureMatrix[1]", Matcher.expressionPattern);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package net.coderbot.iris.pipeline.transform;
|
||||
|
||||
import net.coderbot.iris.pipeline.transform.parameter.Parameters;
|
||||
import org.taumc.glsl.Util;
|
||||
import org.taumc.glsl.grammar.GLSLParser;
|
||||
|
||||
class SodiumTransformer {
|
||||
public static void transform(GLSLParser.Translation_unitContext translationUnit, Parameters parameters) {
|
||||
switch (parameters.type) {
|
||||
// For Sodium patching, treat fragment and geometry the same
|
||||
case FRAGMENT:
|
||||
case GEOMETRY:
|
||||
transformFragment(translationUnit, parameters);
|
||||
break;
|
||||
case VERTEX:
|
||||
transformVertex(translationUnit, parameters);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected Sodium terrain patching shader type: " + parameters.type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms vertex shaders.
|
||||
*/
|
||||
public static void transformVertex(GLSLParser.Translation_unitContext translationUnit, Parameters parameters) {
|
||||
|
||||
Util.injectVariable(translationUnit, "attribute vec3 iris_Pos;");
|
||||
Util.injectVariable(translationUnit, "attribute vec4 iris_Color;");
|
||||
Util.injectVariable(translationUnit, "attribute vec2 iris_TexCoord;");
|
||||
Util.injectVariable(translationUnit, "attribute vec2 iris_LightCoord;");
|
||||
Util.injectVariable(translationUnit, "attribute vec3 iris_Normal;");
|
||||
Util.injectVariable(translationUnit, "uniform vec3 u_ModelScale;");
|
||||
Util.injectVariable(translationUnit, "uniform vec2 u_TextureScale;");
|
||||
Util.injectVariable(translationUnit, "attribute vec4 iris_ModelOffset;");
|
||||
Util.injectFunction(translationUnit, "vec4 iris_LightTexCoord = vec4(iris_LightCoord, 0, 1);");
|
||||
Util.injectFunction(translationUnit, "vec4 ftransform() { return gl_ModelViewProjectionMatrix * gl_Vertex; }");
|
||||
|
||||
transformShared(translationUnit, parameters);
|
||||
|
||||
Util.replaceExpression(translationUnit, "gl_Vertex", "vec4((iris_Pos * u_ModelScale) + iris_ModelOffset.xyz, 1.0)");
|
||||
Util.replaceExpression(translationUnit, "gl_MultiTexCoord0", "vec4(iris_TexCoord * u_TextureScale, 0.0, 1.0)");
|
||||
Util.replaceExpression(translationUnit, "gl_MultiTexCoord1", "iris_LightTexCoord");
|
||||
Util.replaceExpression(translationUnit, "gl_MultiTexCoord2", "iris_LightTexCoord");
|
||||
Util.rename(translationUnit, "gl_Color", "iris_Color");
|
||||
Util.rename(translationUnit, "gl_Normal", "iris_Normal");
|
||||
Util.rename(translationUnit, "ftransform", "iris_ftransform");
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms fragment shaders. The fragment shader does only the shared things
|
||||
* from the vertex shader.
|
||||
*/
|
||||
public static void transformFragment(GLSLParser.Translation_unitContext translationUnit, Parameters parameters) {
|
||||
// interestingly there is nothing that isn't shared
|
||||
transformShared(translationUnit, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the things that transformVertex and transformFragment have in common.
|
||||
*/
|
||||
private static void transformShared(GLSLParser.Translation_unitContext translationUnit, Parameters parameters) {
|
||||
Util.injectVariable(translationUnit, "uniform mat4 iris_ModelViewMatrix;");
|
||||
Util.injectVariable(translationUnit, "uniform mat4 u_ModelViewProjectionMatrix;");
|
||||
Util.injectVariable(translationUnit, "uniform mat4 iris_NormalMatrix;");
|
||||
Util.injectVariable(translationUnit, "uniform mat4 iris_LightmapTextureMatrix;");
|
||||
|
||||
Util.rename(translationUnit, "gl_ModelViewMatrix", "iris_ModelViewMatrix");
|
||||
Util.rename(translationUnit, "gl_ModelViewProjectionMatrix", "u_ModelViewProjectionMatrix");
|
||||
Util.replaceExpression(translationUnit, "gl_NormalMatrix", "mat3(iris_NormalMatrix)");
|
||||
|
||||
Util.replaceExpression(translationUnit, "gl_TextureMatrix[0]", "mat4(1.0)");
|
||||
Util.replaceExpression(translationUnit, "gl_TextureMatrix[1]", "iris_LightmapTextureMatrix");
|
||||
}
|
||||
}
|
||||
@@ -1,226 +1,115 @@
|
||||
package net.coderbot.iris.pipeline.transform;
|
||||
|
||||
import io.github.douira.glsl_transformer.ast.node.Identifier;
|
||||
import io.github.douira.glsl_transformer.ast.node.TranslationUnit;
|
||||
import io.github.douira.glsl_transformer.ast.node.Version;
|
||||
import io.github.douira.glsl_transformer.ast.print.PrintType;
|
||||
import io.github.douira.glsl_transformer.ast.query.Root;
|
||||
import io.github.douira.glsl_transformer.ast.transform.EnumASTTransformer;
|
||||
import io.github.douira.glsl_transformer.cst.core.SemanticException;
|
||||
import io.github.douira.glsl_transformer.cst.token_filter.ChannelFilter;
|
||||
import io.github.douira.glsl_transformer.cst.token_filter.TokenChannel;
|
||||
import io.github.douira.glsl_transformer.cst.token_filter.TokenFilter;
|
||||
import io.github.douira.glsl_transformer.util.LRUCache;
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
|
||||
import net.coderbot.iris.pipeline.PatchedShaderPrinter;
|
||||
import org.antlr.v4.runtime.RecognitionException;
|
||||
import org.antlr.v4.runtime.Token;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import net.coderbot.iris.pipeline.transform.parameter.AttributeParameters;
|
||||
import net.coderbot.iris.pipeline.transform.parameter.Parameters;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* The transform patcher (triforce 2) uses glsl-transformer's ASTTransformer to
|
||||
* do shader transformation.
|
||||
*
|
||||
* The TransformPatcher does caching on the source string and associated
|
||||
* parameters. For this to work, all objects contained in a parameter must have
|
||||
* an equals method and they must never be changed after having been used for
|
||||
* patching. Since the cache also contains the source string, it doesn't need to
|
||||
* be disabled when developing shaderpacks. However, when changes are made to
|
||||
* the patcher, the cache should be disabled with {@link #useCache}.
|
||||
*
|
||||
* NOTE: This patcher expects (and ensures) that the string doesn't contain any
|
||||
* (!) preprocessor directives. The only allowed ones are #extension and #pragma
|
||||
* as they are considered "parsed" directives. If any other directive appears in
|
||||
* the string, it will throw.
|
||||
*/
|
||||
public class TransformPatcher {
|
||||
static Logger LOGGER = LogManager.getLogger(TransformPatcher.class);
|
||||
private static EnumASTTransformer<Parameters, PatchShaderType> transformer;
|
||||
private static final boolean useCache = true;
|
||||
private static final Map<CacheKey, Map<PatchShaderType, String>> cache = new LRUCache<>(400);
|
||||
|
||||
private static class CacheKey {
|
||||
final Parameters parameters;
|
||||
final String vertex;
|
||||
final String geometry;
|
||||
final String fragment;
|
||||
private static final int MAX_CACHE_ENTRIES = 400;
|
||||
private static final Map<TransformPatcher.CacheKey, Map<PatchShaderType, String>> cache = new LinkedHashMap<>(MAX_CACHE_ENTRIES + 1, .75F, true) {
|
||||
public boolean removeEldestEntry(Map.Entry eldest) {
|
||||
return size() > MAX_CACHE_ENTRIES;
|
||||
}
|
||||
};
|
||||
|
||||
public CacheKey(Parameters parameters, String vertex, String geometry, String fragment) {
|
||||
this.parameters = parameters;
|
||||
this.vertex = vertex;
|
||||
this.geometry = geometry;
|
||||
this.fragment = fragment;
|
||||
}
|
||||
private static final boolean useCache = true;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((fragment == null) ? 0 : fragment.hashCode());
|
||||
result = prime * result + ((geometry == null) ? 0 : geometry.hashCode());
|
||||
result = prime * result + ((parameters == null) ? 0 : parameters.hashCode());
|
||||
result = prime * result + ((vertex == null) ? 0 : vertex.hashCode());
|
||||
return result;
|
||||
}
|
||||
private static class CacheKey {
|
||||
final Parameters parameters;
|
||||
final String vertex;
|
||||
final String geometry;
|
||||
final String fragment;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CacheKey other = (CacheKey) obj;
|
||||
if (fragment == null) {
|
||||
if (other.fragment != null)
|
||||
return false;
|
||||
} else if (!fragment.equals(other.fragment))
|
||||
return false;
|
||||
if (geometry == null) {
|
||||
if (other.geometry != null)
|
||||
return false;
|
||||
} else if (!geometry.equals(other.geometry))
|
||||
return false;
|
||||
if (parameters == null) {
|
||||
if (other.parameters != null)
|
||||
return false;
|
||||
} else if (!parameters.equals(other.parameters))
|
||||
return false;
|
||||
if (vertex == null) {
|
||||
if (other.vertex != null)
|
||||
return false;
|
||||
} else if (!vertex.equals(other.vertex))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public CacheKey(Parameters parameters, String vertex, String geometry, String fragment) {
|
||||
this.parameters = parameters;
|
||||
this.vertex = vertex;
|
||||
this.geometry = geometry;
|
||||
this.fragment = fragment;
|
||||
}
|
||||
|
||||
// TODO: Only do the NewLines patches if the source code isn't from
|
||||
// gbuffers_lines (what does this mean?)
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((fragment == null) ? 0 : fragment.hashCode());
|
||||
result = prime * result + ((geometry == null) ? 0 : geometry.hashCode());
|
||||
result = prime * result + ((parameters == null) ? 0 : parameters.hashCode());
|
||||
result = prime * result + ((vertex == null) ? 0 : vertex.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
static TokenFilter<Parameters> parseTokenFilter = new ChannelFilter<Parameters>(TokenChannel.PREPROCESSOR) {
|
||||
@Override
|
||||
public boolean isTokenAllowed(Token token) {
|
||||
if (!super.isTokenAllowed(token)) {
|
||||
throw new SemanticException("Unparsed preprocessor directives such as '" + token.getText()
|
||||
+ "' may not be present at this stage of shader processing!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
TransformPatcher.CacheKey other = (TransformPatcher.CacheKey) obj;
|
||||
if (fragment == null) {
|
||||
if (other.fragment != null)
|
||||
return false;
|
||||
} else if (!fragment.equals(other.fragment))
|
||||
return false;
|
||||
if (geometry == null) {
|
||||
if (other.geometry != null)
|
||||
return false;
|
||||
} else if (!geometry.equals(other.geometry))
|
||||
return false;
|
||||
if (parameters == null) {
|
||||
if (other.parameters != null)
|
||||
return false;
|
||||
} else if (!parameters.equals(other.parameters))
|
||||
return false;
|
||||
if (vertex == null) {
|
||||
if (other.vertex != null)
|
||||
return false;
|
||||
} else if (!vertex.equals(other.vertex))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
transformer = new EnumASTTransformer<Parameters, PatchShaderType>(PatchShaderType.class) {
|
||||
@Override
|
||||
public TranslationUnit parseTranslationUnit(String input) throws RecognitionException {
|
||||
// parse #version directive using an efficient regex before parsing so that the
|
||||
// parser can be set to the correct version
|
||||
Matcher matcher = versionPattern.matcher(input);
|
||||
if (!matcher.find()) {
|
||||
throw new IllegalArgumentException("No #version directive found in source code! See debugging.md for more information.");
|
||||
}
|
||||
Version version = Version.fromNumber(Integer.parseInt(matcher.group(1)));
|
||||
transformer.getLexer().version = version;
|
||||
private static Map<PatchShaderType, String> transform(String vertex, String geometry, String fragment, Parameters parameters) {
|
||||
if (vertex == null && geometry == null && fragment == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return super.parseTranslationUnit(input);
|
||||
}
|
||||
};
|
||||
transformer.setTransformation((trees, parameters) -> {
|
||||
for (PatchShaderType type : PatchShaderType.values()) {
|
||||
TranslationUnit tree = trees.get(type);
|
||||
if (tree == null) {
|
||||
continue;
|
||||
}
|
||||
// @Asek3 I have old GLSL-Transformer on JRE8, so I will off this
|
||||
//tree.outputOptions.enablePrintInfo();
|
||||
// check if this has been cached
|
||||
TransformPatcher.CacheKey key;
|
||||
Map<PatchShaderType, String> result = null;
|
||||
if (useCache) {
|
||||
key = new TransformPatcher.CacheKey(parameters, vertex, geometry, fragment);
|
||||
if (cache.containsKey(key)) {
|
||||
result = cache.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
parameters.type = type;
|
||||
Root root = tree.getRoot();
|
||||
// if there is no cache result, transform the shaders
|
||||
if (result == null) {
|
||||
result = ShaderTransformer.transform(vertex, geometry, fragment, parameters);
|
||||
if (useCache) {
|
||||
cache.put(key, result);
|
||||
}
|
||||
}
|
||||
|
||||
// check for illegal references to internal Iris shader interfaces
|
||||
Optional<Identifier> violation = root.identifierIndex.prefixQueryFlat("iris_").findAny();
|
||||
if (!violation.isPresent()) {
|
||||
violation = root.identifierIndex.prefixQueryFlat("irisMain").findAny();
|
||||
}
|
||||
violation.ifPresent(id -> {
|
||||
throw new SemanticException(
|
||||
"Detected a potential reference to unstable and internal Iris shader interfaces (iris_ and irisMain). This isn't currently supported. Violation: "
|
||||
+ id.getName() + ". See debugging.md for more information.");
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
Root.indexBuildSession(tree, () -> {
|
||||
switch (parameters.patch) {
|
||||
case ATTRIBUTES:
|
||||
AttributeTransformer.transform(transformer, tree, root, (AttributeParameters) parameters);
|
||||
break;
|
||||
case SODIUM_TERRAIN:
|
||||
SodiumTerrainTransformer.transform(transformer, tree, root, parameters);
|
||||
break;
|
||||
case COMPOSITE:
|
||||
CompositeTransformer.transform(transformer, tree, root);
|
||||
break;
|
||||
}
|
||||
CompatibilityTransformer.transformEach(transformer, tree, root, parameters);
|
||||
});
|
||||
}
|
||||
public static Map<PatchShaderType, String> patchAttributes(String vertex, String geometry, String fragment, InputAvailability inputs) {
|
||||
return transform(vertex, geometry, fragment, new AttributeParameters(Patch.ATTRIBUTES, geometry != null, inputs));
|
||||
}
|
||||
|
||||
// the compatibility transformer does a grouped transformation
|
||||
CompatibilityTransformer.transformGrouped(transformer, trees, parameters);
|
||||
});
|
||||
transformer.setParseTokenFilter(parseTokenFilter);
|
||||
}
|
||||
public static Map<PatchShaderType, String> patchSodiumTerrain(String vertex, String geometry, String fragment) {
|
||||
return transform(vertex, geometry, fragment, new Parameters(Patch.SODIUM_TERRAIN));
|
||||
}
|
||||
|
||||
private static final Pattern versionPattern = Pattern.compile("^.*#version\\s+(\\d+)", Pattern.DOTALL);
|
||||
|
||||
private static Map<PatchShaderType, String> transform(String vertex, String geometry, String fragment, Parameters parameters) {
|
||||
// stop if all are null
|
||||
if (vertex == null && geometry == null && fragment == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// check if this has been cached
|
||||
CacheKey key;
|
||||
Map<PatchShaderType, String> result = null;
|
||||
if (useCache) {
|
||||
key = new CacheKey(parameters, vertex, geometry, fragment);
|
||||
if (cache.containsKey(key)) {
|
||||
result = cache.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
// if there is no cache result, transform the shaders
|
||||
if (result == null) {
|
||||
transformer.setPrintType(PatchedShaderPrinter.prettyPrintShaders ? PrintType.INDENTED : PrintType.SIMPLE);
|
||||
EnumMap<PatchShaderType, String> inputs = new EnumMap<>(PatchShaderType.class);
|
||||
inputs.put(PatchShaderType.VERTEX, vertex);
|
||||
inputs.put(PatchShaderType.GEOMETRY, geometry);
|
||||
inputs.put(PatchShaderType.FRAGMENT, fragment);
|
||||
result = transformer.transform(inputs, parameters);
|
||||
if (useCache) {
|
||||
cache.put(key, result);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Map<PatchShaderType, String> patchAttributes(String vertex, String geometry, String fragment, InputAvailability inputs) {
|
||||
return transform(vertex, geometry, fragment, new AttributeParameters(Patch.ATTRIBUTES, geometry != null, inputs));
|
||||
}
|
||||
|
||||
public static Map<PatchShaderType, String> patchSodiumTerrain(String vertex, String geometry, String fragment) {
|
||||
return transform(vertex, geometry, fragment, new Parameters(Patch.SODIUM_TERRAIN));
|
||||
}
|
||||
|
||||
public static Map<PatchShaderType, String> patchComposite(String vertex, String geometry, String fragment) {
|
||||
return transform(vertex, geometry, fragment, new Parameters(Patch.COMPOSITE));
|
||||
}
|
||||
public static Map<PatchShaderType, String> patchComposite(String vertex, String geometry, String fragment) {
|
||||
return transform(vertex, geometry, fragment, new Parameters(Patch.COMPOSITE));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.coderbot.iris.pipeline.transform.parameter;
|
||||
|
||||
import net.coderbot.iris.gbuffer_overrides.matching.InputAvailability;
|
||||
import net.coderbot.iris.pipeline.transform.Patch;
|
||||
|
||||
public class AttributeParameters extends Parameters {
|
||||
public final boolean hasGeometry;
|
||||
public final InputAvailability inputs;
|
||||
|
||||
public AttributeParameters(Patch patch, boolean hasGeometry, InputAvailability inputs) {
|
||||
super(patch);
|
||||
this.hasGeometry = hasGeometry;
|
||||
this.inputs = inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + (hasGeometry ? 1231 : 1237);
|
||||
result = prime * result + ((inputs == null) ? 0 : inputs.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
AttributeParameters other = (AttributeParameters) obj;
|
||||
if (hasGeometry != other.hasGeometry)
|
||||
return false;
|
||||
if (inputs == null) {
|
||||
if (other.inputs != null)
|
||||
return false;
|
||||
} else if (!inputs.equals(other.inputs))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package net.coderbot.iris.pipeline.transform.parameter;
|
||||
|
||||
public interface JobParameters {
|
||||
|
||||
JobParameters EMPTY = new JobParameters() {
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return other == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
boolean equals(Object other);
|
||||
|
||||
int hashCode();
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package net.coderbot.iris.pipeline.transform.parameter;
|
||||
|
||||
import net.coderbot.iris.pipeline.transform.Patch;
|
||||
import net.coderbot.iris.pipeline.transform.PatchShaderType;
|
||||
|
||||
public class Parameters implements JobParameters {
|
||||
public final Patch patch;
|
||||
public PatchShaderType type; // may only be set by TransformPatcher
|
||||
// WARNING: adding new fields requires updating hashCode and equals methods!
|
||||
|
||||
// name of the shader, this should not be part of hash/equals
|
||||
public String name; // set by TransformPatcher
|
||||
|
||||
public Parameters(Patch patch) {
|
||||
this.patch = patch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((patch == null) ? 0 : patch.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Parameters other = (Parameters) obj;
|
||||
return patch == other.patch;
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class PackDirectives {
|
||||
sun = properties.getSun().orElse(true);
|
||||
moon = properties.getMoon().orElse(true);
|
||||
rainDepth = properties.getRainDepth().orElse(false);
|
||||
separateAo = properties.getSeparateAo().orElse(false);
|
||||
separateAo = false; //properties.getSeparateAo().orElse(false);
|
||||
oldLighting = properties.getOldLighting().orElse(false);
|
||||
concurrentCompute = properties.getConcurrentCompute().orElse(false);
|
||||
oldHandLight = properties.getOldHandLight().orElse(true);
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package net.coderbot.iris.uniforms;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import com.gtnewhorizons.angelica.rendering.RenderingState;
|
||||
import net.coderbot.iris.gl.uniform.UniformHolder;
|
||||
import net.coderbot.iris.gl.uniform.UniformUpdateFrequency;
|
||||
import net.coderbot.iris.uniforms.transforms.SmoothedFloat;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import org.joml.Math;
|
||||
import org.joml.Vector3d;
|
||||
@@ -157,7 +159,8 @@ public class HardcodedCustomUniforms {
|
||||
}
|
||||
|
||||
private static int getWorldDayTime() {
|
||||
return (int) (Minecraft.getMinecraft().theWorld.getWorldTime() % 24000L);
|
||||
final WorldClient world = Minecraft.getMinecraft().theWorld;
|
||||
return (int) ((AngelicaConfig.useTotalWorldTime ? world.getTotalWorldTime() : world.getWorldTime()) % 24000L);
|
||||
// Level level = Minecraft.getMinecraft().theWorld;
|
||||
// long timeOfDay = level.getDayTime();
|
||||
// long dayTime = ((DimensionTypeAccessor) level.dimensionType()).getFixedTime().orElse(timeOfDay % 24000L);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package net.coderbot.iris.uniforms;
|
||||
|
||||
import static net.coderbot.iris.gl.uniform.UniformUpdateFrequency.PER_TICK;
|
||||
|
||||
import com.gtnewhorizons.angelica.config.AngelicaConfig;
|
||||
import java.util.Objects;
|
||||
import net.coderbot.iris.gl.uniform.UniformHolder;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.multiplayer.WorldClient;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.coderbot.iris.gl.uniform.UniformUpdateFrequency.PER_TICK;
|
||||
|
||||
public final class WorldTimeUniforms {
|
||||
private WorldTimeUniforms() {
|
||||
}
|
||||
@@ -25,13 +25,14 @@ public final class WorldTimeUniforms {
|
||||
}
|
||||
|
||||
static int getWorldDayTime() {
|
||||
return (int) (getWorld().getWorldTime() % 24000L);
|
||||
final WorldClient world = getWorld();
|
||||
return (int) ((AngelicaConfig.useTotalWorldTime ? world.getTotalWorldTime() : world.getWorldTime()) % 24000L);
|
||||
|
||||
// long dayTime = ((DimensionTypeAccessor) getWorld().dimensionType()).getFixedTime().orElse(timeOfDay % 24000L);
|
||||
}
|
||||
|
||||
private static int getWorldDay() {
|
||||
return (int) (getWorld().getWorldTime() / 24000L);
|
||||
return (int) (getWorld().getTotalWorldTime() / 24000L);
|
||||
}
|
||||
|
||||
private static WorldClient getWorld() {
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
public net.minecraft.block.Block func_149641_N()Ljava/lang/String; # getTextureName
|
||||
|
||||
public net.minecraft.client.renderer.EntityRenderer func_78476_b(FI)V # void renderHand(float, int)
|
||||
public net.minecraft.client.renderer.EntityRenderer func_78481_a(FZ)F # float getFOVModifier(float, boolean)
|
||||
public net.minecraft.client.renderer.EntityRenderer func_78482_e(F)V # void hurtCameraEffect(float)
|
||||
public net.minecraft.client.renderer.EntityRenderer func_78475_f(F)V # void setupViewBobbing(float)
|
||||
public net.minecraft.client.renderer.EntityRenderer field_78503_V # cameraZoom
|
||||
public net.minecraft.client.renderer.EntityRenderer field_78502_W # cameraYaw
|
||||
public net.minecraft.client.renderer.EntityRenderer field_78509_X # cameraPitch
|
||||
public net.minecraft.client.renderer.EntityRenderer field_78530_s # farPlaneDistance
|
||||
public net.minecraft.client.renderer.EntityRenderer field_78527_v # mouseFilterXAxis
|
||||
public net.minecraft.client.renderer.EntityRenderer field_78526_w # mouseFilterYAxis
|
||||
|
||||
public net.minecraft.client.renderer.RenderGlobal field_72765_l # worldRenderers
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ options.button.shader=Shaders...
|
||||
|
||||
options.chunks=%s chunks
|
||||
options.entityShadows=Entity Shadows
|
||||
options.droppedItems=%s items
|
||||
options.droppedItems.max=Unlimited
|
||||
sodium.option_impact.low=Low
|
||||
sodium.option_impact.medium=Medium
|
||||
sodium.option_impact.high=High
|
||||
@@ -124,12 +126,19 @@ options.iris.setToDefault=Set option to default value?
|
||||
options.iris.profile=Profile
|
||||
options.iris.profile.custom=Custom
|
||||
options.iris.shadowDistance=Max Shadow Distance
|
||||
options.iris.shadowDistance.sodium_tooltip=Max Shadow Distance
|
||||
options.iris.shadowDistance.enabled=Allows you to change the maximum distance for shadows. Terrain and entities beyond this distance will not cast shadows. Lowering the shadow distance can significantly increase performance.
|
||||
options.iris.shadowDistance.disabled=Your current shader pack has already set a render distance for shadows; you cannot change it.
|
||||
options.iris.gui.hide=Hide GUI
|
||||
options.iris.gui.show=Show GUI
|
||||
options.dynamic_lights=Dynamic Lights
|
||||
options.dynamic_lights.tooltip=Enables dynamic lights. Modes: OFF - off, FASTEST - 500ms delay, FAST - 250ms delay, FANCY - no delay. Disabled if shaders are in use.
|
||||
options.dynamic_lights.tooltip=Enables dynamic lights. Modes: OFF - off, FASTEST - 500ms delay, FAST - 250ms delay, FANCY - 50ms delay, REALTIME - no delay.
|
||||
options.dynamic_lights_shader_force=Dynamic Lights - Forced With Shaders
|
||||
options.dynamic_lights_shader_force.tooltip=Enabled - Dynamic Lights are shown even when a shader is active, Disabled - Dynamic Lights are disabled when a shader is active.
|
||||
options.angelica.droppedItemLimit=Dropped Item Render Limit
|
||||
options.angelica.droppedItemLimit.tooltip=The maximum number of dropped items that will be rendered. Lower values can improve performance.
|
||||
options.angelica.itemdisplaylistcount=Item Renderer Display List Cache Size
|
||||
options.angelica.itemdisplaylistcount.tooltip=The maximum number of display lists to cache in the optimized item renderer. Higher values will increase performance but increase VRAM usage.
|
||||
pack.iris.select.title=Select
|
||||
pack.iris.configure.title=Configure
|
||||
label.iris.true=On
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#version 120
|
||||
|
||||
uniform int headIdx;
|
||||
uniform float scaleFactor;
|
||||
uniform float samples[240];
|
||||
uniform float pxPerNs;
|
||||
uniform bool left;
|
||||
uniform float fbWidth;
|
||||
|
||||
void main() {
|
||||
// Get position - gl_FragCoord starts from the lower left and returns the position of the center of the pixel
|
||||
// i.e. the lower-left-most pixel is (0.5, 0.5). Shift if we're on the right side of the screen.
|
||||
int dx = int((left ? gl_FragCoord.x : gl_FragCoord.x - fbWidth) / scaleFactor) - 1;
|
||||
int dy = int(gl_FragCoord.y / scaleFactor);
|
||||
|
||||
// Get the time for this frag. Last at the left edge, first at the right, shifting as needed when the head moves.
|
||||
int idx = int(mod(dx + headIdx, 240));
|
||||
float time = samples[idx];
|
||||
|
||||
// Time is in nanoseconds. Height is calculated from the given pixels/ns factor.
|
||||
// If it's higher or as high as we are, recolor accordingly.
|
||||
// Also, apparently GLSL 120 doesn't have rounding.
|
||||
float height = floor(time * pxPerNs + 0.5);
|
||||
|
||||
// Calculate the nanoseconds at the midpoint, 30px. The bar can exceed twice that, but it's used for coloring
|
||||
float midNs = 30.0 / pxPerNs;
|
||||
|
||||
// Increase red from 0-midpoint, and decrease green from midpoint-"max"
|
||||
vec4 color = vec4(0.0, 0.0, 0.0, 0.0);
|
||||
float r = clamp(time / midNs, 0.0, 1.0);
|
||||
float g = 1.0 - clamp((time - midNs) / midNs, 0.0, 1.0);
|
||||
if (dy <= height)
|
||||
color = vec4(r, g, 0.0, 1.0);
|
||||
gl_FragColor = color;
|
||||
}
|
||||
Loaded 100 of 131 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user