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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions com.unity.render-pipelines.core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [13.1.6] - 2022-01-14

Version Updated
The version number for this package has increased due to a version update of a related graphics package.
### Fixed
- Fixed undo in for `DebugUI.EnumFields` on the rendering debugger. (case 1386964)

## [13.1.5] - 2021-12-17

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
* [Synchronizing shader code and C#](generating-shader-includes.md)
* [Look Dev](Look-Dev.md)
* [Environment Library](Look-Dev-Environment-Library.md)
* [View Lighting Tool](view-lighting-tool.md)
* [Light Anchor](view-lighting-tool.md)
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
## View Lighting tool
## Light Anchor

The View Lighting tool allows you to set up lighting in camera space. It uses the main Camera (the one that renders to the Game view) to set the orientation of the Light using spherical coordinates, and it uses a target and distance to set the position of the Light.
The Light Anchor can help to place light sources around subjects, in relation to a Camera and an anchor point. It's particularly effective for cinematic lighting, which often requires multiple light sources orbiting a subject.

Since the View Lighting tool uses camera-space, it is especially useful when setting up lighting for cinematics.
## Using the Light Anchor Component

To be able to use the view lighting tool, we need to have at least one camera tagged as "MainCamera" (only one will be used).
To use the Light Anchor, you must set the Tag of at least one Camera to "MainCamera". By default, the Anchor's position will be the same as the position of the GameObject the Light Anchor Component is attached to.

## Using the View Lighting tool
Use the **Orbit** and **Elevation** to control the orientation of the light, in degrees, relative to the main Camera's and Anchor's positions. If the Light has a Cookie or an IES Profile, use the **Roll** to change their orientation. Use the **Distance** to control how far from the anchor, in meters, you want to place the Light.

The View Lighting tool uses the Light Anchor component to position and orient the Light. When this component is attached to a Light, you can use a custom Scene view gizmo to position the Light, and use the component's Inspector to orient the Light.
Using the **Anchor Position Override**, you can provide a custom GameObject as an anchor point for the light. This is useful if you want the light to follow a specific GameObject in the Scene.

To get started with the View Lighting tool:

1. In the Scene view or Hierarchy, select a GameObject with an attached Light component.
2. In the Inspector click **Add Component > Rendering > Light Anchor**.
3. To use the Light Anchor gizmo, click the custom tool button then, in the drop-down, click **Light Anchor**.<br/>![](Images/view-lighting-tool-gizmo.png)
4. You can now use the gizmo to move the Light's target. This gizmo also shows you a visualization of the yaw, pitch, and roll from the target to the Light. To change the yaw, pitch, and roll, as well as the distance from the Light to the target, see [Light Anchor](#light-anchor).

### Light Anchor

The Light Anchor controls the Light's orientation and the distance it is from the target position. **Yaw** and **Pitch** control the orientation and **Distance** controls the distance between the Light and the target. If the Light has a cookie or uses [IES](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest/index.html?subfolder=/manual/IES-Profile.html), **Roll** controls the orientation of the cookie or IES profile.

To quickly reset the angle of a knob to zero. Right-click on it.
You can set a **Position Offset** for this custom Anchor. This is useful if the Transform position of the custom Anchor isn't centered appropriately for the light to orbit correctly around the custom Anchor.

![](Images/view-lighting-tool-light-anchor0.png)

The Light Anchor component also includes a list of **Presets** that you can use to quickly set the Light's orientation relative to the Game view.
The Light Anchor component also includes a list of **Presets** that you can use to set the Light's orientation relative to the main Camera.
44 changes: 43 additions & 1 deletion com.unity.render-pipelines.core/Editor/Debugging/DebugState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,52 @@ public DebugStateAttribute(params Type[] types)
[Serializable, DebugState(typeof(DebugUI.BoolField), typeof(DebugUI.Foldout), typeof(DebugUI.HistoryBoolField))]
public sealed class DebugStateBool : DebugState<bool> { }

/// <summary>
/// Enums Debug State.
/// </summary>
[Serializable, DebugState(typeof(DebugUI.EnumField), typeof(DebugUI.HistoryEnumField))]
public sealed class DebugStateEnum : DebugState<int>, ISerializationCallbackReceiver
{
DebugUI.EnumField m_EnumField;

/// <summary>
/// Set the value of the Debug Item.
/// </summary>
/// <param name="value">Input value.</param>
/// <param name="field">Debug Item field.</param>
public override void SetValue(object value, DebugUI.IValueField field)
{
m_EnumField = field as DebugUI.EnumField;
base.SetValue(value, field);
}

void UpdateValue()
{
if (m_EnumField != null)
{
base.SetValue(value, m_EnumField);
// There might be cases that the value does not map the index, look for the correct index
var newCurrentIndex = Array.IndexOf(m_EnumField.enumValues, value);
if (m_EnumField.currentIndex != newCurrentIndex)
m_EnumField.currentIndex = newCurrentIndex;
}
}

/// <summary>
/// On Before Serialize Callback
/// </summary>
public void OnBeforeSerialize() => UpdateValue();

/// <summary>
/// On After Deserialize Callback
/// </summary>
public void OnAfterDeserialize() => UpdateValue();
}

/// <summary>
/// Integer Debug State.
/// </summary>
[Serializable, DebugState(typeof(DebugUI.IntField), typeof(DebugUI.EnumField), typeof(DebugUI.HistoryEnumField))]
[Serializable, DebugState(typeof(DebugUI.IntField))]
public sealed class DebugStateInt : DebugState<int> { }

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public sealed class DebugUIDrawerEnumField : DebugUIDrawer
public override bool OnGUI(DebugUI.Widget widget, DebugState state)
{
var w = Cast<DebugUI.EnumField>(widget);
var s = Cast<DebugStateInt>(state);
var s = Cast<DebugStateEnum>(state);

if (w.indexes == null)
w.InitIndexes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public virtual void End(DebugUI.Widget widget, DebugState state)
/// <param name="value">Input value.</param>
protected void Apply(DebugUI.IValueField widget, DebugState state, object value)
{
Undo.RegisterCompleteObjectUndo(state, "Debug Property Change");
Undo.RegisterCompleteObjectUndo(state, $"Debug Property '{state.queryPath}' Change");
state.SetValue(value, widget);
widget.SetValue(value);
EditorUtility.SetDirty(state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void OnGUI()
GUI.Toggle(elementRect, m_Settings.selectedPanel == i, panel.displayName, s_Styles.sectionElement);
if (EditorGUI.EndChangeCheck())
{
Undo.RegisterCompleteObjectUndo(m_Settings, "Debug Panel Selection");
Undo.RegisterCompleteObjectUndo(m_Settings, $"Debug Panel '{panel.displayName}' Selection");
var previousPanel = m_Settings.selectedPanel >= 0 && m_Settings.selectedPanel < panels.Count
? panels[m_Settings.selectedPanel]
: null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ void InitializeBakingSetList()
m_RenameSelectedBakingSet = false;

// Rename profile asset to match name:
set.profile.name = set.name;
AssetDatabase.RenameAsset(AssetDatabase.GetAssetPath(set.profile), set.name);
set.profile.name = set.name;
}
}
else
Expand Down Expand Up @@ -163,6 +163,9 @@ void InitializeBakingSetList()
AssetDatabase.DeleteAsset(pathToDelete);
Undo.RegisterCompleteObjectUndo(sceneData.parentAsset, "Deleted baking set");
ReorderableList.defaultBehaviours.DoRemoveButton(list);
// A new set will be selected automatically, so we perform the same operations as if we did the selection explicitly.
OnBakingSetSelected(m_BakingSets);

}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ protected void EndAdditionalPropertiesScope()
/// </summary>
protected Editor m_Inspector;

/// <summary>
/// Obtains the <see cref="Volume"/> that is being edited from this volume component
/// </summary>
protected Volume volume => inspector?.target as Volume;

List<(GUIContent displayName, int displayOrder, SerializedDataParameter param)> m_Parameters;

static Dictionary<Type, VolumeParameterDrawer> s_ParameterDrawers;
Expand Down
136 changes: 136 additions & 0 deletions com.unity.render-pipelines.core/Runtime/Volume/VolumeParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,23 @@ public TextureParameter(Texture value, bool overrideState = false)
: base(value, overrideState) { }

// TODO: Texture interpolation

/// <summary>
/// Returns a hash code for the current object.
/// </summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
int hash = base.GetHashCode();

unchecked
{
if (value != null)
hash = 23 * CoreUtils.GetTextureHash(value);
}

return hash;
}
}

