Пример #1
0
        public override void Interp(Texture from, Texture to, float t)
        {
            // Both are null, do nothing
            if (from == null && to == null)
            {
                value = null;
                return;
            }

            // Both aren't null we're ready to blend
            if (from != null && to != null)
            {
                value = TextureLerper.instance.Lerp(from, to, t);
                return;
            }

            // One of them is null, blend to/from a default value is applicable
            {
                Texture defaultTexture;

                switch (defaultState)
                {
                case TextureParameterDefault.Black:
                    defaultTexture = RuntimeUtilities.blackTexture;
                    break;

                case TextureParameterDefault.White:
                    defaultTexture = RuntimeUtilities.whiteTexture;
                    break;

                case TextureParameterDefault.Transparent:
                    defaultTexture = RuntimeUtilities.transparentTexture;
                    break;

                case TextureParameterDefault.Lut2D:
                    // Find the current lut size
                    int size = from != null ? from.height : to.height;
                    defaultTexture = RuntimeUtilities.GetLutStrip(size);
                    break;

                default:
                    defaultTexture = null;
                    break;
                }

                if (from == null)
                {
                    from = defaultTexture;
                }
                if (to == null)
                {
                    to = defaultTexture;
                }

                // defaultState could have been explicitly set to None
                if (from == null || to == null)
                {
                    base.Interp(from, to, t);
                    return;
                }

                value = TextureLerper.instance.Lerp(from, to, t);
            }
        }
Пример #2
0
        public override void Interp(Texture from, Texture to, float t)
        {
            // Both are null, do nothing
            if (from == null && to == null)
            {
                value = null;
                return;
            }

            // Both aren't null we're ready to blend
            if (from != null && to != null)
            {
                value = TextureLerper.instance.Lerp(from, to, t);
                return;
            }

            // One of them is null, blend to/from a default value is applicable
            {
                if (defaultState == TextureParameterDefault.Lut2D)
                {
                    int     size           = from != null ? from.height : to.height;
                    Texture defaultTexture = RuntimeUtilities.GetLutStrip(size);

                    if (from == null)
                    {
                        from = defaultTexture;
                    }
                    if (to == null)
                    {
                        to = defaultTexture;
                    }
                }

                Color tgtColor;

                switch (defaultState)
                {
                case TextureParameterDefault.Black:
                    tgtColor = Color.black;
                    break;

                case TextureParameterDefault.White:
                    tgtColor = Color.white;
                    break;

                case TextureParameterDefault.Transparent:
                    tgtColor = Color.clear;
                    break;

                case TextureParameterDefault.Lut2D:
                {
                    // Find the current lut size
                    int     size           = from != null ? from.height : to.height;
                    Texture defaultTexture = RuntimeUtilities.GetLutStrip(size);
                    if (from == null)
                    {
                        from = defaultTexture;
                    }
                    if (to == null)
                    {
                        to = defaultTexture;
                    }

                    value = TextureLerper.instance.Lerp(from, to, t);
                    // All done, return
                    return;
                }

                default:
                    // defaultState is none, so just interpolate the base and return
                    base.Interp(from, to, t);
                    return;
                }
                // If we made it this far, tgtColor contains the color we'll be lerping into (or out of)
                if (from == null)
                {
                    // color -> texture lerp, invert ratio
                    value = TextureLerper.instance.Lerp(to, tgtColor, 1f - t);
                }
                else
                {
                    value = TextureLerper.instance.Lerp(from, tgtColor, t);
                }
            }
        }
Пример #3
0
        public override void Interp(Texture from, Texture to, float t)
        {
            if (from == null && to == null)
            {
                value = null;
                return;
            }
            if (from != null && to != null)
            {
                value = TextureLerper.instance.Lerp(from, to, t);
                return;
            }
            if (defaultState == TextureParameterDefault.Lut2D)
            {
                int     size     = (!(from != null)) ? to.height : from.height;
                Texture lutStrip = RuntimeUtilities.GetLutStrip(size);
                if (from == null)
                {
                    from = lutStrip;
                }
                if (to == null)
                {
                    to = lutStrip;
                }
            }
            Color to2;

            switch (defaultState)
            {
            case TextureParameterDefault.Black:
                to2 = Color.black;
                break;

            case TextureParameterDefault.White:
                to2 = Color.white;
                break;

            case TextureParameterDefault.Transparent:
                to2 = Color.clear;
                break;

            case TextureParameterDefault.Lut2D:
            {
                int     size2     = (!(from != null)) ? to.height : from.height;
                Texture lutStrip2 = RuntimeUtilities.GetLutStrip(size2);
                if (from == null)
                {
                    from = lutStrip2;
                }
                if (to == null)
                {
                    to = lutStrip2;
                }
                value = TextureLerper.instance.Lerp(from, to, t);
                return;
            }

            default:
                base.Interp(from, to, t);
                return;
            }
            if (from == null)
            {
                value = TextureLerper.instance.Lerp(to, to2, 1f - t);
            }
            else
            {
                value = TextureLerper.instance.Lerp(from, to2, t);
            }
        }