public static FragmentOperationContainer Load(Utility utility)
        {
            var foc = new FragmentOperationContainer();

            CGFXDebug.LoadStart(foc, utility);

            ///////// DEPTH /////////
            // See also SPICA GfxFragOp / GfxFragOpDepth
            foc.DepthFlags           = utility.ReadU32();
            foc.DepthPICACommandsRaw = utility.ReadUInts(4);


            ///////// BLEND /////////
            // See also SPICA GfxFragOp / GfxFragOpBlend
            foc.BlendMode            = (BlendModeType)utility.ReadU32();
            foc.BlendColor           = ColorFloat.Read(utility);
            foc.BlendPICACommandsRaw = utility.ReadUInts(6);


            ///////// STENCIL /////////
            // See also SPICA GfxFragOp / GfxFragOpStencil
            foc.StencilOperationRaw = utility.ReadUInts(4);

            return(foc);
        }
Exemple #2
0
        public static new PlacedText ReadFrom(System.IO.BinaryReader reader)
        {
            if (reader == null)
            {
                throw new System.ArgumentNullException(nameof(reader));
            }

            var           text = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(reader.ReadInt32()));
            var           pos  = Vec2Float.ReadFrom(reader);
            TextAlignment alignment;

            switch (reader.ReadInt32())
            {
            case 0:
                alignment = TextAlignment.Left;
                break;

            case 1:
                alignment = TextAlignment.Center;
                break;

            case 2:
                alignment = TextAlignment.Right;
                break;

            default:
                throw new System.Exception("Unexpected discriminant value");
            }

            var size  = reader.ReadSingle();
            var color = ColorFloat.ReadFrom(reader);

            return(new PlacedText(text, pos, alignment, size, color));
        }
        public static MaterialColorContainer Load(Utility utility)
        {
            var mcc = new MaterialColorContainer();

            CGFXDebug.LoadStart(mcc, utility);

            mcc.EmissionF  = ColorFloat.Read(utility);
            mcc.AmbientF   = ColorFloat.Read(utility);
            mcc.DiffuseF   = ColorFloat.Read(utility);
            mcc.Specular0F = ColorFloat.Read(utility);
            mcc.Specular1F = ColorFloat.Read(utility);
            mcc.Constant0F = ColorFloat.Read(utility);
            mcc.Constant1F = ColorFloat.Read(utility);
            mcc.Constant2F = ColorFloat.Read(utility);
            mcc.Constant3F = ColorFloat.Read(utility);
            mcc.Constant4F = ColorFloat.Read(utility);
            mcc.Constant5F = ColorFloat.Read(utility);

            mcc.Emission  = Color.Read(utility);
            mcc.Ambient   = Color.Read(utility);
            mcc.Diffuse   = Color.Read(utility);
            mcc.Specular0 = Color.Read(utility);
            mcc.Specular1 = Color.Read(utility);
            mcc.Constant0 = Color.Read(utility);
            mcc.Constant1 = Color.Read(utility);
            mcc.Constant2 = Color.Read(utility);
            mcc.Constant3 = Color.Read(utility);
            mcc.Constant4 = Color.Read(utility);
            mcc.Constant5 = Color.Read(utility);

            mcc.CommandCache = utility.ReadU32();

            return(mcc);
        }
Exemple #4
0
 public Line(Vec2Float p1, Vec2Float p2, float width, ColorFloat color)
 {
     P1    = p1;
     P2    = p2;
     Width = width;
     Color = color;
 }
Exemple #5
0
            public static new PlacedText ReadFrom(System.IO.BinaryReader reader)
            {
                var result = new PlacedText();

                result.Text = System.Text.Encoding.UTF8.GetString(reader.ReadBytes(reader.ReadInt32()));
                result.Pos  = Vec2Float.ReadFrom(reader);
                switch (reader.ReadInt32())
                {
                case 0:
                    result.Alignment = TextAlignment.Left;
                    break;

                case 1:
                    result.Alignment = TextAlignment.Center;
                    break;

                case 2:
                    result.Alignment = TextAlignment.Right;
                    break;

                default:
                    throw new System.Exception("Unexpected discriminant value");
                }
                result.Size  = reader.ReadSingle();
                result.Color = ColorFloat.ReadFrom(reader);
                return(result);
            }
Exemple #6
0
        public static TextureSampler Load(TextureMapper parent, Utility utility)
        {
            var s = new TextureSampler();

            CGFXDebug.LoadStart(s, utility);

            // This has a TypeId here...
            s.TypeId = utility.ReadU32();
            if (s.TypeId != 0x80000000)
            {
                throw new InvalidOperationException($"TextureSampler: Expected type 0x80000000, got {s.TypeId}");
            }

            // Just reading the offset but we'll resolve this later
            var ownerModelOffset = utility.ReadOffset();

            s.Parent = parent;

            s.MinFilter = (TextureMinFilter)utility.ReadU32();

            s.BorderColor = ColorFloat.Read(utility);
            s.LODBias     = utility.ReadFloat();

            return(s);
        }
Exemple #7
0
        public static ColoredVertex ReadFrom(System.IO.BinaryReader reader)
        {
            var result = new ColoredVertex();

            result.Position = Vec2Float.ReadFrom(reader);
            result.Color    = ColorFloat.ReadFrom(reader);
            return(result);
        }
