/*
        struct SurfaceOutput {
            half3 Albedo;
            half3 Normal;
            half3 Emission;
            half Specular;
            half Gloss;
            half Alpha;
        };
        */
        public ShaderCodeBuilder(MaterialContainer mc, MeshContainer mesh)
        {
            float f1 = 1;
            f1.GetType();
            _normalizeNormals = true;
            if (mesh != null)
                AnalyzeMesh(mesh);
            else
            {
                _hasVertices = _hasNormals = _hasUVs = true;
            }
            AnalyzeMaterial(mc);

            StringBuilder vs = new StringBuilder();
            MeshInputDeclarations(vs);
            MatrixDeclarations(vs);
            VSBody(vs);
            _vs = vs.ToString();

            StringBuilder ps = new StringBuilder();
            PixelInputDeclarations(ps);
            PSBody(ps);
            _ps = ps.ToString();
        }
 private void AnalyzeMesh(MeshContainer mesh)
 {
     _hasVertices = (mesh.Vertices != null && mesh.Vertices.Length > 0);
     _hasNormals = (mesh.Normals != null && mesh.Normals.Length > 0);
     _hasUVs = (mesh.UVs != null && mesh.UVs.Length > 0);
     _hasColors = false;
     // _hasColors = (mesh.Colors != null && mesh.Colors.Length > 0);
 }
        private void TestDeserialize()
        {
            var ser = new Serializer();
            SceneContainer mc2;
            using (var file = File.OpenRead(@"Assets/Test.fus"))
            {
                mc2 = ser.Deserialize(file, null, typeof(SceneContainer)) as SceneContainer;
            }
            /**/
            Diagnostics.Log(mc2.ToString());
        }

        private void TestSerialize()
        {
            /**/
            var aMesh = new MeshContainer
            {
                Vertices = new[]
                {
                    new float3(-1, -1, -1),
                    new float3(-1, -1, 1),
                    new float3(-1, 1, -1),
                    new float3(1, -1, -1),
                    new float3(1, 1, 1),
                    new float3(-1, 1, 1),
                    new float3(1, -1, 1),
                    new float3(1, 1, -1),
                },
                Normals = new[]
                {
                    new float3(-1, -1, -1),
                    new float3(-1, -1, 1),
                    new float3(-1, 1, -1),
                    new float3(1, -1, -1),
                    new float3(1, 1, 1),
                    new float3(-1, 1, 1),
                    new float3(1, -1, 1),
                    new float3(1, 1, -1),
                },
                Triangles = new ushort[]
                {
                    0, 1, 2,
                    0, 2, 3,
                    0, 3, 1,
                    4, 5, 6,
                    4, 6, 7,
                    4, 7, 5,
                }
            };

            var aChild = new SceneObjectContainer()
            {
                Mesh = aMesh,
                Transform = new TransformContainer(){Rotation = new float3(0, 0, 0), Translation = new float3(0.11f, 0.11f, 0), Scale = new float3(1, 1, 1)}
            };

            var parent = new SceneContainer()
            {
                Header = new SceneHeader()
                {
                    Version = 1,
                    Generator = "Fusee.SceneViewer",
                    CreatedBy = "FuseeProjetTeam"
                },
                Children = new List<SceneObjectContainer>(new SceneObjectContainer[]
                {
                    aChild,
                    aChild,
                    new SceneObjectContainer()
                    {
                        Mesh = aMesh,
                        Transform = new TransformContainer(){Rotation = new float3(0, 0, 0), Translation = new float3(0.22f, 0.22f, 0), Scale = new float3(1, 1, 1)}
                    },
                }),
            };
            var ser = new Serializer();
            using (var file = File.Create(@"Assets/Test.fus"))
            {
                ser.Serialize(file, parent);
            }
        }