Skip to content

Commit

Permalink
Merge pull request #7994 from Unity-Technologies/internal/master
Browse files Browse the repository at this point in the history
Internal/master
  • Loading branch information
UnityAljosha authored Nov 10, 2023
2 parents a194c2a + 27c9c2d commit 0f93f53
Show file tree
Hide file tree
Showing 420 changed files with 9,525 additions and 2,551 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ For an overview of the `RenderGraphBuilder` APIs, see the below table. For more
| void SetRenderFunc<PassData>(RenderFunc<PassData> renderFunc) where PassData : class, new() | Set the rendering function for the render pass. |
| void EnableAsyncCompute(bool value) | Declares that the render pass runs on the asynchronous compute pipeline. |
| void AllowPassCulling(bool value) | Specifies whether Unity should cull the render pass (default is true). This can be useful when the render pass has side effects and you never want the render graph system to cull. |
| void EnableFoveatedRasterization(bool value) | Declares that the render pass runs with foveated rendering feature enabled. |

#### Rendering Code

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace UnityEditor.Rendering
/// </example>
public class HierarchicalBox
{
const float k_HandleSizeCoef = 0.05f;
const float k_HandleSizeCoef = 0.07f;
static Material k_Material_Cache;
static Material k_Material => (k_Material_Cache == null || k_Material_Cache.Equals(null) ? (k_Material_Cache = new Material(Shader.Find("Hidden/UnlitTransparentColored"))) : k_Material_Cache);
static Mesh k_MeshQuad_Cache;
Expand Down Expand Up @@ -492,6 +492,6 @@ public void DrawHandle()
}
}

