Skip to content

[Draft] Lighting/probevolumes cleanup #756

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 26 commits into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2f64702
Simplify EvaluateProbeVolumes interface and builtin SampleBakedGI code
Apr 17, 2020
ca0cbbc
Fix clearing of uninitialized GI
Apr 30, 2020
a1f06f6
Added ProbeVolumesEncodingMode to ShaderOptions in ShaderConfig to al…
pastasfuture May 29, 2020
ade9534
Probe Volumes: SH0, SH1, and SH2 evaluation based on ShaderConfig ful…
pastasfuture May 31, 2020
a9264b7
Probe Volumes: Instead of specifying AtlasWidth, AtlasHeight and Atla…
pastasfuture May 31, 2020
6393f55
Probe Volumes: HDRenderPipelineAsset: Add memory usage information to…
pastasfuture Jun 1, 2020
204a94d
Probe Volumes: Bugfix for Probe Volume UI: Only display Additive blen…
pastasfuture Jun 1, 2020
abdc3c9
Probe Volumes: Bugfix: DataIsAssigned function needed in build as well.
pastasfuture Jun 1, 2020
a8b14d4
Probe Volumes: Accumulate SH coefficients, and evaluate SH at normal …
pastasfuture Jun 1, 2020
58c13fa
Probe Volumes: Rename EvaluateProbeVolumes() to AccumulateProbeVolume…
pastasfuture Jun 1, 2020
10b36c8
Probe Volumes: Major cleanup to AccumulateProbeVolumes(), pulling out…
pastasfuture Jun 1, 2020
a83f4b3
Probe Volumes: Add ShaderConfig.s_ProbeVolumesBilaterialFilteringMode…
pastasfuture Jun 2, 2020
2b83000
Probe Volumes: Do not allocate or bake octahedral depth data in Probe…
pastasfuture Jun 2, 2020
357fdf1
Probe Volumes: Always allocate and pass octahedralDepth array into Ge…
pastasfuture Jun 2, 2020
c886f89
Probe Volumes: Explicit ProbeVolumeAccumulateSphericalHarmonicsL0, L1…
pastasfuture Jun 2, 2020
c82b63f
Probe Volumes: Add simple method for configuring what order of SH Pro…
pastasfuture Jun 8, 2020
3693943
Probe Volumes: Fix to ProbeVolumeUI string names
pastasfuture Jun 8, 2020
ea4c88d
Probe Volumes: Move LightLoop::CreateBoxVolumeDataAndBound out parame…
pastasfuture Jun 8, 2020
f84dedd
Probe Volumes: Remove redundant include from DebugDisplayProbeVolume.…
pastasfuture Jun 8, 2020
b962581
Probe Volumes: Only support SH1 and SH2 atlas (SH0 was not needed). C…
pastasfuture Jun 9, 2020
03e1ea6
Probe Volumes: Wrap supporting accumulation, evaluation, and fallback…
pastasfuture Jun 9, 2020
cda5537
Probe Volumes: Update SampleBakedGI() API (#759)
sebastienlagarde Jun 9, 2020
c685c00
Probe Volumes: Fix DebugViewTiles shader after updates to ProbeVolume…
pastasfuture Jun 9, 2020
dd36bbf
Probe Volumes: Set ShaderConfig evaluation mode to be disabled by def…
pastasfuture Jun 9, 2020
afb0e93
Probe Volumes: Update EvaluateOctahedralDepth function name to match …
pastasfuture Jun 9, 2020
6b510b7
Probe Volumes: Fix up ShaderVariablesGlobal after naming conflict fro…
pastasfuture Jun 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,22 @@ public enum ProbeVolumesEvaluationModes
MaterialPass = 2,
}

[GenerateHLSL(PackingRules.Exact)]
public enum ProbeVolumesEncodingModes
{
SphericalHarmonicsL0 = 0,
SphericalHarmonicsL1 = 1,
SphericalHarmonicsL2 = 2
}

