浏览代码

Simplified Show light type debug settings

/main
Antoine Lelievre 6 年前
当前提交
c278bbee
共有 7 个文件被更改,包括 43 次插入54 次删除
  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. 17
      com.unity.render-pipelines.high-definition/HDRP/Debug/DebugDisplay.cs
  5. 16
      com.unity.render-pipelines.high-definition/HDRP/Debug/LightingDebug.cs
  6. 13
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightDefinition.cs
  7. 23
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.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;
}
}
}

17
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();

{
var list = new List<DebugUI.Widget>();
list.Add(new DebugUI.EnumMaskField
list.Add(new DebugUI.Foldout
displayName = "Show Light Type",
getter = () => lightingDebugSettings.showLight,
setter = value => lightingDebugSettings.showLight = (DebugShowLight)value
displayName = "Show Light By Type",
children = {
new DebugUI.BoolField { displayName = "Show Directional Lights", getter = () => lightingDebugSettings.showDirectionalLight, setter = value => lightingDebugSettings.showDirectionalLight = value },
new DebugUI.BoolField { displayName = "Show Punctual Lights", getter = () => lightingDebugSettings.showPunctualLight, setter = value => lightingDebugSettings.showPunctualLight = value },
new DebugUI.BoolField { displayName = "Show Area Lights", getter = () => lightingDebugSettings.showAreaLight, setter = value => lightingDebugSettings.showAreaLight = value },
new DebugUI.BoolField { displayName = "Show Reflection Probe", getter = () => lightingDebugSettings.showReflectionProbe, setter = value => lightingDebugSettings.showReflectionProbe = value },
}
});
list.Add(new DebugUI.EnumField

16
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 debugExposure = 0.0f;
public DebugShowLight showLight = (DebugShowLight)~0;
public bool showPunctualLight = true;
public bool showDirectionalLight = true;
public bool showAreaLight = true;
public bool showReflectionProbe = true;
public LightLoop.TileClusterDebug tileClusterDebug = LightLoop.TileClusterDebug.None;
public LightLoop.TileClusterCategoryDebug tileClusterDebugByCategory = LightLoop.TileClusterCategoryDebug.Punctual;

13
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightDefinition.cs


// Disk,
};
public static class GPULightTypeExtension
{
public static bool IsAreaLight(this GPULightType lightType)
{
return lightType == GPULightType.Rectangle || lightType == GPULightType.Line;
}
public static bool IsSpot(this GPULightType lightType)
{
return lightType == GPULightType.Spot || lightType == GPULightType.ProjectorBox || lightType == GPULightType.ProjectorPyramid;
}
}
// This is use to distinguish between reflection and refraction probe in LightLoop
[GenerateHLSL]
public enum GPUImageBasedLightingType

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


namespace UnityEngine.Experimental.Rendering.HDPipeline
{
class ShadowSetup : IDisposable
{
// shadow related stuff

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

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;
if (lightData.lightType.IsAreaLight())
{
if (!debugDisplaySettings.lightingDebugSettings.showAreaLight)
return false;
}
else
{
if (!debugDisplaySettings.lightingDebugSettings.showPunctualLight)
return false;
}
// In the shader we do range remapping: (x - start) / (end - start) = (dist^2 * rangeAttenuationScale + rangeAttenuationBias)
if (applyRangeAttenuation)

}
}
public bool GetEnvLightData(CommandBuffer cmd, Camera camera, ProbeWrapper probe)
public bool GetEnvLightData(CommandBuffer cmd, Camera camera, ProbeWrapper probe, DebugDisplaySettings debugDisplaySettings)
return false;
// Discard probe if disabled in debug menu
if (!debugDisplaySettings.lightingDebugSettings.showReflectionProbe)
return false;
var capturePosition = Vector3.zero;

var probeWrapper = ProbeWrapper.Wrap(probe, planarProbe);
if (GetEnvLightData(cmd, camera, probeWrapper))
if (GetEnvLightData(cmd, camera, probeWrapper, debugDisplaySettings))
{
GetEnvLightVolumeDataAndBound(probeWrapper, lightVolumeType, worldToView);
if (stereoEnabled)

正在加载...
取消
保存