Skip to content

Commit 1bdf5e9

Browse files
committed
Probe Volume:
Probe Volumes: Fix case when ShaderConfig enables them, but they have not yet been enabled in the frame settings. Previously this case would spill errors about unassigned compute parameters like _ProbeVolumeAtlasSH - this comes up when creating standalone HDRP template projects for repro demos Probe Volume sampling quality (#102) * Added a frame setting for Probe Volume lighting sampling quality between SHL0, SHL1 and SHL2. * Probe Volume sampling quality cleanup. * WIP switch Probe Volume spherical harmonics level with global keywords. L0 and L1 are not supported by Dynamic GI yet. * Implemented missing SH L0 and L1 modes for Dynamic GI. * Removed Probe Volume SHL0 option to save shader variants. Fixed Volumetric Lighting. * Fixed VFX shaders after introducing different Probe Volume encodings. * Support baking SHL2 fallback radiance from within the SHL1 mode. Cleanup. Check if probeVolumeAtlas is null before trying to release a slot from it. The atlas could be not created yet as we are doing it later in a rendering now to match the selected SH encoding for a given frame. (#108) Probe Volumes: Remove an unnecessary editor only GC.Alloc Reflection Probe Normalization: Fix bad rebase merge of reflection probe normalization code
1 parent 9ed02f9 commit 1bdf5e9

36 files changed

+343
-114
lines changed

com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ public enum ShaderOptions
110110
/// <summary>The probe volume bilateral filtering sample mode.</summary>
111111
/// <seealso cref="ProbeVolumesBilateralFilteringSampleModes"/>
112112
ProbeVolumesBilateralFilteringSampleMode = ProbeVolumesBilateralFilteringSampleModes.ApproximateSample,
113-
/// <summary>The probe volume encoding method.</summary>
114-
/// <seealso cref="ProbeVolumesEncodingModes"/>
115-
ProbeVolumesEncodingMode = ProbeVolumesEncodingModes.SphericalHarmonicsL2,
116113

117114
/// <summary>Support for area lights.</summary>
118115
AreaLights = 1,
@@ -158,9 +155,6 @@ public class ShaderConfig
158155
/// <summary>Specifies the probe volume filtering mode.</summary>
159156
///<seealso cref="ShaderOptions.ProbeVolumesBilateralFilteringMode"/>
160157
public static ProbeVolumesBilateralFilteringSampleModes s_ProbeVolumesBilateralFilteringSampleMode = (ProbeVolumesBilateralFilteringSampleModes)ShaderOptions.ProbeVolumesBilateralFilteringSampleMode;
161-
/// <summary>Specifies the probe volume encoding method.</summary>
162-
///<seealso cref="ShaderOptions.ProbeVolumesEncodingMode"/>
163-
public static ProbeVolumesEncodingModes s_ProbeVolumesEncodingMode = (ProbeVolumesEncodingModes)ShaderOptions.ProbeVolumesEncodingMode;
164158
/// <summary>Indicates whether to support area lights.</summary>
165159
///<seealso cref="ShaderOptions.AreaLights"/>
166160
public static int s_AreaLights = (int)ShaderOptions.AreaLights;

com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#define SHADEROPTIONS_PROBE_VOLUMES_ADDITIVE_BLENDING (1)
4444
#define SHADEROPTIONS_PROBE_VOLUMES_BILATERAL_FILTERING_MODE (1)
4545
#define SHADEROPTIONS_PROBE_VOLUMES_BILATERAL_FILTERING_SAMPLE_MODE (0)
46-
#define SHADEROPTIONS_PROBE_VOLUMES_ENCODING_MODE (2)
4746
#define SHADEROPTIONS_AREA_LIGHTS (1)
4847
#define SHADEROPTIONS_BARN_DOOR (0)
4948

com.unity.render-pipelines.high-definition/Editor/Lighting/ProbeVolume/ProbeVolumeSHPreview.shader

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Shader "Hidden/Debug/ProbeVolumeSHPreview"
2929
#pragma vertex vert
3030
#pragma fragment frag
3131

32+
#pragma multi_compile PROBE_VOLUMES_ENCODING_SPHERICAL_HARMONICS_L1 PROBE_VOLUMES_ENCODING_SPHERICAL_HARMONICS_L2
33+
3234
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
3335
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
3436
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl"
@@ -125,14 +127,21 @@ Shader "Hidden/Debug/ProbeVolumeSHPreview"
125127

126128
#if SHADEROPTIONS_PROBE_VOLUMES_EVALUATION_MODE != PROBEVOLUMESEVALUATIONMODES_DISABLED
127129

128-
#if SHADEROPTIONS_PROBE_VOLUMES_ENCODING_MODE == PROBEVOLUMESENCODINGMODES_SPHERICAL_HARMONICS_L1
130+
#if defined(PROBE_VOLUMES_ENCODING_SPHERICAL_HARMONICS_L0)
131+
ProbeVolumeSphericalHarmonicsL0 coefficients;
132+
ZERO_INITIALIZE(ProbeVolumeSphericalHarmonicsL0, coefficients);
133+
ProbeVolumeLoadAccumulateSphericalHarmonicsL0(probeIndexAtlas3D, 1.0f, coefficients);
134+
ProbeVolumeSwizzleAndNormalizeSphericalHarmonicsL0(coefficients);
135+
outgoingRadiance = coefficients.data[0].xyz;
136+
137+
#elif defined(PROBE_VOLUMES_ENCODING_SPHERICAL_HARMONICS_L1)
129138
ProbeVolumeSphericalHarmonicsL1 coefficients;
130139
ZERO_INITIALIZE(ProbeVolumeSphericalHarmonicsL1, coefficients);
131140
ProbeVolumeLoadAccumulateSphericalHarmonicsL1(probeIndexAtlas3D, 1.0f, coefficients);
132141
ProbeVolumeSwizzleAndNormalizeSphericalHarmonicsL1(coefficients);
133142
outgoingRadiance = SHEvalLinearL0L1(normalWS, coefficients.data[0], coefficients.data[1], coefficients.data[2]);
134143

135-
#elif SHADEROPTIONS_PROBE_VOLUMES_ENCODING_MODE == PROBEVOLUMESENCODINGMODES_SPHERICAL_HARMONICS_L2
144+
#elif defined(PROBE_VOLUMES_ENCODING_SPHERICAL_HARMONICS_L2)
136145
ProbeVolumeSphericalHarmonicsL2 coefficients;
137146
ZERO_INITIALIZE(ProbeVolumeSphericalHarmonicsL2, coefficients);
138147
ProbeVolumeLoadAccumulateSphericalHarmonicsL2(probeIndexAtlas3D, 1.0f, coefficients);

com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,20 @@ static class CoreKeywordDescriptors
11501150
}
11511151
};
11521152

