Пример #1
0
        public override bool Process(int frame)
        {
            UpdateOutputSize();
            Texture texture = InputSequence.RequestFrame(frame).texture;

            m_Material.SetTexture("_MainTex", texture);
            m_Material.SetInt("_Mode", (int)settings.FrameRotateMode);
            ExecuteShaderAndDump(frame, texture);
            return(true);
        }
Пример #2
0
        public override bool Process(int frame)
        {
            Texture tex = InputSequence.RequestFrame(frame).texture;

            SetOutputSize(tex.width, tex.height);
            m_Material.SetTexture("_MainTex", tex);
            m_Material.SetColor("_BackgroundColor", settings.BackgroundColor);
            ExecuteShaderAndDump(frame, tex);
            return(true);
        }
Пример #3
0
        public override bool Process(int frame)
        {
            Texture inputFrame = InputSequence.RequestFrame(frame).texture;

            m_Material.SetTexture("_MainTex", inputFrame);
            m_Material.SetInt("_RemoveAlpha", settings.RemoveAlpha?1:0);
            m_Material.SetFloat("_AlphaValue", settings.AlphaValue);
            ExecuteShaderAndDump(frame, inputFrame);
            return(true);
        }
        public override bool Process(int frame)
        {
            Texture texture       = InputSequence.RequestFrame(frame).texture;
            Vector4 kernelAndSize = new Vector4((float)texture.width / (float)settings.Width, (float)texture.height / (float)settings.Height, (float)settings.Width, (float)settings.Height);

            m_Material.SetTexture("_MainTex", texture);
            m_Material.SetVector("_KernelAndSize", kernelAndSize);
            ExecuteShaderAndDump(frame, texture);
            return(true);
        }
Пример #5
0
        public override bool Process(int frame)
        {
            Texture inputFrame = InputSequence.RequestFrame(frame).texture;

            m_Material.SetTexture("_MainTex", inputFrame);
            m_Material.SetVector("_RGBTint", settings.BWFilterTint);

            ExecuteShaderAndDump(frame, inputFrame);
            return(true);
        }
Пример #6
0
        public override bool Process(int frame)
        {
            Texture inputFrame = InputSequence.RequestFrame(frame).texture;

            m_Material.SetTexture("_MainTex", inputFrame);
            m_Material.SetColor("_FadeToColor", settings.FadeToColor);
            m_Material.SetFloat("_Ratio", settings.FadeCurve.Evaluate(((float)frame) / GetProcessorSequenceLength()));
            ExecuteShaderAndDump(frame, inputFrame);
            return(true);
        }
Пример #7
0
        public override bool Process(int frame)
        {
            Texture inputFrame = InputSequence.RequestFrame(frame).texture;

            m_Material.SetTexture("_MainTex", inputFrame);
            m_Material.SetVector("_FixFactors", settings.FixFactors);
            m_Material.SetColor("_FadeToColor", settings.FadeToColor);
            m_Material.SetFloat("_FadeToAlpha", settings.FadeToAlpha);
            m_Material.SetFloat("_Exponent", settings.Exponent);
            ExecuteShaderAndDump(frame, inputFrame);
            return(true);
        }
