Skip to content

HDRP Compositor Tool #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
fix variable names that don't affect serialization
  • Loading branch information
pmavridis committed Apr 16, 2020
commit a3fbc69db1892263edab89b0c6c615d39e830afb
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,43 @@ namespace UnityEditor.Rendering.HighDefinition.Compositor
{
internal class CompositionFilterUI
{
static partial class TextUI
static partial class Styles
{
static public readonly GUIContent ChromaKeing = EditorGUIUtility.TrTextContent("Chroma Keying", "Performs chroma keying in the input frame before any other composition operations are performed.");
static public readonly GUIContent KeyColor = EditorGUIUtility.TrTextContent("Key Color", "Use this parameter to smooth-out the edges of the generated mask. A value of 0 corresponds to sharp edges.");
static public readonly GUIContent Threshold = EditorGUIUtility.TrTextContent("Key Threshold", "Indicates the areas of the image that will be masked (or in other words, the areas that are transparent.");
static public readonly GUIContent Tolerance = EditorGUIUtility.TrTextContent("Key Tolerance", "Controls the sensitivity of the mask color parameter. Increasing this value will include more pixels (with a value close to the mask color) in the masked areas.");
static public readonly GUIContent SpillRemoval = EditorGUIUtility.TrTextContent("Spill Removal", "Use this parameter to change the tint of non-masked areas.");
static public readonly GUIContent AlphaMask = EditorGUIUtility.TrTextContent("Alpha Mask", "A static texture that overrides the alpha mask of the sub-layer. Post-processing is then applied only on the masked frame regions.");
static public readonly GUIContent k_ChromaKeing = EditorGUIUtility.TrTextContent("Chroma Keying", "Performs chroma keying in the input frame before any other composition operations are performed.");
static public readonly GUIContent k_KeyColor = EditorGUIUtility.TrTextContent("Key Color", "Use this parameter to smooth-out the edges of the generated mask. A value of 0 corresponds to sharp edges.");
static public readonly GUIContent k_Threshold = EditorGUIUtility.TrTextContent("Key Threshold", "Indicates the areas of the image that will be masked (or in other words, the areas that are transparent.");
static public readonly GUIContent k_Tolerance = EditorGUIUtility.TrTextContent("Key Tolerance", "Controls the sensitivity of the mask color parameter. Increasing this value will include more pixels (with a value close to the mask color) in the masked areas.");
static public readonly GUIContent k_SpillRemoval = EditorGUIUtility.TrTextContent("Spill Removal", "Use this parameter to change the tint of non-masked areas.");
static public readonly GUIContent k_AlphaMask = EditorGUIUtility.TrTextContent("Alpha Mask", "A static texture that overrides the alpha mask of the sub-layer. Post-processing is then applied only on the masked frame regions.");
}
public static void Draw(Rect rect, SerializedCompositionFilter serialized)
{
rect.height = CompositorStyle.k_SingleLineHeight;
float spacing = rect.height * 1.1f;

if (serialized.FilterType.intValue == (int)CompositionFilter.FilterType.CHROMA_KEYING)
if (serialized.filterType.intValue == (int)CompositionFilter.FilterType.CHROMA_KEYING)
{
SerializedProperty KeyColor = serialized.MaskColor;
SerializedProperty KeyThreshold = serialized.KeyThreshold;
SerializedProperty KeyTolerance = serialized.KeyTolerance;
SerializedProperty SpillRemoval = serialized.SpillRemoval;
SerializedProperty keyColor = serialized.maskColor;
SerializedProperty keyThreshold = serialized.keyThreshold;
SerializedProperty keyTolerance = serialized.keyTolerance;
SerializedProperty spillRemoval = serialized.spillRemoval;

EditorGUI.LabelField(rect, TextUI.ChromaKeing);
EditorGUI.LabelField(rect, Styles.k_ChromaKeing);
rect.y += spacing;
rect.x += 20;
rect.width -= 20;
EditorGUI.PropertyField(rect, KeyColor, TextUI.KeyColor);
EditorGUI.PropertyField(rect, keyColor, Styles.k_KeyColor);
rect.y += spacing;
EditorGUI.PropertyField(rect, KeyThreshold, TextUI.Threshold);
EditorGUI.PropertyField(rect, keyThreshold, Styles.k_Threshold);
rect.y += spacing;
EditorGUI.PropertyField(rect, KeyTolerance, TextUI.Tolerance);
EditorGUI.PropertyField(rect, keyTolerance, Styles.k_Tolerance);
rect.y += spacing;
EditorGUI.PropertyField(rect, SpillRemoval, TextUI.SpillRemoval);
EditorGUI.PropertyField(rect, spillRemoval, Styles.k_SpillRemoval);
}
else
{
SerializedProperty AlphaMask = serialized.AlphaMask;
EditorGUI.PropertyField(rect, AlphaMask, TextUI.AlphaMask);
SerializedProperty alphaMask = serialized.alphaMask;
EditorGUI.PropertyField(rect, alphaMask, Styles.k_AlphaMask);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ namespace UnityEditor.Rendering.HighDefinition.Compositor
{
internal class CompositionLayerUI
{
static partial class TextUI
static partial class Styles
{
// main layer
static public readonly GUIContent Resolution = EditorGUIUtility.TrTextContent("Resolution", "Specifies the resolution of this layer's render target. Lower resolution increases the performance at the expense of visual quality.");
static public readonly GUIContent BufferFormat = EditorGUIUtility.TrTextContent("Format", "Specifies the color buffer format of this layer. ");
static public readonly GUIContent OutputRenderer = EditorGUIUtility.TrTextContent("Output Renderer", "Redirects the output of this layer to the surface which is drawn by the selected mesh renderer. ");
static public readonly GUIContent AOVs = EditorGUIUtility.TrTextContent("AOVs", "Specifies the Arbitrary Output Variable (AOV) that will be drawn on this layer. This option affects all cameras that are stacked on this layer.");
static public readonly GUIContent k_Resolution = EditorGUIUtility.TrTextContent("Resolution", "Specifies the resolution of this layer's render target. Lower resolution increases the performance at the expense of visual quality.");
static public readonly GUIContent k_BufferFormat = EditorGUIUtility.TrTextContent("Format", "Specifies the color buffer format of this layer. ");
static public readonly GUIContent k_OutputRenderer = EditorGUIUtility.TrTextContent("Output Renderer", "Redirects the output of this layer to the surface which is drawn by the selected mesh renderer. ");
static public readonly GUIContent k_AOVs = EditorGUIUtility.TrTextContent("AOVs", "Specifies the Arbitrary Output Variable (AOV) that will be drawn on this layer. This option affects all cameras that are stacked on this layer.");

// Sub layer
static public readonly GUIContent NameContent = EditorGUIUtility.TrTextContent("Layer Name", "Specifies the name of this layer.");
static public readonly GUIContent Camera = EditorGUIUtility.TrTextContent("Source Camera", "Specifies the camera of the scene that will provide the content for this layer.");
static public readonly GUIContent Image = EditorGUIUtility.TrTextContent("Source Image", "Specifies the image that will provide the content for this layer.");
static public readonly GUIContent Video = EditorGUIUtility.TrTextContent("Source Video", "Specifies the video that will provide the content for this layer.");
static public readonly GUIContent ClearDepth = EditorGUIUtility.TrTextContent("Clear Depth", "If enabled, the depth buffer will be cleared before rendering this layer.");
static public readonly GUIContent ClearAlpha = EditorGUIUtility.TrTextContent("Clear Alpha", "If enabled, the alpha channel will be cleared before rendering this layer. If enabled, post processing will affect only the objects of this layer");
static public readonly GUIContent ClearMode = EditorGUIUtility.TrTextContent("Clear Color", "To override the clear mode of this layer, activate the option by clicking on the check-box and then select the desired value.");
static public readonly GUIContent AAMode = EditorGUIUtility.TrTextContent("Anti Aliasing", "To override the anti-aliasing mode, activate the option by clicking on the check-box and then select the desired value.");
static public readonly GUIContent CullingMask = EditorGUIUtility.TrTextContent("Culling Mask", "To override the culling mask, activate the option by clicking on the check-box and then select the desired value.");
static public readonly GUIContent VolumeMask = EditorGUIUtility.TrTextContent("Volume Mask", "To override the volume mask, activate the option by clicking on the check-box and then select the desired value.");
static public readonly GUIContent k_NameContent = EditorGUIUtility.TrTextContent("Layer Name", "Specifies the name of this layer.");
static public readonly GUIContent k_Camera = EditorGUIUtility.TrTextContent("Source Camera", "Specifies the camera of the scene that will provide the content for this layer.");
static public readonly GUIContent k_Image = EditorGUIUtility.TrTextContent("Source Image", "Specifies the image that will provide the content for this layer.");
static public readonly GUIContent k_Video = EditorGUIUtility.TrTextContent("Source Video", "Specifies the video that will provide the content for this layer.");
static public readonly GUIContent k_ClearDepth = EditorGUIUtility.TrTextContent("Clear Depth", "If enabled, the depth buffer will be cleared before rendering this layer.");
static public readonly GUIContent k_ClearAlpha = EditorGUIUtility.TrTextContent("Clear Alpha", "If enabled, the alpha channel will be cleared before rendering this layer. If enabled, post processing will affect only the objects of this layer");
static public readonly GUIContent k_ClearMode = EditorGUIUtility.TrTextContent("Clear Color", "To override the clear mode of this layer, activate the option by clicking on the check-box and then select the desired value.");
static public readonly GUIContent k_AAMode = EditorGUIUtility.TrTextContent("Anti Aliasing", "To override the anti-aliasing mode, activate the option by clicking on the check-box and then select the desired value.");
static public readonly GUIContent k_CullingMask = EditorGUIUtility.TrTextContent("Culling Mask", "To override the culling mask, activate the option by clicking on the check-box and then select the desired value.");
static public readonly GUIContent k_VolumeMask = EditorGUIUtility.TrTextContent("Volume Mask", "To override the volume mask, activate the option by clicking on the check-box and then select the desired value.");
}

public static void DrawItemInList(Rect rect, SerializedCompositionLayer serialized, RenderTexture thumbnail, float aspectRatio, bool isAlphaEnbaled)
{
bool isCameraStack = serialized.OutTarget.intValue == (int)CompositorLayer.OutputTarget.CameraStack;
bool isCameraStack = serialized.outTarget.intValue == (int)CompositorLayer.OutputTarget.CameraStack;

// Compute the desired indentation
{
Expand All @@ -49,7 +49,7 @@ public static void DrawItemInList(Rect rect, SerializedCompositionLayer serializ
{
Rect newRect = rect;
newRect.width = EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(newRect, serialized.Show, GUIContent.none);
EditorGUI.PropertyField(newRect, serialized.show, GUIContent.none);
rect.x += CompositorStyle.k_CheckboxSpacing;
Rect previewRect = rect;
previewRect.width = CompositorStyle.k_ThumbnailSize * aspectRatio;
Expand All @@ -70,21 +70,21 @@ public static void DrawItemInList(Rect rect, SerializedCompositionLayer serializ
}

rect.y += CompositorStyle.k_LabelVerticalOffset;
EditorGUI.LabelField(rect, serialized.LayerName.stringValue);
EditorGUI.LabelField(rect, serialized.layerName.stringValue);
}
else
{
Rect newRect = rect;
newRect.width = EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(newRect, serialized.Show, GUIContent.none);
EditorGUI.PropertyField(newRect, serialized.show, GUIContent.none);
newRect.x += CompositorStyle.k_CheckboxSpacing;
if (isCameraStack)
{
Rect iconRect = newRect;
iconRect.width = CompositorStyle.k_IconSize;
iconRect.height = CompositorStyle.k_IconSize;
iconRect.y -= CompositorStyle.k_IconVerticalOffset;
switch (serialized.InputLayerType.enumValueIndex)
switch (serialized.inputLayerType.enumValueIndex)
{
case (int)CompositorLayer.LayerType.Camera:
GUI.DrawTexture(iconRect, EditorGUIUtility.ObjectContent(null, typeof(Camera)).image);
Expand All @@ -104,7 +104,7 @@ public static void DrawItemInList(Rect rect, SerializedCompositionLayer serializ
}

newRect.width = rect.width - newRect.x;
EditorGUI.LabelField(newRect, serialized.LayerName.stringValue);
EditorGUI.LabelField(newRect, serialized.layerName.stringValue);
}
}

Expand All @@ -113,11 +113,11 @@ public static void DrawOutputLayerProperties(Rect rect, SerializedCompositionLay
rect.y += CompositorStyle.k_ListItemPading;
rect.height = CompositorStyle.k_SingleLineHeight;

EditorGUI.PropertyField(rect, serializedProperties.ColorFormat, TextUI.BufferFormat);
EditorGUI.PropertyField(rect, serializedProperties.colorFormat, Styles.k_BufferFormat);
rect.y += CompositorStyle.k_Spacing;

EditorGUI.BeginChangeCheck();
EditorGUI.PropertyField(rect, serializedProperties.ResolutionScale, TextUI.Resolution);
EditorGUI.PropertyField(rect, serializedProperties.resolutionScale, Styles.k_Resolution);

if (EditorGUI.EndChangeCheck())
{
Expand All @@ -126,10 +126,10 @@ public static void DrawOutputLayerProperties(Rect rect, SerializedCompositionLay
}
rect.y += CompositorStyle.k_Spacing;

EditorGUI.PropertyField(rect, serializedProperties.OutputRenderer, TextUI.OutputRenderer);
EditorGUI.PropertyField(rect, serializedProperties.outputRenderer, Styles.k_OutputRenderer);
rect.y += CompositorStyle.k_Spacing;

EditorGUI.PropertyField(rect, serializedProperties.AOVBitmask, TextUI.AOVs);
EditorGUI.PropertyField(rect, serializedProperties.aovBitmask, Styles.k_AOVs);

rect.y += CompositorStyle.k_Spacing;
}
Expand All @@ -139,21 +139,21 @@ public static void DrawStackedLayerProperties(Rect rect, SerializedCompositionLa
rect.y += CompositorStyle.k_ListItemPading;
rect.height = CompositorStyle.k_SingleLineHeight;

EditorGUI.PropertyField(rect, serializedProperties.LayerName, TextUI.NameContent);
EditorGUI.PropertyField(rect, serializedProperties.layerName, Styles.k_NameContent);
rect.y += CompositorStyle.k_Spacing;

switch (serializedProperties.InputLayerType.enumValueIndex)
switch (serializedProperties.inputLayerType.enumValueIndex)
{
case (int)CompositorLayer.LayerType.Camera:
EditorGUI.PropertyField(rect, serializedProperties.InputCamera, TextUI.Camera);
EditorGUI.PropertyField(rect, serializedProperties.inputCamera, Styles.k_Camera);
break;
case (int)CompositorLayer.LayerType.Video:
EditorGUI.PropertyField(rect, serializedProperties.InputVideo, TextUI.Video);
EditorGUI.PropertyField(rect, serializedProperties.inputVideo, Styles.k_Video);
break;
case (int)CompositorLayer.LayerType.Image:
EditorGUI.PropertyField(rect, serializedProperties.InputTexture, TextUI.Image);
EditorGUI.PropertyField(rect, serializedProperties.inputTexture, Styles.k_Image);
rect.y += CompositorStyle.k_Spacing;
EditorGUI.PropertyField(rect, serializedProperties.FitType);
EditorGUI.PropertyField(rect, serializedProperties.fitType);
break;
default:
// This will happen if someone adds a new layer type and does not update this switch statement
Expand All @@ -162,26 +162,26 @@ public static void DrawStackedLayerProperties(Rect rect, SerializedCompositionLa
}
rect.y += 1.5f * CompositorStyle.k_Spacing;

EditorGUI.PropertyField(rect, serializedProperties.ClearDepth, TextUI.ClearDepth);
EditorGUI.PropertyField(rect, serializedProperties.clearDepth, Styles.k_ClearDepth);
rect.y += CompositorStyle.k_Spacing;

EditorGUI.PropertyField(rect, serializedProperties.ClearAlpha, TextUI.ClearAlpha);
EditorGUI.PropertyField(rect, serializedProperties.clearAlpha, Styles.k_ClearAlpha);
rect.y += 1.5f * CompositorStyle.k_Spacing;

// The clear mode should be visible / configurable only for the first layer in the stack. For the other layers we set a camera-stacking specific clear-mode .
if (serializedProperties.PositionInStack.intValue == 0)
if (serializedProperties.positionInStack.intValue == 0)
{
DrawPropertyHelper(rect, TextUI.ClearMode, serializedProperties.OverrideClearMode, serializedProperties.ClearMode);
DrawPropertyHelper(rect, Styles.k_ClearMode, serializedProperties.overrideClearMode, serializedProperties.clearMode);
rect.y += CompositorStyle.k_Spacing;
}

DrawPropertyHelper(rect, TextUI.AAMode, serializedProperties.OverrideAA, serializedProperties.AAMode);
DrawPropertyHelper(rect, Styles.k_AAMode, serializedProperties.overrideAA, serializedProperties.aaMode);
rect.y += CompositorStyle.k_Spacing;

DrawPropertyHelper(rect, TextUI.CullingMask, serializedProperties.OverrideCulling, serializedProperties.CullingMaskProperty);
DrawPropertyHelper(rect, Styles.k_CullingMask, serializedProperties.overrideCulling, serializedProperties.cullingMaskProperty);
rect.y += CompositorStyle.k_Spacing;

DrawPropertyHelper(rect, TextUI.VolumeMask, serializedProperties.OverrideVolume, serializedProperties.VolumeMask);
DrawPropertyHelper(rect, Styles.k_VolumeMask, serializedProperties.overrideVolume, serializedProperties.volumeMask);
rect.y += CompositorStyle.k_Spacing;

Rect filterRect = rect;
Expand All @@ -199,7 +199,7 @@ static void DrawPropertyHelper(Rect rect, GUIContent label, SerializedProperty c
rectCopy.width = EditorGUIUtility.labelWidth - EditorGUIUtility.singleLineHeight;
EditorGUI.LabelField(rectCopy, label);

using (new EditorGUI.DisabledScope(checkBox.boolValue != true))
using (new EditorGUI.DisabledScope(!checkBox.boolValue))
{
float pad = EditorGUIUtility.labelWidth;
rect.x += pad;
Expand Down
Loading