Exemple #8
0
 public PlacedText(string text, Vec2Float pos, TextAlignment alignment, float size, ColorFloat color)
 {
     Text      = text;
     Pos       = pos;
     Alignment = alignment;
     Size      = size;
     Color     = color;
 }
Exemple #9
0
            public static new Rect ReadFrom(System.IO.BinaryReader reader)
            {
                var result = new Rect();

                result.Pos   = Vec2Float.ReadFrom(reader);
                result.Size  = Vec2Float.ReadFrom(reader);
                result.Color = ColorFloat.ReadFrom(reader);
                return(result);
            }
Exemple #10
0
        public static ColorFloat ReadFrom(System.IO.BinaryReader reader)
        {
            var result = new ColorFloat();

            result.R = reader.ReadSingle();
            result.G = reader.ReadSingle();
            result.B = reader.ReadSingle();
            result.A = reader.ReadSingle();
            return(result);
        }
Exemple #11
0
            public static new Line ReadFrom(System.IO.BinaryReader reader)
            {
                var result = new Line();

                result.P1    = Vec2Float.ReadFrom(reader);
                result.P2    = Vec2Float.ReadFrom(reader);
                result.Width = reader.ReadSingle();
                result.Color = ColorFloat.ReadFrom(reader);
                return(result);
            }
Exemple #12
0
        public static FragmentShader Load(Utility utility)
        {
            var fs = new FragmentShader();

            CGFXDebug.LoadStart(fs, utility);

            fs.TexEnvBufferColorF = ColorFloat.Read(utility);

            // Fragment Shader
            fs.FragmentFlags     = utility.ReadU32();
            fs.TranslucencyKind  = (TranslucencyKind)utility.ReadU32();
            fs.FresnelSelector   = (GfxFresnelSelector)utility.ReadU32();
            fs.BumpTexture       = utility.ReadI32();
            fs.BumpMode          = (GfxBumpMode)utility.ReadU32();
            fs.IsBumpRenormalize = utility.ReadU32() == 1;

            // Fragment Lighting
            CGFXDebug.LoadStart($"HEADER of list of FragLightLUTs", utility);
            utility.LoadIndirect(() =>
            {
                CGFXDebug.LoadStart($"List of FragLightLUTs", utility);
                fs.ReflectanceRSampler  = GetFragLightLUT(utility);
                fs.ReflectanceGSampler  = GetFragLightLUT(utility);
                fs.ReflectanceBSampler  = GetFragLightLUT(utility);
                fs.Distribution0Sampler = GetFragLightLUT(utility);
                fs.Distribution1Sampler = GetFragLightLUT(utility);
                fs.FresnelSampler       = GetFragLightLUT(utility);
            });

            fs.TextureEnvironments = new TexEnv[6];
            for (var i = 0; i < fs.TextureEnvironments.Length; i++)
            {
                fs.TextureEnvironments[i] = TexEnv.Load(utility);
            }

            fs.AlphaTestRawCommands = utility.ReadUInts(2);

            fs.FragmentShaderRawCommands = utility.ReadUInts(6);

            return(fs);
        }
Exemple #13
0
 public Metal(float r, float g, float b, float roughness = 0.0f)
     : this(ColorFloat.FromARGB(r, g, b), roughness)
 {
 }
Exemple #14
0
 public ColoredVertex(Vec2Float position, ColorFloat color)
 {
     Position = position;
     Color    = color;
 }
Exemple #15
0
 public Metal(ColorFloat albedo, float roughness = 0.0f)
 {
     Albedo    = albedo;
     Roughness = MathUtils.Clamp(roughness, 0, 1);
 }
Exemple #16
0
 public Dielectric(ColorFloat refractedColor, float refractiveIndex)
 {
     RefractedColor  = refractedColor;
     RefractiveIndex = refractiveIndex;
 }
Exemple #17
0
        public static new Line ReadFrom(System.IO.BinaryReader reader)
        {
            if (reader == null)
            {
                throw new System.ArgumentNullException(nameof(reader));
            }

            return(new Line(Vec2Float.ReadFrom(reader), Vec2Float.ReadFrom(reader), reader.ReadSingle(), ColorFloat.ReadFrom(reader)));
        }
Exemple #18
0
 public static ColoredVertex ReadFrom(System.IO.BinaryReader reader)
 {
     return(new ColoredVertex(Vec2Float.ReadFrom(reader), ColorFloat.ReadFrom(reader)));
 }
Exemple #19
0
 public Lambertian(ColorFloat albedo)
 {
     Albedo = albedo;
 }
Exemple #20
0
 public Rect(Vec2Float pos, Vec2Float size, ColorFloat color)
 {
     Pos   = pos;
     Size  = size;
     Color = color;
 }
Exemple #21
0
 public static new Rect ReadFrom(System.IO.BinaryReader reader)
 {
     return(new Rect(Vec2Float.ReadFrom(reader), Vec2Float.ReadFrom(reader), ColorFloat.ReadFrom(reader)));
 }
Exemple #22
0
 public Lambertian(float r, float g, float b)
     : this(ColorFloat.FromARGB(r, g, b))
 {
 }