/// <summary>
Expand All @@ -1462,6 +1479,23 @@ public class NoInterpTextureParameter : VolumeParameter<Texture>
/// <param name="overrideState">The initial override state for the parameter.</param>
public NoInterpTextureParameter(Texture value, bool overrideState = false)
: base(value, overrideState) { }

/// <summary>
/// Returns a hash code for the current object.
/// </summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
int hash = base.GetHashCode();

unchecked
{
if (value != null)
hash = 23 * CoreUtils.GetTextureHash(value);
}

return hash;
}
}

/// <summary>
Expand All @@ -1477,6 +1511,23 @@ public class Texture2DParameter : VolumeParameter<Texture>
/// <param name="overrideState">The initial override state for the parameter.</param>
public Texture2DParameter(Texture value, bool overrideState = false)
: base(value, overrideState) { }

/// <summary>
/// Returns a hash code for the current object.
/// </summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
int hash = base.GetHashCode();

unchecked
{
if (value != null)
hash = 23 * CoreUtils.GetTextureHash(value);
}

return hash;
}
}

/// <summary>
Expand All @@ -1492,6 +1543,23 @@ public class Texture3DParameter : VolumeParameter<Texture>
/// <param name="overrideState">The initial override state for the parameter.</param>
public Texture3DParameter(Texture value, bool overrideState = false)
: base(value, overrideState) { }

