浏览代码

Add option to disable light by type in the debug menu

/main
Antoine Lelievre 6 年前
当前提交
03c9b17a
共有 7 个文件被更改,包括 67 次插入6 次删除
  1. 5
      com.unity.render-pipelines.core/CoreRP/Debugging/DebugUI.Fields.cs
  2. 3
      com.unity.render-pipelines.core/CoreRP/Editor/Debugging/DebugState.cs
  3. 20
      com.unity.render-pipelines.core/CoreRP/Editor/Debugging/DebugUIDrawer.Builtins.cs
  4. 12
      com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.cs
  5. 13
      com.unity.render-pipelines.high-definition/HDRP/Debug/LightingDebug.cs
  6. 18
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.cs
  7. 2
      com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs

5
com.unity.render-pipelines.core/CoreRP/Debugging/DebugUI.Fields.cs


}
}
public class EnumMaskField : Field<Enum>
{
public Enum value;
}
public class ColorField : Field<Color>
{
public bool hdr = false;

3
com.unity.render-pipelines.core/CoreRP/Editor/Debugging/DebugState.cs


[Serializable, DebugState(typeof(DebugUI.IntField), typeof(DebugUI.EnumField))]
public sealed class DebugStateInt : DebugState<int> {}
[Serializable, DebugState(typeof(DebugUI.EnumMaskField))]
public sealed class DebugStateEnumMask : DebugState<Enum> {}
[Serializable, DebugState(typeof(DebugUI.UIntField))]
public sealed class DebugStateUInt : DebugState<uint> {}

20
com.unity.render-pipelines.core/CoreRP/Editor/Debugging/DebugUIDrawer.Builtins.cs


EditorGUILayout.EndVertical();
}
}
[DebugUIDrawer(typeof(DebugUI.EnumMaskField))]
public sealed class DebugUIDrawerMask : DebugUIDrawer
{
public override bool OnGUI(DebugUI.Widget widget, DebugState state)
{
var m = Cast<DebugUI.EnumMaskField>(widget);
var s = Cast<DebugStateEnumMask>(state);
EditorGUI.BeginChangeCheck();
var rect = PrepareControlRect();
Enum value = EditorGUI.EnumFlagsField(rect, CoreEditorUtils.GetContent(widget.displayName), m.GetValue());
if (EditorGUI.EndChangeCheck())
Apply(m, s, value);
return true;
}
}
}

12
com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.cs


