Skip to content

Implementing scalabity settings for planar resolutions #2059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0ba556e
- Added a rough refraction option on planar reflections.
anisunity Sep 22, 2020
1bf54fc
review changes
anisunity Sep 28, 2020
5a2c71a
Added scalability settings for the planar reflection resolution.
anisunity Sep 30, 2020
8c49ddf
support migration.
anisunity Sep 30, 2020
753af88
renamed the resolution parameters for the planar reflections
anisunity Sep 30, 2020
9b0ebb5
Merge branch 'HDRP/staging' into HDRP/SmoothDistortionSmoothPlanar
sebastienlagarde Oct 3, 2020
b45523a
Merge branch 'HDRP/staging' into HDRP/SmoothDistortionSmoothPlanar
sebastienlagarde Oct 6, 2020
b56410c
removed PerceptualRoughnessToMipmapLevel_LODFlag which isn't required.
sebastienlagarde Oct 6, 2020
d5f6f6f
clean more code (remove OutputSmoothPlanarReflection)
sebastienlagarde Oct 6, 2020
6b72a10
missing one update
sebastienlagarde Oct 6, 2020
13c5cbd
removed rough distortion
sebastienlagarde Oct 6, 2020
640d025
remove distortion test scene
sebastienlagarde Oct 6, 2020
0bed53d
Update DistortionUIBlock.cs
sebastienlagarde Oct 6, 2020
9c247b1
clean distortion
sebastienlagarde Oct 6, 2020
0f1727b
update documentation
sebastienlagarde Oct 6, 2020
add0fb8
Merge branch 'HDRP/staging' into HDRP/rough-refrlections-option
sebastienlagarde Oct 6, 2020
2d09411
address doc feedback
sebastienlagarde Oct 6, 2020
46b0ebe
Update Upgrading-from-2020.1-to-2020.2.md
sebastienlagarde Oct 6, 2020
4a04fa3
Update Upgrading-from-2020.1-to-2020.2.md
sebastienlagarde Oct 6, 2020
d13e23e
update test 2220
sebastienlagarde Oct 6, 2020
fbf3572
Revert "renamed the resolution parameters for the planar reflections"
sebastienlagarde Oct 6, 2020
c39e140
cleanup migration code
sebastienlagarde Oct 6, 2020
1985cd1
Merge branch 'HDRP/rough-refrlections-option' into HDRP/planar-resolu…
sebastienlagarde Oct 6, 2020
78cf03c
update smoothness test
sebastienlagarde Oct 6, 2020
e2d6027
Create 2220_SmoothPlanarReflection.png
sebastienlagarde Oct 6, 2020
0028d99
Merge branch 'HDRP/rough-refrlections-option' into HDRP/planar-resolu…
sebastienlagarde Oct 6, 2020
62b4e31
some cleanup
sebastienlagarde Oct 6, 2020
093fac8
Revert "Revert "renamed the resolution parameters for the planar refl…
sebastienlagarde Oct 6, 2020
99fdabe
update doc
sebastienlagarde Oct 6, 2020
b799851
Merge branch 'HDRP/staging' into HDRP/planar-resolution-scalability
sebastienlagarde Oct 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added high quality prefiltering option for Bloom.
- Added support for camera relative ray tracing (and keeping non-camera relative ray tracing working)
- Added a rough refraction option on planar reflections.
- Added scalability settings for the planar reflection resolution.

