Skip to content

Commit

Permalink
post processing
Browse files Browse the repository at this point in the history
  • Loading branch information
aedenthorn committed May 26, 2020
1 parent 049c8e9 commit 7e2bc1d
Show file tree
Hide file tree
Showing 10 changed files with 883 additions and 211 deletions.
Binary file modified .vs/PortiaMods/v16/.suo
Binary file not shown.
134 changes: 5 additions & 129 deletions Environment/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public static partial class Main
private static bool isDebug = false;
private static float labelWidth = 80f;
private static float indentSpace = 30f;
private static string[] toneMappers = new string[] {
"None",
"ACES",
"Neutral"
};

public static void Dbgl(string str = "", bool pref = true)
{
Expand Down Expand Up @@ -63,8 +68,6 @@ private static void OnGUI(UnityModManager.ModEntry modEntry)
GUILayout.EndHorizontal();
GUILayout.Space(20f);

GUILayout.Space(20f);

settings.colorsShow = GUILayout.Toggle(settings.colorsShow, $"<b>Color Variables</b>", new GUILayoutOption[0]);
GUILayout.Space(10f);
if (settings.colorsShow)
Expand Down Expand Up @@ -131,133 +134,6 @@ private static void OnGUI(UnityModManager.ModEntry modEntry)
GUILayout.EndHorizontal();
}

settings.processingShow = GUILayout.Toggle(settings.processingShow, $"<b>PostProcessing Variables</b>", new GUILayoutOption[0]);
if (settings.processingShow)
{
GUILayout.Space(10f);
GUILayout.BeginHorizontal();
GUILayout.Space(indentSpace);
GUILayout.BeginVertical();
settings.customVignette = GUILayout.Toggle(settings.customVignette, $"<b>Use Custom Vignette</b>", new GUILayoutOption[0]);
if (settings.customVignette)
{
GUILayout.Space(10f);
GUILayout.BeginHorizontal();
GUILayout.Space(indentSpace);
GUILayout.BeginVertical();

GUILayout.Label("<b>Color</b>", new GUILayoutOption[0]);

GUILayout.BeginHorizontal();
GUILayout.Space(indentSpace);
GUILayout.BeginVertical();

GUILayout.Label(string.Format("Red: <b>{0:F2}</b> ", settings.vignetteColorRed), new GUILayoutOption[] { GUILayout.Width(labelWidth) });
settings.vignetteColorRed = GUILayout.HorizontalSlider((float)settings.vignetteColorRed * 100f, 0, 100f) / 100f;
GUILayout.Label(string.Format("Green: <b>{0:F2}</b> ", settings.vignetteColorRed), new GUILayoutOption[] { GUILayout.Width(labelWidth) });
settings.vignetteColorGreen = GUILayout.HorizontalSlider((float)settings.vignetteColorGreen * 100f, 0, 100f) / 100f;
GUILayout.Label(string.Format("Blue: <b>{0:F2}</b> ", settings.vignetteColorBlue), new GUILayoutOption[] { GUILayout.Width(labelWidth) });
settings.vignetteColorBlue = GUILayout.HorizontalSlider((float)settings.vignetteColorBlue * 100f, 0, 100f) / 100f;
GUILayout.Label(string.Format("Alpha: <b>{0:F2}</b> ", settings.vignetteColorAlpha), new GUILayoutOption[] { GUILayout.Width(labelWidth) });
settings.vignetteColorAlpha = GUILayout.HorizontalSlider((float)settings.vignetteColorAlpha * 100f, 0, 100f) / 100f;
GUILayout.EndVertical();
GUILayout.EndHorizontal();

GUILayout.Space(10f);


GUILayout.Label("<b>Center</b>", new GUILayoutOption[0]);

GUILayout.BeginHorizontal();
GUILayout.Space(indentSpace);
GUILayout.BeginVertical();

GUILayout.Label(string.Format("X: <b>{0:F2}</b> ", settings.vignetteX), new GUILayoutOption[] { GUILayout.Width(labelWidth) });
settings.vignetteX = GUILayout.HorizontalSlider((float)settings.vignetteX * 100f, 0, 100f) / 100f;
GUILayout.Label(string.Format("Y: <b>{0:F2}</b> ", settings.vignetteY), new GUILayoutOption[] { GUILayout.Width(labelWidth) });
settings.vignetteY = GUILayout.HorizontalSlider((float)settings.vignetteY * 100f, 0, 100f) / 100f;
GUILayout.EndVertical();
GUILayout.EndHorizontal();


GUILayout.Space(10f);

GUILayout.Label(string.Format("Intensity <b>{0:F2}</b> ", settings.vignetteIntensity), new GUILayoutOption[0]);
settings.vignetteIntensity = GUILayout.HorizontalSlider((float)settings.vignetteIntensity * 100f, 0, 100f) / 100f;

GUILayout.Space(10f);


GUILayout.Label(string.Format("Smoothness <b>{0:F2}</b> ", settings.vignetteSmoothness), new GUILayoutOption[0]);
settings.vignetteSmoothness = GUILayout.HorizontalSlider((float)settings.vignetteSmoothness * 100f, 1, 100f) / 100f;

GUILayout.Space(10f);


GUILayout.Label(string.Format("Roundness <b>{0:F2}</b> ", settings.vignetteRoundness), new GUILayoutOption[0]);
settings.vignetteRoundness = GUILayout.HorizontalSlider((float)settings.vignetteRoundness * 100f, 0, 100f) / 100f;

GUILayout.Space(10f);

settings.vignetteRounded = GUILayout.Toggle(settings.vignetteRounded, "<b>Force round vignette</b>", new GUILayoutOption[0]);

GUILayout.EndVertical();
GUILayout.EndHorizontal();

}
GUILayout.Space(10f);
settings.customBloom = GUILayout.Toggle(settings.customBloom, "<b>Use Custom Bloom</b>", new GUILayoutOption[0]);
if (settings.customBloom)
{
GUILayout.Space(10f);
GUILayout.BeginHorizontal();
GUILayout.Space(indentSpace);
GUILayout.BeginVertical();

GUILayout.Label(string.Format("Intensity <b>{0:F2}</b> ", settings.bloomIntensity), new GUILayoutOption[0]);
settings.bloomIntensity = GUILayout.HorizontalSlider((float)settings.bloomIntensity * 100f, 0, 1000f) / 100f;

GUILayout.Space(10f);


GUILayout.Label(string.Format("Threshold <b>{0:F2}</b> ", settings.bloomThreshold), new GUILayoutOption[0]);
settings.bloomThreshold = GUILayout.HorizontalSlider((float)settings.bloomThreshold * 100f, 0, 1000f) / 100f;

GUILayout.Space(10f);


GUILayout.Label(string.Format("Soft Knee <b>{0:F2}</b> ", settings.bloomSoftKnee), new GUILayoutOption[0]);
settings.bloomSoftKnee = GUILayout.HorizontalSlider((float)settings.bloomSoftKnee * 100f, 0, 100f) / 100f;

GUILayout.Space(10f);


GUILayout.Label(string.Format("Radius <b>{0:F2}</b> ", settings.bloomRadius), new GUILayoutOption[0]);
settings.bloomRadius = GUILayout.HorizontalSlider((float)settings.bloomRadius * 10f, 10, 70f) / 10f;

GUILayout.Space(10f);


GUILayout.Label(string.Format("Lens Dirt Intensity <b>{0:F2}</b> ", settings.bloomLensDirtIntensity), new GUILayoutOption[0]);
settings.bloomLensDirtIntensity = GUILayout.HorizontalSlider((float)settings.bloomLensDirtIntensity * 100f, 0, 1000f) / 100f;

GUILayout.Space(10f);


settings.bloomAntiFlicker = GUILayout.Toggle(settings.bloomAntiFlicker, "<b>Anti-flicker</b>", new GUILayoutOption[0]);

GUILayout.Space(10f);
GUILayout.EndVertical();
GUILayout.EndHorizontal();

}

GUILayout.Space(10f);

GUILayout.EndVertical();
GUILayout.EndHorizontal();

}
GUILayout.Space(20f);

}
Expand Down
81 changes: 0 additions & 81 deletions Environment/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,86 +255,5 @@ static void Prefix(ref Sky __instance)
}
}

private static bool defaultPostProcessingSet = false;
private static VignetteModel.Settings defaultVignetteSettings;
private static BloomModel.Settings defaultBloomSettings;

[HarmonyPatch(typeof(PostProcessingBehaviour), "OnEnable")]
static class PostProcessingBehaviour_OnEnable_Patch
{

static void Prefix(PostProcessingBehaviour __instance)
{
if(__instance.profile != null && !defaultPostProcessingSet)
{
defaultVignetteSettings = __instance.profile.vignette.settings;
defaultBloomSettings = __instance.profile.bloom.settings;
defaultPostProcessingSet = true;
}
else
{
defaultVignetteSettings = VignetteModel.Settings.defaultSettings;
defaultBloomSettings = BloomModel.Settings.defaultSettings;
}
}
}

