Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions com.unity.render-pipelines.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The version number for this package has increased due to a version update of a r
- Added UNITY_PREV_MATRIX_M and UNITY_PREV_MATRIX_I_M shader macros to support instanced motion vector rendering
- Added new API to customize the rtHandleProperties of a particular RTHandle. This is a temporary work around to assist with viewport setup of Custom post process when dealing with DLSS or TAAU
- Added `IAdditionalData` interface to identify the additional datas on the core package.
- Added new API to draw color temperature for Lights.

### Fixed
- Help boxes with fix buttons do not crop the label.
Expand Down
66 changes: 66 additions & 0 deletions com.unity.render-pipelines.core/Editor/Lighting/LightUI.Drawers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using UnityEngine;
using UnityEngine.Rendering;

namespace UnityEditor.Rendering
{
/// <summary>
/// Contains a set of methods to help render the inspectors of Lights across SRP's
/// </summary>
public partial class LightUI
{
/// <summary>
/// Draws the color temperature for a serialized light
/// </summary>
/// <param name="serialized">The serizalized light</param>
/// <param name="owner">The editor</param>
public static void DrawColor(ISerializedLight serialized, Editor owner)
{
if (GraphicsSettings.lightsUseLinearIntensity && GraphicsSettings.lightsUseColorTemperature)
{
// Use the color temperature bool to create a popup dropdown to choose between the two modes.
var colorTemperaturePopupValue = Convert.ToInt32(serialized.settings.useColorTemperature.boolValue);
colorTemperaturePopupValue = EditorGUILayout.Popup(Styles.lightAppearance, colorTemperaturePopupValue, Styles.lightAppearanceOptions);
serialized.settings.useColorTemperature.boolValue = Convert.ToBoolean(colorTemperaturePopupValue);

if (serialized.settings.useColorTemperature.boolValue)
{
EditorGUI.indentLevel += 1;
EditorGUILayout.PropertyField(serialized.settings.color, Styles.colorFilter);

// Light unit slider
const int k_ValueUnitSeparator = 2;
var lineRect = EditorGUILayout.GetControlRect();
var labelRect = lineRect;
labelRect.width = EditorGUIUtility.labelWidth;
EditorGUI.LabelField(labelRect, Styles.colorTemperature);

var temperatureSliderRect = lineRect;
temperatureSliderRect.x += EditorGUIUtility.labelWidth + k_ValueUnitSeparator;
temperatureSliderRect.width -= EditorGUIUtility.labelWidth + k_ValueUnitSeparator;
TemperatureSliderUIDrawer.Draw(serialized.settings, serialized.serializedObject, serialized.settings.colorTemperature, temperatureSliderRect);

// Value and unit label
// Match const defined in EditorGUI.cs
const int k_IndentPerLevel = 15;
const int k_UnitWidth = 60 + k_IndentPerLevel;
int indent = k_IndentPerLevel * EditorGUI.indentLevel;
Rect valueRect = EditorGUILayout.GetControlRect();
valueRect.width += indent - k_ValueUnitSeparator - k_UnitWidth;
Rect unitRect = valueRect;
unitRect.x += valueRect.width - indent + k_ValueUnitSeparator;
unitRect.width = k_UnitWidth + k_ValueUnitSeparator;

EditorGUI.PropertyField(valueRect, serialized.settings.colorTemperature, CoreEditorStyles.empty);
EditorGUI.LabelField(unitRect, Styles.lightAppearanceUnits[0]);

EditorGUI.indentLevel -= 1;
}
else
EditorGUILayout.PropertyField(serialized.settings.color, Styles.color);
}
else
EditorGUILayout.PropertyField(serialized.settings.color, Styles.color);
}
}
}

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
Expand Up @@ -94,7 +94,7 @@ static HDLightUI()
CED.FoldoutGroup(s_Styles.celestialBodyHeader, Expandable.CelestialBody, k_ExpandedState, DrawCelestialBodyContent)),
CED.AdditionalPropertiesFoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedState, AdditionalProperties.Emission, k_AdditionalPropertiesState,
CED.Group(
DrawColor,
LightUI.DrawColor,
DrawLightIntensityGUILayout,
DrawEmissionContent),
DrawEmissionAdditionalContent),
Expand Down Expand Up @@ -137,7 +137,9 @@ static HDLightUI()
EditorGUILayout.HelpBox(LightUI.Styles.unsupportedPresetPropertiesMessage, MessageType.Info)),
CED.Group((serialized, owner) => EditorGUILayout.Space()),
CED.FoldoutGroup(LightUI.Styles.generalHeader, Expandable.General, k_ExpandedStatePreset, CED.Group((serialized, owner) => DrawGeneralContent(serialized, owner, true))),
CED.FoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedStatePreset, CED.Group(DrawColor, DrawEmissionContent)),
CED.FoldoutGroup(LightUI.Styles.emissionHeader, Expandable.Emission, k_ExpandedStatePreset, CED.Group(
LightUI.DrawColor,
DrawEmissionContent)),
CED.FoldoutGroup(LightUI.Styles.shadowHeader, Expandable.Shadows, k_ExpandedStatePreset, DrawEnableShadowMapInternal)
);

Expand Down Expand Up @@ -666,55 +668,6 @@ static void DrawLightIntensityGUILayout(SerializedHDLight serialized, Editor own
}
}

