From d4f8de3894abbd7f161e6ef18da0eb0b23526270 Mon Sep 17 00:00:00 2001 From: M'aiq Date: Wed, 13 Jan 2021 16:20:42 -0600 Subject: [PATCH] add intensity for recolor --- Better1911/Configs/Frame.cs | 1 + Better1911/Configs/Grips.cs | 3 ++- Better1911/Configs/Shared.cs | 2 ++ Better1911/Configs/Slide.cs | 3 ++- Better1911/IConfig.cs | 1 + Better1911/Patches.cs | 33 ++++++++++++++++----------------- 6 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Better1911/Configs/Frame.cs b/Better1911/Configs/Frame.cs index 7b6f9e3..1f7f4a3 100644 --- a/Better1911/Configs/Frame.cs +++ b/Better1911/Configs/Frame.cs @@ -9,6 +9,7 @@ public FrameConfig(string section, ConfigFile config) { var c = new Vector4(255, 255, 255, 1); Recolor = config.Bind(section, nameof(Recolor), c, "Color of the frame (RGBA)"); + RecolorIntensity = config.Bind(section, nameof(RecolorIntensity), 1f, "Color intensity of the recolor. Increase if the colors appear too dark"); Roughness = config.Bind(section, nameof(Roughness), 1f, "Roughness of the material. Decrease for a more mirrored finish."); Metallic = config.Bind(section, nameof(Metallic), 1f, "Metallic value for the material. Decrease for a flatter more polymer look."); NormalStrength = config.Bind(section, nameof(NormalStrength), 1f, "Strength of the normal maps. Increase this for a more rugged look or decrease for a smoother look."); diff --git a/Better1911/Configs/Grips.cs b/Better1911/Configs/Grips.cs index 0d85dea..9294494 100644 --- a/Better1911/Configs/Grips.cs +++ b/Better1911/Configs/Grips.cs @@ -9,10 +9,11 @@ public GripsConfig(string section, ConfigFile config) { var c = new Vector4(28, 28, 28, 1); Recolor = config.Bind(section, nameof(Recolor), c, "Color of the grips (RGBA)"); + RecolorIntensity = config.Bind(section, nameof(RecolorIntensity), 1f, "Color intensity of the recolor. Increase if the colors appear too dark"); Roughness = config.Bind(section, nameof(Roughness), 0.409f, "Roughness of the material. Decrease for a more mirrored finish"); Metallic = config.Bind(section, nameof(Metallic), 0.489f, "Metallic value for the material. Decrease for a flatter more polymer look"); NormalStrength = config.Bind(section, nameof(NormalStrength), 1f, "Strength of the normal maps. Increase this for a more rugged look or decrease for a smoother look"); - Specularity = config.Bind(section, nameof(Specularity), 0f, "Specularity for the material"); + Specularity = config.Bind(section, nameof(Specularity), 0f, "Specularity for the material"); } } } diff --git a/Better1911/Configs/Shared.cs b/Better1911/Configs/Shared.cs index 805a6a1..0d8864c 100644 --- a/Better1911/Configs/Shared.cs +++ b/Better1911/Configs/Shared.cs @@ -11,11 +11,13 @@ public abstract class SharedConfigs : IConfig public ConfigEntry NormalStrength { get; set; } public ConfigEntry Specularity { get; set; } public ConfigEntry RemoveTexture { get; set; } + public ConfigEntry RecolorIntensity { get; set; } Vector4 IConfig.Recolor => Recolor.Value; float IConfig.Roughness => Roughness.Value; float IConfig.Metallic => Metallic.Value; float IConfig.NormalStrength => NormalStrength.Value; float IConfig.Specularity => Specularity.Value; + float IConfig.RecolorIntensity => RecolorIntensity.Value; } } diff --git a/Better1911/Configs/Slide.cs b/Better1911/Configs/Slide.cs index dd480a0..017f2d2 100644 --- a/Better1911/Configs/Slide.cs +++ b/Better1911/Configs/Slide.cs @@ -9,9 +9,10 @@ public SlideConfig(string section, ConfigFile config) { var c = new Vector4(255, 255, 255, 1); Recolor = config.Bind(section, nameof(Recolor), c, "Color of the slide (RGBA)"); + RecolorIntensity = config.Bind(section, nameof(RecolorIntensity), 1f, "Color intensity of the recolor. Increase if the colors appear too dark"); Roughness = config.Bind(section, nameof(Roughness), 1f, "Roughness of the material. Decrease for a more mirrored finish"); Metallic = config.Bind(section, nameof(Metallic), 1f, "Metallic value for the material. Decrease for a flatter more polymer look"); - NormalStrength = config.Bind(section, nameof(NormalStrength), 1f, "Strength of the normal maps. Increase this for a more rugged look or decrease for a smoother look"); + NormalStrength = config.Bind(section, nameof(NormalStrength), 1f, "Strength of the normal maps. Increase this for a more rugged look or decrease for a smoother look"); Specularity = config.Bind(section, nameof(Specularity), 1f, "Specularity for the material"); RemoveTexture = config.Bind(section, nameof(RemoveTexture), false, "Enable to remove texture. This can allow cleaner finishes and better recoloring"); } diff --git a/Better1911/IConfig.cs b/Better1911/IConfig.cs index ca5b27f..494feaf 100644 --- a/Better1911/IConfig.cs +++ b/Better1911/IConfig.cs @@ -9,5 +9,6 @@ public interface IConfig float Roughness { get; } Vector4 Recolor { get; } float Specularity { get; } + float RecolorIntensity { get; } } } diff --git a/Better1911/Patches.cs b/Better1911/Patches.cs index de2cc1b..a892641 100644 --- a/Better1911/Patches.cs +++ b/Better1911/Patches.cs @@ -1,9 +1,8 @@ -using FistVR; -using HarmonyLib; +using BepInEx.Configuration; using Better1911.Configs; +using FistVR; +using HarmonyLib; using UnityEngine; -using BepInEx.Configuration; -using BepInEx.Logging; namespace Better1911 { @@ -52,13 +51,13 @@ private static void ChangeHandgun(HandgunSlide __instance) } else if (glowCfg.CustomColor.Value) { - for(var i = 0; i < glowsights.Length; i++) + for (var i = 0; i < glowsights.Length; i++) { var mat = glowsights[i].GetComponent().material; - if(i == glowsights.Length-1) + if (i == glowsights.Length - 1) { mat.SetColor("_Color", Recolor(glowCfg.FrontColor.Value)); - mat.SetColor("_EmissionColor", Recolor(glowCfg.FrontColor.Value, glowCfg.Intensity.Value)); + mat.SetColor("_EmissionColor", Recolor(glowCfg.FrontColor.Value, glowCfg.Intensity.Value)); } else { @@ -67,13 +66,13 @@ private static void ChangeHandgun(HandgunSlide __instance) } } } - + // Gun Materials var gunCfg = Config.GunCustomization; if (gunCfg.CustomMaterials.Value) { var gun = slideTF.parent; - + // Frame var frameMat = gun.transform.Find("Frame").GetComponent().material; var frameCfg = gunCfg.Frame; @@ -99,7 +98,7 @@ private static void ChangeHandgun(HandgunSlide __instance) } PaintComponent(slideMat, slideCfg); - } + } } } } @@ -159,7 +158,7 @@ private static void Patch(FVRFireArmMagazine __instance) } } } - } + } } } @@ -189,7 +188,7 @@ private static void PaintMag(Material mat, IConfig config, string id) { mat.SetFloat("_Metal", config.Metallic); mat.SetFloat("_BumpScale", config.NormalStrength); - mat.SetColor("_Color", Recolor(config.Recolor)); + mat.SetColor("_Color", Recolor(config.Recolor, config.RecolorIntensity)); mat.SetFloat("_Specularity", config.Specularity); } else @@ -199,7 +198,7 @@ private static void PaintMag(Material mat, IConfig config, string id) mat.SetTexture("_MainTex", null); } PaintComponent(mat, config); - } + } } private static void PaintComponent(Material mat, IConfig config) @@ -207,8 +206,8 @@ private static void PaintComponent(Material mat, IConfig config) mat.SetFloat("_Metal", config.Metallic); mat.SetFloat("_BumpScale", config.NormalStrength); mat.SetFloat("_Roughness", config.Roughness); - mat.SetColor("_Color", Recolor(config.Recolor)); - mat.SetFloat("_Specularity", config.Specularity); + mat.SetColor("_Color", Recolor(config.Recolor, config.RecolorIntensity)); + mat.SetFloat("_Specularity", config.Specularity); } private static bool Better1911(FVRFireArm gun) @@ -226,7 +225,7 @@ private static bool Better1911(FVRFireArm gun) private static bool FixPose(FVRFireArmMagazine mag) { - if(Config.Magazine.FixMagPos.Value) + if (Config.Magazine.FixMagPos.Value) { var obj = mag.ObjectWrapper; if (obj != null) @@ -237,7 +236,7 @@ private static bool FixPose(FVRFireArmMagazine mag) } } } - + return false; }