### Fixed
- Fixed several issues with physically-based DoF (TAA ghosting of the CoC buffer, smooth layer transitions, etc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ Use the Reflection settings to configure the max number and resolution of the pr
| **Reflection Cubemap Size** | Use the drop-down to select the maximum resolution of individual Reflection Probe[ ](https://docs.unity3d.com/Manual/class-Cubemap.html)[cubemaps](https://docs.unity3d.com/Manual/class-Cubemap.html). |
| **Probe Cache Size** | The maximum size of the Probe Cache. Defines how many Probe cube maps HDRP can save in cache. |
| **Planar Reflection Atlas Size** | Use the drop-down to select the resolution of the planar probe atlas. It defines how many reflection probe you'll be able to render at once and at which resolution. |
| ****Planar Resolution Tiers**** | |
| **- L** | Set the resolution of planar reflection set to this quality. Planar Reflection Probe's with their **Resolution** set to **Low** use this resolution for their planar reflection. |
| **- M** | Set the resolution of planar reflection set to this quality. Planar Reflection Probe's with their **Resolution** set to **Medium** use this resolution for their planar reflection. |
| **- H** | Set the resolution of planar reflection set to this quality. Planar Reflection Probe's with their **Resolution** set to **High** use this resolution for their planar reflection. |
| **Max Planar Reflection On Screen** | The maximum number of planar reflections on screen at once. |
| **Maximum Environment Lights on Screen** | The maximum number of environment Lights HDRP can manage on screen at once. |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ The following properties control the method that the Planar Reflection Probe use
| **Clipping Planes - Far** | The furthest point relative to the Planar Reflection Probe that it captures reflections. |
| **Probe Layer Mask** | Acts as a culling mask for environment lights (light from other Planar Reflection Probes and Reflection Probes). This Planar Reflection Probe ignores all Reflection Probes that are on Layers not included in this Layer mask, so use this property to ignore certain Reflection Probes when rendering this one. |
| **Custom Frame Settings** | Allows you to define custom [Frame Settings](Frame-Settings.md) for this Probe. Disable this property to use the **Default Frame Settings** in your Unity Project’s [HDRP Asset](HDRP-Asset.md). |
| **Resolution** | Sets the resolution for the probe camera. |
| **Resolution** | Set the resolution of this Planar Reflection Probe. Use the drop-down to select which quality mode to derive the resolution from. If you select Custom, set the resolution, measured in pixels, in the input field. A higher resolution increases the fidelity of planar reflection at the cost of GPU performance and memory usage, so if you experience any performance issues, try using a lower value. |
| **Rough Reflections** | Disable the checkbox to tell HDRP to use this Planar Reflection Probe as a mirror. If you do this, the receiving surface must be perfectly smooth or the reflection result is not accurate. If you want perfect reflection, disabling this option can be useful because it means HDRP does not need to process rough refraction and thus decreases the resource intensity of the effect.|
| **Mirror Position** | Offsets the position of the mirror from the Transform Position. This is only available in **Advanced** mode. |
| **Range Compression Factor** | The factor which HDRP divides the result of the probe's rendering by. This is useful to deal with very bright or dark objects in the reflections that would otherwise be saturated. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ public static bool BakeProbes(IEnumerable<HDProbe> bakedProbes)
"please switch your render pipeline or use another reflection system");
return false;
}



var cubemapSize = (int)hdPipeline.currentPlatformRenderPipelineSettings.lightLoopSettings.reflectionCubemapSize;
// We force RGBAHalf as we don't support 11-11-10 textures (only RT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@ ProbeSettingsOverride displayedFields

CameraSettingsUI.Draw(serialized.cameraSettings, owner, displayedFields.camera);

PropertyFieldWithoutToggle(ProbeSettingsFields.resolution, serialized.resolution, EditorGUIUtility.TrTextContent("Resolution", "Sets the resolution for the planar probe camera."), displayedFields.probe);
// Only display the field if it should
if (((int)ProbeSettingsFields.resolution & (int)displayedFields.probe) != 0 )
{
var scalableSetting = HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.planarReflectionResolution;
serialized.resolutionScalable.LevelAndEnumGUILayout<PlanarReflectionAtlasResolution>(
EditorGUIUtility.TrTextContent("Resolution", "Sets the resolution for the planar probe camera."), scalableSetting, null
);
}

PropertyFieldWithoutToggle(ProbeSettingsFields.roughReflections, serialized.roughReflections, EditorGUIUtility.TrTextContent("Rough Reflections", "When disabled the reflections evaluated using the planar reflection will be perfectly smooth. This save GPU time when the planar reflection is used as a pure mirror."), displayedFields.probe);

