浏览代码

More Processors

/main
Thomas ICHÉ 5 年前
当前提交
7c1cec3b
共有 25 个文件被更改,包括 1590 次插入1 次删除
  1. 1
      ImageSequencer/Editor/Serialization/Processors/RetimeProcessor.cs
  2. 48
      ImageSequencer/Editor/Serialization/Processors/AlphaFromRGBProcessor.cs
  3. 12
      ImageSequencer/Editor/Serialization/Processors/AlphaFromRGBProcessor.cs.meta
  4. 113
      ImageSequencer/Editor/Serialization/Processors/ColorCorrectionProcessor.cs
  5. 12
      ImageSequencer/Editor/Serialization/Processors/ColorCorrectionProcessor.cs.meta
  6. 230
      ImageSequencer/Editor/Serialization/Processors/CropProcessor.cs
  7. 12
      ImageSequencer/Editor/Serialization/Processors/CropProcessor.cs.meta
  8. 82
      ImageSequencer/Editor/Serialization/Processors/CustomMaterialProcessor.cs
  9. 12
      ImageSequencer/Editor/Serialization/Processors/CustomMaterialProcessor.cs.meta
  10. 101
      ImageSequencer/Editor/Serialization/Processors/FadeProcessor.cs
  11. 12
      ImageSequencer/Editor/Serialization/Processors/FadeProcessor.cs.meta
  12. 137
      ImageSequencer/Editor/Serialization/Processors/FixBordersProcessor.cs
  13. 12
      ImageSequencer/Editor/Serialization/Processors/FixBordersProcessor.cs.meta
  14. 301
      ImageSequencer/Editor/Serialization/Processors/LoopingProcessor.cs
  15. 12
      ImageSequencer/Editor/Serialization/Processors/LoopingProcessor.cs.meta
  16. 50
      ImageSequencer/Editor/Serialization/Processors/PremultiplyAlphaProcessor.cs
  17. 12
      ImageSequencer/Editor/Serialization/Processors/PremultiplyAlphaProcessor.cs.meta
  18. 87
      ImageSequencer/Editor/Serialization/Processors/RemapColorProcessor.cs
  19. 12
      ImageSequencer/Editor/Serialization/Processors/RemapColorProcessor.cs.meta
  20. 80
      ImageSequencer/Editor/Serialization/Processors/RemoveBackgroundProcessor.cs
  21. 12
      ImageSequencer/Editor/Serialization/Processors/RemoveBackgroundProcessor.cs.meta
  22. 144
      ImageSequencer/Editor/Serialization/Processors/ResizeProcessor.cs
  23. 12
      ImageSequencer/Editor/Serialization/Processors/ResizeProcessor.cs.meta
  24. 73
      ImageSequencer/Editor/Serialization/Processors/RotateProcessor.cs
  25. 12
      ImageSequencer/Editor/Serialization/Processors/RotateProcessor.cs.meta

1
ImageSequencer/Editor/Serialization/Processors/RetimeProcessor.cs


m_CurveDrawer.OnPostGUI = OnCurveFieldGUI;
}
var useCurve = serializedObject.FindProperty("useCurve");
var outputSequenceLength = serializedObject.FindProperty("outputSequenceLength");

48
ImageSequencer/Editor/Serialization/Processors/AlphaFromRGBProcessor.cs