Пример #8
0
        protected override bool DrawSidePanelContent(bool hasChanged)
        {
            var bgColor = m_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 (InputSequence.length > 0)
                    {
                        InputSequence.RequestFrame(0);

                        Color background;

                        if (InputSequence.frames[0].texture is RenderTexture)
                        {
                            background = VFXToolboxUtility.ReadBack((RenderTexture)InputSequence.frames[0].texture)[0];
                        }
                        else
                        {
                            Texture2D     inputFrame = (Texture2D)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();
                Invalidate();
                hasChanged = 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(hasChanged);
        }
Пример #9
0
        public override bool Process(int frame)
        {
            UpdateOutputSize();
            Texture texture = InputSequence.RequestFrame(frame).texture;

            m_Material.SetTexture("_MainTex", texture);
            m_Material.SetVector("_CropFactors", new Vector4(
                                     (float)settings.Crop_Left / texture.width,
                                     (float)settings.Crop_Right / texture.width,
                                     (float)settings.Crop_Top / texture.height,
                                     (float)settings.Crop_Bottom / texture.height
                                     ));

            ExecuteShaderAndDump(frame, texture);
            return(true);
        }
Пример #10
0
        public override bool Process(int frame)
        {
            Texture inputFrame = InputSequence.RequestFrame(frame).texture;

            if (settings.material != null)
            {
                settings.material.SetTexture("_InputFrame", inputFrame);
                settings.material.SetVector("_FrameData", new Vector4(OutputWidth, OutputHeight, frame, GetProcessorSequenceLength()));
                settings.material.SetVector("_FlipbookData", new Vector4(NumU, NumV, 0, 0));
                ExecuteShaderAndDump(frame, inputFrame, settings.material);
            }
            else
            {
                m_Material.SetTexture("_MainTex", inputFrame);
                ExecuteShaderAndDump(frame, inputFrame);
            }
            return(true);
        }
Пример #11
0
        public override bool Process(int frame)
        {
            if (m_GradientTexture == null)
            {
                InitTexture();
            }

            CurveToTextureUtility.GradientToTexture(settings.Gradient, ref m_GradientTexture);
            Texture inputFrame = InputSequence.RequestFrame(frame).texture;

            m_Material.SetTexture("_MainTex", inputFrame);

            m_Material.SetFloat("_Mode", (int)settings.ColorSource);

            m_Material.SetTexture("_Gradient", m_GradientTexture);

            ExecuteShaderAndDump(frame, inputFrame);
            return(true);
        }
Пример #12
0
        public override bool Process(int frame)
        {
            if (m_CurveTexture == null)
            {
                InitTexture();
            }

            CurveToTextureUtility.CurveToTexture(settings.AlphaCurve, ref m_CurveTexture);
            Texture inputFrame = InputSequence.RequestFrame(frame).texture;

            m_Material.SetTexture("_MainTex", inputFrame);
            m_Material.SetFloat("_Brightness", settings.Brightness);
            m_Material.SetFloat("_Contrast", settings.Contrast);
            m_Material.SetFloat("_Saturation", settings.Saturation);

            m_Material.SetTexture("_AlphaCurve", m_CurveTexture);

            ExecuteShaderAndDump(frame, inputFrame);
            return(true);
        }
Пример #13
0
        public override bool Process(int frame)
        {
            Texture texture = InputSequence.RequestFrame(0).texture;

            m_Material.SetTexture("_MainTex", texture);
            Vector4 rect = new Vector4();

            int u = Mathf.Min(settings.FlipbookNumU, texture.width);
            int v = Mathf.Min(settings.FlipbookNumV, texture.height);

            int x = frame % settings.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;

            m_Material.SetVector("_Rect", rect);
            ExecuteShaderAndDump(frame, texture);
            return(true);
        }
Пример #14
0
        public override bool Process(int frame)
        {
            int inputlength  = InputSequence.length;
            int outputlength = GetProcessorSequenceLength();

            float t = (float)frame / outputlength;

            float blendFactor = Mathf.Clamp(settings.curve.Evaluate(t), 0.0f, 1.0f);

            int Prev = Mathf.Clamp((int)Mathf.Ceil(settings.syncFrame + frame), 0, inputlength - 1);
            int Next = Mathf.Clamp((int)Mathf.Floor(settings.syncFrame - (outputlength - frame)), 0, inputlength - 1);

            Texture prevtex = InputSequence.RequestFrame(Prev).texture;
            Texture nexttex = InputSequence.RequestFrame(Next).texture;

            m_Material.SetTexture("_MainTex", prevtex);
            m_Material.SetTexture("_AltTex", nexttex);
            m_Material.SetFloat("_BlendFactor", blendFactor);

            ExecuteShaderAndDump(frame, prevtex);
            return(true);
        }
Пример #15
0
        public override bool Process(int frame)
        {
            int length = InputSequence.length;

            RenderTexture backup = RenderTexture.active;

            switch (settings.Mode)
            {
            case AssembleProcessorSettings.AssembleMode.FullSpriteSheet:

                // Blit Every Image inside output
                for (int i = 0; i < (settings.FlipbookNumU * settings.FlipbookNumV); i++)
                {
                    int u = i % settings.FlipbookNumU;
                    int v = (settings.FlipbookNumV - 1) - (int)Mathf.Floor((float)i / settings.FlipbookNumU);

                    Vector2 size = new Vector2(1.0f / settings.FlipbookNumU, 1.0f / settings.FlipbookNumV);
                    int     idx  = Mathf.Clamp(i, 0, length - 1);

                    Texture currentTexture = InputSequence.RequestFrame(idx).texture;

                    Vector4 ClipCoordinates = new Vector4(u * size.x, v * size.y, size.x, size.y);

                    m_Material.SetTexture("_MainTex", currentTexture);
                    m_Material.SetVector("_CC", ClipCoordinates);

                    Graphics.Blit(currentTexture, (RenderTexture)m_OutputSequence.frames[0].texture, m_Material);
                }

                RenderTexture.active = backup;

                break;

            case AssembleProcessorSettings.AssembleMode.VerticalSequence:

                // Blit Every N'th Image inside output
                int cycleLength = InputSequence.length / settings.FlipbookNumV;

                for (int i = 0; i < settings.FlipbookNumV; i++)
                {
                    int u = 0;
                    int v = settings.FlipbookNumV - 1 - i;

                    Vector2 size = new Vector2(1.0f, 1.0f / settings.FlipbookNumV);
                    int     idx  = Mathf.Clamp((i * cycleLength) + frame, 0, length - 1);

                    Texture currentTexture = InputSequence.RequestFrame(idx).texture;

                    Vector4 ClipCoordinates = new Vector4(u * size.x, v * size.y, size.x, size.y);

                    m_Material.SetTexture("_MainTex", currentTexture);
                    m_Material.SetVector("_CC", ClipCoordinates);

                    Graphics.Blit(currentTexture, (RenderTexture)m_OutputSequence.frames[frame].texture, m_Material);
                }

                RenderTexture.active = backup;
                break;
            }

            return(true);
        }
Пример #16
0
        public override bool OnCanvasGUI(ImageSequencerCanvas canvas)
        {
            int inLength  = InputSequence.length;
            int outLength = GetProcessorSequenceLength();
            int syncFrame = settings.syncFrame;

            int   outCurIDX = canvas.currentFrameIndex;
            float outCurT   = (float)outCurIDX / outLength;
            int   inSeqAIDX = (syncFrame - outLength) + outCurIDX;
            int   inSeqBIDX = syncFrame + outCurIDX;

            AnimationCurve mixCurve = settings.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, 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, 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);
        }