Esempio n. 1
0
        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())
            {
                Invalidate();
                changed = true;
            }

            return(changed);
        }
Esempio n. 2
0
        public ColorCorrectionProcessor(FrameProcessorStack stack, ProcessorInfo info)
            : base("Assets/VFXToolbox/ImageSequencer/Editor/Shaders/ColorCorrection.shader", stack, info)
        {
            if (m_CurveDrawer == null)
            {
                m_CurveDrawer = new CurveDrawer(null, 0.0f, 1.0f, 0.0f, 1.0f, 140, false);
                m_CurveDrawer.AddCurve(m_SerializedObject.FindProperty("AlphaCurve"), new Color(1.0f, 0.55f, 0.1f), "Alpha Curve");
            }

            if (settings.AlphaCurve == null)
            {
                settings.DefaultCurve();
            }
        }
        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)
            {
                Invalidate();
                changed = true;
            }

            return(changed);
        }
Esempio n. 4
0
        public RetimeProcessor(FrameProcessorStack processorStack, ProcessorInfo info)
            : base("Packages/com.unity.vfx-toolbox/ImageSequencer/Editor/Shaders/Blend.shader", processorStack, info)
        {
            if (m_CurveDrawer == null)
            {
                m_CurveDrawer = new CurveDrawer("Retime Curve", 0.0f, 1.0f, 0.0f, InputSequence.length, 140, false);
                m_CurveDrawer.AddCurve(m_SerializedObject.FindProperty("curve"), new Color(0.5f, 0.75f, 1.0f), "Retime Curve");
                m_CurveDrawer.OnPostGUI = OnCurveFieldGUI;
            }

            if (settings.curve.keys.Length < 2)
            {
                settings.curve.AddKey(new Keyframe(0, 0));
                settings.curve.AddKey(new Keyframe(1, 24));
            }
        }
Esempio n. 5
0
        public FadeProcessor(FrameProcessorStack processorStack, ProcessorInfo info)
            : base("Assets/VFXToolbox/ImageSequencer/Editor/Shaders/Fade.shader", processorStack, info)
        {
            if (m_CurveDrawer == null)
            {
                m_CurveDrawer = new CurveDrawer("Fade Curve", 0.0f, 1.0f, 0.0f, 1.0f, 140, false);
                m_CurveDrawer.AddCurve(m_SerializedObject.FindProperty("FadeCurve"), new Color(0.75f, 0.5f, 1.0f), "Fade Curve");
                m_CurveDrawer.OnPostGUI = OnCurveFieldGUI;
            }

            if (settings.FadeCurve.keys.Length < 2)
            {
                settings.FadeCurve.AddKey(new Keyframe(0.85f, 1f));
                settings.FadeCurve.AddKey(new Keyframe(1f, 0f));
            }
        }
Esempio n. 6
0
        public LoopingProcessor(FrameProcessorStack processorStack, ProcessorInfo info)
            : base("Assets/VFXToolbox/ImageSequencer/Editor/Shaders/Blend.shader", processorStack, info)
        {
            if (m_CurveDrawer == null)
            {
                m_CurveDrawer = new CurveDrawer(null, 0.0f, 1.0f, 0.0f, 1.0f, 140, false);
                m_CurveDrawer.AddCurve(m_SerializedObject.FindProperty("curve"), new Color(0.5f, 0.75f, 1.0f), "Looping Curve");
                m_CurveDrawer.OnPostGUI = OnCurveFieldGUI;
            }

            if (settings.curve.keys.Length < 2)
            {
                settings.curve.AddKey(0.25f, 0.0f);
                settings.curve.AddKey(0.75f, 1.0f);
            }
        }
        public override bool OnInspectorGUI(bool changed, SerializedObject serializedObject)
        {
            if (m_CurveDrawer == null)
            {
                m_CurveDrawer = new CurveDrawer("Retime Curve", 0.0f, 1.0f, 0.0f, inputSequenceLength, 140, false);
                m_CurveDrawer.AddCurve(serializedObject.FindProperty("curve"), new Color(0.5f, 0.75f, 1.0f), "Retime Curve");
                m_CurveDrawer.OnPostGUI = OnCurveFieldGUI;
            }

            var useCurve             = serializedObject.FindProperty("useCurve");
            var outputSequenceLength = serializedObject.FindProperty("outputSequenceLength");

            EditorGUI.BeginChangeCheck();

            int length    = outputSequenceLength.intValue;
            int newlength = EditorGUILayout.IntSlider(VFXToolboxGUIUtility.Get("Sequence Length"), length, 1, inputSequenceLength);

            if (newlength != length)
            {
                outputSequenceLength.intValue = newlength;
            }

            EditorGUILayout.PropertyField(useCurve, VFXToolboxGUIUtility.Get("Use Retiming Curve"));

            if (useCurve.boolValue)
            {
                m_CurveDrawer.SetBounds(new Rect(0, 0, 1, inputSequenceLength - 1));

                if (m_CurveDrawer.OnGUILayout())
                {
                    changed = true;
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                changed = true;
            }

            return(changed);
        }
Esempio n. 8
0
        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, inputSequenceLength - outputSequenceLength.intValue);

            if (newSync != sync)
            {
                newSync            = Mathf.Clamp(newSync, 0 + outputSequenceLength.intValue, inputSequenceLength - 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, (inputSequenceLength / 2) + 1);

            if (newlength != length)
            {
                newlength = Mathf.Min(newlength, Mathf.Max(1, (inputSequenceLength / 2)));
                outputSequenceLength.intValue = newlength;
                syncFrame.intValue            = Mathf.Clamp(syncFrame.intValue, 0 + outputSequenceLength.intValue, inputSequenceLength - outputSequenceLength.intValue);
            }

            float seqRatio = -1.0f;

            if (isCurrentlyPreviewed)
            {
                seqRatio = (previewSequenceLength > 1) ? (float)previewCurrentFrame / (previewSequenceLength - 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 = this.outputSequenceLength;
                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);
        }