using UnityEngine;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("Color","Alpha From RGB")]
class AlphaFromRGBProcessor : ProcessorBase
{
public Color BWFilterTint;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/AlphaFromRGB.shader";
public override string processorName => "Alpha From RGB";
public override void Default()
{
BWFilterTint = Color.white;
}
public override bool Process(int frame)
{
Texture inputFrame = processor.InputSequence.RequestFrame(frame).texture;
processor.material.SetTexture("_MainTex", inputFrame);
processor.material.SetVector("_RGBTint", BWFilterTint);
processor.ExecuteShaderAndDump(frame, inputFrame);
return true;
}
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
var tint = serializedObject.FindProperty("BWFilterTint");
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(tint, VFXToolboxGUIUtility.Get("Color Filter"));
EditorGUILayout.HelpBox("Color Filter serves as a tint before applying the black and white desaturation, just like in black and white photography. This way you can filter color weighting.", MessageType.Info);
if (EditorGUI.EndChangeCheck())
{
processor.Invalidate();
changed = true;
}
return changed;
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/AlphaFromRGBProcessor.cs.meta


fileFormatVersion: 2
guid: fa620cc053ad857459f8451c2f9f2823
timeCreated: 1474881116
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

113
ImageSequencer/Editor/Serialization/Processors/ColorCorrectionProcessor.cs


using UnityEngine;
using UnityEngine.VFXToolbox;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("Color","Color Correction")]
class ColorCorrectionProcessor : ProcessorBase
{
[FloatSlider(0.0f,2.0f)]
public float Brightness;
[FloatSlider(0.0f,2.0f)]
public float Contrast;
[FloatSlider(0.0f,2.0f)]
public float Saturation;
public AnimationCurve AlphaCurve;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/ColorCorrection.shader";
public override string processorName => "Color Correction";
public override void Default()
{
Brightness = 1.0f;
Contrast = 1.0f;
Saturation = 1.0f;
DefaultCurve();
}
public void DefaultCurve()
{
AlphaCurve = AnimationCurve.Linear(0, 0, 1, 1);
}
public override bool Process(int frame)
{
if (m_CurveTexture == null)
{
InitTexture();
}
CurveToTextureUtility.CurveToTexture(AlphaCurve, ref m_CurveTexture);
Texture inputFrame = processor.InputSequence.RequestFrame(frame).texture;
processor.material.SetTexture("_MainTex", inputFrame);
processor.material.SetFloat("_Brightness", Brightness);
processor.material.SetFloat("_Contrast", Contrast);
processor.material.SetFloat("_Saturation", Saturation);
processor.material.SetTexture("_AlphaCurve", m_CurveTexture);
processor.ExecuteShaderAndDump(frame, inputFrame);
return true;
}
private void InitTexture()
{
m_CurveTexture = new Texture2D(256, 1, TextureFormat.RGBAHalf, false, true);
m_CurveTexture.wrapMode = TextureWrapMode.Clamp;
m_CurveTexture.filterMode = FilterMode.Bilinear;
CurveToTextureUtility.CurveToTexture(AlphaCurve, ref m_CurveTexture);
}
Texture2D m_CurveTexture;
CurveDrawer m_CurveDrawer;
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
if (m_CurveDrawer == null)
{
m_CurveDrawer = new CurveDrawer(null, 0.0f, 1.0f, 0.0f, 1.0f, 140, false);
m_CurveDrawer.AddCurve(serializedObject.FindProperty("AlphaCurve"), new Color(1.0f, 0.55f, 0.1f), "Alpha Curve");
}
if (AlphaCurve == null)
DefaultCurve();
var brightness = serializedObject.FindProperty("Brightness");
var contrast = serializedObject.FindProperty("Contrast");
var saturation = serializedObject.FindProperty("Saturation");
var alphaCurve = serializedObject.FindProperty("AlphaCurve");
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(brightness, VFXToolboxGUIUtility.Get("Brightness"));
EditorGUILayout.PropertyField(contrast, VFXToolboxGUIUtility.Get("Contrast"));
EditorGUILayout.PropertyField(saturation, VFXToolboxGUIUtility.Get("Saturation"));
bool curveChanged = false;
using (new GUILayout.HorizontalScope())
{
EditorGUILayout.LabelField(VFXToolboxGUIUtility.Get("Alpha Curve"), GUILayout.Width(EditorGUIUtility.labelWidth));
if (GUILayout.Button(VFXToolboxGUIUtility.Get("Reset")))
{
alphaCurve.animationCurveValue = AnimationCurve.Linear(0, 0, 1, 1);
m_CurveDrawer.ClearSelection();
curveChanged = true;
}
}
if (!curveChanged)
curveChanged = m_CurveDrawer.OnGUILayout();
if (EditorGUI.EndChangeCheck() || curveChanged)
{
processor.Invalidate();
changed = true;
}
return changed;
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/ColorCorrectionProcessor.cs.meta


fileFormatVersion: 2
guid: a3ca7dec4216fca4f943c6c73a5f5819
timeCreated: 1471449594
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

230
ImageSequencer/Editor/Serialization/Processors/CropProcessor.cs


using UnityEngine;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("Common","Crop")]
class CropProcessor : ProcessorBase
{
public uint Crop_Top;
public uint Crop_Bottom;
public uint Crop_Left;
public uint Crop_Right;
public float AutoCropThreshold = 0.003f;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/Crop.shader";
public override string processorName => "Crop";
public override void UpdateOutputSize()
{
int width = (processor.InputSequence.width - (int)Crop_Left) - (int)Crop_Right;
int height = (processor.InputSequence.height - (int)Crop_Top) - (int)Crop_Bottom;
processor.SetOutputSize(width, height);
}
public override void Default()
{
Crop_Top = 0;
Crop_Bottom = 0;
Crop_Left = 0;
Crop_Right = 0;
AutoCropThreshold = 0.003f;
}
public override bool Process(int frame)
{
UpdateOutputSize();
Texture texture = processor.InputSequence.RequestFrame(frame).texture;
processor.material.SetTexture("_MainTex", texture);
processor.material.SetVector("_CropFactors", new Vector4(
(float)Crop_Left / texture.width,
(float)Crop_Right / texture.width,
(float)Crop_Top / texture.height,
(float)Crop_Bottom / texture.height
));
processor.ExecuteShaderAndDump(frame, texture);
return true;
}
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
int sourceWidth = processor.InputSequence.width;
int sourceHeight = processor.InputSequence.height;
var crop_top = serializedObject.FindProperty("Crop_Top");
var crop_bottom = serializedObject.FindProperty("Crop_Bottom");
var crop_left = serializedObject.FindProperty("Crop_Left");
var crop_right = serializedObject.FindProperty("Crop_Right");
var threshold = serializedObject.FindProperty("AutoCropThreshold");
EditorGUI.BeginChangeCheck();
EditorGUILayout.IntSlider(crop_top, 0, (sourceHeight / 2) - 1, VFXToolboxGUIUtility.Get("Top"));
EditorGUILayout.IntSlider(crop_bottom, 0, (sourceHeight / 2) - 1, VFXToolboxGUIUtility.Get("Bottom"));
EditorGUILayout.IntSlider(crop_left, 0, (sourceWidth / 2) - 1, VFXToolboxGUIUtility.Get("Left"));
EditorGUILayout.IntSlider(crop_right, 0, (sourceWidth / 2) - 1, VFXToolboxGUIUtility.Get("Right"));
GUILayout.Space(20);
GUILayout.Label(VFXToolboxGUIUtility.Get("Automatic Crop Values"), EditorStyles.boldLabel);
EditorGUI.indentLevel += 2;
using (new EditorGUILayout.HorizontalScope())
{
EditorGUILayout.Slider(threshold, 0.0f, 1.0f, VFXToolboxGUIUtility.Get("Alpha Threshold"));
if (GUILayout.Button(VFXToolboxGUIUtility.Get("Find")))
{
FindProperValues(threshold.floatValue, ref crop_top, ref crop_bottom, ref crop_left, ref crop_right);
GUI.changed = true;
}
}
EditorGUI.indentLevel -= 2;
GUILayout.Space(20);
Rect preview_rect;
using (new GUILayout.HorizontalScope())
{
GUILayout.FlexibleSpace();
preview_rect = GUILayoutUtility.GetRect(200, 200);
GUILayout.FlexibleSpace();
}
EditorGUI.DrawRect(preview_rect, new Color(0, 0, 0, 0.1f));
GUI.BeginClip(preview_rect);
GUI.Label(new Rect(0, 0, 200, 16), "Preview");
int top = 40;
int left = 40;
int right = 160;
int bottom = 160;
Handles.color = Color.green;
Handles.DrawLine(new Vector3(left, top), new Vector3(left, bottom));
Handles.DrawLine(new Vector3(left, bottom), new Vector3(right, bottom));
Handles.DrawLine(new Vector3(right, bottom), new Vector3(right, top));
Handles.DrawLine(new Vector3(right, top), new Vector3(left, top));
top = (int)(40 + 120 * (float)crop_top.intValue / sourceHeight);
bottom = (int)(160 - 120 * (float)crop_bottom.intValue / sourceHeight);
left = (int)(40 + 120 * (float)crop_left.intValue / sourceWidth);
right = (int)(160 - 120 * (float)crop_right.intValue / sourceWidth);
Handles.color = Color.red;
Handles.DrawLine(new Vector3(left, top), new Vector3(left, bottom));
Handles.DrawLine(new Vector3(left, bottom), new Vector3(right, bottom));
Handles.DrawLine(new Vector3(right, bottom), new Vector3(right, top));
Handles.DrawLine(new Vector3(right, top), new Vector3(left, top));
GUI.EndClip();
if (EditorGUI.EndChangeCheck())
{
UpdateOutputSize();
processor.Invalidate();
changed = true;
}
return changed;
}
private void FindProperValues(float threshold, ref SerializedProperty top, ref SerializedProperty bottom, ref SerializedProperty left, ref SerializedProperty right)
{
int width = processor.InputSequence.width;
int height = processor.InputSequence.height;
int minX = width;
int maxX = 0;
int minY = height;
int maxY = 0;
Color[] colors;
RenderTexture tempRT = RenderTexture.GetTemporary(width, height, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear);
for (int i = 0; i < processor.InputSequence.frames.Count; i++)
{
ProcessingFrame f = processor.InputSequence.frames[i];
VFXToolboxGUIUtility.DisplayProgressBar("Crop processor", "Evaluating closest bound (Frame #" + i + " on " + processor.InputSequence.frames.Count + "...)", (float)i / processor.InputSequence.frames.Count);
if (processor.InputSequence.processor != null)
{
f.Process();
colors = VFXToolboxUtility.ReadBack(f.texture as RenderTexture);
}
else
{
Graphics.Blit(f.texture, tempRT);
colors = VFXToolboxUtility.ReadBack(tempRT);
}
// Check frame
for (int j = 0; j < colors.Length; j++)
{
int x = j % width;
int y = j / width;
if (colors[j].a >= threshold)
{
minX = Mathf.Min(minX, x);
maxX = Mathf.Max(maxX, x);
minY = Mathf.Min(minY, y);
maxY = Mathf.Max(maxY, y);
}
}
}
VFXToolboxGUIUtility.ClearProgressBar();
bottom.intValue = minY;
top.intValue = height - maxY - 1;
left.intValue = minX;
right.intValue = width - maxX - 1;
RenderTexture.ReleaseTemporary(tempRT);
}
public override bool OnCanvasGUI(ImageSequencerCanvas canvas)
{
if (Event.current.type != EventType.Repaint)
return false;
Vector2 center = canvas.CanvasToScreen(Vector2.zero);
Vector2 topRight;
Vector2 bottomLeft;
topRight = canvas.CanvasToScreen(new Vector2(-canvas.currentFrame.texture.width / 2 - Crop_Right, canvas.currentFrame.texture.height / 2 + Crop_Top));
bottomLeft = canvas.CanvasToScreen(new Vector2(canvas.currentFrame.texture.width / 2 + Crop_Left, -canvas.currentFrame.texture.height / 2 - Crop_Bottom));
Handles.DrawSolidRectangleWithOutline(new Rect(topRight, bottomLeft - topRight), Color.clear, canvas.styles.green);
Vector2 topRightCrop;
Vector2 bottomLeftCrop;
topRightCrop = canvas.CanvasToScreen(new Vector2(-canvas.currentFrame.texture.width / 2, canvas.currentFrame.texture.height / 2));
bottomLeftCrop = canvas.CanvasToScreen(new Vector2(canvas.currentFrame.texture.width / 2, -canvas.currentFrame.texture.height / 2));
Handles.DrawSolidRectangleWithOutline(new Rect(topRightCrop, bottomLeftCrop - topRightCrop), Color.clear, canvas.styles.red);
// Arrows
Handles.color = canvas.styles.white;
Handles.DrawLine(new Vector3(center.x, topRight.y), new Vector3(center.x, topRightCrop.y));
Handles.DrawLine(new Vector3(center.x, bottomLeft.y), new Vector3(center.x, bottomLeftCrop.y));
Handles.DrawLine(new Vector3(topRight.x, center.y), new Vector3(topRightCrop.x, center.y));
Handles.DrawLine(new Vector3(bottomLeft.x, center.y), new Vector3(bottomLeftCrop.x, center.y));
Handles.color = Color.white;
// Texts
GUI.Label(new Rect(center.x, topRightCrop.y - 16, 64, 16), Crop_Top.ToString(), canvas.styles.miniLabel);
GUI.Label(new Rect(center.x, bottomLeftCrop.y, 64, 16), Crop_Bottom.ToString(), canvas.styles.miniLabel);
GUI.Label(new Rect(topRightCrop.x, center.y, 64, 16), Crop_Right.ToString(), canvas.styles.miniLabel);
GUI.Label(new Rect(bottomLeftCrop.x - 64, center.y, 64, 16), Crop_Left.ToString(), canvas.styles.miniLabelRight);
return false;
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/CropProcessor.cs.meta


fileFormatVersion: 2
guid: ffd658e7a2564734aaef1a1eddf45e1a
timeCreated: 1464881358
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

82
ImageSequencer/Editor/Serialization/Processors/CustomMaterialProcessor.cs


using UnityEngine;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("","Custom Material")]
class CustomMaterialProcessor : ProcessorBase
{
public Material material;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/Null.shader";
public override string processorName => "Custom Material";
public override string label => $"{processorName} ({((material == null) ? "Not Set" : material.name)})";
public override void Default()
{
material = null;
}
public override bool Process(int frame)
{
Texture inputFrame = processor.InputSequence.RequestFrame(frame).texture;
if (material != null)
{
material.SetTexture("_InputFrame", inputFrame);
material.SetVector("_FrameData", new Vector4(processor.OutputWidth, processor.OutputHeight, frame, sequenceLength));
material.SetVector("_FlipbookData", new Vector4(processor.NumU, processor.NumV, 0, 0));
processor.ExecuteShaderAndDump(frame, inputFrame, material);
}
else
{
processor.material.SetTexture("_MainTex", inputFrame);
processor.ExecuteShaderAndDump(frame, inputFrame);
}
return true;
}
private Editor m_MaterialEditor;
private Shader m_CachedShader;
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
EditorGUI.BeginChangeCheck();
Material mat = (Material)EditorGUILayout.ObjectField(VFXToolboxGUIUtility.Get("Material"), material, typeof(Material), false);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(this, "Custom Material Change");
material = mat;
EditorUtility.SetDirty(this);
processor.Invalidate();
changed = true;
}
if (material != null)
{
Editor.CreateCachedEditor(material, typeof(MaterialEditor), ref m_MaterialEditor);
EditorGUI.BeginChangeCheck();
m_MaterialEditor.DrawHeader();
EditorGUIUtility.labelWidth = 120;
m_MaterialEditor.OnInspectorGUI();
if (m_CachedShader != material.shader)
{
// Hack : we cache shader in order to track changes as DrawHeader does not consider shader change as a EditorGUI.changed
m_CachedShader = material.shader;
GUI.changed = true;
}
if (EditorGUI.EndChangeCheck())
{
processor.Invalidate();
changed = true;
}
}
return changed;
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/CustomMaterialProcessor.cs.meta