[HarmonyPatch(typeof(PostProcessingBehaviour), "OnPreCull")]
static class PostProcessingBehaviour_OnPreCull_Patch
{
static void Postfix(PostProcessingBehaviour __instance, PostProcessingContext ___m_Context, ref VignetteComponent ___m_Vignette, ref BloomComponent ___m_Bloom)
{
PostProcessingContext postProcessingContext = ___m_Context;

if (enabled && settings.customVignette)
{

VignetteModel.Settings vSettings = new VignetteModel.Settings
{
mode = VignetteModel.Mode.Classic,
intensity = settings.vignetteIntensity,
color = new Color(settings.vignetteColorRed, settings.vignetteColorGreen, settings.vignetteColorBlue, settings.vignetteColorAlpha),
center = new Vector2(settings.vignetteX,settings.vignetteY),
smoothness = settings.vignetteSmoothness,
roundness = settings.vignetteRoundness,
rounded = settings.vignetteRounded
};
___m_Vignette.model.settings = vSettings;
}
else
{
___m_Vignette.model.settings = defaultVignetteSettings;
}

if (enabled && settings.customBloom)
{
BloomModel.BloomSettings bbSettings = new BloomModel.BloomSettings
{
intensity = settings.bloomIntensity,
threshold = settings.bloomThreshold,
softKnee = settings.bloomSoftKnee,
radius = settings.bloomRadius,
antiFlicker = settings.bloomAntiFlicker
};

BloomModel.LensDirtSettings blSettings = new BloomModel.LensDirtSettings
{
texture = ___m_Bloom.model.settings.lensDirt.texture,
intensity = settings.bloomLensDirtIntensity
};
BloomModel.Settings bSettings = new BloomModel.Settings
{
bloom = bbSettings,
lensDirt = blSettings
};

___m_Bloom.model.settings = bSettings;
}
else
{
___m_Bloom.model.settings = defaultBloomSettings;
}
}
}
}
}
40 changes: 40 additions & 0 deletions Environment/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,9 @@ public class Settings : UnityModManager.ModSettings

public bool customVignette = false;
public bool customBloom = false;
public bool customEyeAdapt = false;
public bool customMotionBlur = false;
public bool customColorGrading = false;

public float vignetteColorRed = 0f;
public float vignetteColorGreen = 0f;
Expand All @@ -504,6 +507,43 @@ public class Settings : UnityModManager.ModSettings
public bool bloomAntiFlicker = false;
public float bloomLensDirtIntensity = 3f;

public float eyeAdaptLowPercent = 45f;
public float eyeAdaptHighPercent = 95f;
public float eyeAdaptMinLuminance = -5f;
public float eyeAdaptMaxLuminance = 1f;
public float eyeAdaptKeyValue = 0.25f;
public bool eyeAdaptDynamicKeyValue = true;
public bool eyeAdaptAdaptationFixed = false;
public float eyeAdaptSpeedUp = 2f;
public float eyeAdaptSpeedDown = 1f;
public int eyeAdaptLogMin = -8;
public int eyeAdaptLogMax = 4;

public float motionBlurShutterAngle = 270f;
public int motionBlurSampleCount = 10;
public float motionBlurFrameBlending = 0f;

public float depthOfFieldFocusDistance = 10f;
public float depthOfFieldAperture = 5.6f;
public float depthOfFieldFocalLength = 50f;
public bool depthOfFieldUseCameraFov = false;
public int depthOfFieldKernelSize = 1;

public int colorGradingTonemapper = 2;
public float colorGradingNeutralBlackIn = 0.02f;
public float colorGradingNeutralWhiteIn = 10f;
public float colorGradingNeutralBlackOut = 0f;
public float colorGradingNeutralWhiteOut = 10f;
public float colorGradingNeutralWhiteLevel = 5.3f;
public float colorGradingNeutralWhiteClip = 10f;

public float colorGradingPostExposure = 0f;
public float colorGradingTemperature = 0f;
public float colorGradingTint = 0f;
public float colorGradingHueShift = 0f;
public float colorGradingSaturation = 1f;
public float colorGradingContrast = 1f;

public string ToggleKey = "page up";

public override void Save(UnityModManager.ModEntry modEntry)
Expand Down
6 changes: 6 additions & 0 deletions PortiaMods.sln
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomMerch", "CustomMerch\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenDungeons", "OpenDungeons\OpenDungeons.csproj", "{EE0D6BD7-1FA5-46E5-AF10-E4225E88BE3A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PostProcessing", "PostProcessing\PostProcessing.csproj", "{5AD3331E-8F85-4E91-96F0-C65972137ADA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -237,6 +239,10 @@ Global
{EE0D6BD7-1FA5-46E5-AF10-E4225E88BE3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE0D6BD7-1FA5-46E5-AF10-E4225E88BE3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE0D6BD7-1FA5-46E5-AF10-E4225E88BE3A}.Release|Any CPU.Build.0 = Release|Any CPU
{5AD3331E-8F85-4E91-96F0-C65972137ADA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5AD3331E-8F85-4E91-96F0-C65972137ADA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5AD3331E-8F85-4E91-96F0-C65972137ADA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5AD3331E-8F85-4E91-96F0-C65972137ADA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading

0 comments on commit 7e2bc1d

Please sign in to comment.