public static ChannelInfo Convert(IExportContainer container, ChannelInfo origin)
        {
            ChannelInfo instance = origin;

            if (origin.IsSet)
            {
                if (VertexFormatExtensions.VertexFormat2019Relevant(container.Version))
                {
                }
                else if (ShaderChannelExtensions.ShaderChannel5Relevant(container.Version))
                {
                    if (VertexFormatExtensions.VertexFormat2019Relevant(container.ExportVersion))
                    {
                        instance.Format = origin.GetVertexFormat(container.Version).ToFormat(container.ExportVersion);
                    }
                }
                else
                {
                    if (container.ExportVersion.IsGreaterEqual(5))
                    {
                        VertexChannelFormat formatv4 = (VertexChannelFormat)origin.Format;
                        instance.Format = formatv4.ToVertexFormat().ToFormat(container.ExportVersion);
                        if (formatv4 == VertexChannelFormat.Color)
                        {
                            // replace Color4b[1] to Color1b[4]
                            instance.RawDimension = (byte)(instance.Dimension * 4);
                        }
                    }
                }
            }
            return(instance);
        }
Beispiel #2
0
        public static VertexFormat ToVertexFormat(this VertexChannelFormat _this)
        {
            switch (_this)
            {
            case VertexChannelFormat.Float:
                return(VertexFormat.Float);

            case VertexChannelFormat.Float16:
                return(VertexFormat.Float16);

            case VertexChannelFormat.Color:
                return(VertexFormat.Color);

            default:
                throw new Exception(_this.ToString());
            }
        }
Beispiel #3
0
        public static ChannelInfo Convert(IExportContainer container, ChannelInfo origin)
        {
            ChannelInfo instance = origin;

            if (origin.IsSet)
            {
                if (container.Version.IsLess(5))
                {
                    if (container.ExportVersion.IsGreaterEqual(5))
                    {
                        VertexChannelFormat formatv4 = (VertexChannelFormat)origin.Format;
                        if (formatv4 == VertexChannelFormat.Color)
                        {
                            // replace Color[1] to Byte[4]
                            instance.Format       = VertexFormat.Byte.ToFormat(container.ExportVersion);
                            instance.RawDimension = (byte)((instance.RawDimension & 0xF0) | (instance.Dimension * 4));
                        }
                        else
                        {
                            instance.Format = formatv4.ToVertexFormat().ToFormat(container.ExportVersion);
                        }
                    }
                }
                else if (container.Version.IsLess(2019))
                {
                    if (container.ExportVersion.IsGreaterEqual(2019))
                    {
                        instance.Format = origin.GetVertexFormat(container.Version).ToFormat(container.ExportVersion);
                    }
                }
                else                 // Version >= 2019
                {
                    // TEMP: downgrade
                    if (container.ExportVersion.IsLess(2019))
                    {
                        instance.Format = origin.GetVertexFormat(container.Version).ToFormat(container.ExportVersion);
                    }
                }
            }
            return(instance);
        }