return colorPickerDebugSettings.colorPickerMode;
}
public DebugShowLight GetShowLightMask()
{
return lightingDebugSettings.showLight;
}
public bool IsDebugDisplayEnabled()
{
return materialDebugSettings.IsDebugDisplayEnabled() || lightingDebugSettings.IsDebugDisplayEnabled() || mipMapDebugSettings.IsDebugDisplayEnabled() || IsDebugFullScreenEnabled();

public void RegisterLightingDebug()
{
var list = new List<DebugUI.Widget>();
list.Add(new DebugUI.EnumMaskField
{
displayName = "Show Light Type",
getter = () => lightingDebugSettings.showLight,
setter = value => lightingDebugSettings.showLight = (DebugShowLight)value
});
list.Add(new DebugUI.EnumField
{

13
com.unity.render-pipelines.high-definition/HDRP/Debug/LightingDebug.cs


VisualizeShadowMap
}
[Flags]
public enum DebugShowLight
{
None = 0,
Directional = 1 << GPULightType.Directional,
Point = 1 << GPULightType.Point,
Spot = (1 << GPULightType.ProjectorBox) | (1 << GPULightType.ProjectorPyramid) | (1 << GPULightType.Spot),
Line = 1 << GPULightType.Line,
Rectangle = 1 << GPULightType.Rectangle,
}
[Serializable]
public class LightingDebugSettings
{

public float environmentProxyDepthScale = 20;
public float debugExposure = 0.0f;
public DebugShowLight showLight = (DebugShowLight)~0;
public LightLoop.TileClusterDebug tileClusterDebug = LightLoop.TileClusterDebug.None;
public LightLoop.TileClusterCategoryDebug tileClusterDebugByCategory = LightLoop.TileClusterCategoryDebug.Punctual;

18
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.cs


return true;
}
public bool GetDirectionalLightData(CommandBuffer cmd, ShadowSettings shadowSettings, GPULightType gpuLightType, VisibleLight light, HDAdditionalLightData additionalData, AdditionalShadowData additionalShadowData, int lightIndex)
public bool GetDirectionalLightData(CommandBuffer cmd, ShadowSettings shadowSettings, GPULightType gpuLightType, VisibleLight light, HDAdditionalLightData additionalData, AdditionalShadowData additionalShadowData, int lightIndex, DebugDisplaySettings debugDisplaySettings)
{
var directionalLightData = new DirectionalLightData();

return false;
// Discard light if disabled in debug display settings
if ((((int)debugDisplaySettings.lightingDebugSettings.showLight >> (int)GPULightType.Directional) & 1) == 0)
return false;
directionalLightData.lightLayers = additionalData.GetLightLayers();

public bool GetLightData(CommandBuffer cmd, ShadowSettings shadowSettings, Camera camera, GPULightType gpuLightType,
VisibleLight light, HDAdditionalLightData additionalLightData, AdditionalShadowData additionalshadowData,
int lightIndex, ref Vector3 lightDimensions)
int lightIndex, ref Vector3 lightDimensions, DebugDisplaySettings debugDisplaySettings)
{
var lightData = new LightData();

lightData.positionRWS = light.light.transform.position;
bool applyRangeAttenuation = additionalLightData.applyRangeAttenuation && (gpuLightType != GPULightType.ProjectorBox);
// Discard light if disabled in debug display settings
if ((((int)debugDisplaySettings.lightingDebugSettings.showLight >> (int)lightData.lightType) & 1) == 0)
return false;
// In the shader we do range remapping: (x - start) / (end - start) = (dist^2 * rangeAttenuationScale + rangeAttenuationBias)
if (applyRangeAttenuation)

// Return true if BakedShadowMask are enabled
public bool PrepareLightsForGPU(CommandBuffer cmd, HDCamera hdCamera, ShadowSettings shadowSettings, CullResults cullResults,
ReflectionProbeCullResults reflectionProbeCullResults, DensityVolumeList densityVolumes)
ReflectionProbeCullResults reflectionProbeCullResults, DensityVolumeList densityVolumes, DebugDisplaySettings debugDisplaySettings)
{
using (new ProfilingSample(cmd, "Prepare Lights For GPU"))
{

// Directional rendering side, it is separated as it is always visible so no volume to handle here
if (gpuLightType == GPULightType.Directional)
{
if (GetDirectionalLightData(cmd, shadowSettings, gpuLightType, light, additionalLightData, additionalShadowData, lightIndex))
if (GetDirectionalLightData(cmd, shadowSettings, gpuLightType, light, additionalLightData, additionalShadowData, lightIndex, debugDisplaySettings))
{
directionalLightcount++;

Vector3 lightDimensions = new Vector3(); // X = length or width, Y = height, Z = range (depth)
// Punctual, area, projector lights - the rendering side.
if (GetLightData(cmd, shadowSettings, camera, gpuLightType, light, additionalLightData, additionalShadowData, lightIndex, ref lightDimensions))
if (GetLightData(cmd, shadowSettings, camera, gpuLightType, light, additionalLightData, additionalShadowData, lightIndex, ref lightDimensions, debugDisplaySettings))
{
switch (lightCategory)
{

2
com.unity.render-pipelines.high-definition/HDRP/RenderPipeline/HDRenderPipeline.cs


bool enableBakeShadowMask;
using (new ProfilingSample(cmd, "TP_PrepareLightsForGPU", CustomSamplerId.TPPrepareLightsForGPU.GetSampler()))
{
enableBakeShadowMask = m_LightLoop.PrepareLightsForGPU(cmd, hdCamera, m_ShadowSettings, m_CullResults, m_ReflectionProbeCullResults, densityVolumes);
enableBakeShadowMask = m_LightLoop.PrepareLightsForGPU(cmd, hdCamera, m_ShadowSettings, m_CullResults, m_ReflectionProbeCullResults, densityVolumes, m_DebugDisplaySettings);
}
ConfigureForShadowMask(enableBakeShadowMask, cmd);
ConfigureForLightLayers(hdCamera.frameSettings.enableLightLayers, cmd);

正在加载...
取消
保存