Color GetHandleColor(NamedFace name) => monoHandle ? m_MonochromeHandleColor : m_PolychromeHandleColor[(int)name];
Color GetHandleColor(NamedFace name) => monoHandle ? m_MonochromeHandleColor : GizmoUtility.GetHandleColor(m_PolychromeHandleColor[(int)name]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,11 @@ static void PerformDilation(ProbeReferenceVolume.Cell cell, ProbeDilationSetting
parameters.samplingNoise = 0;
parameters.weight = 1f;
parameters.leakReductionMode = APVLeakReductionMode.None;
parameters.occlusionWeightContribution = 0.0f;
parameters.minValidNormalWeight = 0.0f;
parameters.frameIndexForNoise = 0;
parameters.reflNormalizationLowerClamp = 0.1f;
parameters.reflNormalizationUpperClamp = 1.0f;
parameters.skyOcclusion = false;
parameters.skyOcclusionIntensity = 0.0f;
parameters.skyOcclusionShadingDirection = false;
ProbeReferenceVolume.instance.UpdateConstantBuffer(cmd, parameters);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ static void CreateSkyOcclusionRayTracingResources()
RayTracingResources resources = ScriptableObject.CreateInstance<RayTracingResources>();
ResourceReloader.ReloadAllNullIn(resources, packagePath);

if (RayTracingContext.IsBackendSupported(RayTracingBackend.Hardware))
{
ProbeGIBaking.m_SkyOcclusionRayTracingContext = new RayTracingContext(RayTracingBackend.Hardware, resources);
ProbeGIBaking.m_SkyOcclusionRayTracingShader = ProbeGIBaking.m_SkyOcclusionRayTracingContext.CreateRayTracingShader(ProbeGIBaking.m_DynamicGISkyOcclusionResources.hardwareRayTracingShader);
}
else
// Disabled hardware backend as it's inconsistent on yamato
//if (RayTracingContext.IsBackendSupported(RayTracingBackend.Hardware))
//{
// ProbeGIBaking.m_SkyOcclusionRayTracingContext = new RayTracingContext(RayTracingBackend.Hardware, resources);
// ProbeGIBaking.m_SkyOcclusionRayTracingShader = ProbeGIBaking.m_SkyOcclusionRayTracingContext.CreateRayTracingShader(ProbeGIBaking.m_DynamicGISkyOcclusionResources.hardwareRayTracingShader);
//}
//else
{
ProbeGIBaking.m_SkyOcclusionRayTracingContext = new RayTracingContext(RayTracingBackend.Compute, resources);
ProbeGIBaking.m_SkyOcclusionRayTracingShader = ProbeGIBaking.m_SkyOcclusionRayTracingContext.CreateRayTracingShader(ProbeGIBaking.m_DynamicGISkyOcclusionResources.rayTracingShader);
Expand Down Expand Up @@ -234,7 +235,7 @@ static void GatherSkyOcclusionGPU(RayTracingContext context,

skyOccShader.SetBufferParam(cmd, _SobolBuffer, sobolBuffer);
skyOccShader.SetBufferParam(cmd, _CPRBuffer, cprBuffer);

skyOccShader.Dispatch(cmd, scratchBuffer,(uint)numProbes, 1, 1);

Graphics.ExecuteCommandBuffer(cmd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ public override void OnInspectorGUI()
return;
}

ProbeVolumeEditor.FrameSettingDisabledHelpBox();

serializedObject.Update();
ProbeTouchupVolumeUI.Inspector.Draw(m_SerializedTouchupVolume, this);
serializedObject.ApplyModifiedProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,25 @@ internal static void APVDisabledHelpBox()
}
}

internal static void FrameSettingDisabledHelpBox()
{
var renderPipelineAssetType = GraphicsSettings.currentRenderPipelineAssetType;

// HDRP only
if (renderPipelineAssetType != null && renderPipelineAssetType.Name == "HDRenderPipelineAsset")
{
static int IndexOf(string[] names, string name) { for (int i = 0; i < names.Length; i++) { if (name == names[i]) return i; } return -1; }

var k_FrameSettingsField = Type.GetType("UnityEngine.Rendering.HighDefinition.FrameSettingsField,Unity.RenderPipelines.HighDefinition.Runtime");
var k_APVFrameSetting = k_FrameSettingsField.GetEnumValues().GetValue(IndexOf(k_FrameSettingsField.GetEnumNames(), "ProbeVolume"));

var k_EnsureFrameSetting = Type.GetType("UnityEditor.Rendering.HighDefinition.HDEditorUtils,Unity.RenderPipelines.HighDefinition.Editor")
.GetMethod("EnsureFrameSetting", BindingFlags.Static | BindingFlags.NonPublic);

k_EnsureFrameSetting.Invoke(null, new object[] { k_APVFrameSetting, "Probe Volumes" });
}
}

public override void OnInspectorGUI()
{
ProbeVolume probeVolume = target as ProbeVolume;
Expand Down Expand Up @@ -107,6 +126,8 @@ public override void OnInspectorGUI()

if (drawInspector)
{
ProbeVolumeEditor.FrameSettingDisabledHelpBox();

serializedObject.Update();
ProbeVolumeUI.Inspector.Draw(m_SerializedProbeVolume, this);
m_SerializedProbeVolume.Apply();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static class Styles
public static readonly GUIContent bakeBox = new GUIContent("", "Controls if Probe Volumes in this scene are baked when Generating Lighting.");
public static readonly GUIContent warnings = new GUIContent("Warnings");

public static readonly string[] bakingModeOptions = new string[] { "Single Scene", "Baking Sets (Advanced)" };
public static readonly string[] bakingModeOptions = new string[] { "Single Scene", "Baking Set" };

public static readonly GUIContent iconEnableAll = new GUIContent("", CoreEditorStyles.GetMessageTypeIcon(MessageType.Info), "The Scene is loaded but is currently not enabled for Baking. It will therefore not be considered when generating lighting data.");
public static readonly GUIContent iconLoadForBake = new GUIContent("", CoreEditorStyles.GetMessageTypeIcon(MessageType.Warning), "The Scene is currently enabled for baking but is unloaded in the Hierarchy. This may result in incomplete lighting data being generated.\nLoad the Scene in the Hierarchy, or use the shortcuts below to fix the issue.");
Expand Down Expand Up @@ -191,6 +191,8 @@ void Initialize()
return;
}

ProbeVolumeEditor.FrameSettingDisabledHelpBox();

if (m_Initialized)
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ sealed class ProbeVolumesOptionsEditor : VolumeComponentEditor
SerializedDataParameter m_AnimateNoise;
SerializedDataParameter m_OcclusionOnlyNormalization;

SerializedDataParameter m_IntensityMultiplier;
SerializedDataParameter m_SkyOcclusionIntensityMultiplier;

public override void OnEnable()
{
var o = new PropertyFetcher<ProbeVolumesOptions>(serializedObject);
Expand All @@ -27,6 +30,9 @@ public override void OnEnable()
m_AnimateNoise = Unpack(o.Find(x => x.animateSamplingNoise));
m_OcclusionOnlyNormalization = Unpack(o.Find(x => x.occlusionOnlyReflectionNormalization));

m_IntensityMultiplier = Unpack(o.Find(x => x.intensityMultiplier));
m_SkyOcclusionIntensityMultiplier = Unpack(o.Find(x => x.skyOcclusionIntensityMultiplier));

base.OnEnable();
}

Expand All @@ -46,6 +52,8 @@ public override void OnInspectorGUI()

PropertyField(m_OcclusionOnlyNormalization);

PropertyField(m_IntensityMultiplier);
PropertyField(m_SkyOcclusionIntensityMultiplier);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void FindSamplingData(float3 posWS, float3 normalWS, out float3 snappedProbePosi
{
float2 posNDC = ComputeNormalizedDeviceCoordinates(GetCameraRelativePositionWS(posWS), UNITY_MATRIX_VP);
float2 posSS = floor(posNDC.xy * _ScreenSize.xy);
posWS = AddNoiseToSamplingPosition(posWS, posSS);
posWS = AddNoiseToSamplingPosition(posWS, posSS, viewDir_WS);
}

APVResources apvRes = FillAPVResources();
Expand All @@ -89,7 +89,7 @@ void FindSamplingData(float3 posWS, float3 normalWS, out float3 snappedProbePosi

WarpUVWLeakReduction(apvRes, posWS, normalWS, subdiv, biasedPosWS, uvw, normalizedOffset, validityWeights);

if (_LeakReductionParams.x != 0)
if (_LeakReductionMode != 0)
{
samplingPosition_WS = snappedProbePosition_WS + (normalizedOffset*probeDistance);
}
Expand Down Expand Up @@ -273,7 +273,7 @@ float3 CalculateDiffuseLighting(v2f i)
{
float skyOcclusion = 0.0f;
float skyOcclusionNoExposure = 0.0f;
if (_EnableSkyOcclusion > 0)
if (_SkyOcclusionIntensity > 0)
{
// L0 L1
float4 temp = float4(kSHBasis0, kSHBasis1 * normal.x, kSHBasis1 * normal.y, kSHBasis1 * normal.z);
Expand Down Expand Up @@ -312,7 +312,7 @@ float3 CalculateDiffuseLighting(v2f i)

bakeDiffuseLighting += EvalL2(L0, L2_R, L2_G, L2_B, L2_C, normal);
#endif
if (_EnableSkyOcclusion > 0)
if (_SkyOcclusionIntensity > 0)
bakeDiffuseLighting += skyOcclusion * EvaluateAmbientProbe(skyShadingDirection);

return bakeDiffuseLighting;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
using static UnityEngine.Rendering.DebugUI.Widget;

namespace UnityEngine.Rendering
{
/// <summary>
/// GPU Resident Drawer Rendering Debugger settings.
/// </summary>
public class DebugDisplayGPUResidentDrawer : IDebugDisplaySettingsData
{
const string k_FormatString = "{0}";
const float k_RefreshRate = 1f / 5f;
const int k_MaxViewCount = 32;

private bool displayBatcherStats
{
get
{
return GPUResidentDrawer.GetDebugStats()?.enabled ?? false;
}
set
{
DebugRendererBatcherStats debugStats = GPUResidentDrawer.GetDebugStats();
if (debugStats != null)
debugStats.enabled = value;
}
}

private static InstanceCullerViewStats GetInstanceCullerViewStats(int viewIndex)
{
DebugRendererBatcherStats debugStats = GPUResidentDrawer.GetDebugStats();
if (debugStats != null && viewIndex < debugStats.instanceCullerStats.Length)
return debugStats.instanceCullerStats[viewIndex];
else
return new InstanceCullerViewStats();
}

static class Strings
{
public const string drawerSettingsContainerName = "GPU Resident Drawer Settings";
public static readonly NameAndTooltip displayBatcherStats = new() { name = "Display Culling Stats", tooltip = "Enable the checkbox to display stats for instance culling." };
}

private static int GetInstanceCullerViewCount()
{
return GPUResidentDrawer.GetDebugStats()?.instanceCullerStats.Length ?? 0;
}

private static DebugUI.Table.Row AddInstanceCullerViewDataRow(int viewIndex)
{
return new DebugUI.Table.Row
{
displayName = "",
opened = true,
isHiddenCallback = () => { return viewIndex >= GetInstanceCullerViewCount(); },
children =
{
new DebugUI.Value { displayName = "View Type", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => $"{GetInstanceCullerViewStats(viewIndex).splitID.viewType}" },
new DebugUI.Value { displayName = "Subview Index", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => GetInstanceCullerViewStats(viewIndex).splitID.splitIndex },
new DebugUI.Value { displayName = "Visible Instances", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => GetInstanceCullerViewStats(viewIndex).visibleInstances },
new DebugUI.Value { displayName = "Draw Commands", refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => GetInstanceCullerViewStats(viewIndex).drawCommands },
}
};
}

[DisplayInfo(name = "GPU Resident Drawer", order = 5)]
private class SettingsPanel : DebugDisplaySettingsPanel
{
public override string PanelName => "GPU Resident Drawer";

public override DebugUI.Flags Flags => DebugUI.Flags.EditorForceUpdate;

public SettingsPanel(DebugDisplayGPUResidentDrawer data)
{
AddWidget(new DebugUI.Container()
{
displayName = Strings.drawerSettingsContainerName,
children =
{
new DebugUI.BoolField { nameAndTooltip = Strings.displayBatcherStats, getter = () => data.displayBatcherStats, setter = value => data.displayBatcherStats = value},
}
});

AddInstanceCullingStatsWidget(data);
}

private void AddInstanceCullingStatsWidget(DebugDisplayGPUResidentDrawer data)
{
var instanceCullerStats = new DebugUI.Foldout
{
displayName = "Instance Culler Stats",
isHeader = true,
opened = true,
isHiddenCallback = () => !data.displayBatcherStats
};

instanceCullerStats.children.Add(new DebugUI.ValueTuple()
{
displayName = "View Count",
values = new[]
{
new DebugUI.Value { refreshRate = k_RefreshRate, formatString = k_FormatString, getter = () => GetInstanceCullerViewCount() }
}
});

DebugUI.Table viewTable = new DebugUI.Table
{
displayName = "", // First column is empty because its content needs to change dynamically
isReadOnly = true
};

// Always add all possible rows, they are dynamically hidden based on actual data
for (int i = 0; i < k_MaxViewCount; i++)
viewTable.children.Add(AddInstanceCullerViewDataRow(i));

var perViewStats = new DebugUI.Foldout
{
displayName = "Per View Stats",
isHeader = true,
opened = false,
isHiddenCallback = () => !data.displayBatcherStats
};
perViewStats.children.Add(viewTable);

instanceCullerStats.children.Add(perViewStats);

AddWidget(instanceCullerStats);
}
}

#region IDebugDisplaySettingsQuery

/// <inheritdoc/>
public bool AreAnySettingsActive => displayBatcherStats;

/// <inheritdoc/>
public bool IsPostProcessingAllowed => true;

/// <inheritdoc/>
public bool IsLightingActive => true;

/// <inheritdoc/>
public bool TryGetScreenClearColor(ref Color color)
{
return false;
}

/// <inheritdoc/>
IDebugDisplaySettingsPanelDisposable IDebugDisplaySettingsData.CreatePanel()
{
return new SettingsPanel(this);
}

#endregion
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0f93f53

Please sign in to comment.