PropertyFieldWithoutToggle(ProbeSettingsFields.roughReflections, serialized.roughReflections, EditorGUIUtility.TrTextContent("Rough Reflections", "When disabled the reflections evaluated using the planar reflection will be perfectly smooth. This save GPU time when the planar reflection is used as a pure mirror."), displayedFields.probe);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal class SerializedProbeSettings
internal SerializedProperty proxyCaptureRotationProxySpace;
internal SerializedProperty proxyMirrorPositionProxySpace;
internal SerializedProperty proxyMirrorRotationProxySpace;
internal SerializedProperty resolution;
internal SerializedScalableSettingValue resolutionScalable;
internal SerializedProperty roughReflections;
internal SerializedProperty frustumFieldOfViewMode;
internal SerializedProperty frustumFixedValue;
Expand All @@ -62,7 +62,7 @@ internal SerializedProbeSettings(SerializedProperty root)
proxyCaptureRotationProxySpace = root.FindPropertyRelative("proxySettings.captureRotationProxySpace");
proxyMirrorPositionProxySpace = root.FindPropertyRelative("proxySettings.mirrorPositionProxySpace");
proxyMirrorRotationProxySpace = root.FindPropertyRelative("proxySettings.mirrorRotationProxySpace");
resolution = root.FindPropertyRelative("resolution");
resolutionScalable = new SerializedScalableSettingValue(root.Find((ProbeSettings p) => p.resolutionScalable));
roughReflections = root.FindPropertyRelative("roughReflections");
frustumFieldOfViewMode = root.FindPropertyRelative("frustum.fieldOfViewMode");
frustumFixedValue = root.FindPropertyRelative("frustum.fixedValue");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class GeneralSection

public static readonly GUIContent supportShadowMaskContent = EditorGUIUtility.TrTextContent("Shadowmask", "When enabled, HDRP allocates Shader variants and memory for processing shadow masks. This allows you to use shadow masks in your Unity Project.");
public static readonly GUIContent supportSSRContent = EditorGUIUtility.TrTextContent("Screen Space Reflection", "When enabled, HDRP allocates memory for processing screen space reflection (SSR). This allows you to use SSR in your Unity Project.");
public static readonly GUIContent planarResolutionTitle = EditorGUIUtility.TrTextContent("Planar Resolution Tiers");
public static readonly GUIContent supportSSRTransparentContent = EditorGUIUtility.TrTextContent("Transparent Screen Space Reflection", "When enabled, HDRP executes additional steps to achieve screen space reflection (SSR) on transparent objects.");
public static readonly GUIContent supportSSAOContent = EditorGUIUtility.TrTextContent("Screen Space Ambient Occlusion", "When enabled, HDRP allocates memory for processing screen space ambient occlusion (SSAO). This allows you to use SSAO in your Unity Project.");
public static readonly GUIContent supportSSGIContent = EditorGUIUtility.TrTextContent("Screen Space Global Illumination", "When enabled, HDRP allocates memory for processing screen space global illumination (SSGI). This allows you to use SSGI in your Unity Project.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,29 @@ static void Drawer_SectionReflection(SerializedHDRenderPipelineAsset serialized,

EditorGUILayout.Space();

EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.planarReflectionAtlasSize, Styles.planarAtlasSizeContent);
if (serialized.renderPipelineSettings.lightLoopSettings.planarReflectionAtlasSize.hasMultipleDifferentValues)
EditorGUILayout.HelpBox(Styles.multipleDifferenteValueMessage, MessageType.Info);
else
// Planar reflection probes section
{
long currentCache = PlanarReflectionProbeCache.GetApproxCacheSizeInByte(1, serialized.renderPipelineSettings.lightLoopSettings.planarReflectionAtlasSize.intValue, GraphicsFormat.R16G16B16A16_UNorm);
string message = string.Format(Styles.cacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache));
EditorGUILayout.HelpBox(message, MessageType.Info);
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.planarReflectionAtlasSize, Styles.planarAtlasSizeContent);
serialized.renderPipelineSettings.planarReflectionResolution.ValueGUI<PlanarReflectionAtlasResolution>(Styles.planarResolutionTitle);
// We need to clamp the values to the resolution
int atlasResolution = serialized.renderPipelineSettings.lightLoopSettings.planarReflectionAtlasSize.intValue;
int numLevels = serialized.renderPipelineSettings.planarReflectionResolution.values.arraySize;
for(int levelIdx = 0; levelIdx < numLevels; ++levelIdx)
{
SerializedProperty levelValue = serialized.renderPipelineSettings.planarReflectionResolution.values.GetArrayElementAtIndex(levelIdx);
levelValue.intValue = Mathf.Min(levelValue.intValue, atlasResolution);
}
if (serialized.renderPipelineSettings.lightLoopSettings.planarReflectionAtlasSize.hasMultipleDifferentValues)
EditorGUILayout.HelpBox(Styles.multipleDifferenteValueMessage, MessageType.Info);
else
{
long currentCache = PlanarReflectionProbeCache.GetApproxCacheSizeInByte(1, serialized.renderPipelineSettings.lightLoopSettings.planarReflectionAtlasSize.intValue, GraphicsFormat.R16G16B16A16_UNorm);
string message = string.Format(Styles.cacheInfoFormat, HDEditorUtils.HumanizeWeight(currentCache));
EditorGUILayout.HelpBox(message, MessageType.Info);
}
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.maxPlanarReflectionOnScreen, Styles.maxPlanarReflectionOnScreen);
}
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.lightLoopSettings.maxPlanarReflectionOnScreen, Styles.maxPlanarReflectionOnScreen);