1153+
public static KeywordDescriptor ProbeVolumesEncoding = new KeywordDescriptor()
1154+
{
1155+
displayName = "Probe Volumes Encoding",
1156+
referenceName = "PROBE_VOLUMES_ENCODING",
1157+
type = KeywordType.Enum,
1158+
definition = KeywordDefinition.MultiCompile,
1159+
scope = KeywordScope.Global,
1160+
entries = new KeywordEntry[]
1161+
{
1162+
new KeywordEntry() { displayName = "Spherical Harmonics L1", referenceName = "SPHERICAL_HARMONICS_L1" },
1163+
new KeywordEntry() { displayName = "Spherical Harmonics L2", referenceName = "SPHERICAL_HARMONICS_L2" },
1164+
}
1165+
};
1166+
11531167
public static KeywordDescriptor SurfaceTypeTransparent = new KeywordDescriptor()
11541168
{
11551169
displayName = "Surface Type Transparent",

com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/LightingSubTarget.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ protected override void CollectPassKeywords(ref PassDescriptor pass)
126126
{
127127
pass.keywords.Add(CoreKeywordDescriptors.Shadow);
128128
pass.keywords.Add(CoreKeywordDescriptors.ScreenSpaceShadow);
129+
pass.keywords.Add(CoreKeywordDescriptors.ProbeVolumesEncoding);
129130

130131
if (pass.lightMode == HDShaderPassNames.s_TransparentBackfaceStr)
131132
pass.defines.Add(CoreKeywordDescriptors.LightList, 1);

com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,12 @@ static void Drawer_SectionLightingSettings(SerializedFrameSettings serialized, E
341341
// Probe Volumes
342342
area.AmmendInfo(FrameSettingsField.ProbeVolume, overrideable: () => hdrpSettings.supportProbeVolume);
343343
area.AmmendInfo(FrameSettingsField.NormalizeReflectionProbeWithProbeVolume, overrideable: () => hdrpSettings.supportProbeVolume);
344+
area.AmmendInfo(FrameSettingsField.ProbeVolumeEncoding,
345+
customGetter: () => (ProbeVolumesEncodingSetting)serialized.probeVolumeEncoding.intValue, // Levels 1-2
346+
customSetter: v => serialized.probeVolumeEncoding.intValue = Math.Max(1, Math.Min((int)v, 2)), // Levels 1-2
347+
hasMixedValues: serialized.probeVolumeEncoding.hasMultipleDifferentValues,
348+
overrideable: () => hdrpSettings.supportProbeVolume
349+
);
344350
area.AmmendInfo(FrameSettingsField.ProbeVolumeDynamicGI, overrideable: () => hdrpSettings.supportProbeVolume && hdrpSettings.supportProbeVolumeDynamicGI);
345351
area.AmmendInfo(FrameSettingsField.ProbeVolumeDynamicGIInfiniteBounces, overrideable: () => hdrpSettings.supportProbeVolume && hdrpSettings.supportProbeVolumeDynamicGI);
346352
area.AmmendInfo(FrameSettingsField.ProbeVolumeDynamicGIPropagationQuality,

com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/SerializedFrameSettings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class SerializedFrameSettings
2020
public SerializedProperty maximumLODLevel;
2121
public SerializedProperty maximumLODLevelMode;
2222
public SerializedProperty maximumLODLevelQualityLevel;
23+
public SerializedProperty probeVolumeEncoding;
2324
public SerializedProperty probeVolumeDynamicGIPropagationQuality;
2425
public SerializedProperty probeVolumeDynamicGIMaxSimulationsPerFrame;
2526
public SerializedProperty probeVolumeDynamicGIMixedLightMode;
@@ -104,6 +105,7 @@ public SerializedFrameSettings(SerializedProperty rootData, SerializedProperty r
104105
maximumLODLevel = rootData.FindPropertyRelative("maximumLODLevel");
105106
maximumLODLevelMode = rootData.FindPropertyRelative("maximumLODLevelMode");
106107
maximumLODLevelQualityLevel = rootData.FindPropertyRelative("maximumLODLevelQualityLevel");
108+
probeVolumeEncoding = rootData.FindPropertyRelative("probeVolumeEncoding");
107109
probeVolumeDynamicGIPropagationQuality = rootData.FindPropertyRelative("probeVolumeDynamicGIPropagationQuality");
108110
probeVolumeDynamicGIMaxSimulationsPerFrame = rootData.FindPropertyRelative("probeVolumeDynamicGIMaxSimulationsPerFrame");
109111
probeVolumeDynamicGIMixedLightMode = rootData.FindPropertyRelative("probeVolumeDynamicGIMixedLightMode");

com.unity.render-pipelines.high-definition/Editor/VFXGraph/Shaders/Templates/Mesh/PassForward.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Pass
1212
${VFXHDRPForwardDefines}
1313
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
1414
#pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH
15+
#pragma multi_compile PROBE_VOLUMES_ENCODING_SPHERICAL_HARMONICS_L1 PROBE_VOLUMES_ENCODING_SPHERICAL_HARMONICS_L2
1516
#pragma multi_compile _ DEBUG_DISPLAY
1617
//#pragma enable_d3d11_debug_symbols
1718

com.unity.render-pipelines.high-definition/Editor/VFXGraph/Shaders/Templates/PlanarPrimitive/PassForward.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Pass
1313
${VFXHDRPForwardDefines}
1414
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
1515
#pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH
16+
#pragma multi_compile PROBE_VOLUMES_ENCODING_SPHERICAL_HARMONICS_L1 PROBE_VOLUMES_ENCODING_SPHERICAL_HARMONICS_L2
1617
#pragma multi_compile _ DEBUG_DISPLAY
1718
//#pragma enable_d3d11_debug_symbols
1819

com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Shader "Hidden/HDRP/Deferred"
4040
#pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON
4141
#pragma multi_compile _ DEBUG_DISPLAY
4242
#pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH
43+
#pragma multi_compile PROBE_VOLUMES_ENCODING_SPHERICAL_HARMONICS_L1 PROBE_VOLUMES_ENCODING_SPHERICAL_HARMONICS_L2
4344

4445
#define USE_FPTL_LIGHTLIST // deferred opaque always use FPTL
4546

0 commit comments

Comments
 (0)