/// <summary>
/// Returns a hash code for the current object.
/// </summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
int hash = base.GetHashCode();

unchecked
{
if (value != null)
hash = 23 * CoreUtils.GetTextureHash(value);
}

return hash;
}
}

/// <summary>
Expand All @@ -1509,6 +1577,23 @@ public RenderTextureParameter(RenderTexture value, bool overrideState = false)
: base(value, overrideState) { }

// TODO: RenderTexture interpolation

/// <summary>
/// Returns a hash code for the current object.
/// </summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
int hash = base.GetHashCode();

unchecked
{
if (value != null)
hash = 23 * CoreUtils.GetTextureHash(value);
}

return hash;
}
}

/// <summary>
Expand All @@ -1524,6 +1609,23 @@ public class NoInterpRenderTextureParameter : VolumeParameter<RenderTexture>
/// <param name="overrideState">The initial override state for the parameter.</param>
public NoInterpRenderTextureParameter(RenderTexture value, bool overrideState = false)
: base(value, overrideState) { }

/// <summary>
/// Returns a hash code for the current object.
/// </summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
int hash = base.GetHashCode();

unchecked
{
if (value != null)
hash = 23 * CoreUtils.GetTextureHash(value);
}

return hash;
}
}

/// <summary>
Expand All @@ -1540,6 +1642,23 @@ public class CubemapParameter : VolumeParameter<Texture>
public CubemapParameter(Texture value, bool overrideState = false)
: base(value, overrideState) { }
// TODO: Cubemap interpolation

/// <summary>
/// Returns a hash code for the current object.
/// </summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
int hash = base.GetHashCode();

unchecked
{
if (value != null)
hash = 23 * CoreUtils.GetTextureHash(value);
}

return hash;
}
}

/// <summary>
Expand All @@ -1555,6 +1674,23 @@ public class NoInterpCubemapParameter : VolumeParameter<Cubemap>
/// <param name="overrideState">The initial override state for the parameter.</param>
public NoInterpCubemapParameter(Cubemap value, bool overrideState = false)
: base(value, overrideState) { }

/// <summary>
/// Returns a hash code for the current object.
/// </summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
int hash = base.GetHashCode();

unchecked
{
if (value != null)
hash = 23 * CoreUtils.GetTextureHash(value);
}

return hash;
}
}

/// <summary>
Expand Down
Loading