Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit fa655c3

Browse files
committed
Unlocked SSR quality settings
1 parent 241b952 commit fa655c3

2 files changed

Lines changed: 25 additions & 16 deletions

File tree

PostProcessing/Editor/PostProcessLayerEditor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public sealed class PostProcessLayerEditor : BaseEditor<PostProcessLayer>
4242
SerializedProperty m_SSREnabled;
4343
SerializedProperty m_SSRPreset;
4444
SerializedProperty m_SSRMaximumIterationCount;
45-
SerializedProperty m_SSRDownsampling;
45+
SerializedProperty m_SSRResolution;
4646
SerializedProperty m_SSRThickness;
4747
SerializedProperty m_SSRMaximumMarchDistance;
4848
SerializedProperty m_SSRDistanceFade;
@@ -107,7 +107,7 @@ void OnEnable()
107107
m_SSREnabled = FindProperty(x => x.screenSpaceReflections.enabled);
108108
m_SSRPreset = FindProperty(x => x.screenSpaceReflections.preset);
109109
m_SSRMaximumIterationCount = FindProperty(x => x.screenSpaceReflections.maximumIterationCount);
110-
m_SSRDownsampling = FindProperty(x => x.screenSpaceReflections.downsampling);
110+
m_SSRResolution = FindProperty(x => x.screenSpaceReflections.resolution);
111111
m_SSRThickness = FindProperty(x => x.screenSpaceReflections.thickness);
112112
m_SSRMaximumMarchDistance = FindProperty(x => x.screenSpaceReflections.maximumMarchDistance);
113113
m_SSRDistanceFade = FindProperty(x => x.screenSpaceReflections.distanceFade);
@@ -327,7 +327,7 @@ void DoScreenSpaceReflections(Camera camera)
327327
EditorGUI.indentLevel++;
328328
EditorGUILayout.PropertyField(m_SSRMaximumIterationCount);
329329
EditorGUILayout.PropertyField(m_SSRThickness);
330-
EditorGUILayout.PropertyField(m_SSRDownsampling);
330+
EditorGUILayout.PropertyField(m_SSRResolution);
331331
EditorGUI.indentLevel--;
332332
}
333333

PostProcessing/Runtime/Effects/ScreenSpaceReflections.cs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,24 @@ public enum Preset
1818
Custom
1919
}
2020

21+
public enum Resolution
22+
{
23+
Downsampled,
24+
FullSize,
25+
Supersampled
26+
}
27+
2128
[Tooltip("Enables screen-space reflections.")]
2229
public bool enabled;
2330

2431
[Tooltip("Choose a quality preset, or use \"Custom\" to fine tune it. Don't use a preset higher than \"Medium\" if you care about performances on consoles.")]
2532
public Preset preset = Preset.Medium;
2633

27-
[Range(0, 128), Tooltip("Maximum iteration count.")]
34+
[Range(0, 256), Tooltip("Maximum iteration count.")]
2835
public int maximumIterationCount;
2936

30-
[Tooltip("Downsamples the SSR buffer to maximize performances at the cost of a blurrier result.")]
31-
public bool downsampling = true;
37+
[Tooltip("Changes the size of the SSR buffer. Downsample it to maximize performances or supersample it to get slow but higher quality results.")]
38+
public Resolution resolution = Resolution.Downsampled;
3239

3340
[Range(1f, 64f), Tooltip("Ray thickness. Lower values are more expensive but allow the effect to detect smaller details.")]
3441
public float thickness = 8f;
@@ -46,18 +53,18 @@ class QualityPreset
4653
{
4754
public int maximumIterationCount;
4855
public float thickness;
49-
public bool downsampling;
56+
public Resolution downsampling;
5057
}
5158

5259
QualityPreset[] m_Presets =
5360
{
54-
new QualityPreset { maximumIterationCount = 10, thickness = 32, downsampling = true }, // Lower
55-
new QualityPreset { maximumIterationCount = 16, thickness = 32, downsampling = true }, // Low
56-
new QualityPreset { maximumIterationCount = 32, thickness = 16, downsampling = true }, // Medium
57-
new QualityPreset { maximumIterationCount = 48, thickness = 8, downsampling = true }, // High
58-
new QualityPreset { maximumIterationCount = 16, thickness = 32, downsampling = false }, // Higher
59-
new QualityPreset { maximumIterationCount = 48, thickness = 16, downsampling = false }, // Ultra
60-
new QualityPreset { maximumIterationCount = 64, thickness = 12, downsampling = false }, // Overkill
61+
new QualityPreset { maximumIterationCount = 10, thickness = 32, downsampling = Resolution.Downsampled }, // Lower
62+
new QualityPreset { maximumIterationCount = 16, thickness = 32, downsampling = Resolution.Downsampled }, // Low
63+
new QualityPreset { maximumIterationCount = 32, thickness = 16, downsampling = Resolution.Downsampled }, // Medium
64+
new QualityPreset { maximumIterationCount = 48, thickness = 8, downsampling = Resolution.Downsampled }, // High
65+
new QualityPreset { maximumIterationCount = 16, thickness = 32, downsampling = Resolution.FullSize }, // Higher
66+
new QualityPreset { maximumIterationCount = 48, thickness = 16, downsampling = Resolution.FullSize }, // Ultra
67+
new QualityPreset { maximumIterationCount = 128, thickness = 12, downsampling = Resolution.Supersampled }, // Overkill
6168
};
6269

6370
RenderTexture m_Test;
@@ -117,16 +124,18 @@ internal void Render(PostProcessRenderContext context)
117124
int id = (int)preset;
118125
maximumIterationCount = m_Presets[id].maximumIterationCount;
119126
thickness = m_Presets[id].thickness;
120-
downsampling = m_Presets[id].downsampling;
127+
resolution = m_Presets[id].downsampling;
121128
}
122129

123130
maximumMarchDistance = Mathf.Max(0f, maximumMarchDistance);
124131

125132
// Square POT target
126133
int size = Mathf.ClosestPowerOfTwo(Mathf.Min(context.width, context.height));
127134

128-
if (downsampling)
135+
if (resolution == Resolution.Downsampled)
129136
size >>= 1;
137+
else if (resolution == Resolution.Supersampled)
138+
size <<= 1;
130139

131140
// The gaussian pyramid compute works in blocks of 8x8 so make sure the last lod has a
132141
// minimum size of 8x8

0 commit comments

Comments
 (0)