Thomas ICHÉ
5 年前
当前提交
80ab0699
共有 50 个文件被更改,包括 545 次插入 和 671 次删除
-
4ImageSequencer/Editor/Attributes/ProcessorAttribute.cs
-
3ImageSequencer/Editor/FilterPopup/ProcessorDataProvider.cs
-
139ImageSequencer/Editor/FrameProcessor.cs
-
5ImageSequencer/Editor/FrameProcessorStack.Serialization.cs
-
18ImageSequencer/Editor/FrameProcessorStack.cs
-
2ImageSequencer/Editor/ImageSequenceAssetEditor.cs
-
1ImageSequencer/Editor/ImageSequencerCanvas.cs
-
2ImageSequencer/Editor/Serialization/ImageSequence.cs
-
10ImageSequencer/Editor/Serialization/ProcessorInfo.cs
-
28ImageSequencer/Editor/Serialization/ProcessorBase.cs
-
317ImageSequencer/Editor/Serialization/Processors/AssembleProcessor.cs
-
109ImageSequencer/Editor/Serialization/Processors/BreakFlipbookProcessor.cs
-
17ImageSequencer/Editor/Serialization/Processors/AlphaFromRGBProcessorSettings.cs
-
12ImageSequencer/Editor/Serialization/Processors/AlphaFromRGBProcessorSettings.cs.meta
-
25ImageSequencer/Editor/Serialization/Processors/AssembleProcessorSettings.cs
-
16ImageSequencer/Editor/Serialization/Processors/BreakFilpbookProcessorSettings.cs
-
32ImageSequencer/Editor/Serialization/Processors/ColorCorrectionProcessorSettings.cs
-
12ImageSequencer/Editor/Serialization/Processors/ColorCorrectionProcessorSettings.cs.meta
-
23ImageSequencer/Editor/Serialization/Processors/CropProcessorSettings.cs
-
12ImageSequencer/Editor/Serialization/Processors/CropProcessorSettings.cs.meta
-
15ImageSequencer/Editor/Serialization/Processors/CustomMaterialProcessorSettings.cs
-
12ImageSequencer/Editor/Serialization/Processors/CustomMaterialProcessorSettings.cs.meta
-
12ImageSequencer/Editor/Serialization/Processors/DecimateProcessorSettings.cs.meta
-
17ImageSequencer/Editor/Serialization/Processors/FadeProcessorSettings.cs
-
12ImageSequencer/Editor/Serialization/Processors/FadeProcessorSettings.cs.meta
-
12ImageSequencer/Editor/Serialization/Processors/FixBordersProcessorSettings.cs.meta
-
12ImageSequencer/Editor/Serialization/Processors/LoopingProcessorSettings.cs.meta
-
12ImageSequencer/Editor/Serialization/Processors/PremultiplyAlphaProcessorSettings.cs.meta
-
12ImageSequencer/Editor/Serialization/Processors/RemapColorProcessorSettings.cs.meta
-
12ImageSequencer/Editor/Serialization/Processors/RemoveBackgroundSettings.cs.meta
-
12ImageSequencer/Editor/Serialization/Processors/ResizeProcessorSettings.cs.meta
-
12ImageSequencer/Editor/Serialization/Processors/RetimeProcessorSettings.cs.meta
-
12ImageSequencer/Editor/Serialization/Processors/RotateProcessorSettings.cs.meta
-
15ImageSequencer/Editor/Serialization/Processors/DecimateProcessorSettings.cs
-
23ImageSequencer/Editor/Serialization/Processors/FixBordersProcessorSettings.cs
-
19ImageSequencer/Editor/Serialization/Processors/LoopingProcessorSettings.cs
-
15ImageSequencer/Editor/Serialization/Processors/PremultiplyAlphaProcessorSettings.cs
-
35ImageSequencer/Editor/Serialization/Processors/RemapColorProcessorSettings.cs
-
15ImageSequencer/Editor/Serialization/Processors/RemoveBackgroundSettings.cs
-
16ImageSequencer/Editor/Serialization/Processors/ResizeProcessorSettings.cs
-
19ImageSequencer/Editor/Serialization/Processors/RetimeProcessorSettings.cs
-
22ImageSequencer/Editor/Serialization/Processors/RotateProcessorSettings.cs
-
11ImageSequencer/Editor/Serialization/ProcessorSettingsBase.cs
-
54ImageSequencer/Editor/GPUFrameProcessor.cs
-
12ImageSequencer/Editor/GPUFrameProcessor.cs.meta
-
9ImageSequencer/Editor/Processors.meta
-
0/ImageSequencer/Editor/Serialization/Processors/AssembleProcessor.cs.meta
-
0/ImageSequencer/Editor/Serialization/Processors/BreakFlipbookProcessor.cs.meta
-
0/ImageSequencer/Editor/Serialization/ProcessorBase.cs.meta
|
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
internal abstract class ProcessorBase : ScriptableObject |
|||
{ |
|||
public abstract string shaderPath { get; } |
|||
public abstract string processorName { get; } |
|||
public virtual string label => processorName; |
|||
public virtual int GetNumU(FrameProcessor processor) => 1; |
|||
public virtual int GetNumV(FrameProcessor processor) => 1; |
|||
|
|||
public abstract bool Process(FrameProcessor processor, int frame); |
|||
public virtual void UpdateOutputSize(FrameProcessor processor) |
|||
{ |
|||
processor.SetOutputSize(processor.InputSequence.width, processor.InputSequence.height); |
|||
} |
|||
public abstract int GetProcessorSequenceLength(FrameProcessor processor); |
|||
|
|||
public abstract bool OnInspectorGUI(bool changed, SerializedObject serializedObject, FrameProcessor processor); |
|||
public abstract bool OnCanvasGUI(ImageSequencerCanvas canvas); |
|||
public abstract void Default(); |
|||
|
|||
|
|||
} |
|||
} |
|||
|
|||
|
|
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Texture Sheet", "Assemble Flipbook")] |
|||
internal class AssembleProcessor : ProcessorBase |
|||
{ |
|||
public enum AssembleMode |
|||
{ |
|||
FullSpriteSheet = 0, |
|||
VerticalSequence = 1 |
|||
} |
|||
|
|||
public int FlipbookNumU; |
|||
public int FlipbookNumV; |
|||
public AssembleMode Mode; |
|||
|
|||
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/AssembleBlit.shader"; |
|||
|
|||
public override string processorName => "Assemble Flipbook"; |
|||
|
|||
public override string label |
|||
{ |
|||
get |
|||
{ |
|||
string numU = (Mode == AssembleMode.VerticalSequence) ? "*" : FlipbookNumU.ToString(); |
|||
string numV = FlipbookNumV.ToString(); |
|||
return $"{processorName} ({numU}x{numV})"; |
|||
} |
|||
} |
|||
|
|||
public override void Default() |
|||
{ |
|||
FlipbookNumU = 5; |
|||
FlipbookNumV = 5; |
|||
Mode = AssembleMode.FullSpriteSheet; |
|||
} |
|||
|
|||
public override void UpdateOutputSize(FrameProcessor processor) |
|||
{ |
|||
switch (Mode) |
|||
{ |
|||
case AssembleMode.FullSpriteSheet: |
|||
|
|||
processor.SetOutputSize(processor.InputSequence.width * FlipbookNumU, processor.InputSequence.height * FlipbookNumV); |
|||
break; |
|||
|
|||
case AssembleMode.VerticalSequence: |
|||
|
|||
processor.SetOutputSize(processor.InputSequence.width, processor.InputSequence.height * FlipbookNumV); |
|||
break; |
|||
} |
|||
|
|||
} |
|||
|
|||
public override int GetProcessorSequenceLength(FrameProcessor processor) |
|||
{ |
|||
switch (Mode) |
|||
{ |
|||
default: |
|||
case AssembleMode.FullSpriteSheet: |
|||
return 1; |
|||
|
|||
case AssembleMode.VerticalSequence: |
|||
return processor.InputSequence.length / FlipbookNumV; |
|||
} |
|||
} |
|||
|
|||
public override bool OnCanvasGUI(ImageSequencerCanvas canvas) |
|||
{ |
|||
if (Event.current.type != EventType.Repaint) |
|||
return false; |
|||
|
|||
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)); |
|||
|
|||
// Texts
|
|||
GUI.color = canvas.styles.green; |
|||
for (int i = 0; i < FlipbookNumU; i++) |
|||
{ |
|||
float cw = (topRight.x - bottomLeft.x) / FlipbookNumU; |
|||
GUI.Label(new Rect(bottomLeft.x + i * cw, topRight.y - 16, cw, 16), (i + 1).ToString(), canvas.styles.miniLabelCenter); |
|||
} |
|||
|
|||
for (int i = 0; i < FlipbookNumV; i++) |
|||
{ |
|||
float ch = (bottomLeft.y - topRight.y) / FlipbookNumV; |
|||
VFXToolboxGUIUtility.GUIRotatedLabel(new Rect(bottomLeft.x - 8, topRight.y + i * ch, 16, ch), (i + 1).ToString(), -90.0f, canvas.styles.miniLabelCenter); |
|||
} |
|||
|
|||
GUI.color = Color.white; |
|||
return false; |
|||
} |
|||
|
|||
public override int GetNumU(FrameProcessor processor) |
|||
{ |
|||
switch (Mode) |
|||
{ |
|||
default: |
|||
case AssembleMode.FullSpriteSheet: |
|||
return FlipbookNumU * processor.InputSequence.numU; |
|||
case AssembleMode.VerticalSequence: |
|||
return processor.InputSequence.numU; |
|||
} |
|||
} |
|||
|
|||
public override int GetNumV(FrameProcessor processor) |
|||
{ |
|||
return FlipbookNumV * processor.InputSequence.numV; |
|||
} |
|||
|
|||
public override bool Process(FrameProcessor processor, int frame) |
|||
{ |
|||
int length = processor.InputSequence.length; |
|||
|
|||
RenderTexture backup = RenderTexture.active; |
|||
|
|||
switch (Mode) |
|||
{ |
|||
case AssembleMode.FullSpriteSheet: |
|||
|
|||
// Blit Every Image inside output
|
|||
for (int i = 0; i < (FlipbookNumU * FlipbookNumV); i++) |
|||
{ |
|||
int u = i % FlipbookNumU; |
|||
int v = (FlipbookNumV - 1) - (int)Mathf.Floor((float)i / FlipbookNumU); |
|||
|
|||
Vector2 size = new Vector2(1.0f / FlipbookNumU, 1.0f / FlipbookNumV); |
|||
int idx = Mathf.Clamp(i, 0, length - 1); |
|||
|
|||
Texture currentTexture = processor.InputSequence.RequestFrame(idx).texture; |
|||
|
|||
Vector4 ClipCoordinates = new Vector4(u * size.x, v * size.y, size.x, size.y); |
|||
|
|||
processor.material.SetTexture("_MainTex", currentTexture); |
|||
processor.material.SetVector("_CC", ClipCoordinates); |
|||
|
|||
Graphics.Blit(currentTexture, (RenderTexture)processor.OutputSequence.frames[0].texture, processor.material); |
|||
} |
|||
|
|||
RenderTexture.active = backup; |
|||
|
|||
break; |
|||
|
|||
case AssembleMode.VerticalSequence: |
|||
|
|||
// Blit Every N'th Image inside output
|
|||
int cycleLength = processor.InputSequence.length / FlipbookNumV; |
|||
|
|||
for (int i = 0; i < FlipbookNumV; i++) |
|||
{ |
|||
int u = 0; |
|||
int v = FlipbookNumV - 1 - i; |
|||
|
|||
Vector2 size = new Vector2(1.0f, 1.0f / FlipbookNumV); |
|||
int idx = Mathf.Clamp((i * cycleLength) + frame, 0, length - 1); |
|||
|
|||
Texture currentTexture = processor.InputSequence.RequestFrame(idx).texture; |
|||
|
|||
Vector4 ClipCoordinates = new Vector4(u * size.x, v * size.y, size.x, size.y); |
|||
|
|||
processor.material.SetTexture("_MainTex", currentTexture); |
|||
processor.material.SetVector("_CC", ClipCoordinates); |
|||
|
|||
Graphics.Blit(currentTexture, (RenderTexture)processor.OutputSequence.frames[frame].texture, processor.material); |
|||
} |
|||
|
|||
RenderTexture.active = backup; |
|||
break; |
|||
} |
|||
|
|||
return true; |
|||
} |
|||
|
|||
bool hasChanged = false; |
|||
|
|||
public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject, FrameProcessor processor) |
|||
{ |
|||
var flipbookNumU = serializedObject.FindProperty("FlipbookNumU"); |
|||
var flipbookNumV = serializedObject.FindProperty("FlipbookNumV"); |
|||
var mode = serializedObject.FindProperty("Mode"); |
|||
|
|||
var assembleMode = (AssembleMode)mode.intValue; |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
|
|||
assembleMode = (AssembleMode)EditorGUILayout.EnumPopup(VFXToolboxGUIUtility.Get("Assemble Mode"), assembleMode); |
|||
if (assembleMode != (AssembleMode)mode.intValue) |
|||
{ |
|||
mode.intValue = (int)assembleMode; |
|||
hasChanged = true; |
|||
} |
|||
|
|||
switch (assembleMode) |
|||
{ |
|||
case AssembleMode.FullSpriteSheet: |
|||
|
|||
int newU = EditorGUILayout.IntField(VFXToolboxGUIUtility.Get("Columns (U) : "), flipbookNumU.intValue); |
|||
int newV = EditorGUILayout.IntField(VFXToolboxGUIUtility.Get("Rows (V) : "), flipbookNumV.intValue); |
|||
|
|||
if (processor.InputSequence.length > 0) |
|||
{ |
|||
using (new GUILayout.HorizontalScope()) |
|||
{ |
|||
GUILayout.Label(VFXToolboxGUIUtility.Get("Find Best Ratios"), GUILayout.Width(EditorGUIUtility.labelWidth)); |
|||
if (GUILayout.Button(VFXToolboxGUIUtility.Get("Get"))) |
|||
{ |
|||
float frameRatio = (float)processor.InputSequence.frames[0].texture.width / (float)processor.InputSequence.frames[0].texture.height; |
|||
int length = processor.InputSequence.frames.Count; |
|||
List<int> ratios = new List<int>(); |
|||
SortedDictionary<int, float> coeffs = new SortedDictionary<int, float>(); |
|||
float rad = Mathf.Sqrt(length); |
|||
for (int i = (int)rad; i >= 1; i--) |
|||
{ |
|||
if (((float)length / (float)i) % 1.0f == 0.0f) |
|||
{ |
|||
float pageRatio = (float)i / (length / i); |
|||
float fullRatio = frameRatio * pageRatio; |
|||
float divergence = Mathf.Abs(Mathf.Log(fullRatio, 2.0f) % 1.0f); |
|||
|
|||
if (!ratios.Contains(i)) |
|||
{ |
|||
ratios.Add(i); |
|||
coeffs.Add(i, divergence); |
|||
} |
|||
|
|||
fullRatio = frameRatio / pageRatio; |
|||
divergence = Mathf.Abs(Mathf.Log(fullRatio, 2.0f) % 1.0f); |
|||
|
|||
if (!ratios.Contains(length / i)) |
|||
{ |
|||
ratios.Add(length / i); |
|||
coeffs.Add((length / i), divergence); |
|||
} |
|||
} |
|||
} |
|||
|
|||
GenericMenu menu = new GenericMenu(); |
|||
|
|||
var sortedValues = coeffs.OrderBy(kvp => kvp.Value); |
|||
|
|||
foreach (KeyValuePair<int, float> kvp in sortedValues) |
|||
{ |
|||
int value = kvp.Key; |
|||
|
|||
menu.AddItem(new GUIContent(value + " x " + (length / value) + ((kvp.Value == 0.0f) ? " (PERFECT)" : "")), false, |
|||
(o) => { |
|||
var seq_length = processor.InputSequence.length; |
|||
var seq_numU = (int)o; |
|||
var seq_numV = seq_length / seq_numU; |
|||
serializedObject.Update(); |
|||
var seq_flipbookNumU = serializedObject.FindProperty("FlipbookNumU"); |
|||
var seq_flipbookNumV = serializedObject.FindProperty("FlipbookNumV"); |
|||
|
|||
seq_flipbookNumU.intValue = seq_numU; |
|||
seq_flipbookNumV.intValue = seq_numV; |
|||
|
|||
serializedObject.ApplyModifiedProperties(); |
|||
UpdateOutputSize(processor); |
|||
processor.Invalidate(); |
|||
} |
|||
, value); |
|||
} |
|||
if (menu.GetItemCount() > 0) |
|||
menu.ShowAsContext(); |
|||
} |
|||
} |
|||
EditorGUILayout.HelpBox("Find Best Ratios will try to find matching possibilities for the current sequence, ordered by ratio pertinence, meaning that first results will have less stretch when resized to power-of-two textures.", MessageType.Info); |
|||
} |
|||
|
|||
|
|||
if (newU != flipbookNumU.intValue) |
|||
{ |
|||
newU = Mathf.Clamp(newU, 1, processor.InputSequence.length / newV); |
|||
flipbookNumU.intValue = newU; |
|||
} |
|||
|
|||
if (newV != flipbookNumV.intValue) |
|||
{ |
|||
newV = Mathf.Clamp(newV, 1, processor.InputSequence.length / newU); |
|||
flipbookNumV.intValue = newV; |
|||
} |
|||
break; |
|||
|
|||
case AssembleMode.VerticalSequence: |
|||
|
|||
int numRows = EditorGUILayout.IntField(VFXToolboxGUIUtility.Get("Rows (V) : "), flipbookNumV.intValue); |
|||
|
|||
if (numRows != flipbookNumV.intValue) |
|||
{ |
|||
numRows = Mathf.Clamp(numRows, 1, processor.InputSequence.length); |
|||
flipbookNumV.intValue = numRows; |
|||
} |
|||
|
|||
break; |
|||
|
|||
} |
|||
|
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
UpdateOutputSize(processor); |
|||
processor.Invalidate(); |
|||
hasChanged = true; |
|||
} |
|||
|
|||
return hasChanged; |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|||
|
|
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Texture Sheet", "Break Flipbook")] |
|||
internal class BreakFlipbookProcessor : ProcessorBase |
|||
{ |
|||
public int FlipbookNumU; |
|||
public int FlipbookNumV; |
|||
|
|||
public override string shaderPath => "Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/GetSubUV.shader"; |
|||
|
|||
public override string processorName => "Break Flipbook"; |
|||
|
|||
public override string label => $"{name} ({FlipbookNumU}x{FlipbookNumV}): {FlipbookNumU * FlipbookNumV} frame(s)."; |
|||
|
|||
private bool m_BypassSecurityCheck = false; |
|||
|
|||
public override void Default() |
|||
{ |
|||
FlipbookNumU = 5; |
|||
FlipbookNumV = 5; |
|||
} |
|||
|
|||
public override void UpdateOutputSize(FrameProcessor processor) |
|||
{ |
|||
int width = (int)Mathf.Ceil((float)processor.InputSequence.RequestFrame(0).texture.width / FlipbookNumU); |
|||
int height = (int)Mathf.Ceil((float)processor.InputSequence.RequestFrame(0).texture.height / FlipbookNumV); |
|||
processor.SetOutputSize(width, height); |
|||
} |
|||
|
|||
public override int GetProcessorSequenceLength(FrameProcessor processor) |
|||
{ |
|||
return Mathf.Min(FlipbookNumU, processor.InputSequence.width) * Mathf.Min(FlipbookNumV, processor.InputSequence.height); |
|||
} |
|||
|
|||
public override bool OnCanvasGUI(ImageSequencerCanvas canvas) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
public override bool Process(FrameProcessor processor, int frame) |
|||
{ |
|||
Texture texture = processor.InputSequence.RequestFrame(0).texture; |
|||
processor.material.SetTexture("_MainTex", texture); |
|||
Vector4 rect = new Vector4(); |
|||
|
|||
int u = Mathf.Min(FlipbookNumU, texture.width); |
|||
int v = Mathf.Min(FlipbookNumV, texture.height); |
|||
|
|||
int x = frame % FlipbookNumU; |
|||
int y = (int)Mathf.Floor((float)frame / u); |
|||
rect.x = (float)x; |
|||
rect.y = (float)(v - 1) - y; |
|||
rect.z = 1.0f / u; |
|||
rect.w = 1.0f / v; |
|||
|
|||
processor.material.SetVector("_Rect", rect); |
|||
processor.ExecuteShaderAndDump(frame, texture); |
|||
return true; |
|||
} |
|||
|
|||
public override bool OnInspectorGUI(bool hasChanged, SerializedObject serializedObject, FrameProcessor processor) |
|||
{ |
|||
var flipbookNumU = serializedObject.FindProperty("FlipbookNumU"); |
|||
var flipbookNumV = serializedObject.FindProperty("FlipbookNumV"); |
|||
|
|||
EditorGUI.BeginChangeCheck(); |
|||
|
|||
int newU = Mathf.Clamp(EditorGUILayout.IntField(VFXToolboxGUIUtility.Get("Columns (U) : "), flipbookNumU.intValue), 1, processor.InputSequence.width); |
|||
int newV = Mathf.Clamp(EditorGUILayout.IntField(VFXToolboxGUIUtility.Get("Rows (V) : "), flipbookNumV.intValue), 1, processor.InputSequence.height); |
|||
|
|||
if (newU != flipbookNumU.intValue || flipbookNumV.intValue != newV) |
|||
GUI.changed = true; |
|||
|
|||
if (m_BypassSecurityCheck) |
|||
EditorGUILayout.HelpBox("Warning: you are currently bypassing frame count limits. Proceed with caution when entering values, as it can take a long time to process and stall your editor.", MessageType.Warning); |
|||
|
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
Debug.Log("Updated"); |
|||
|
|||
if (newU * newV <= 4096) |
|||
{ |
|||
flipbookNumU.intValue = newU; |
|||
flipbookNumV.intValue = newV; |
|||
} |
|||
else |
|||
{ |
|||
if (!m_BypassSecurityCheck && EditorUtility.DisplayDialog("VFX Toolbox", "CAUTION : You are going to generate a sequence of " + newU * newV + " frames. This could take a long time to process, stall your editor, and consume a large amount of memory. Are you SURE you want to Continue?", "I know what I am doing, proceed", "Cancel")) |
|||
m_BypassSecurityCheck = true; |
|||
|
|||
if (m_BypassSecurityCheck) |
|||
{ |
|||
flipbookNumU.intValue = newU; |
|||
flipbookNumV.intValue = newV; |
|||
} |
|||
} |
|||
|
|||
processor.Invalidate(); |
|||
hasChanged = true; |
|||
} |
|||
|
|||
return hasChanged; |
|||
} |
|||
|
|||
} |
|||
} |
|||
|
|
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Color","Alpha From RGB", typeof(AlphaFromRGBProcessor))] |
|||
public class AlphaFromRGBProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public Color BWFilterTint; |
|||
//public Vector3 Weights;
|
|||
|
|||
public override void Default() |
|||
{ |
|||
BWFilterTint = Color.white; |
|||
//Weights = new Vector3(0.2126f, 0.7152f, 0.0722f);
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fa620cc053ad857459f8451c2f9f2823 |
|||
timeCreated: 1474881116 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Texture Sheet","Assemble Flipbook", typeof(AssembleProcessor))] |
|||
public class AssembleProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public enum AssembleMode |
|||
{ |
|||
FullSpriteSheet = 0, |
|||
VerticalSequence = 1 |
|||
} |
|||
|
|||
public int FlipbookNumU; |
|||
public int FlipbookNumV; |
|||
public AssembleMode Mode; |
|||
|
|||
public override void Default() |
|||
{ |
|||
FlipbookNumU = 5; |
|||
FlipbookNumV = 5; |
|||
Mode = AssembleMode.FullSpriteSheet; |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Texture Sheet","Break Flipbook", typeof(BreakFlipbookProcessor))] |
|||
public class BreakFilpbookProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public int FlipbookNumU; |
|||
public int FlipbookNumV; |
|||
|
|||
public override void Default() |
|||
{ |
|||
FlipbookNumU = 5; |
|||
FlipbookNumV = 5; |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
using UnityEngine; |
|||
using UnityEngine.VFXToolbox; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Color","Color Correction", typeof(ColorCorrectionProcessor))] |
|||
public class ColorCorrectionProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
[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 void Default() |
|||
{ |
|||
Brightness = 1.0f; |
|||
Contrast = 1.0f; |
|||
Saturation = 1.0f; |
|||
DefaultCurve(); |
|||
} |
|||
|
|||
public void DefaultCurve() |
|||
{ |
|||
AlphaCurve = AnimationCurve.Linear(0, 0, 1, 1); |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: a3ca7dec4216fca4f943c6c73a5f5819 |
|||
timeCreated: 1471449594 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Common","Crop", typeof(CropProcessor))] |
|||
public class CropProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public uint Crop_Top; |
|||
public uint Crop_Bottom; |
|||
public uint Crop_Left; |
|||
public uint Crop_Right; |
|||
|
|||
public float AutoCropThreshold = 0.003f; |
|||
|
|||
public override void Default() |
|||
{ |
|||
Crop_Top = 0; |
|||
Crop_Bottom = 0; |
|||
Crop_Left = 0; |
|||
Crop_Right = 0; |
|||
AutoCropThreshold = 0.003f; |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: ffd658e7a2564734aaef1a1eddf45e1a |
|||
timeCreated: 1464881358 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("","Custom Material", typeof(CustomMaterialProcessor))] |
|||
public class CustomMaterialProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public Material material; |
|||
|
|||
public override void Default() |
|||
{ |
|||
material = null; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 05487723e0bf7674d8819359ce0d8fdc |
|||
timeCreated: 1478610071 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 35539f9025900914e96e7eb931166504 |
|||
timeCreated: 1465476802 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Sequence","Fade", typeof(FadeProcessor))] |
|||
public class FadeProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public AnimationCurve FadeCurve; |
|||
public Color FadeToColor; |
|||
|
|||
public override void Default() |
|||
{ |
|||
FadeCurve = new AnimationCurve(); |
|||
FadeToColor = new Color(0.25f,0.25f,0.25f,0.0f); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4cecbc83322782040aa2e239d6bb99be |
|||
timeCreated: 1464795182 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 524ca2e5a7796534ab1f8dc4bd20c436 |
|||
timeCreated: 1465982250 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 0af546431c1df1e4cbb10dcd3b8c8e73 |
|||
timeCreated: 1463757012 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: a5e0ec12414f668468843340c4ea49d5 |
|||
timeCreated: 1471447757 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 94fe7c5309b5be14584db469f32df97c |
|||
timeCreated: 1474890317 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ba009c82a545a464986d0e411726f3a9 |
|||
timeCreated: 1465487664 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ba984ba4af4e5884b8c8e887abee8051 |
|||
timeCreated: 1464771182 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 67121233fc1872a4e9b4d2c8f5fc6542 |
|||
timeCreated: 1463757012 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 74b10a87cbc48a5458e7ebe6abc6b861 |
|||
timeCreated: 1464879392 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Sequence","Decimate", typeof(DecimateProcessor))] |
|||
class DecimateProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public ushort DecimateBy; |
|||
|
|||
public override void Default() |
|||
{ |
|||
DecimateBy = 3; |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|
|||
using UnityEngine; |
|||
using UnityEngine.VFXToolbox; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Common","Fix Borders", typeof(FixBordersProcessor))] |
|||
class FixBordersProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public Vector4 FixFactors; |
|||
public Color FadeToColor; |
|||
public float FadeToAlpha; |
|||
[FloatSlider(0.5f,4.0f)] |
|||
public float Exponent; |
|||
|
|||
public override void Default() |
|||
{ |
|||
FixFactors = Vector4.zero; |
|||
FadeToColor = new Color(0.0f, 0.0f, 0.0f, 0.0f); |
|||
FadeToAlpha = 0.0f; |
|||
Exponent = 1.5f; |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Sequence","Loop Sequence", typeof(LoopingProcessor))] |
|||
class LoopingProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public AnimationCurve curve; |
|||
public int syncFrame; |
|||
public int outputSequenceLength; |
|||
|
|||
public override void Default() |
|||
{ |
|||
curve = new AnimationCurve(); |
|||
syncFrame = 25; |
|||
outputSequenceLength = 25; |
|||
} |
|||
} |
|||
} |
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Color","Premultiply Alpha", typeof(PremultiplyAlphaProcessor))] |
|||
class PremultiplyAlphaProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public bool RemoveAlpha; |
|||
public float AlphaValue; |
|||
|
|||
public override void Default() |
|||
{ |
|||
RemoveAlpha = false; |
|||
AlphaValue = 1.0f; |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Color","Remap Color", typeof(RemapColorProcessor))] |
|||
class RemapColorProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public enum RemapColorSource |
|||
{ |
|||
sRGBLuminance = 0, |
|||
LinearRGBLuminance = 1, |
|||
Alpha = 2, |
|||
LinearR = 3, |
|||
LinearG = 4, |
|||
LinearB = 5 |
|||
} |
|||
|
|||
public Gradient Gradient; |
|||
public RemapColorSource ColorSource; |
|||
|
|||
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); |
|||
} |
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Color","Remove Background", typeof(RemoveBackgroundBlendingProcessor))] |
|||
class RemoveBackgroundSettings : ProcessorSettingsBase |
|||
{ |
|||
public Color BackgroundColor; |
|||
|
|||
public override void Default() |
|||
{ |
|||
BackgroundColor = new Color(0.25f,0.25f,0.25f,0.0f); |
|||
} |
|||
} |
|||
} |
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Common","Resize", typeof(ResizeProcessor))] |
|||
class ResizeProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public ushort Width; |
|||
public ushort Height; |
|||
|
|||
public override void Default() |
|||
{ |
|||
Width = 256; |
|||
Height = 256; |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Sequence","Retime", typeof(RetimeProcessor))] |
|||
class RetimeProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public AnimationCurve curve; |
|||
public int outputSequenceLength; |
|||
public bool useCurve; |
|||
|
|||
public override void Default() |
|||
{ |
|||
curve = new AnimationCurve(); |
|||
outputSequenceLength = 25; |
|||
useCurve = true; |
|||
} |
|||
} |
|||
} |
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
[Processor("Common","Rotate", typeof(RotateProcessor))] |
|||
class RotateProcessorSettings : ProcessorSettingsBase |
|||
{ |
|||
public enum RotateMode |
|||
{ |
|||
None = 0, |
|||
Rotate90 = 1, |
|||
Rotate180 = 2, |
|||
Rotate270 = 3 |
|||
} |
|||
|
|||
public RotateMode FrameRotateMode; |
|||
|
|||
public override void Default() |
|||
{ |
|||
FrameRotateMode = 0; |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
public abstract class ProcessorSettingsBase : ScriptableObject |
|||
{ |
|||
public abstract void Default(); |
|||
} |
|||
} |
|||
|
|||
|
|
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.VFXToolbox.ImageSequencer |
|||
{ |
|||
internal abstract class GPUFrameProcessor<T> : FrameProcessor<T> where T : ProcessorSettingsBase |
|||
{ |
|||
protected Shader m_Shader; |
|||
protected Material m_Material; |
|||
|
|||
public GPUFrameProcessor(string shaderPath, FrameProcessorStack processorStack, ProcessorInfo info ) |
|||
: this(AssetDatabase.LoadAssetAtPath<Shader>(shaderPath),processorStack, info) |
|||
{ } |
|||
|
|||
public GPUFrameProcessor(Shader shader, FrameProcessorStack processorStack, ProcessorInfo info ) : base(processorStack, info) |
|||
{ |
|||
m_Shader = shader; |
|||
m_Material = new Material(m_Shader) { hideFlags = HideFlags.DontSave }; |
|||
m_Material.hideFlags = HideFlags.DontSave; |
|||
} |
|||
|
|||
public void ExecuteShaderAndDump(int outputframe, Texture mainTex) |
|||
{ |
|||
ExecuteShaderAndDump(outputframe, mainTex, m_Material); |
|||
} |
|||
|
|||
public void ExecuteShaderAndDump(int outputframe, Texture mainTex, Material material) |
|||
{ |
|||
RenderTexture backup = RenderTexture.active; |
|||
Graphics.Blit(mainTex, (RenderTexture)m_OutputSequence.frames[outputframe].texture, material); |
|||
RenderTexture.active = backup; |
|||
} |
|||
|
|||
public override void Dispose() |
|||
{ |
|||
Material.DestroyImmediate(m_Material); |
|||
base.Dispose(); |
|||
} |
|||
|
|||
protected override int GetNumU() |
|||
{ |
|||
if (InputSequence.processor == null) |
|||
return 1; |
|||
return InputSequence.numU; |
|||
} |
|||
|
|||
protected override int GetNumV() |
|||
{ |
|||
if (InputSequence.processor == null) |
|||
return 1; |
|||
return InputSequence.numV; |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a00044f5e3e7b924e925a45bcb585727 |
|||
timeCreated: 1461162132 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ea5d7b44dca491240a1a52832e86c71e |
|||
folderAsset: yes |
|||
timeCreated: 1461139447 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue