Skip to content

Commit

Permalink
add intensity for recolor
Browse files Browse the repository at this point in the history
  • Loading branch information
Maiq-The-Dude committed Jan 13, 2021
1 parent 9548fe2 commit d4f8de3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
1 change: 1 addition & 0 deletions Better1911/Configs/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
3 changes: 2 additions & 1 deletion Better1911/Configs/Grips.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
2 changes: 2 additions & 0 deletions Better1911/Configs/Shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ public abstract class SharedConfigs : IConfig
public ConfigEntry<float> NormalStrength { get; set; }
public ConfigEntry<float> Specularity { get; set; }
public ConfigEntry<bool> RemoveTexture { get; set; }
public ConfigEntry<float> 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;
}
}
3 changes: 2 additions & 1 deletion Better1911/Configs/Slide.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
1 change: 1 addition & 0 deletions Better1911/IConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public interface IConfig
float Roughness { get; }
Vector4 Recolor { get; }
float Specularity { get; }
float RecolorIntensity { get; }
}
}
33 changes: 16 additions & 17 deletions Better1911/Patches.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -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<Renderer>().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
{
Expand All @@ -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<Renderer>().material;
var frameCfg = gunCfg.Frame;
Expand All @@ -99,7 +98,7 @@ private static void ChangeHandgun(HandgunSlide __instance)
}

PaintComponent(slideMat, slideCfg);
}
}
}
}
}
Expand Down Expand Up @@ -159,7 +158,7 @@ private static void Patch(FVRFireArmMagazine __instance)
}
}
}
}
}
}
}

Expand Down Expand Up @@ -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
Expand All @@ -199,16 +198,16 @@ 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)
{
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)
Expand All @@ -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)
Expand All @@ -237,7 +236,7 @@ private static bool FixPose(FVRFireArmMagazine mag)
}
}
}

return false;
}

Expand Down

0 comments on commit d4f8de3

Please sign in to comment.