fileFormatVersion: 2
guid: 05487723e0bf7674d8819359ce0d8fdc
timeCreated: 1478610071
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

101
ImageSequencer/Editor/Serialization/Processors/FadeProcessor.cs


using UnityEngine;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("Sequence","Fade")]
class FadeProcessor : ProcessorBase
{
public AnimationCurve FadeCurve;
public Color FadeToColor;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/Fade.shader";
public override string processorName => "Fade";
public override void Default()
{
FadeCurve = new AnimationCurve();
FadeCurve.AddKey(new Keyframe(0.85f, 1f));
FadeCurve.AddKey(new Keyframe(1f, 0f));
FadeToColor = new Color(0.25f,0.25f,0.25f,0.0f);
}
public override bool Process(int frame)
{
Texture inputFrame = processor.InputSequence.RequestFrame(frame).texture;
processor.material.SetTexture("_MainTex", inputFrame);
processor.material.SetColor("_FadeToColor", FadeToColor);
processor.material.SetFloat("_Ratio", FadeCurve.Evaluate(((float)frame) / sequenceLength));
processor.ExecuteShaderAndDump(frame, inputFrame);
return true;
}
CurveDrawer m_CurveDrawer;
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
if (m_CurveDrawer == null)
{
m_CurveDrawer = new CurveDrawer("Fade Curve", 0.0f, 1.0f, 0.0f, 1.0f, 140, false);
m_CurveDrawer.AddCurve(serializedObject.FindProperty("FadeCurve"), new Color(0.75f, 0.5f, 1.0f), "Fade Curve");
m_CurveDrawer.OnPostGUI = OnCurveFieldGUI;
}
var fadeToColor = serializedObject.FindProperty("FadeToColor");
EditorGUI.BeginChangeCheck();
Color c = EditorGUILayout.ColorField(VFXToolboxGUIUtility.Get("Fade To Color"), fadeToColor.colorValue);
if (c != fadeToColor.colorValue)
{
fadeToColor.colorValue = c;
}
if (m_CurveDrawer.OnGUILayout())
{
changed = true;
}
if (EditorGUI.EndChangeCheck())
{
processor.Invalidate();
changed = true;
}
return changed;
}
void OnCurveFieldGUI(Rect renderArea, Rect curveArea)
{
float seqRatio = -1.0f;
if (processor.isCurrentlyPreviewed)
{
seqRatio = (processor.currentPreviewSequenceLength > 1) ? (float)processor.currentPreviewFrame / (processor.currentPreviewSequenceLength - 1) : 0.0f;
}
// If previewing current sequence : draw trackbar
if (seqRatio >= 0.0f)
{
Handles.color = Color.white;
Handles.DrawLine(new Vector3(curveArea.xMin + seqRatio * curveArea.width, renderArea.yMin), new Vector3(curveArea.xMin + seqRatio * curveArea.width, renderArea.yMax));
}
}
bool CurveEquals(AnimationCurve target)
{
for (int i = 0; i < target.keys.Length; i++)
{
if (target[i].time != FadeCurve[i].time ||
target[i].value != FadeCurve[i].value ||
target[i].inTangent != FadeCurve[i].inTangent ||
target[i].outTangent != FadeCurve[i].outTangent)
{
return false;
}
}
return true;
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/FadeProcessor.cs.meta


fileFormatVersion: 2
guid: 4cecbc83322782040aa2e239d6bb99be
timeCreated: 1464795182
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

137
ImageSequencer/Editor/Serialization/Processors/FixBordersProcessor.cs


using UnityEngine;
using UnityEngine.VFXToolbox;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("Common","Fix Borders")]
class FixBordersProcessor : ProcessorBase
{
public Vector4 FixFactors;
public Color FadeToColor;
public float FadeToAlpha;
[FloatSlider(0.5f,4.0f)]
public float Exponent;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/FixBorders.shader";
public override string processorName => "Fix Borders";
public override void Default()
{
FixFactors = Vector4.zero;
FadeToColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
FadeToAlpha = 0.0f;
Exponent = 1.5f;
}
public override bool Process(int frame)
{
Texture inputFrame = processor.InputSequence.RequestFrame(frame).texture;
processor.material.SetTexture("_MainTex", inputFrame);
processor.material.SetVector("_FixFactors", FixFactors);
processor.material.SetColor("_FadeToColor", FadeToColor);
processor.material.SetFloat("_FadeToAlpha", FadeToAlpha);
processor.material.SetFloat("_Exponent", Exponent);
processor.ExecuteShaderAndDump(frame, inputFrame);
return true;
}
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
var fixFactors = serializedObject.FindProperty("FixFactors");
var fadeToColor = serializedObject.FindProperty("FadeToColor");
var fadeToAlpha = serializedObject.FindProperty("FadeToAlpha");
var exponent = serializedObject.FindProperty("Exponent");
Vector4 value = fixFactors.vector4Value;
EditorGUI.BeginChangeCheck();
float left = EditorGUILayout.Slider(VFXToolboxGUIUtility.Get("Left"), value.x, 0.0f, 1.0f);
float right = EditorGUILayout.Slider(VFXToolboxGUIUtility.Get("Right"), value.y, 0.0f, 1.0f);
float top = EditorGUILayout.Slider(VFXToolboxGUIUtility.Get("Top"), value.z, 0.0f, 1.0f);
float bottom = EditorGUILayout.Slider(VFXToolboxGUIUtility.Get("Bottom"), value.w, 0.0f, 1.0f);
if (
left != value.x
|| right != value.y
|| top != value.z
|| bottom != value.w
)
{
fixFactors.vector4Value = new Vector4(left, right, top, bottom);
}
Color c = EditorGUILayout.ColorField(new GUIContent("Fade to Color"), fadeToColor.colorValue, true, true, true);
if (c != fadeToColor.colorValue)
{
fadeToColor.colorValue = c;
}
float a = EditorGUILayout.Slider("Fade to Alpha", fadeToAlpha.floatValue, 0.0f, 1.0f);
if (a != fadeToAlpha.floatValue)
{
fadeToAlpha.floatValue = a;
}
EditorGUILayout.PropertyField(exponent, VFXToolboxGUIUtility.Get("Exponent"));
if (EditorGUI.EndChangeCheck())
{
processor.Invalidate();
changed = true;
}
return changed;
}
public override bool OnCanvasGUI(ImageSequencerCanvas canvas)
{
if (Event.current.type != EventType.Repaint)
return false;
Vector2 center = canvas.CanvasToScreen(Vector2.zero);
int width = canvas.currentFrame.texture.width;
int height = canvas.currentFrame.texture.height;
// (left, right, top, bottom)
float left = FixFactors.x * width;
float right = FixFactors.y * width;
float top = FixFactors.z * height;
float bottom = FixFactors.w * height;
Vector2 topRight = canvas.CanvasToScreen(new Vector2(-width / 2, height / 2));
Vector2 bottomLeft = canvas.CanvasToScreen(new Vector2(width / 2, -height / 2));
Vector2 topRightCrop = canvas.CanvasToScreen(new Vector2(-width / 2 + right, height / 2 - top));
Vector2 bottomLeftCrop = canvas.CanvasToScreen(new Vector2(width / 2 - left, -height / 2 + bottom));
// Arrows
Handles.color = canvas.styles.green;
Handles.DrawLine(new Vector3(center.x, topRight.y), new Vector3(center.x, topRightCrop.y));
Handles.DrawLine(new Vector3(center.x, bottomLeft.y), new Vector3(center.x, bottomLeftCrop.y));
Handles.DrawLine(new Vector3(topRight.x, center.y), new Vector3(topRightCrop.x, center.y));
Handles.DrawLine(new Vector3(bottomLeft.x, center.y), new Vector3(bottomLeftCrop.x, center.y));
// Limits
Handles.color = canvas.styles.fadewhite;
Handles.DrawLine(new Vector3(topRight.x, topRightCrop.y), new Vector3(bottomLeft.x, topRightCrop.y));
Handles.DrawLine(new Vector3(topRight.x, bottomLeftCrop.y), new Vector3(bottomLeft.x, bottomLeftCrop.y));
Handles.DrawLine(new Vector3(topRightCrop.x, topRight.y), new Vector3(topRightCrop.x, bottomLeft.y));
Handles.DrawLine(new Vector3(bottomLeftCrop.x, topRight.y), new Vector3(bottomLeftCrop.x, bottomLeft.y));
// Texts
int labelwidth = 36;
GUI.color = canvas.styles.green;
GUI.Label(new Rect(center.x - labelwidth / 2, topRight.y - 20, labelwidth, 16), FixFactors.z.ToString(), canvas.styles.miniLabel);
GUI.Label(new Rect(center.x - labelwidth / 2, bottomLeft.y + 4, labelwidth, 16), FixFactors.w.ToString(), canvas.styles.miniLabel);
GUI.Label(new Rect(topRight.x + 4, center.y - 8, labelwidth, 16), FixFactors.y.ToString(), canvas.styles.miniLabel);
GUI.Label(new Rect(bottomLeft.x - labelwidth - 4, center.y - 8, labelwidth, 16), FixFactors.x.ToString(), canvas.styles.miniLabelRight);
Handles.color = Color.white;
GUI.color = Color.white;
return false;
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/FixBordersProcessor.cs.meta


fileFormatVersion: 2
guid: 524ca2e5a7796534ab1f8dc4bd20c436
timeCreated: 1465982250
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

301
ImageSequencer/Editor/Serialization/Processors/LoopingProcessor.cs


using UnityEngine;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("Sequence","Loop Sequence")]
class LoopingProcessor : ProcessorBase
{
public AnimationCurve curve;
public int syncFrame;
public int outputSequenceLength;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/Blend.shader";
public override string processorName => "Looping";
public override string label => $"{processorName} ({outputSequenceLength} frame(s), Sync : {syncFrame + 1})";
public override int sequenceLength
{
get
{
if (processor.InputSequence.length > 0)
return outputSequenceLength;
else
return 0;
}
}
public override void Default()
{
curve = new AnimationCurve();
curve.AddKey(0.25f, 0.0f);
curve.AddKey(0.75f, 1.0f);
syncFrame = 25;
outputSequenceLength = 25;
}
public override bool Process(int frame)
{
int inputlength = processor.InputSequence.length;
int outputlength = sequenceLength;
float t = (float)frame / outputlength;
float blendFactor = Mathf.Clamp(curve.Evaluate(t), 0.0f, 1.0f);
int Prev = Mathf.Clamp((int)Mathf.Ceil(syncFrame + frame), 0, inputlength - 1);
int Next = Mathf.Clamp((int)Mathf.Floor(syncFrame - (outputlength - frame)), 0, inputlength - 1);
Texture prevtex = processor.InputSequence.RequestFrame(Prev).texture;
Texture nexttex = processor.InputSequence.RequestFrame(Next).texture;
processor.material.SetTexture("_MainTex", prevtex);
processor.material.SetTexture("_AltTex", nexttex);
processor.material.SetFloat("_BlendFactor", blendFactor);
processor.ExecuteShaderAndDump(frame, prevtex);
return true;
}
CurveDrawer m_CurveDrawer;
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
var outputSequenceLength = serializedObject.FindProperty("outputSequenceLength");
var syncFrame = serializedObject.FindProperty("syncFrame");
EditorGUI.BeginChangeCheck();
int sync = syncFrame.intValue;
int newSync = EditorGUILayout.IntSlider(VFXToolboxGUIUtility.Get("Input Sync Frame|The frame from input sequence that will be used at start and end of the output sequence."), sync, 0 + outputSequenceLength.intValue, processor.InputSequence.length - outputSequenceLength.intValue);
if (newSync != sync)
{
newSync = Mathf.Clamp(newSync, 0 + outputSequenceLength.intValue, processor.InputSequence.length - outputSequenceLength.intValue);
syncFrame.intValue = newSync;
}
int length = outputSequenceLength.intValue;
int newlength = EditorGUILayout.IntSlider(VFXToolboxGUIUtility.Get("Output Sequence Length|How many frames will be in the output sequence?"), length, 2, (processor.InputSequence.length / 2) + 1);
if (newlength != length)
{
newlength = Mathf.Min(newlength, Mathf.Max(1, (processor.InputSequence.length / 2)));
outputSequenceLength.intValue = newlength;
syncFrame.intValue = Mathf.Clamp(syncFrame.intValue, 0 + outputSequenceLength.intValue, processor.InputSequence.length - outputSequenceLength.intValue);
}
float seqRatio = -1.0f;
if (processor.isCurrentlyPreviewed)
{
seqRatio = (processor.currentPreviewSequenceLength > 1) ? (float)processor.currentPreviewFrame / (processor.currentPreviewSequenceLength - 1) : 0.0f;
}
// Draw Preview
GUILayout.Label(VFXToolboxGUIUtility.Get("Mix Curve"));
Rect preview_rect;
using (new GUILayout.HorizontalScope())
{
preview_rect = GUILayoutUtility.GetRect(200, 80);
}
EditorGUI.DrawRect(preview_rect, new Color(0.0f, 0.0f, 0.0f, 0.25f));
Rect gradient_rect = new RectOffset(40, 16, 0, 16).Remove(preview_rect);
float width = gradient_rect.width;
float height = gradient_rect.height;
Color topTrackColor = new Color(1.0f, 0.8f, 0.25f);
Color bottomTrackColor = new Color(0.25f, 0.8f, 1.0f);
using (new GUI.ClipScope(preview_rect))
{
GUI.color = topTrackColor;
Handles.color = topTrackColor;
GUI.Label(new Rect(0, 0, 32, 16), "In:", VFXToolboxStyles.miniLabel);
Handles.DrawLine(new Vector3(72, 8), new Vector3(width + 40 - 32, 8));
GUI.color = bottomTrackColor;
Handles.color = bottomTrackColor;
GUI.Label(new Rect(0, height - 16, 32, 16), "In:", VFXToolboxStyles.miniLabel);
Handles.DrawLine(new Vector3(72, height - 8), new Vector3(width + 40 - 32, height - 8));
GUI.color = Color.white;
Handles.color = Color.white;
GUI.Label(new Rect(0, height, 32, 16), "Out:", VFXToolboxStyles.miniLabel);
GUI.Label(new Rect(40, height, 32, 16), "1", VFXToolboxStyles.miniLabel);
GUI.Label(new Rect(width + 40 - 32, height, 32, 16), length.ToString(), VFXToolboxStyles.miniLabelRight);
Handles.DrawLine(new Vector3(72, height + 8), new Vector3(width + 40 - 32, height + 8));
}
AnimationCurve curve = serializedObject.FindProperty("curve").animationCurveValue;
using (new GUI.ClipScope(gradient_rect))
{
int seqLen = processor.OutputSequence.length;
int syncF = syncFrame.intValue;
float w = Mathf.Ceil((float)width / seqLen);
for (int i = 0; i < seqLen; i++)
{
float t = (float)i / seqLen;
Color blended = Color.Lerp(bottomTrackColor, topTrackColor, curve.Evaluate(t));
EditorGUI.DrawRect(new Rect(i * w, 18, w, height - 36), blended);
}
GUI.color = topTrackColor;
GUI.Label(new Rect(0, 0, 32, 16), (syncF - seqLen + 1).ToString(), VFXToolboxStyles.miniLabel);
GUI.Label(new Rect(width - 32, 0, 32, 16), (syncF).ToString(), VFXToolboxStyles.miniLabelRight);
GUI.color = bottomTrackColor;
GUI.Label(new Rect(0, height - 16, 32, 16), (syncF + 1).ToString(), VFXToolboxStyles.miniLabel);
GUI.Label(new Rect(width - 32, height - 16, 32, 16), (syncF + seqLen).ToString(), VFXToolboxStyles.miniLabelRight);
GUI.color = Color.white;
}
// If previewing current sequence : draw trackbar
if (seqRatio >= 0.0f)
{
Handles.color = Color.white;
Handles.DrawLine(new Vector3(gradient_rect.xMin + seqRatio * gradient_rect.width, preview_rect.yMin), new Vector3(gradient_rect.xMin + seqRatio * gradient_rect.width, preview_rect.yMax));
}
// Curve Drawer
if (m_CurveDrawer == null)
{
m_CurveDrawer = new CurveDrawer(null, 0.0f, 1.0f, 0.0f, 1.0f, 140, false);
m_CurveDrawer.AddCurve(serializedObject.FindProperty("curve"), new Color(0.5f, 0.75f, 1.0f), "Looping Curve");
m_CurveDrawer.OnPostGUI = OnCurveFieldGUI;
}
if (m_CurveDrawer.OnGUILayout())
{
changed = true;
}
if (EditorGUI.EndChangeCheck())
{
changed = true;
}
if (curve.keys.Length < 2 || curve.keys[0].value > 0.0f || curve.keys[curve.keys.Length - 1].value < 1.0f)
EditorGUILayout.HelpBox("Warning : Mix Curve must have first key's value equal 0 and last key's value equal 1 to achieve looping", MessageType.Warning);
return changed;
}
bool CurveEquals(AnimationCurve target)
{
for (int i = 0; i < target.keys.Length; i++)
{
if (target[i].time != curve[i].time ||
target[i].value != curve[i].value ||
target[i].inTangent != curve[i].inTangent ||
target[i].outTangent != curve[i].outTangent)
{
return false;
}
}
return true;
}
void OnCurveFieldGUI(Rect renderArea, Rect curveArea)
{
float seqRatio = -1.0f;
if (processor.isCurrentlyPreviewed)
{
seqRatio = (processor.currentPreviewSequenceLength > 1) ? (float)processor.currentPreviewFrame / (processor.currentPreviewSequenceLength - 1) : 0.0f;
}
// If previewing current sequence : draw trackbar
if (seqRatio >= 0.0f)
{
Handles.color = Color.white;
Handles.DrawLine(new Vector3(curveArea.xMin + seqRatio * curveArea.width, renderArea.yMin), new Vector3(curveArea.xMin + seqRatio * curveArea.width, renderArea.yMax));
}
}
public override bool OnCanvasGUI(ImageSequencerCanvas canvas)
{
int inLength = processor.InputSequence.length;
int outLength = sequenceLength;
int syncFrame = this.syncFrame;
int outCurIDX = canvas.currentFrameIndex;
float outCurT = (float)outCurIDX / outLength;
int inSeqAIDX = (syncFrame - outLength) + outCurIDX;
int inSeqBIDX = syncFrame + outCurIDX;
AnimationCurve mixCurve = curve;
float mix = mixCurve.Evaluate(outCurT);
Color topTrackColor = canvas.styles.yellow;
Color bottomTrackColor = canvas.styles.cyan;
Vector2 top = canvas.CanvasToScreen(new Vector2(-canvas.currentFrame.texture.width, canvas.currentFrame.texture.height) / 2);
Rect rect = new Rect((int)top.x + 24, (int)top.y + 8, 260, 280);
EditorGUI.DrawRect(new RectOffset(8, 8, 8, 8).Add(rect), canvas.styles.backgroundPanelColor);
GUILayout.BeginArea(rect);
GUI.color = topTrackColor;
GUILayout.Label("Mix Chunk A (Input Range : " + (syncFrame - outLength + 1).ToString() + "-" + syncFrame.ToString() + ")", canvas.styles.label);
using (new GUILayout.HorizontalScope())
{
Rect imgARect = GUILayoutUtility.GetRect(100, 100);
imgARect.width = 100;
imgARect.height = 100;
GUI.color = Color.white;
#if !UNITY_2018_2_OR_NEWER
GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear);
#endif
GUI.DrawTexture(imgARect, processor.InputSequence.RequestFrame(inSeqAIDX).texture);
#if !UNITY_2018_2_OR_NEWER
GL.sRGBWrite = false;
#endif
GUI.color = canvas.styles.white;
Handles.DrawSolidRectangleWithOutline(imgARect, Color.clear, topTrackColor);
using (new GUILayout.VerticalScope())
{
GUI.color = topTrackColor;
GUILayout.Label("Frame #" + (inSeqAIDX + 1).ToString(), canvas.styles.miniLabel);
GUILayout.Label("Mixed at : " + (int)(mix * 100) + "%", canvas.styles.miniLabel);
}
}
GUILayout.Space(16);
GUI.color = bottomTrackColor;
GUILayout.Label("Mix Chunk B (Input Range : " + (syncFrame + 1).ToString() + "-" + (syncFrame + outLength).ToString() + ")", canvas.styles.label);
using (new GUILayout.HorizontalScope())
{
Rect imgBRect = GUILayoutUtility.GetRect(100, 100);
imgBRect.width = 100;
imgBRect.height = 100;
GUI.color = Color.white;
#if !UNITY_2018_2_OR_NEWER
GL.sRGBWrite = (QualitySettings.activeColorSpace == ColorSpace.Linear);
#endif
GUI.DrawTexture(imgBRect, processor.InputSequence.RequestFrame(inSeqBIDX).texture);
#if !UNITY_2018_2_OR_NEWER
GL.sRGBWrite = false;
#endif
GUI.color = canvas.styles.white;
Handles.DrawSolidRectangleWithOutline(imgBRect, Color.clear, bottomTrackColor);
using (new GUILayout.VerticalScope())
{
GUI.color = bottomTrackColor;
GUILayout.Label("Frame #" + (inSeqBIDX + 1).ToString(), canvas.styles.miniLabel);
GUILayout.Label("Mixed at : " + (int)((1.0f - mix) * 100) + "%", canvas.styles.miniLabel);
}
}
GUI.color = Color.white;
GUILayout.EndArea();
return false;
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/LoopingProcessor.cs.meta