EditorGUILayout.Space();

EditorGUI.BeginChangeCheck();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class SerializedRenderPipelineSettings
public SerializedProperty colorBufferFormat;
public SerializedProperty supportCustomPass;
public SerializedProperty customBufferFormat;
public SerializedScalableSetting planarReflectionResolution;

public SerializedProperty supportDecals;
public SerializedProperty supportDecalLayers;
Expand Down Expand Up @@ -113,6 +114,7 @@ public SerializedRenderPipelineSettings(SerializedProperty root)
customBufferFormat = root.Find((RenderPipelineSettings s) => s.customBufferFormat);
supportCustomPass = root.Find((RenderPipelineSettings s) => s.supportCustomPass);
supportedLitShaderMode = root.Find((RenderPipelineSettings s) => s.supportedLitShaderMode);
planarReflectionResolution = new SerializedScalableSetting(root.Find((RenderPipelineSettings s) => s.planarReflectionResolution));

supportDecals = root.Find((RenderPipelineSettings s) => s.supportDecals);
supportDecalLayers = root.Find((RenderPipelineSettings s) => s.supportDecalLayers);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ public static void ValueGUI<T>(this SerializedScalableSetting self, GUIContent l
LevelValuesFieldGUI<int>(contentRect, self, count, schema);
else if (typeof(T) == typeof(float))
LevelValuesFieldGUI<float>(contentRect, self, count, schema);

else if (typeof(T).IsEnum)
LevelValuesFieldGUI<T>(contentRect, self, count, schema);
EditorGUI.showMixedValue = false;
}

Expand Down Expand Up @@ -178,6 +179,8 @@ static void MultiField<T>(Rect position, GUIContent[] subLabels, T[] values)
values[index] = (T)(object)EditorGUI.Toggle(fieldSlot, (bool)(object)values[index]);
else if (typeof(T) == typeof(float))
values[index] = (T)(object)EditorGUI.FloatField(fieldSlot, (float)(object)values[index]);
else if (typeof(T).IsEnum)
values[index] = (T)(object)EditorGUI.EnumPopup(fieldSlot, (Enum)(object)values[index]);
else
throw new ArgumentOutOfRangeException($"<{typeof(T)}> is not a supported type for multi field");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ public static void LevelAndToggleGUILayout(
string sourceName
) => LevelAndGUILayout<bool, ToggleFieldGUI>(self, label, sourceValue, sourceName);

/// <summary>Draws the level popup and the associated value in a field style GUI with an Enum field.</summary>
/// <param name="self">The scalable setting value to draw.</param>
/// <param name="label">The label to use for the field.</param>
/// <param name="sourceValue">The associated scalable setting. This one defines the levels for this value.</param>
/// <param name="sourceName">A string describing the source of the scalable settings. Usually the name of the containing asset.</param>
public static void LevelAndEnumGUILayout<H>
(
this SerializedScalableSettingValue self,
GUIContent label,
ScalableSetting<H> sourceValue,
string sourceName
) where H : Enum => LevelAndGUILayout<H, EnumFieldGUI<H>>(self, label, sourceValue, sourceName);