[GenerateHLSL(PackingRules.Exact)]
public enum ProbeVolumesBilateralFilteringModes
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just something to have in mind: the more you have option in shader config, the less they are tested (as it required a dedicated project to test it).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good point. I've been leaning in to using ShaderConfig here to avoid creating more shader variants, as I know the variant explosion has been a big problem. But yeah, good point to at least be aware that that means less test coverage.

{
Disabled = 0,
Validity = 1,
OctahedralDepth = 2
}

[GenerateHLSL(PackingRules.Exact)]
public enum ShaderOptions
{
Expand Down Expand Up @@ -47,6 +63,8 @@ public enum ShaderOptions
// Probe Volumes feature must also be enabled inside of your HDRenderPipelineAsset.
ProbeVolumesEvaluationMode = ProbeVolumesEvaluationModes.Disabled,
ProbeVolumesAdditiveBlending = 1,
ProbeVolumesBilateralFilteringMode = ProbeVolumesBilateralFilteringModes.Validity,
ProbeVolumesEncodingMode = ProbeVolumesEncodingModes.SphericalHarmonicsL1,

AreaLights = 1,

Expand All @@ -69,6 +87,8 @@ public class ShaderConfig
public static int s_PrecomputedAtmosphericAttenuation = (int)ShaderOptions.PrecomputedAtmosphericAttenuation;
public static ProbeVolumesEvaluationModes s_ProbeVolumesEvaluationMode = (ProbeVolumesEvaluationModes)ShaderOptions.ProbeVolumesEvaluationMode;
public static int s_ProbeVolumesAdditiveBlending = (int)ShaderOptions.ProbeVolumesAdditiveBlending;
public static ProbeVolumesBilateralFilteringModes s_ProbeVolumesBilateralFilteringMode = (ProbeVolumesBilateralFilteringModes)ShaderOptions.ProbeVolumesBilateralFilteringMode;
public static ProbeVolumesEncodingModes s_ProbeVolumesEncodingMode = (ProbeVolumesEncodingModes)ShaderOptions.ProbeVolumesEncodingMode;
public static int s_AreaLights = (int)ShaderOptions.AreaLights;
public static int s_BarnDoor = (int)ShaderOptions.BarnDoor;
[System.Obsolete("Deferred shadow can now assume any value, so this field is not used anymore.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@
#define PROBEVOLUMESEVALUATIONMODES_LIGHT_LOOP (1)
#define PROBEVOLUMESEVALUATIONMODES_MATERIAL_PASS (2)

//
// UnityEngine.Rendering.HighDefinition.ProbeVolumesEncodingModes: static fields
//
#define PROBEVOLUMESENCODINGMODES_SPHERICAL_HARMONICS_L0 (0)
#define PROBEVOLUMESENCODINGMODES_SPHERICAL_HARMONICS_L1 (1)
#define PROBEVOLUMESENCODINGMODES_SPHERICAL_HARMONICS_L2 (2)

//
// UnityEngine.Rendering.HighDefinition.ProbeVolumesBilateralFilteringModes: static fields
//
#define PROBEVOLUMESBILATERALFILTERINGMODES_DISABLED (0)
#define PROBEVOLUMESBILATERALFILTERINGMODES_VALIDITY (1)
#define PROBEVOLUMESBILATERALFILTERINGMODES_OCTAHEDRAL_DEPTH (2)

//
// UnityEngine.Rendering.HighDefinition.ShaderOptions: static fields
//
Expand All @@ -28,6 +42,8 @@
#define SHADEROPTIONS_XR_MAX_VIEWS (2)
#define SHADEROPTIONS_PROBE_VOLUMES_EVALUATION_MODE (0)
#define SHADEROPTIONS_PROBE_VOLUMES_ADDITIVE_BLENDING (1)
#define SHADEROPTIONS_PROBE_VOLUMES_BILATERAL_FILTERING_MODE (1)
#define SHADEROPTIONS_PROBE_VOLUMES_ENCODING_MODE (1)
#define SHADEROPTIONS_AREA_LIGHTS (1)
#define SHADEROPTIONS_DEFERRED_SHADOW_FILTERING (1)
#define SHADEROPTIONS_BARN_DOOR (0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,37 @@ static bool IsFeatureDisabled(SerializedProbeVolume serialized, Editor owner)

static void Drawer_FeatureWarningMessage(SerializedProbeVolume serialized, Editor owner)
{
EditorGUILayout.HelpBox(Styles.k_featureWarning, MessageType.Warning);
EditorGUILayout.HelpBox(Styles.k_FeatureWarning, MessageType.Warning);
}

static void Drawer_FeatureEnableInfo(SerializedProbeVolume serialized, Editor owner)
{
EditorGUILayout.HelpBox(Styles.k_featureEnableInfo, MessageType.Error);
EditorGUILayout.HelpBox(Styles.k_FeatureEnableInfo, MessageType.Error);
}

static void Drawer_BakeToolBar(SerializedProbeVolume serialized, Editor owner)
{
var asset = serialized.probeVolumeAsset.objectReferenceValue as ProbeVolumeAsset;

if (ShaderConfig.s_ProbeVolumesBilateralFilteringMode == ProbeVolumesBilateralFilteringModes.OctahedralDepth
&& asset != null && asset.payload.dataOctahedralDepth == null)
{
EditorGUILayout.HelpBox(Styles.k_FeatureOctahedralDepthEnabledNoData, MessageType.Error);
}

if (ShaderConfig.s_ProbeVolumesBilateralFilteringMode != ProbeVolumesBilateralFilteringModes.OctahedralDepth
&& asset != null && asset.payload.dataOctahedralDepth != null)
{
EditorGUILayout.HelpBox(Styles.k_FeatureOctahedralDepthDisableYesData, MessageType.Error);
}

EditorGUILayout.PropertyField(serialized.probeVolumeAsset, Styles.s_DataAssetLabel);

EditorGUILayout.Slider(serialized.backfaceTolerance, 0.0f, 1.0f, Styles.s_BackfaceToleranceLabel);
EditorGUILayout.PropertyField(serialized.dilationIterations, Styles.s_DilationIterationLabel);

GUILayout.BeginHorizontal();
if (GUILayout.Button("Bake Selected"))
if (GUILayout.Button(Styles.k_BakeSelectedText))
{
ProbeVolumeManager.BakeSelected();
}
Expand Down Expand Up @@ -266,7 +280,20 @@ static void Drawer_VolumeContent(SerializedProbeVolume serialized, Editor owner)
EditorGUILayout.PropertyField(serialized.lightLayers);
EditorGUILayout.PropertyField(serialized.volumeBlendMode, Styles.s_VolumeBlendModeLabel);
EditorGUILayout.Slider(serialized.weight, 0.0f, 1.0f, Styles.s_WeightLabel);
{
EditorGUI.BeginChangeCheck();
float normalBiasWS = EditorGUILayout.FloatField(Styles.s_NormalBiasWSLabel, serialized.normalBiasWS.floatValue);
if (EditorGUI.EndChangeCheck())
{
serialized.normalBiasWS.floatValue = Mathf.Max(0, normalBiasWS);
}
}
EditorGUILayout.PropertyField(serialized.debugColor, Styles.s_DebugColorLabel);

if (ShaderConfig.s_ProbeVolumesAdditiveBlending == 0 && serialized.volumeBlendMode.intValue != (int)VolumeBlendMode.Normal)
{
EditorGUILayout.HelpBox(Styles.k_FeatureAdditiveBlendingDisabledError, MessageType.Error);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ static partial class ProbeVolumeUI
{
internal static class Styles
{
internal const string k_featureWarning = "Warning: Probe Volumes is a highly experimental feature.\nIt is disabled by default for this reason.\nIt's functionality is subject to breaking changes and whole sale removal.\nIt is not recommended for use outside of for providing feedback.\nIt should not be used in production.";
internal const string k_featureEnableInfo = "\nProbe Volumes feature is disabled. To enable, set:\nProbeVolumesEvaluationMode = ProbeVolumesEvaluationModes.MaterialPass\ninside of ShaderConfig.cs and inside of the editor run:\nEdit->Render Pipeline->Generate Shader Includes\nProbe Volumes feature must also be enabled inside of your HDRenderPipelineAsset.";
internal const string k_FeatureWarning = "Warning: Probe Volumes is a highly experimental feature.\nIt is disabled by default for this reason.\nIt's functionality is subject to breaking changes and whole sale removal.\nIt is not recommended for use outside of for providing feedback.\nIt should not be used in production.";
internal const string k_FeatureEnableInfo = "\nProbe Volumes feature is disabled. To enable, set:\nProbeVolumesEvaluationMode = ProbeVolumesEvaluationModes.MaterialPass\ninside of ShaderConfig.cs. Then inside of the editor run:\nEdit->Render Pipeline->Generate Shader Includes\nProbe Volumes feature must also be enabled inside of your HDRenderPipelineAsset.";
internal const string k_FeatureAdditiveBlendingDisabledError = "Error: ProbeVolumesAdditiveBlending feature is disabled inside of ShaderConfig.cs.\nThis probe volume will not be rendered.\nTo enable, set:\nProbeVolumesAdditiveBlending = 1\ninside of ShaderConfig.cs. Then inside of the editor run:\nEdit->Render Pipeline->Generate Shader Includes.";
internal const string k_FeatureOctahedralDepthEnabledNoData = "Error: ProbeVolumesBilateralFilteringMode inside of ShaderConfig.cs is set to OctahedralDepth, but asset was baked with OctahedralDepth disabled.\nPlease rebake if you would like this probe volume to use octahedral depth filtering.";
internal const string k_FeatureOctahedralDepthDisableYesData = "Error: ProbeVolumesBilateralFilteringMode inside of ShaderConfig.cs is not set to OctahedralDepth, but was baked with OctahedralDepth enabled.\nPlease rebake to discard octahedral depth data from asset.";
internal const string k_VolumeHeader = "Volume";
internal const string k_ProbesHeader = "Probes";
internal const string k_BakingHeader = "Baking";
internal const string k_BakeSelectedText = "Bake Selected";

internal static readonly GUIContent[] s_Toolbar_Contents = new GUIContent[]
{
Expand Down Expand Up @@ -38,6 +42,7 @@ internal static class Styles

internal static readonly GUIContent s_VolumeBlendModeLabel = new GUIContent("Volume Blend Mode", "A blending mode for the entire volume when overlapping others.");
internal static readonly GUIContent s_WeightLabel = new GUIContent("Weight", "Weigh the probe contribution for the entire volume.");
internal static readonly GUIContent s_NormalBiasWSLabel = new GUIContent("Normal Bias", "Controls the distance in world space units to bias along the surface normal to mitigate light leaking and self-shadowing artifacts.\nA value of 0.0 is physically accurate, but can result in self shadowing artifacts on surfaces that contribute to GI.\nIncrease value to mitigate self shadowing artifacts.\nSignificantly large values can have performance implications, as normal bias will dilate a probe volumes bounding box, causing it to be sampled in additional neighboring tiles / clusters.");

internal static readonly GUIContent s_BackfaceToleranceLabel = new GUIContent("Backface Tolerance", "The percentage of backfaces sampled per probe is acceptable before probe will receive dilated data.");
internal static readonly GUIContent s_DilationIterationLabel = new GUIContent("Dilation Iterations", "The number of iterations Dilation copies over data from each probe to its neighbors.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class SerializedProbeVolume

internal SerializedProperty volumeBlendMode;
internal SerializedProperty weight;
internal SerializedProperty normalBiasWS;

internal SerializedProperty size;

Expand Down Expand Up @@ -59,6 +60,7 @@ internal SerializedProbeVolume(SerializedObject serializedObject)

volumeBlendMode = probeVolumeParams.FindPropertyRelative("volumeBlendMode");
weight = probeVolumeParams.FindPropertyRelative("weight");
normalBiasWS = probeVolumeParams.FindPropertyRelative("normalBiasWS");

size = probeVolumeParams.FindPropertyRelative("size");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,8 @@ public class GeneralSection
public static readonly GUIContent LODBias = EditorGUIUtility.TrTextContent("LOD Bias");
internal static readonly GUIContent supportProbeVolumeContent = EditorGUIUtility.TrTextContent("Probe Volume", "When enabled, HDRP allocates Shader variants and memory for probe volume based GI. This allows you to use probe volumes in your Unity Project.");
internal const string probeVolumeInfo = "Warning: Probe Volumes is a highly experimental feature.\nIt is disabled by default for this reason.\nIt's functionality is subject to breaking changes and whole sale removal.\nIt is not recommended for use outside of for providing feedback.\nIt should not be used in production.\nTo enable, set:\nProbeVolumesEvaluationMode = ProbeVolumesEvaluationModes.MaterialPass\ninside of ShaderConfig.cs\and inside of the editor run:\nEdit->Render Pipeline->Generate Shader Includes\nProbe Volumes feature must also be enabled here.";
internal static readonly GUIContent probeVolumeAtlasWidth = EditorGUIUtility.TrTextContent("Atlas Width", "Width (resolution in X) of the atlas containing visible ProbeVolumes.");
internal static readonly GUIContent probeVolumeAtlasHeight = EditorGUIUtility.TrTextContent("Atlas Height", "Height (resolution in Y) of the atlas containing visible ProbeVolumes.");
internal static readonly GUIContent probeVolumeAtlasDepth = EditorGUIUtility.TrTextContent("Atlas Depth", "Depth (resolution in Z) of the atlas containing visible ProbeVolumes.");
internal static readonly GUIContent probeVolumeAtlasOctahedralDepthWidth = EditorGUIUtility.TrTextContent("Octahedral Depth Atlas Width", "Width of the atlas containing visible ProbeVolumes octahedral depth data");
internal static readonly GUIContent probeVolumeAtlasOctahedralDepthHeight = EditorGUIUtility.TrTextContent("Octahedral Depth Atlas Height", "Height of the atlas containing visible ProbeVolumes octahedral depth data.");
internal static readonly GUIContent probeVolumeAtlasResolution = EditorGUIUtility.TrTextContent("Atlas Resolution", "Resolution of the 3D texture atlas containing visible ProbeVolumes.");
internal static readonly GUIContent probeVolumeAtlasOctahedralDepthResolution = EditorGUIUtility.TrTextContent("Octahedral Depth Atlas Resolution", "Resolution of the 2D texture atlas containing visible ProbeVolumes octahedral depth data.");


public const string cacheErrorFormat = "This configuration will lead to more than 2 GB reserved for this cache at runtime! ({0} requested) Only {1} element will be reserved instead.";
Expand Down Expand Up @@ -234,10 +231,7 @@ public class GeneralSection
{ supportTransparentDepthPrepass , shaderVariantDrawback },
{ supportTransparentDepthPostpass , shaderVariantDrawback },
{ supportRaytracing , string.Format("{0}, {1}", memoryDrawback, lotShaderVariantDrawback) },
{ supportProbeVolumeContent , string.Format("{0}, {1}", memoryDrawback, shaderVariantDrawback) },
{ probeVolumeAtlasWidth , memoryDrawback },
{ probeVolumeAtlasHeight , memoryDrawback },
{ probeVolumeAtlasDepth , memoryDrawback },
{ supportProbeVolumeContent , string.Format("{0}, {1}", memoryDrawback, shaderVariantDrawback) }
};

public static Dictionary<SupportedLitShaderMode, string> supportLitShaderModeDrawbacks = new Dictionary<SupportedLitShaderMode, string>
Expand Down
Loading