fileFormatVersion: 2
guid: 0af546431c1df1e4cbb10dcd3b8c8e73
timeCreated: 1463757012
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

50
ImageSequencer/Editor/Serialization/Processors/PremultiplyAlphaProcessor.cs


using UnityEngine;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("Color","Premultiply Alpha")]
class PremultiplyAlphaProcessor : ProcessorBase
{
public bool RemoveAlpha;
public float AlphaValue;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/PremultiplyAlpha.shader";
public override string processorName => "Premultiply Alpha";
public override void Default()
{
RemoveAlpha = false;
AlphaValue = 1.0f;
}
public override bool Process(int frame)
{
Texture inputFrame = processor.InputSequence.RequestFrame(frame).texture;
processor.material.SetTexture("_MainTex", inputFrame);
processor.material.SetInt("_RemoveAlpha", RemoveAlpha ? 1 : 0);
processor.material.SetFloat("_AlphaValue", AlphaValue);
processor.ExecuteShaderAndDump(frame, inputFrame);
return true;
}
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
var removeAlpha = serializedObject.FindProperty("RemoveAlpha");
var alphaValue = serializedObject.FindProperty("AlphaValue");
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(removeAlpha, VFXToolboxGUIUtility.Get("Remove Alpha"));
EditorGUI.BeginDisabledGroup(!removeAlpha.boolValue);
EditorGUILayout.PropertyField(alphaValue, VFXToolboxGUIUtility.Get("Alpha Value"));
EditorGUI.EndDisabledGroup();
if (EditorGUI.EndChangeCheck())
{
processor.Invalidate();
changed = true;
}
return changed;
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/PremultiplyAlphaProcessor.cs.meta


fileFormatVersion: 2
guid: a5e0ec12414f668468843340c4ea49d5
timeCreated: 1471447757
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

87
ImageSequencer/Editor/Serialization/Processors/RemapColorProcessor.cs


using UnityEngine;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("Color","Remap Color")]
class RemapColorProcessor: ProcessorBase
{
public enum RemapColorSource
{
sRGBLuminance = 0,
LinearRGBLuminance = 1,
Alpha = 2,
LinearR = 3,
LinearG = 4,
LinearB = 5
}
public Gradient Gradient;
public RemapColorSource ColorSource;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/RemapColor.shader";
public override string processorName => "Remap Color";
public override void Default()
{
ColorSource = RemapColorSource.sRGBLuminance;
DefaultGradient();
}
public void DefaultGradient()
{
Gradient = new Gradient();
GradientColorKey[] colors = new GradientColorKey[2] { new GradientColorKey(Color.black, 0),new GradientColorKey(Color.white, 1) };
GradientAlphaKey[] alpha = new GradientAlphaKey[2] { new GradientAlphaKey(0,0), new GradientAlphaKey(1,1) };
Gradient.SetKeys(colors, alpha);
}
public override bool Process(int frame)
{
if (m_GradientTexture == null)
{
InitTexture();
}
CurveToTextureUtility.GradientToTexture(Gradient, ref m_GradientTexture);
Texture inputFrame = processor.InputSequence.RequestFrame(frame).texture;
processor.material.SetTexture("_MainTex", inputFrame);
processor.material.SetFloat("_Mode", (int)ColorSource);
processor.material.SetTexture("_Gradient", m_GradientTexture);
processor.ExecuteShaderAndDump(frame, inputFrame);
return true;
}
Texture2D m_GradientTexture;
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
var colorSource = serializedObject.FindProperty("ColorSource");
var gradient = serializedObject.FindProperty("Gradient");
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(colorSource, VFXToolboxGUIUtility.Get("Color Source"));
EditorGUILayout.PropertyField(gradient, VFXToolboxGUIUtility.Get("Remap Gradient"));
if (EditorGUI.EndChangeCheck())
{
processor.Invalidate();
changed = true;
}
return changed;
}
private void InitTexture()
{
m_GradientTexture = new Texture2D(256, 1, TextureFormat.RGBA32, false, false);
m_GradientTexture.wrapMode = TextureWrapMode.Clamp;
m_GradientTexture.filterMode = FilterMode.Bilinear;
CurveToTextureUtility.GradientToTexture(Gradient, ref m_GradientTexture);
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/RemapColorProcessor.cs.meta


fileFormatVersion: 2
guid: 94fe7c5309b5be14584db469f32df97c
timeCreated: 1474890317
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

80
ImageSequencer/Editor/Serialization/Processors/RemoveBackgroundProcessor.cs


using UnityEngine;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("Color","Remove Background")]
class RemoveBackgroundProcessor : ProcessorBase
{
public Color BackgroundColor;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/Unblend.shader";
public override string processorName => "Remove Background";
public override void Default()
{
BackgroundColor = new Color(0.25f,0.25f,0.25f,0.0f);
}
public override bool Process(int frame)
{
Texture tex = processor.InputSequence.RequestFrame(frame).texture;
processor.SetOutputSize(tex.width, tex.height);
processor.material.SetTexture("_MainTex", tex);
processor.material.SetColor("_BackgroundColor", BackgroundColor);
processor.ExecuteShaderAndDump(frame, tex);
return true;
}
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
var bgColor = serializedObject.FindProperty("BackgroundColor");
EditorGUI.BeginChangeCheck();
using (new GUILayout.HorizontalScope())
{
EditorGUILayout.PropertyField(bgColor, VFXToolboxGUIUtility.Get("Background Color"));
if (GUILayout.Button(VFXToolboxGUIUtility.Get("Grab"), GUILayout.Width(40)))
{
if (processor.InputSequence.length > 0)
{
processor.InputSequence.RequestFrame(0);
Color background;
if (processor.InputSequence.frames[0].texture is RenderTexture)
{
background = VFXToolboxUtility.ReadBack((RenderTexture)processor.InputSequence.frames[0].texture)[0];
}
else
{
Texture2D inputFrame = (Texture2D)processor.InputSequence.frames[0].texture;
RenderTexture rt = RenderTexture.GetTemporary(inputFrame.width, inputFrame.height, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear);
Graphics.Blit(inputFrame, rt);
background = VFXToolboxUtility.ReadBack(rt)[0];
RenderTexture.ReleaseTemporary(rt);
}
if (QualitySettings.activeColorSpace == ColorSpace.Linear)
background = background.gamma;
bgColor.colorValue = background;
}
}
}
if (EditorGUI.EndChangeCheck())
{
UpdateOutputSize();
processor.Invalidate();
changed = true;
}
GUILayout.Space(20);
EditorGUILayout.HelpBox("Please select a color corresponding to the solid background of the flipbook to try to reconstruct the pixel's color. \n\nThis filter will only work if your flipbook was rendered on a solid color background. Try the Grab button to fetch the upper left pixel of the first frame, or use the color picker.", MessageType.Info);
return changed;
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/RemoveBackgroundProcessor.cs.meta


fileFormatVersion: 2
guid: ba009c82a545a464986d0e411726f3a9
timeCreated: 1465487664
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

144
ImageSequencer/Editor/Serialization/Processors/ResizeProcessor.cs


using UnityEngine;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("Common","Resize")]
class ResizeProcessor : ProcessorBase
{
public ushort Width;
public ushort Height;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/Resize.shader";
public override string processorName => "Resize";
public override string label => $"{processorName} ({Width}x{Height})";
public override void Default()
{
Width = 256;
Height = 256;
}
public override void UpdateOutputSize()
{
processor.SetOutputSize(Width, Height);
}
public override bool Process(int frame)
{
Texture texture = processor.InputSequence.RequestFrame(frame).texture;
Vector4 kernelAndSize = new Vector4((float)texture.width / (float)Width, (float)texture.height / (float)Height, (float)Width, (float)Height);
processor.material.SetTexture("_MainTex", texture);
processor.material.SetVector("_KernelAndSize", kernelAndSize);
processor.ExecuteShaderAndDump(frame, texture);
return true;
}
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
var width = serializedObject.FindProperty("Width");
var height = serializedObject.FindProperty("Height");
EditorGUI.BeginChangeCheck();
using (new GUILayout.HorizontalScope())
{
int w = Mathf.Clamp(EditorGUILayout.IntField(VFXToolboxGUIUtility.Get("Width"), width.intValue), 1, 8192);
if (GUILayout.Button("", EditorStyles.popup, GUILayout.Width(16)))
{
GenericMenu menu = new GenericMenu();
for (int s = 8192; s >= 16; s /= 2)
{
menu.AddItem(VFXToolboxGUIUtility.Get(s.ToString()), false,
(o) => {
serializedObject.Update();
var out_width = serializedObject.FindProperty("Width");
out_width.intValue = (int)o;
serializedObject.ApplyModifiedProperties();
processor.Invalidate();
UpdateOutputSize();
}, s);
}
menu.ShowAsContext();
}
if (w != width.intValue)
{
width.intValue = w;
}
}
using (new GUILayout.HorizontalScope())
{
int h = Mathf.Clamp(EditorGUILayout.IntField(VFXToolboxGUIUtility.Get("Height"), height.intValue), 1, 8192);
if (GUILayout.Button("", EditorStyles.popup, GUILayout.Width(16)))
{
GenericMenu menu = new GenericMenu();
for (int s = 8192; s >= 16; s /= 2)
{
menu.AddItem(VFXToolboxGUIUtility.Get(s.ToString()), false, (o) => {
serializedObject.Update();
var out_height = serializedObject.FindProperty("Height");
out_height.intValue = (int)o;
serializedObject.ApplyModifiedProperties();
processor.Invalidate();
UpdateOutputSize();
}, s);
}
menu.ShowAsContext();
}
if (h != height.intValue)
{
height.intValue = h;
}
}
if (Mathf.Log(height.intValue, 2) % 1.0f != 0 || Mathf.Log(width.intValue, 2) % 1.0f != 0)
{
EditorGUILayout.HelpBox("Warning: your resize resolution is not a power of two.", MessageType.Warning);
}
if (EditorGUI.EndChangeCheck())
{
UpdateOutputSize();
processor.Invalidate();
changed = true;
}
return changed;
}
public override bool OnCanvasGUI(ImageSequencerCanvas canvas)
{
if (Event.current.type != EventType.Repaint)
return false;
Vector2 center = canvas.CanvasToScreen(Vector2.zero);
Vector2 topRight;
Vector2 bottomLeft;
topRight = canvas.CanvasToScreen(new Vector2(-canvas.currentFrame.texture.width / 2, canvas.currentFrame.texture.height / 2));
bottomLeft = canvas.CanvasToScreen(new Vector2(canvas.currentFrame.texture.width / 2, -canvas.currentFrame.texture.height / 2));
// Arrows
Handles.color = canvas.styles.green;
Handles.DrawLine(new Vector3(topRight.x, topRight.y - 16), new Vector3(bottomLeft.x, topRight.y - 16));
Handles.DrawLine(new Vector3(bottomLeft.x - 16, topRight.y), new Vector3(bottomLeft.x - 16, bottomLeft.y));
Handles.color = Color.white;
// Texts
GUI.color = Color.green;
GUI.Label(new Rect(center.x - 32, topRight.y - 32, 64, 16), Width.ToString(), canvas.styles.miniLabelCenter);
VFXToolboxGUIUtility.GUIRotatedLabel(new Rect(bottomLeft.x - 48, center.y - 8, 64, 16), Height.ToString(), -90.0f, canvas.styles.miniLabelCenter);
GUI.color = Color.white;
return false;
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/ResizeProcessor.cs.meta


fileFormatVersion: 2
guid: ba984ba4af4e5884b8c8e887abee8051
timeCreated: 1464771182
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

73
ImageSequencer/Editor/Serialization/Processors/RotateProcessor.cs


using UnityEngine;
namespace UnityEditor.VFXToolbox.ImageSequencer
{
[Processor("Common","Rotate")]
class RotateProcessor : ProcessorBase
{
public enum RotateMode
{
None = 0,
Rotate90 = 1,
Rotate180 = 2,
Rotate270 = 3
}
public RotateMode FrameRotateMode;
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/Rotate.shader";
public override string processorName => "Rotate";
public override string label => $"{processorName} ({FrameRotateMode})";
public override void UpdateOutputSize()
{
if (FrameRotateMode == RotateMode.None || FrameRotateMode == RotateMode.Rotate180)
processor.SetOutputSize(processor.InputSequence.width, processor.InputSequence.height);
else
processor.SetOutputSize(processor.InputSequence.height, processor.InputSequence.width);
}
public override void Default()
{
FrameRotateMode = 0;
}
public override bool Process(int frame)
{
UpdateOutputSize();
Texture texture = processor.InputSequence.RequestFrame(frame).texture;
processor.material.SetTexture("_MainTex", texture);
processor.material.SetInt("_Mode", (int)FrameRotateMode);
processor.ExecuteShaderAndDump(frame, texture);
return true;
}
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
{
var rotatemode = serializedObject.FindProperty("FrameRotateMode");
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(rotatemode, VFXToolboxGUIUtility.Get("Rotation Mode"));
if (EditorGUI.EndChangeCheck())
{
UpdateOutputSize();
processor.Invalidate();
changed = true;
}
return changed;
}
public override bool OnCanvasGUI(ImageSequencerCanvas canvas)
{
Vector2 pos = canvas.CanvasToScreen(Vector2.zero + (new Vector2(canvas.currentFrame.texture.width, canvas.currentFrame.texture.height) / 2));
Rect r = new Rect(pos.x, pos.y - 16, 150, 16);
GUI.Label(r, VFXToolboxGUIUtility.Get($"Rotation : {ObjectNames.NicifyVariableName(FrameRotateMode.ToString())}"));
return false;
}
}
}

12
ImageSequencer/Editor/Serialization/Processors/RotateProcessor.cs.meta


fileFormatVersion: 2
guid: 74b10a87cbc48a5458e7ebe6abc6b861
timeCreated: 1464879392
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存