/// <summary>
/// Draw the level enum popup for a scalable setting value.
///
Expand Down Expand Up @@ -424,6 +437,52 @@ string sourceName
EditorGUI.LabelField(fieldRect, $"---");
}
}

struct EnumFieldGUI<H> : IFieldGUI<H>
{
public void CustomGUI(
Rect fieldRect,
SerializedScalableSettingValue self,
GUIContent label,
ScalableSetting<H> sourceValue,
string sourceName
)
{
// Due to a constraint in the scalability setting, we cannot simply precise the H type as an Enum in the struct declaration.
// this shenanigans are not pretty, but we do not fall into a high complexity everytime we want to support a new enum.
Enum data = (Enum)Enum.Parse(typeof(H), self.@override.intValue.ToString());
self.@override.intValue = (int)(object)EditorGUI.EnumPopup(fieldRect, data);
}

public void LevelValueDescriptionGUI(
Rect fieldRect,
SerializedScalableSettingValue self,
GUIContent label,
ScalableSetting<H> sourceValue,
string sourceName
)
{
var enabled = GUI.enabled;
GUI.enabled = false;
// See the comment in the function above.
var defaultValue = (Enum)(Enum.GetValues(typeof(H)).GetValue(0));
EditorGUI.EnumPopup(fieldRect, sourceValue != null ? (Enum)(object)(sourceValue[self.level.intValue]) : defaultValue);
fieldRect.x += 25;
fieldRect.width -= 25;
GUI.enabled = enabled;
}

public void MixedValueDescriptionGUI(
Rect fieldRect,
SerializedScalableSettingValue self,
GUIContent label,
ScalableSetting<H> sourceValue,
string sourceName
)
{
EditorGUI.LabelField(fieldRect, $"---");
}
}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@ public enum ReflectionAndPlanarProbeFormat
public enum PlanarReflectionAtlasResolution
{
/// <summary>Size 64</summary>
PlanarReflectionResolution64 = 64,
Resolution64 = 64,
/// <summary>Size 128</summary>
PlanarReflectionResolution128 = 128,
Resolution128 = 128,
/// <summary>Size 256</summary>
PlanarReflectionResolution256 = 256,
Resolution256 = 256,
/// <summary>Size 512</summary>
PlanarReflectionResolution512 = 512,
Resolution512 = 512,
/// <summary>Size 1024</summary>
PlanarReflectionResolution1024 = 1024,
Resolution1024 = 1024,
/// <summary>Size 2048</summary>
PlanarReflectionResolution2048 = 2048,
Resolution2048 = 2048,
/// <summary>Size 4096</summary>
PlanarReflectionResolution4096 = 4096,
Resolution4096 = 4096,
/// <summary>Size 8192</summary>
PlanarReflectionResolution8192 = 8192,
Resolution8192 = 8192,
/// <summary>Size 16384</summary>
PlanarReflectionResolution16384 = 16384
Resolution16384 = 16384
}

/// <summary>
Expand Down Expand Up @@ -133,7 +133,7 @@ public struct GlobalLightLoopSettings
cookieTexArraySize = 1,
#pragma warning restore 618

planarReflectionAtlasSize = PlanarReflectionAtlasResolution.PlanarReflectionResolution1024,
planarReflectionAtlasSize = PlanarReflectionAtlasResolution.Resolution1024,
reflectionProbeCacheSize = 64,
reflectionCubemapSize = CubeReflectionResolution.CubeReflectionResolution256,
reflectionProbeFormat = ReflectionAndPlanarProbeFormat.R11G11B10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ protected enum Version
AddReflectionFrameSetting,
/// <summary>Version Step</summary>
AddFrameSettingDirectSpecularLighting,
/// <summary>Version Step</summary>
PlanarResolutionScalability,
}

/// <summary>
Expand Down
Loading