Skip to content

Commit

Permalink
Allow configuring the edge detection depth for over 800u far clip dis…
Browse files Browse the repository at this point in the history
…tance
  • Loading branch information
SuiMachine committed Aug 19, 2022
1 parent 7ed92f6 commit cbf1aea
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
Binary file modified Release/Mods/SuisHack.dll
Binary file not shown.
Binary file modified Release/Mods/SuisHack.pdb
Binary file not shown.
6 changes: 6 additions & 0 deletions Source/ExposedSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public enum LightImprovements
public MelonPreferences_Entry<float> Entry_Quality_SSR_DistanceFade;
public MelonPreferences_Entry<float> Entry_Quality_SSR_MaxMarchingDistance;
public MelonPreferences_Entry<bool> Entry_Quality_EdgeDetection;
public MelonPreferences_Entry<float> Entry_Quality_EdgeDetectionDepth;


//Input settings
public MelonPreferences_Entry<InputType> Input_Override;
Expand Down Expand Up @@ -224,6 +226,10 @@ private void RegisterGraphicsSettings()
Entry_Quality_EdgeDetection = Category_graphicsSettings.CreateEntry("Edge Detection Filter", true, description: "Responsible for Enabling/Disabling edge detection post process filter.");
Entry_Quality_EdgeDetection.OnValueChanged += (bool oldValue, bool newValue) => { Hacks.PostProcessLayerHook.EnableEdgeDetectionFilter = newValue; };
Hacks.PostProcessLayerHook.EnableEdgeDetectionFilter = Entry_Quality_EdgeDetection.Value;

Entry_Quality_EdgeDetectionDepth = Category_graphicsSettings.CreateEntry("Edge Detection Filter Depth", 1.0f, description: "Responsible for figuring out how to apply edges based on distance from camera. This might have to be changed to lower values when extending camera's far plane to avoid glitches.");
Entry_Quality_EdgeDetectionDepth.OnValueChanged += (float oldValue, float newValue) => { Hacks.PostProcessLayerHook.EnableEdgeDetectionFilterDepth = newValue; };
Hacks.PostProcessLayerHook.EnableEdgeDetectionFilterDepth = Entry_Quality_EdgeDetectionDepth.Value;
}

private void RegisterInputSettings()
Expand Down
18 changes: 18 additions & 0 deletions Source/Hacks/PostProcessLayerHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,22 @@ public static bool EnableEdgeDetectionFilter
}
}
}

private static float m_EnableEdgeDetectionFilterDepth;
public static float EnableEdgeDetectionFilterDepth
{
get { return m_EnableEdgeDetectionFilterDepth; }
set
{
if (m_EnableEdgeDetectionFilterDepth != value)
{
ClearNullReferences();

m_EnableEdgeDetectionFilterDepth = value;
ApplyEdgeDetectionChange();
}
}
}
#endregion

private static void ApplyHBAOChange()
Expand Down Expand Up @@ -298,6 +314,7 @@ private static void ApplyEdgeDetectionChange()

var filter = volume.profile.settings[i].TryCast<SCPE.EdgeDetection>();
filter.enabled.value = m_EnableEdgeDetectionFilter;
filter.sensitivityDepth.value = m_EnableEdgeDetectionFilterDepth;
}
}
}
Expand Down Expand Up @@ -352,6 +369,7 @@ public static void PostProcessVolumeOnEnablePostfix(PostProcessVolume __instance

var filter = __instance.profile.settings[i].TryCast<SCPE.EdgeDetection>();
filter.enabled.value = m_EnableEdgeDetectionFilter;
filter.sensitivityDepth.value = m_EnableEdgeDetectionFilterDepth;
}

if (!m_SSR_Enabled)
Expand Down
15 changes: 15 additions & 0 deletions Source/SettingsGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,17 @@ private void DrawQuality()
GUILayout.BeginVertical(GUI.skin.box, null);
Settings.Entry_Quality_EdgeDetection.Value = GUILayout.Toggle(Settings.Entry_Quality_EdgeDetection.Value, "Edge detection post process filter", null);

if (Settings.Entry_Quality_EdgeDetection.Value && Settings.Entry_Quality_CameraFarPlaneDistance.Value > 800)
{
GUILayout.Label("Warning - extending far clip camera plane distance can cause issues with edge detection filter.\nIf you experience issues with lines on characters being displayed up close, try lowering the value below:", null);
GUILayout.BeginHorizontal(null);
GUILayout.Label($"Edge detection depth {Settings.Entry_Quality_EdgeDetectionDepth.Value:0.00}", null);
Settings.Entry_Quality_EdgeDetectionDepth.Value = GUILayout.HorizontalSlider(Settings.Entry_Quality_EdgeDetectionDepth.Value, 0, 1, null);
GUILayout.EndHorizontal();
}
else
Settings.Entry_Quality_EdgeDetectionDepth.Value = 1;

GUILayout.EndVertical();
}

Expand Down Expand Up @@ -856,7 +867,11 @@ private void RestartToDefault()
Settings.Entry_Quality_SSR_Tickness.Value = Settings.Entry_Quality_SSR_Tickness.DefaultValue;
Settings.Entry_Quality_SSR_Vignette.Value = Settings.Entry_Quality_SSR_Vignette.DefaultValue;

Settings.Entry_Quality_HBAO_Preset.Value = Settings.Entry_Quality_HBAO_Preset.DefaultValue;
Settings.Entry_Quality_HBAO_Intensity.Value = Settings.Entry_Quality_HBAO_Intensity.DefaultValue;

Settings.Entry_Quality_EdgeDetection.Value = Settings.Entry_Quality_EdgeDetection.DefaultValue;
Settings.Entry_Quality_EdgeDetectionDepth.Value = Settings.Entry_Quality_EdgeDetectionDepth.DefaultValue;
}

private string GetTextureString(int masterTextureLimit)
Expand Down

0 comments on commit cbf1aea

Please sign in to comment.