예제 #1
0
        public MTAlphaBlend(BinaryReader Reader)
        {
            //First 4 bytes seems to use bit 0 for something else, so we need to rsh the value by 1?
            BlendMode = (PICABlendMode)(Reader.ReadByte() >> 1);

            MTBlendFunction   ColorSrcFunc = (MTBlendFunction)(Reader.ReadByte() >> 1);
            MTBlendFunction   ColorDstFunc = (MTBlendFunction)(Reader.ReadByte() >> 1);
            PICABlendEquation ColorEqu     = (PICABlendEquation)(Reader.ReadByte() >> 1);

            MTBlendFunction   AlphaSrcFunc = (MTBlendFunction)Reader.ReadByte();
            MTBlendFunction   AlphaDstFunc = (MTBlendFunction)Reader.ReadByte();
            PICABlendEquation AlphaEqu     = (PICABlendEquation)Reader.ReadByte();

            byte Padding = Reader.ReadByte(); //?

            byte[] BufferRW =
            {
                Reader.ReadByte(),
                Reader.ReadByte(), //Always 0xf?
                Reader.ReadByte(), //Always 0xf?
                Reader.ReadByte(), //Always 0xf?
                Reader.ReadByte(), //Always 0xf?
                Reader.ReadByte(), //Always 0xf?
                Reader.ReadByte(), //Always 0xf?
                Reader.ReadByte()  //Always 0xf?
            };

            BlendFunction.ColorEquation = ColorEqu;
            BlendFunction.AlphaEquation = AlphaEqu;

            BlendFunction.ColorSrcFunc = ColorSrcFunc.ToPICABlendFunc(false);
            BlendFunction.ColorDstFunc = ColorDstFunc.ToPICABlendFunc(false);

            BlendFunction.AlphaSrcFunc = ColorSrcFunc.ToPICABlendFunc(true);
            BlendFunction.AlphaDstFunc = ColorDstFunc.ToPICABlendFunc(true);

            RedWrite   = (BufferRW[0] & 1) != 0;
            GreenWrite = (BufferRW[0] & 2) != 0;
            BlueWrite  = (BufferRW[0] & 4) != 0;
            AlphaWrite = (BufferRW[0] & 8) != 0;
        }
예제 #2
0
        public static PICABlendFunc ToPICABlendFunc(this MTBlendFunction BlendFunc, bool Alpha)
        {
            switch (BlendFunc)
            {
            case MTBlendFunction.Zero:                return(PICABlendFunc.Zero);

            case MTBlendFunction.One:                 return(PICABlendFunc.One);

            case MTBlendFunction.SourceColor:         return(PICABlendFunc.SourceColor);

            case MTBlendFunction.InvSourceColor:      return(PICABlendFunc.OneMinusSourceColor);

            case MTBlendFunction.SourceAlpha:         return(PICABlendFunc.SourceAlpha);

            case MTBlendFunction.InvSourceAlpha:      return(PICABlendFunc.OneMinusSourceAlpha);

            case MTBlendFunction.DestAlpha:           return(PICABlendFunc.DestinationAlpha);

            case MTBlendFunction.InvDestAlpha:        return(PICABlendFunc.OneMinusDestinationAlpha);

            case MTBlendFunction.DestColor:           return(PICABlendFunc.DestinationColor);

            case MTBlendFunction.InvDestColor:        return(PICABlendFunc.OneMinusDestinationColor);

            case MTBlendFunction.SourceAlphaSaturate: return(PICABlendFunc.SourceAlphaSaturate);

            case MTBlendFunction.BlendFactor:
                return(Alpha
                        ? PICABlendFunc.ConstantAlpha
                        : PICABlendFunc.ConstantColor);

            case MTBlendFunction.InvBlendFactor:
                return(Alpha
                        ? PICABlendFunc.OneMinusConstantAlpha
                        : PICABlendFunc.OneMinusConstantColor);

            default: throw new ArgumentException("Invalid Blending Function value!");
            }
        }