RimWorld

RimWorld

[NL] Facial Animation - WIP
1.6 workarounds and hacks
Obviously the proper fix is to wait until Nals updates for 1.6, which could take a long time if they are active and interested in updating, thank you in advance for the work you've done on this.

In the meantime, I've been trying to get the mod working, the current fail state is it makes pawns completely invisible, you can disable it for one gender and when you flip genders they reappear without FA, so it's definitely the mod.

Adding 1.6 to about.xml fools rimworld into thinking it's compatible, but it doesnt change anything, I see somone tried disabling 'Faster GetComp methods replacement' in performance organizer worked, but that option is missing in 1.6, someone posted an error dump pastebin in the mod comments, but it's above my head. https://pastebin.com/VHYFNsB7

Error rendering pawn portrait: System.MissingFieldException: Field not found: Verse.Graphic Verse.PawnRenderNode.graphic Due to: Could not find field in class

Looks like the pawn render node is borked, which makes sense, but I've got no idea if that's an easy fix

Anyone got anything they've tried that got it working.
< >
Showing 1-6 of 6 comments
8cd3 19 Jun @ 1:57pm 
I seem to have gotten it to work by decompiling the assembly with ILSpy (making sure the dependencies are resolved or it won't recompile), changing Assembly-CSharp to Rimworld 1.6, and fixing the resulting build errors. Haven't really tested it much but the pawns at least load.

diff --git a/FacialAnimation/NLFacialAnimationPartNode.cs b/FacialAnimation/NLFacialAnimationPartNode.cs index aa5e95f..e8810fe 100644 --- a/FacialAnimation/NLFacialAnimationPartNode.cs +++ b/FacialAnimation/NLFacialAnimationPartNode.cs @@ -21,12 +21,12 @@ public class NLFacialAnimationPartNode : PawnRenderNode public override Graphic GraphicFor(Pawn pawn) { - graphic = controller.GetGraphic(layerType, rotDrawMode); - if (graphic == null) + primaryGraphic = controller.GetGraphic(layerType, rotDrawMode); + if (primaryGraphic == null) { - graphic = GraphicPool.dummyGraphic; + primaryGraphic = GraphicPool.dummyGraphic; } - return graphic; + return primaryGraphic; } protected override IEnumerable<Graphic> GraphicsFor(Pawn pawn) diff --git a/FacialAnimation/NL_SelectPartWindow.cs b/FacialAnimation/NL_SelectPartWindow.cs index 79231cd..11b4dcc 100644 --- a/FacialAnimation/NL_SelectPartWindow.cs +++ b/FacialAnimation/NL_SelectPartWindow.cs @@ -634,7 +634,7 @@ public class NL_SelectPartWindow : Window val = Mathf.Floor(val); uvRect = new Rect(0f, 0f, val, val); } - listing_Standard.Label("Hot-reload PNGs", -1f, "e.g.,\\Mods\\InDevMod\\Textures"); + listing_Standard.Label("Hot-reload PNGs"); string text = listing_Standard.TextEntry(ReloadPNGFolderPath); if (text != ReloadPNGFolderPath) { @@ -680,7 +680,7 @@ public class NL_SelectPartWindow : Window listing_Standard.Label("Debug Tool for Animators"); listing_Standard.GapLine(0f); listing_Standard.Gap(); - listing_Standard.Label("Hot-reload Defs", -1f, "e.g.,\\Mods\\InDevMod\\Defs"); + listing_Standard.Label("Hot-reload Defs"); string text = listing_Standard.TextEntry(ReloadDefFolderPath); if (text != ReloadDefFolderPath) {
Is your GitHub repo public?
Originally posted by 8cd3:
I seem to have gotten it to work by decompiling the assembly with ILSpy (making sure the dependencies are resolved or it won't recompile), changing Assembly-CSharp to Rimworld 1.6, and fixing the resulting build errors. Haven't really tested it much but the pawns at least load.

diff --git a/FacialAnimation/NLFacialAnimationPartNode.cs b/FacialAnimation/NLFacialAnimationPartNode.cs index aa5e95f..e8810fe 100644 --- a/FacialAnimation/NLFacialAnimationPartNode.cs +++ b/FacialAnimation/NLFacialAnimationPartNode.cs @@ -21,12 +21,12 @@ public class NLFacialAnimationPartNode : PawnRenderNode public override Graphic GraphicFor(Pawn pawn) { - graphic = controller.GetGraphic(layerType, rotDrawMode); - if (graphic == null) + primaryGraphic = controller.GetGraphic(layerType, rotDrawMode); + if (primaryGraphic == null) { - graphic = GraphicPool.dummyGraphic; + primaryGraphic = GraphicPool.dummyGraphic; } - return graphic; + return primaryGraphic; } protected override IEnumerable<Graphic> GraphicsFor(Pawn pawn) diff --git a/FacialAnimation/NL_SelectPartWindow.cs b/FacialAnimation/NL_SelectPartWindow.cs index 79231cd..11b4dcc 100644 --- a/FacialAnimation/NL_SelectPartWindow.cs +++ b/FacialAnimation/NL_SelectPartWindow.cs @@ -634,7 +634,7 @@ public class NL_SelectPartWindow : Window val = Mathf.Floor(val); uvRect = new Rect(0f, 0f, val, val); } - listing_Standard.Label("Hot-reload PNGs", -1f, "e.g.,\\Mods\\InDevMod\\Textures"); + listing_Standard.Label("Hot-reload PNGs"); string text = listing_Standard.TextEntry(ReloadPNGFolderPath); if (text != ReloadPNGFolderPath) { @@ -680,7 +680,7 @@ public class NL_SelectPartWindow : Window listing_Standard.Label("Debug Tool for Animators"); listing_Standard.GapLine(0f); listing_Standard.Gap(); - listing_Standard.Label("Hot-reload Defs", -1f, "e.g.,\\Mods\\InDevMod\\Defs"); + listing_Standard.Label("Hot-reload Defs"); string text = listing_Standard.TextEntry(ReloadDefFolderPath); if (text != ReloadDefFolderPath) {

I somehow managed to follow the directions despite having no C# experience. It loads but all the faces of the pawns are the same shade.
Fixins 25 Jun @ 12:59pm 
Same, I recompiled with all dependencies and just deleted all the errored code lines, and all the pawn faces have the gamma turned down to where it doesnt match the rest of the body.

Hopefully this means it's a simple fix, just the one lighting bug to fix.
Last edited by Fixins; 25 Jun @ 2:03pm
I've had luck with the head color by replacing all the code in NLFacialAnimationPartNode with the following before recompiling
using System.Collections.Generic; using UnityEngine; using Verse; namespace FacialAnimation { public class NLFacialAnimationPartNode : PawnRenderNode { public IFacialAnimationController controller; public NLFacialAnimationLayerType layerType; public RotDrawMode rotDrawMode; public Rot4 overrideHeadRot = Rot4.South; private Graphic cachedRawGraphic; private Graphic cachedColoredGraphic; private Color lastColor; private Shader lastShader; public NLFacialAnimationPartNode(Pawn pawn, PawnRenderNodeProperties props, PawnRenderTree tree) : base(pawn, props, tree) { rotDrawMode = pawn.Drawer?.renderer?.CurRotDrawMode ?? RotDrawMode.Fresh; } public override Graphic GraphicFor(Pawn pawn) { Graphic raw = controller?.GetGraphic(layerType, rotDrawMode); if (raw == null) return base.primaryGraphic = GraphicPool.dummyGraphic; Color skinColor = pawn.story?.SkinColor ?? Color.white; Shader shader = ShaderUtility.GetSkinShader(pawn) ?? ShaderDatabase.CutoutSkinOverlay; bool rawChanged = !ReferenceEquals(raw, cachedRawGraphic); if (rawChanged || skinColor != lastColor || shader != lastShader) { if (UnityData.IsInMainThread) { cachedColoredGraphic = raw.GetColoredVersion(shader, skinColor, skinColor); cachedRawGraphic = raw; lastColor = skinColor; lastShader = shader; } else { // Background thread: fall back to last safe graphic return base.primaryGraphic = cachedColoredGraphic ?? GraphicPool.dummyGraphic; } } return base.primaryGraphic = cachedColoredGraphic; } protected override IEnumerable<Graphic> GraphicsFor(Pawn pawn) { Graphic g = GraphicFor(pawn); yield return g; yield return g; } } }
Last edited by Sunshiney Days; 29 Jun @ 9:54am
Here is a full patch with colors working, and without removing any of the tooltips:

diff --git a/Source/FacialAnimation/FacialAnimationModSettings.cs b/Source/FacialAnimation/FacialAnimationModSettings.cs index 2ee37b1..1f13fbf 100644 --- a/Source/FacialAnimation/FacialAnimationModSettings.cs +++ b/Source/FacialAnimation/FacialAnimationModSettings.cs @@ -164,10 +164,10 @@ public class FacialAnimationModSettings : ModSettings listing_Standard.Begin(inRect.LeftPart(0.6f).ContractedBy(7f)); if (Prefs.DevMode) { - listing_Standard.Label("Debug Info", -1f, (string)null); + listing_Standard.Label("Debug Info", -1f); listing_Standard.Gap(-6f); listing_Standard.GapLine(); - listing_Standard.Label($"RenTex:{MyRenderTexturePool.Count()},Mat:{MyMaterialPool.Count()},Graphic:{MyGraphicPool.Count()}", -1f, (string)null); + listing_Standard.Label($"RenTex:{MyRenderTexturePool.Count()},Mat:{MyMaterialPool.Count()},Graphic:{MyGraphicPool.Count()}", -1f); listing_Standard.CheckboxLabeled("Output Tex Count", ref OutputLogAboutDrawCount); } listing_Standard.End(); @@ -175,7 +175,7 @@ public class FacialAnimationModSettings : ModSettings listing_Standard2.Begin(inRect.RightPart(0.4f).ContractedBy(7f)); if (Prefs.DevMode) { - listing_Standard2.Label("Debug Info", -1f, (string)null); + listing_Standard2.Label("Debug Info", -1f); listing_Standard2.Gap(-6f); listing_Standard2.GapLine(); if (listing_Standard2.ButtonText("Outout Logs")) diff --git a/Source/FacialAnimation/Graphic_RenderTexture.cs b/Source/FacialAnimation/Graphic_RenderTexture.cs index 8442a1e..4859b08 100644 --- a/Source/FacialAnimation/Graphic_RenderTexture.cs +++ b/Source/FacialAnimation/Graphic_RenderTexture.cs @@ -85,7 +85,7 @@ public class Graphic_RenderTexture : Graphic_Multi public override Graphic GetColoredVersion(Shader newShader, Color newColor, Color newColorTwo) { - return GraphicDatabase.Get<Graphic_RenderTexture>(path, newShader, drawSize, newColor, newColorTwo, data); + return GraphicDatabase.Get<Graphic_RenderTexture>(path, newShader, drawSize, newColor, newColorTwo, data, maskPath); } public override string ToString() diff --git a/Source/FacialAnimation/NLFacialAnimationPartNode.cs b/Source/FacialAnimation/NLFacialAnimationPartNode.cs index 5235e38..cd8de09 100644 --- a/Source/FacialAnimation/NLFacialAnimationPartNode.cs +++ b/Source/FacialAnimation/NLFacialAnimationPartNode.cs @@ -21,12 +21,20 @@ public class NLFacialAnimationPartNode : PawnRenderNode public override Graphic GraphicFor(Pawn pawn) { - base.graphic = controller.GetGraphic(layerType, rotDrawMode); - if (base.graphic == null) + if (UnityData.IsInMainThread) { - base.graphic = GraphicPool.dummyGraphic; + var skinColor = pawn.story.SkinColor; + var skinShader = ShaderUtility.GetSkinShader(pawn) ?? ShaderDatabase.CutoutSkinOverlay; + + base.primaryGraphic = controller.GetGraphic(layerType, rotDrawMode) + ?.GetColoredVersion(skinShader, skinColor, skinColor); + } + + if (base.primaryGraphic == null) + { + base.primaryGraphic = GraphicPool.dummyGraphic; } - return base.graphic; + return base.primaryGraphic; } protected override IEnumerable<Graphic> GraphicsFor(Pawn pawn) diff --git a/Source/FacialAnimation/NL_SelectPartWindow.cs b/Source/FacialAnimation/NL_SelectPartWindow.cs index b3b6c67..c2e49a8 100644 --- a/Source/FacialAnimation/NL_SelectPartWindow.cs +++ b/Source/FacialAnimation/NL_SelectPartWindow.cs @@ -625,7 +625,7 @@ public class NL_SelectPartWindow : Window TextAnchor anchor = Text.Anchor; Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.Begin(inRect); - listing_Standard.Label("Debug Tools for Illustrators", -1f, (string)null); + listing_Standard.Label("Debug Tools for Illustrators", -1f); listing_Standard.GapLine(0f); listing_Standard.Gap(); float val = uvRect.width; @@ -634,7 +634,7 @@ public class NL_SelectPartWindow : Window val = Mathf.Floor(val); uvRect = new Rect(0f, 0f, val, val); } - listing_Standard.Label("Hot-reload PNGs", -1f, "e.g.,\\Mods\\InDevMod\\Textures"); + listing_Standard.Label("Hot-reload PNGs", -1f, (TipSignal)"e.g.,\\Mods\\InDevMod\\Textures"); string text = listing_Standard.TextEntry(ReloadPNGFolderPath); if (text != ReloadPNGFolderPath) { @@ -677,10 +677,10 @@ public class NL_SelectPartWindow : Window IEnumerable<FaceAnimationDef> enumerable = DefDatabase<FaceAnimationDef>.AllDefs.Where((FaceAnimationDef x) => !x.targetJobs.Any()); Listing_Standard listing_Standard = new Listing_Standard(); listing_Standard.Begin(inRect); - listing_Standard.Label("Debug Tool for Animators", -1f, (string)null); + listing_Standard.Label("Debug Tool for Animators", -1f); listing_Standard.GapLine(0f); listing_Standard.Gap(); - listing_Standard.Label("Hot-reload Defs", -1f, "e.g.,\\Mods\\InDevMod\\Defs"); + listing_Standard.Label("Hot-reload Defs", -1f, (TipSignal)"e.g.,\\Mods\\InDevMod\\Defs"); string text = listing_Standard.TextEntry(ReloadDefFolderPath); if (text != ReloadDefFolderPath) {

Should probably merge Sunshiney's version, of the color loading because my quick and dirty version has no caching, i just threw the thread check in without confirming, and theirs looks generally more robust.

(If you've already applied the fixes from other people above, but have the face leaking the color, the fix you want is to Graphic_RenderTexture.)
Last edited by Q2F2ZSBKb2huc29u; 3 Jul @ 3:01pm
< >
Showing 1-6 of 6 comments
Per page: 1530 50