static void DrawColor(SerializedHDLight serialized, Editor owner)
{
if (GraphicsSettings.lightsUseLinearIntensity && GraphicsSettings.lightsUseColorTemperature)
{
// Use the color temperature bool to create a popup dropdown to choose between the two modes.
var colorTemperaturePopupValue = Convert.ToInt32(serialized.settings.useColorTemperature.boolValue);
colorTemperaturePopupValue = EditorGUILayout.Popup(LightUI.Styles.lightAppearance, colorTemperaturePopupValue, LightUI.Styles.lightAppearanceOptions);
serialized.settings.useColorTemperature.boolValue = Convert.ToBoolean(colorTemperaturePopupValue);

if (serialized.settings.useColorTemperature.boolValue)
{
EditorGUI.indentLevel += 1;
EditorGUILayout.PropertyField(serialized.settings.color, LightUI.Styles.colorFilter);

// Light unit slider
const int k_ValueUnitSeparator = 2;
var lineRect = EditorGUILayout.GetControlRect();
var labelRect = lineRect;
labelRect.width = EditorGUIUtility.labelWidth;
EditorGUI.LabelField(labelRect, LightUI.Styles.colorTemperature);

var temperatureSliderRect = lineRect;
temperatureSliderRect.x += EditorGUIUtility.labelWidth + k_ValueUnitSeparator;
temperatureSliderRect.width -= EditorGUIUtility.labelWidth + k_ValueUnitSeparator;
TemperatureSliderUIDrawer.Draw(serialized.settings, serialized.serializedObject, serialized.settings.colorTemperature, temperatureSliderRect);

// Value and unit label
// Match const defined in EditorGUI.cs
const int k_IndentPerLevel = 15;
const int k_UnitWidth = 100 + k_IndentPerLevel;
int indent = k_IndentPerLevel * EditorGUI.indentLevel;
Rect valueRect = EditorGUILayout.GetControlRect();
valueRect.width += indent - k_ValueUnitSeparator - k_UnitWidth;
Rect unitRect = valueRect;
unitRect.x += valueRect.width - indent + k_ValueUnitSeparator;
unitRect.width = k_UnitWidth + .5f;

EditorGUI.PropertyField(valueRect, serialized.settings.colorTemperature, CoreEditorStyles.empty);
EditorGUI.Popup(unitRect, 0, new[] { "Kelvin" });

EditorGUI.indentLevel -= 1;
}
else
EditorGUILayout.PropertyField(serialized.settings.color, LightUI.Styles.color);
}
else
EditorGUILayout.PropertyField(serialized.settings.color, LightUI.Styles.color);
}

static void DrawEmissionContent(SerializedHDLight serialized, Editor owner)
{
HDLightType lightType = serialized.type;
Expand Down Expand Up @@ -1183,9 +1136,9 @@ static void DrawShadowMapContent(SerializedHDLight serialized, Editor owner)

if (serialized.settings.isMixed)
{
bool enabled = HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.supportShadowMask;
if (Lightmapping.TryGetLightingSettings(out var settings))
enabled &= settings.mixedBakeMode == MixedLightingMode.Shadowmask;
bool enabled = HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.supportShadowMask;
if (Lightmapping.TryGetLightingSettings(out var settings))
enabled &= settings.mixedBakeMode == MixedLightingMode.Shadowmask;
using (new EditorGUI.DisabledScope(!enabled))
{
Rect nonLightmappedOnlyRect = EditorGUILayout.GetControlRect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ enum Expandable
CED.FoldoutGroup(LightUI.Styles.emissionHeader,
Expandable.Emission,
k_ExpandedState,
CED.Group(DrawerColor, DrawEmissionContent)),
CED.Group(
LightUI.DrawColor,
DrawEmissionContent)),
CED.FoldoutGroup(LightUI.Styles.renderingHeader,
Expandable.Rendering,
k_ExpandedState,
Expand Down Expand Up @@ -241,33 +243,6 @@ static void DrawAreaShapeContent(UniversalRenderPipelineSerializedLight serializ
serializedLight.settings.DrawArea();
}

static void DrawerColor(UniversalRenderPipelineSerializedLight serializedLight, Editor owner)
{
using (var changes = new EditorGUI.ChangeCheckScope())
{
if (GraphicsSettings.lightsUseLinearIntensity && GraphicsSettings.lightsUseColorTemperature)
{
// Use the color temperature bool to create a popup dropdown to choose between the two modes.
var colorTemperaturePopupValue = Convert.ToInt32(serializedLight.settings.useColorTemperature.boolValue);
colorTemperaturePopupValue = EditorGUILayout.Popup(LightUI.Styles.lightAppearance, colorTemperaturePopupValue, LightUI.Styles.lightAppearanceOptions);
serializedLight.settings.useColorTemperature.boolValue = Convert.ToBoolean(colorTemperaturePopupValue);

using (new EditorGUI.IndentLevelScope())
{
if (serializedLight.settings.useColorTemperature.boolValue)
{
EditorGUILayout.PropertyField(serializedLight.settings.color, LightUI.Styles.colorFilter);
k_SliderWithTexture(LightUI.Styles.colorTemperature, serializedLight.settings.colorTemperature, serializedLight.settings);
}
else
EditorGUILayout.PropertyField(serializedLight.settings.color, LightUI.Styles.color);
}
}
else
EditorGUILayout.PropertyField(serializedLight.settings.color, LightUI.Styles.color);
}
}

static void DrawEmissionContent(UniversalRenderPipelineSerializedLight serializedLight, Editor owner)
{
serializedLight.settings.DrawIntensity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ partial class UniversalRenderPipelineLightUI
CED.FoldoutGroup(LightUI.Styles.emissionHeader,
Expandable.Emission,
k_ExpandedStatePreset,
CED.Group(DrawerColor,
DrawEmissionContent))
CED.Group(
LightUI.DrawColor,
DrawEmissionContent)),
CED.FoldoutGroup(Styles.lightCookieHeader,
Expandable.LightCookie,
k_ExpandedState,
DrawLightCookieContent)
);
}
}