diff --git a/Penumbra.GameData b/Penumbra.GameData
index 8ee82929..ac9d9c78 160000
--- a/Penumbra.GameData
+++ b/Penumbra.GameData
@@ -1 +1 @@
-Subproject commit 8ee82929fa6c725b8f556904ba022fb418991b5c
+Subproject commit ac9d9c78ae0025489b80ce2e798cdaacb0b43947
diff --git a/Penumbra/Communication/MtrlShpkLoaded.cs b/Penumbra/Communication/MtrlLoaded.cs
similarity index 73%
rename from Penumbra/Communication/MtrlShpkLoaded.cs
rename to Penumbra/Communication/MtrlLoaded.cs
index 9d3597a8..78498844 100644
--- a/Penumbra/Communication/MtrlShpkLoaded.cs
+++ b/Penumbra/Communication/MtrlLoaded.cs
@@ -6,11 +6,11 @@ namespace Penumbra.Communication;
/// - Parameter is the material resource handle for which the shader package has been loaded.
/// - Parameter is the associated game object.
///
-public sealed class MtrlShpkLoaded() : EventWrapper(nameof(MtrlShpkLoaded))
+public sealed class MtrlLoaded() : EventWrapper(nameof(MtrlLoaded))
{
public enum Priority
{
- ///
+ ///
ShaderReplacementFixer = 0,
}
}
diff --git a/Penumbra/Interop/Hooks/HookSettings.cs b/Penumbra/Interop/Hooks/HookSettings.cs
index 0c0a4020..0bc55dc5 100644
--- a/Penumbra/Interop/Hooks/HookSettings.cs
+++ b/Penumbra/Interop/Hooks/HookSettings.cs
@@ -99,7 +99,7 @@ public class HookOverrides
public struct ResourceHooks
{
public bool ApricotResourceLoad;
- public bool LoadMtrlShpk;
+ public bool LoadMtrl;
public bool LoadMtrlTex;
public bool ResolvePathHooks;
public bool ResourceHandleDestructor;
diff --git a/Penumbra/Interop/Hooks/PostProcessing/ShaderReplacementFixer.cs b/Penumbra/Interop/Hooks/PostProcessing/ShaderReplacementFixer.cs
index 53b69741..d02e18bb 100644
--- a/Penumbra/Interop/Hooks/PostProcessing/ShaderReplacementFixer.cs
+++ b/Penumbra/Interop/Hooks/PostProcessing/ShaderReplacementFixer.cs
@@ -110,7 +110,7 @@ public sealed unsafe class ShaderReplacementFixer : IDisposable, IRequiredServic
_modelRendererOnRenderMaterialHook = hooks.CreateHook("ModelRenderer.OnRenderMaterial",
Sigs.ModelRendererOnRenderMaterial, ModelRendererOnRenderMaterialDetour,
!HookOverrides.Instance.PostProcessing.ModelRendererOnRenderMaterial).Result;
- _communicator.MtrlShpkLoaded.Subscribe(OnMtrlShpkLoaded, MtrlShpkLoaded.Priority.ShaderReplacementFixer);
+ _communicator.MtrlLoaded.Subscribe(OnMtrlLoaded, MtrlLoaded.Priority.ShaderReplacementFixer);
_resourceHandleDestructor.Subscribe(OnResourceHandleDestructor, ResourceHandleDestructor.Priority.ShaderReplacementFixer);
}
@@ -118,7 +118,7 @@ public sealed unsafe class ShaderReplacementFixer : IDisposable, IRequiredServic
{
_modelRendererOnRenderMaterialHook.Dispose();
_humanOnRenderMaterialHook.Dispose();
- _communicator.MtrlShpkLoaded.Unsubscribe(OnMtrlShpkLoaded);
+ _communicator.MtrlLoaded.Unsubscribe(OnMtrlLoaded);
_resourceHandleDestructor.Unsubscribe(OnResourceHandleDestructor);
_hairMaskState.ClearMaterials();
_characterOcclusionState.ClearMaterials();
@@ -147,7 +147,7 @@ public sealed unsafe class ShaderReplacementFixer : IDisposable, IRequiredServic
return shpkName.SequenceEqual(mtrlResource->ShpkNameSpan);
}
- private void OnMtrlShpkLoaded(nint mtrlResourceHandle, nint gameObject)
+ private void OnMtrlLoaded(nint mtrlResourceHandle, nint gameObject)
{
var mtrl = (MaterialResourceHandle*)mtrlResourceHandle;
var shpk = mtrl->ShaderPackageResourceHandle;
diff --git a/Penumbra/Interop/Hooks/Resources/LoadMtrlShpk.cs b/Penumbra/Interop/Hooks/Resources/LoadMtrl.cs
similarity index 55%
rename from Penumbra/Interop/Hooks/Resources/LoadMtrlShpk.cs
rename to Penumbra/Interop/Hooks/Resources/LoadMtrl.cs
index 8c410ad8..f56177e4 100644
--- a/Penumbra/Interop/Hooks/Resources/LoadMtrlShpk.cs
+++ b/Penumbra/Interop/Hooks/Resources/LoadMtrl.cs
@@ -5,28 +5,28 @@ using Penumbra.Services;
namespace Penumbra.Interop.Hooks.Resources;
-public sealed unsafe class LoadMtrlShpk : FastHook
+public sealed unsafe class LoadMtrl : FastHook
{
private readonly GameState _gameState;
private readonly CommunicatorService _communicator;
- public LoadMtrlShpk(HookManager hooks, GameState gameState, CommunicatorService communicator)
+ public LoadMtrl(HookManager hooks, GameState gameState, CommunicatorService communicator)
{
_gameState = gameState;
_communicator = communicator;
- Task = hooks.CreateHook("Load Material Shaders", Sigs.LoadMtrlShpk, Detour, !HookOverrides.Instance.Resources.LoadMtrlShpk);
+ Task = hooks.CreateHook("Load Material", Sigs.LoadMtrl, Detour, !HookOverrides.Instance.Resources.LoadMtrl);
}
- public delegate byte Delegate(MaterialResourceHandle* mtrlResourceHandle);
+ public delegate byte Delegate(MaterialResourceHandle* mtrlResourceHandle, void* unk1, byte unk2);
- private byte Detour(MaterialResourceHandle* handle)
+ private byte Detour(MaterialResourceHandle* handle, void* unk1, byte unk2)
{
var last = _gameState.MtrlData.Value;
var mtrlData = _gameState.LoadSubFileHelper((nint)handle);
_gameState.MtrlData.Value = mtrlData;
- var ret = Task.Result.Original(handle);
+ var ret = Task.Result.Original(handle, unk1, unk2);
_gameState.MtrlData.Value = last;
- _communicator.MtrlShpkLoaded.Invoke((nint)handle, mtrlData.AssociatedGameObject);
+ _communicator.MtrlLoaded.Invoke((nint)handle, mtrlData.AssociatedGameObject);
return ret;
}
}
diff --git a/Penumbra/Interop/Hooks/Resources/LoadMtrlTex.cs b/Penumbra/Interop/Hooks/Resources/LoadMtrlTex.cs
index 0759d9b1..1866e859 100644
--- a/Penumbra/Interop/Hooks/Resources/LoadMtrlTex.cs
+++ b/Penumbra/Interop/Hooks/Resources/LoadMtrlTex.cs
@@ -4,6 +4,7 @@ using Penumbra.GameData;
namespace Penumbra.Interop.Hooks.Resources;
+// TODO check if this is still needed, as our hooked function is called by LoadMtrl's hooked function
public sealed unsafe class LoadMtrlTex : FastHook
{
private readonly GameState _gameState;
diff --git a/Penumbra/Services/CommunicatorService.cs b/Penumbra/Services/CommunicatorService.cs
index cacbe689..5d745419 100644
--- a/Penumbra/Services/CommunicatorService.cs
+++ b/Penumbra/Services/CommunicatorService.cs
@@ -24,8 +24,8 @@ public class CommunicatorService : IDisposable, IService
///
public readonly CreatedCharacterBase CreatedCharacterBase = new();
- ///
- public readonly MtrlShpkLoaded MtrlShpkLoaded = new();
+ ///
+ public readonly MtrlLoaded MtrlLoaded = new();
///
public readonly ModDataChanged ModDataChanged = new();
@@ -87,7 +87,7 @@ public class CommunicatorService : IDisposable, IService
TemporaryGlobalModChange.Dispose();
CreatingCharacterBase.Dispose();
CreatedCharacterBase.Dispose();
- MtrlShpkLoaded.Dispose();
+ MtrlLoaded.Dispose();
ModDataChanged.Dispose();
ModOptionChanged.Dispose();
ModDiscoveryStarted.Dispose();