예제 #1
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         if (Ambient != null)
         {
             hashCode = hashCode * 59 + Ambient.GetHashCode();
         }
         if (Diffuse != null)
         {
             hashCode = hashCode * 59 + Diffuse.GetHashCode();
         }
         if (Specular != null)
         {
             hashCode = hashCode * 59 + Specular.GetHashCode();
         }
         if (Roughness != null)
         {
             hashCode = hashCode * 59 + Roughness.GetHashCode();
         }
         if (Fresnel != null)
         {
             hashCode = hashCode * 59 + Fresnel.GetHashCode();
         }
         return(hashCode);
     }
 }
예제 #2
0
        public void CreateBabylonMaterial(BabylonScene scene)
        {
            var babylonMaterial = new BabylonMaterial();

            scene.MaterialsList.Add(babylonMaterial);

            // Guid
            babylonMaterial.id = ID.ToString();

            // Name
            babylonMaterial.name = Name;

            // Data
            babylonMaterial.backFaceCulling = BackFaceCulling;
            babylonMaterial.diffuse         = Diffuse.ToArray();
            babylonMaterial.emissive        = Emissive.ToArray();
            babylonMaterial.specular        = Specular.ToArray();
            babylonMaterial.specularPower   = SpecularPower;
            babylonMaterial.alpha           = Alpha;

            if (string.IsNullOrEmpty(DiffuseTexture))
            {
                babylonMaterial.diffuseTexture = null;
                return;
            }

            babylonMaterial.diffuseTexture      = new BabylonTexture();
            babylonMaterial.diffuseTexture.name = Path.GetFileName(DiffuseTexture);

            scene.AddTexture(DiffuseTexture);
        }
예제 #3
0
        /// <summary>
        /// Determines whether the specified <see cref="MaterialPalette"/> is equal to the current <see cref="UFLT.Records.MaterialPalette"/>.
        /// </summary>
        /// <param name='other'>
        /// The <see cref="MaterialPalette"/> to compare with the current <see cref="UFLT.Records.MaterialPalette"/>.
        /// </param>
        /// <returns>
        /// <c>true</c> if the specified <see cref="MaterialPalette"/> is equal to the current
        /// <see cref="UFLT.Records.MaterialPalette"/>; otherwise, <c>false</c>.
        /// </returns>
        public bool Equals(MaterialPalette other)
        {
            // Check color fields
            if (!Ambient.Equals(other.Ambient))
            {
                return(false);
            }
            if (!Diffuse.Equals(other.Diffuse))
            {
                return(false);
            }
            if (!Specular.Equals(other.Specular))
            {
                return(false);
            }
            if (!Emissive.Equals(other.Emissive))
            {
                return(false);
            }

            if (Mathf.Approximately(Shininess, other.Shininess))
            {
                return(false);
            }
            if (Mathf.Approximately(Alpha, other.Alpha))
            {
                return(false);
            }

            return(true);
        }
예제 #4
0
 public bool Equals(Material other)
 {
     return(Color.Equals(other.Color) &&
            Ambient.Equals(other.Ambient) &&
            Diffuse.Equals(other.Diffuse) &&
            Specular.Equals(other.Specular) &&
            Shininess.Equals(other.Shininess));
 }
 public void Dispose()
 {
     Diffuse?.Dispose();
     Ambient?.Dispose();
     Normal?.Dispose();
     Specular?.Dispose();
     Reflection?.Dispose();
 }
 public virtual void Visit(MaterialGeneratorContext context)
 {
     Surface.Visit(context);
     MicroSurface.Visit(context);
     Diffuse.Visit(context);
     DiffuseModel.Visit(context);
     Specular.Visit(context);
     SpecularModel.Visit(context);
 }
예제 #7
0
파일: Material.cs 프로젝트: heo732/U3DSpace
 public override int GetHashCode()
 {
     return((int)(
                (Name.GetHashCode() * 3) +
                (Ambient.GetHashCode() * 5) +
                (Diffuse.GetHashCode() * 7) +
                (Specular.GetHashCode() * 11) +
                (Emissive.GetHashCode() * 13) +
                (Reflectivity * 17) +
                (Opacity * 19)));
 }
        public override void Accept(ShaderGeneratorContext context)
        {
            base.Accept(context);

            Surface.Accept(context);
            MicroSurface.Accept(context);
            Diffuse.Accept(context);
            DiffuseModel.Accept(context);
            Specular.Accept(context);
            SpecularModel.Accept(context);
        }
예제 #9
0
        public override int GetHashCode()
        {
            int hashCode = -2043694805;

            hashCode = hashCode * -1521134295 + Ambient.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <Color> .Default.GetHashCode(Color);

            hashCode = hashCode * -1521134295 + Diffuse.GetHashCode();
            hashCode = hashCode * -1521134295 + Shininess.GetHashCode();
            hashCode = hashCode * -1521134295 + Specular.GetHashCode();
            return(hashCode);
        }
예제 #10
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Ambient.GetHashCode();
         hashCode = (hashCode * 397) ^ Color.Truncate().GetHashCode();
         hashCode = (hashCode * 397) ^ Diffuse.Truncate().GetHashCode();
         hashCode = (hashCode * 397) ^ Shininess.Truncate().GetHashCode();
         hashCode = (hashCode * 397) ^ Specular.Truncate().GetHashCode();
         return(hashCode);
     }
 }
예제 #11
0
        public odfMaterialPropertySet Clone()
        {
            odfMaterialPropertySet prop = new odfMaterialPropertySet();

            prop.Unknown1      = Unknown1;
            prop.Diffuse       = new Color4(Diffuse.ToVector4());
            prop.Ambient       = new Color4(Ambient.ToVector4());
            prop.Specular      = new Color4(Specular.ToVector4());
            prop.Emissive      = new Color4(Emissive.ToVector4());
            prop.SpecularPower = SpecularPower;
            return(prop);
        }
예제 #12
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Pattern != null ? Pattern.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Ambient.GetHashCode();
         hashCode = (hashCode * 397) ^ Diffuse.GetHashCode();
         hashCode = (hashCode * 397) ^ Specular.GetHashCode();
         hashCode = (hashCode * 397) ^ Reflective.GetHashCode();
         hashCode = (hashCode * 397) ^ Shininess;
         return(hashCode);
     }
 }
예제 #13
0
        /// <summary>
        /// Generator instantiation for method specific shaders.
        /// </summary>
        public DecalGenerator(Albedo albedo, Blend_Mode blend_mode, Render_Pass render_pass, Specular specular, Bump_Mapping bump_mapping, Tinting tinting, bool applyFixes = false)
        {
            this.albedo       = albedo;
            this.blend_mode   = blend_mode;
            this.render_pass  = render_pass;
            this.specular     = specular;
            this.bump_mapping = bump_mapping;
            this.tinting      = tinting;

            ApplyFixes              = applyFixes;
            DecalIsSimple           = this.render_pass == Render_Pass.Pre_Lighting && this.bump_mapping == Bump_Mapping.Leave;
            TemplateGenerationValid = true;
        }
예제 #14
0
        public DecalGenerator(byte[] options, bool applyFixes = false)
        {
            this.albedo       = (Albedo)options[0];
            this.blend_mode   = (Blend_Mode)options[1];
            this.render_pass  = (Render_Pass)options[2];
            this.specular     = (Specular)options[3];
            this.bump_mapping = (Bump_Mapping)options[4];
            this.tinting      = (Tinting)options[5];

            ApplyFixes              = applyFixes;
            DecalIsSimple           = this.render_pass == Render_Pass.Pre_Lighting && this.bump_mapping == Bump_Mapping.Leave;
            TemplateGenerationValid = true;
        }
예제 #15
0
 public override int GetHashCode()
 {
     return
         (Color.GetHashCode() ^
          Ambient.GetHashCode() ^
          Diffuse.GetHashCode() ^
          Specular.GetHashCode() ^
          Shininess.GetHashCode() ^
          Pattern.GetHashCode() ^
          Reflective.GetHashCode() ^
          Transparency.GetHashCode() ^
          RefractiveIndex.GetHashCode());
 }
예제 #16
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Color != null?Color.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ Ambient.GetHashCode();
                hashCode = (hashCode * 397) ^ Diffuse.GetHashCode();
                hashCode = (hashCode * 397) ^ Specular.GetHashCode();
                hashCode = (hashCode * 397) ^ Shininess.GetHashCode();
                return(hashCode);
            }
        }
예제 #17
0
        private void Update(EvaluationContext context)
        {
            // Parameters
            var parameterBufferContent = new PbrMaterialParams
            {
                BaseColor     = BaseColor.GetValue(context),
                EmissiveColor = EmissiveColor.GetValue(context),
                Roughness     = Roughness.GetValue(context),
                Specular      = Specular.GetValue(context),
                Metal         = Metal.GetValue(context)
            };

            ResourceManager.Instance().SetupConstBuffer(parameterBufferContent, ref _parameterBuffer);

            // Textures
            var resourceManager = ResourceManager.Instance();
            var device          = resourceManager.Device;

            Utilities.Dispose(ref _baseColorMapSrv);
            var tex = BaseColorMap.GetValue(context) ?? PbrContextSettings.WhitePixelTexture;

            _baseColorMapSrv = new ShaderResourceView(device, tex);
            context.PbrMaterialTextures.AlbedoColorMap = _baseColorMapSrv;

            Utilities.Dispose(ref _normalMapSrv);
            var tex2 = NormalMap.GetValue(context) ?? PbrContextSettings.NormalFallbackTexture;

            _normalMapSrv = new ShaderResourceView(device, tex2);
            context.PbrMaterialTextures.NormalMap = _normalMapSrv;

            Utilities.Dispose(ref _rsmoMapSrv);
            var tex3 = RoughnessSpecularMetallicOcclusionMap.GetValue(context) ?? PbrContextSettings.RsmoFallbackTexture;

            _rsmoMapSrv = new ShaderResourceView(device, tex3);
            context.PbrMaterialTextures.RoughnessSpecularMetallicOcclusionMap = _rsmoMapSrv;

            Utilities.Dispose(ref _emissiveColorMapSrv);
            var tex4 = EmissiveColorMap.GetValue(context) ?? PbrContextSettings.WhitePixelTexture;

            _emissiveColorMapSrv = new ShaderResourceView(device, tex4);
            context.PbrMaterialTextures.EmissiveColorMap = _emissiveColorMapSrv;

            var previousParameters = context.PbrMaterialParams;

            context.PbrMaterialParams = _parameterBuffer;


            SubTree.GetValue(context);
            context.PbrMaterialParams = previousParameters;
        }
예제 #18
0
        public override void Save(asStream stream)
        {
            stream.PutString(Name, 32);

            Emission.CopyTo(stream);

            Ambient.CopyTo(stream);
            Diffuse.CopyTo(stream);

            Specular.CopyTo(stream);

            stream.Put(Shininess);
            stream.Put(Reserved);
        }
예제 #19
0
        public override bool Equals(object obj)
        {
            var other = obj as Material;

            return((other != null) &&
                   (Color.Equals(other.Color)) &&
                   (Ambient.IsEqual(other.Ambient)) &&
                   (Diffuse.IsEqual(other.Diffuse)) &&
                   (Specular.IsEqual(other.Specular)) &&
                   (Shininess.IsEqual(other.Shininess)) &&
                   (Reflective.IsEqual(other.Reflective)) &&
                   (Transparency.IsEqual(other.Transparency)) &&
                   (RefractiveIndex.IsEqual(other.RefractiveIndex)));
        }
예제 #20
0
        /// <inheritdoc />
        public bool Equals([AllowNull] Lighting other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     VertexNormalsEpsilon == other.VertexNormalsEpsilon ||
                     VertexNormalsEpsilon != null &&
                     VertexNormalsEpsilon.Equals(other.VertexNormalsEpsilon)
                     ) &&
                 (
                     FaceNormalsEpsilon == other.FaceNormalsEpsilon ||
                     FaceNormalsEpsilon != null &&
                     FaceNormalsEpsilon.Equals(other.FaceNormalsEpsilon)
                 ) &&
                 (
                     Ambient == other.Ambient ||
                     Ambient != null &&
                     Ambient.Equals(other.Ambient)
                 ) &&
                 (
                     Diffuse == other.Diffuse ||
                     Diffuse != null &&
                     Diffuse.Equals(other.Diffuse)
                 ) &&
                 (
                     Specular == other.Specular ||
                     Specular != null &&
                     Specular.Equals(other.Specular)
                 ) &&
                 (
                     Roughness == other.Roughness ||
                     Roughness != null &&
                     Roughness.Equals(other.Roughness)
                 ) &&
                 (
                     Fresnel == other.Fresnel ||
                     Fresnel != null &&
                     Fresnel.Equals(other.Fresnel)
                 ));
        }
        public override PSOutput PSMain(PSInput input)
        {
            PSOutput output = base.PSMain(input);

            Surface.Compute();
            MicroSurface.Compute();
            Diffuse.Compute();
            Specular.Compute();

            ComputeSurfaceLightingAndShading();

            ShaderBaseStream.ColorTarget = new Vector4(MaterialPixelShadingStream.ShadingColor, MaterialPixelShadingStream.ShadingColorAlpha);
            output.ColorTarget           = ShaderBaseStream.ColorTarget;

            return(output);
        }
예제 #22
0
 public bool Equals(Material other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return
         (Ambient.IsEquivalentTo(other.Ambient) &&
          Color.IsEquivalentTo(other.Color) &&
          Diffuse.IsEquivalentTo(other.Diffuse) &&
          Shininess.IsEquivalentTo(other.Shininess) &&
          Specular.IsEquivalentTo(other.Specular));
 }
예제 #23
0
        public DxLight GetLight()
        {
            DxLight light = new DxLight
            {
                Type        = LightType,
                Position    = Position.ToVector3(),
                Direction   = Direction.ToVector3(),
                Ambient     = Ambient.ToVector4(),
                Diffuse     = Diffuse.ToVector4(),
                Specular    = Specular.ToVector4(),
                Attenuation = new Vector3(0.0f, 0.005f, 0.0f),
                SpotPower   = 0.001f,
                Range       = 1000f
            };

            return(light);
        }
예제 #24
0
 public override void Apply(Matrix world)
 {
     base.Apply(world);
     Effect.CurrentTechnique = Effect.Techniques[0];
     Effect.Parameters["World"].SetValue(world);
     Effect.Parameters["View"].SetValue(Camera.Current.View);
     Effect.Parameters["Projection"].SetValue(Camera.Current.Projection);
     Effect.Parameters["LightPosition"].SetValue(Light.Current.Transform.Position);
     Effect.Parameters["CameraPosition"].SetValue(Camera.Current.Transform.Position);
     Effect.Parameters["Shininess"].SetValue(Shininess);
     Effect.Parameters["AmbientColor"].SetValue(Ambient.ToVector4() * Light.Current.Ambient.ToVector4());
     Effect.Parameters["DiffuseColor"].SetValue(Diffuse.ToVector4() * Light.Current.Diffuse.ToVector4());
     Effect.Parameters["SpecularColor"].SetValue(Specular.ToVector4() * Light.Current.Specular.ToVector4());
     Effect.Parameters["Tiling"].SetValue(Tiling);
     Effect.Parameters["Offset"].SetValue(Offset);
     Effect.Parameters["DiffuseTexture"].SetValue(Texture);
     Effect.CurrentTechnique.Passes[0].Apply();
 }
예제 #25
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            DiffuseTexture.Read(reader);
            NormalMapTexture.Read(reader);
            MaskMapTexture.Read(reader);
            TileSize.Read(reader);
            TileOffset.Read(reader);
            Specular.Read(reader);
            Metallic    = reader.ReadSingle();
            Smoothness  = reader.ReadSingle();
            NormalScale = reader.ReadSingle();
            DiffuseRemapMin.Read(reader);
            DiffuseRemapMax.Read(reader);
            MaskMapRemapMin.Read(reader);
            MaskMapRemapMax.Read(reader);
        }
예제 #26
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node = base.ExportYAMLRoot(container);

            node.Add(DiffuseTextureName, DiffuseTexture.ExportYAML(container));
            node.Add(NormalMapTextureName, NormalMapTexture.ExportYAML(container));
            node.Add(MaskMapTextureName, MaskMapTexture.ExportYAML(container));
            node.Add(TileSizeName, TileSize.ExportYAML(container));
            node.Add(TileOffsetName, TileOffset.ExportYAML(container));
            node.Add(SpecularName, Specular.ExportYAML(container));
            node.Add(MetallicName, Metallic);
            node.Add(SmoothnessName, Smoothness);
            node.Add(NormalScaleName, NormalScale);
            node.Add(DiffuseRemapMinName, DiffuseRemapMin.ExportYAML(container));
            node.Add(DiffuseRemapMaxName, DiffuseRemapMax.ExportYAML(container));
            node.Add(MaskMapRemapMinName, MaskMapRemapMin.ExportYAML(container));
            node.Add(MaskMapRemapMaxName, MaskMapRemapMax.ExportYAML(container));
            return(node);
        }
예제 #27
0
 public void Validate()
 {
     if (!Color.IsColor())
     {
         throw new ArgumentException("Color is not a color", nameof(Color));
     }
     if (!Ambient.IsInUnitRange())
     {
         throw new ArgumentOutOfRangeException(nameof(Ambient));
     }
     if (!Diffuse.IsInUnitRange())
     {
         throw new ArgumentOutOfRangeException(nameof(Diffuse));
     }
     if (!Specular.IsInUnitRange())
     {
         throw new ArgumentOutOfRangeException(nameof(Specular));
     }
     if (!Shininess.IsPositive())
     {
         throw new ArgumentOutOfRangeException(nameof(Shininess));
     }
 }
예제 #28
0
        public override int GetHashCode()
        {
            var hashCode = 412502415;

            hashCode = hashCode * -1521134295 + EqualityComparer <Pattern> .Default.GetHashCode(pattern);

            hashCode = hashCode * -1521134295 + EqualityComparer <Color> .Default.GetHashCode(color);

            hashCode = hashCode * -1521134295 + ambient.GetHashCode();
            hashCode = hashCode * -1521134295 + diffuse.GetHashCode();
            hashCode = hashCode * -1521134295 + specular.GetHashCode();
            hashCode = hashCode * -1521134295 + shinniness.GetHashCode();
            hashCode = hashCode * -1521134295 + reflective.GetHashCode();
            hashCode = hashCode * -1521134295 + refractiveIndex.GetHashCode();
            hashCode = hashCode * -1521134295 + transparency.GetHashCode();
            hashCode = hashCode * -1521134295 + Ambient.GetHashCode();
            hashCode = hashCode * -1521134295 + Diffuse.GetHashCode();
            hashCode = hashCode * -1521134295 + Specular.GetHashCode();
            hashCode = hashCode * -1521134295 + Shinniness.GetHashCode();
            hashCode = hashCode * -1521134295 + Reflective.GetHashCode();
            hashCode = hashCode * -1521134295 + RefracIndex.GetHashCode();
            hashCode = hashCode * -1521134295 + Transparency.GetHashCode();
            return(hashCode);
        }
        public override PSOutput PSMain(PSInput input)
        {
            PSOutput output = base.PSMain(input);

            SamplingContext samplingContext;

            samplingContext.Sampler           = Sampler;
            samplingContext.TextureCoordinate = input.TextureCoordinate;

            uint      actualId    = input.InstanceId / RenderTargetCount;
            Matrix4x4 worldMatrix = WorldMatrices[actualId];

            ViewProjectionTransform viewProjectionTransform = ViewProjectionTransforms[input.TargetId];
            Matrix4x4 inverseViewMatrix = viewProjectionTransform.InverseViewMatrix;

            Vector3 eyePosition   = inverseViewMatrix.Translation;
            Vector4 positionWS    = input.PositionWS;
            Vector3 worldPosition = new Vector3(positionWS.X, positionWS.Y, positionWS.Z);
            Vector3 viewWS        = Vector3.Normalize(eyePosition - worldPosition);

            Vector3 materialNormal        = Surface.ComputeNormal(samplingContext);
            float   roughness             = MicroSurface.ComputeRoughness(samplingContext);
            Vector4 diffuseColorWithAlpha = Diffuse.ComputeDiffuseColor(samplingContext);
            Vector3 diffuseColor          = new Vector3(diffuseColorWithAlpha.X, diffuseColorWithAlpha.Y, diffuseColorWithAlpha.Z);
            Vector3 specularColor         = Specular.ComputeSpecularColor(samplingContext, ref diffuseColor);

            Matrix4x4 tangentToWorldMatrix = GetTangentToWorldMatrix(worldMatrix, input.Normal, input.Tangent);
            Vector3   normalWS             = Vector3.Normalize(Vector3.TransformNormal(materialNormal, tangentToWorldMatrix));

            if (!input.IsFrontFace)
            {
                normalWS = -normalWS;
            }

            Vector3 directLightingContribution = Vector3.Zero;

            for (int i = 0; i < DirectionalLights.LightCount; i++)
            {
                Vector3 lightColor     = DirectionalLights.ComputeLightColor(i);
                Vector3 lightDirection = DirectionalLights.ComputeLightDirection(i);

                MaterialShadingContext context;
                context.H              = Vector3.Normalize(viewWS + lightDirection);
                context.NDotL          = Math.Max(Vector3.Dot(normalWS, lightDirection), 0.0001f);
                context.NDotV          = Math.Max(Vector3.Dot(normalWS, viewWS), 0.0001f);
                context.NDotH          = Vector3.Dot(normalWS, context.H);
                context.LDotH          = Vector3.Dot(lightDirection, context.H);
                context.LightColor     = lightColor;
                context.DiffuseColor   = diffuseColor;
                context.SpecularColor  = specularColor;
                context.AlphaRoughness = Math.Max(roughness * roughness, 0.001f);

                directLightingContribution += DiffuseModel.ComputeDirectLightContribution(context);
                directLightingContribution += SpecularModel.ComputeDirectLightContribution(context);
            }

            Vector3 shadingColor = Vector3.Zero;

            shadingColor += directLightingContribution * (float)Math.PI;

            output.ColorTarget = new Vector4(shadingColor, diffuseColorWithAlpha.W);

            return(output);
        }
예제 #30
0
        public VertexChunk(byte[] file, int address)
            : this()
        {
            Header1 = ByteConverter.ToUInt32(file, address);
            Header2 = ByteConverter.ToUInt32(file, address + 4);
            address = address + 8;
            for (int i = 0; i < VertexCount; i++)
            {
                switch (Type)
                {
                case ChunkType.Vertex_VertexSH:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size + sizeof(float);
                    break;

                case ChunkType.Vertex_VertexNormalSH:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size + sizeof(float);
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size + sizeof(float);
                    break;

                case ChunkType.Vertex_Vertex:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    break;

                case ChunkType.Vertex_VertexDiffuse8:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Diffuse.Add(VColor.FromBytes(file, address, ColorType.ARGB8888_32));
                    address += VColor.Size(ColorType.ARGB8888_32);
                    break;

                case ChunkType.Vertex_VertexUserFlags:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    UserFlags.Add(ByteConverter.ToUInt32(file, address));
                    address += sizeof(uint);
                    break;

                case ChunkType.Vertex_VertexNinjaFlags:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    NinjaFlags.Add(ByteConverter.ToUInt32(file, address));
                    address += sizeof(uint);
                    break;

                case ChunkType.Vertex_VertexDiffuseSpecular5:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    uint tmpcolor = ByteConverter.ToUInt32(file, address);
                    address += sizeof(uint);
                    Diffuse.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor & 0xFFFF)), 0, ColorType.RGB565));
                    Specular.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor >> 16)), 0, ColorType.RGB565));
                    break;

                case ChunkType.Vertex_VertexDiffuseSpecular4:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    tmpcolor = ByteConverter.ToUInt32(file, address);
                    address += sizeof(uint);
                    Diffuse.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor & 0xFFFF)), 0, ColorType.ARGB4444));
                    Specular.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor >> 16)), 0, ColorType.RGB565));
                    break;

                case ChunkType.Vertex_VertexNormal:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    break;

                case ChunkType.Vertex_VertexNormalDiffuse8:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Diffuse.Add(VColor.FromBytes(file, address, ColorType.ARGB8888_32));
                    address += VColor.Size(ColorType.ARGB8888_32);
                    break;

                case ChunkType.Vertex_VertexNormalUserFlags:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    UserFlags.Add(ByteConverter.ToUInt32(file, address));
                    address += sizeof(uint);
                    break;

                case ChunkType.Vertex_VertexNormalNinjaFlags:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    NinjaFlags.Add(ByteConverter.ToUInt32(file, address));
                    address += sizeof(uint);
                    break;

                case ChunkType.Vertex_VertexNormalDiffuseSpecular5:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    tmpcolor = ByteConverter.ToUInt32(file, address);
                    address += sizeof(uint);
                    Diffuse.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor & 0xFFFF)), 0, ColorType.RGB565));
                    Specular.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor >> 16)), 0, ColorType.RGB565));
                    break;

                case ChunkType.Vertex_VertexNormalDiffuseSpecular4:
                    Vertices.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    Normals.Add(new Vertex(file, address));
                    address += Vertex.Size;
                    tmpcolor = ByteConverter.ToUInt32(file, address);
                    address += sizeof(uint);
                    Diffuse.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor & 0xFFFF)), 0, ColorType.ARGB4444));
                    Specular.Add(VColor.FromBytes(ByteConverter.GetBytes((ushort)(tmpcolor >> 16)), 0, ColorType.RGB565));
                    break;

                default:
                    throw new NotSupportedException("Unsupported chunk type " + Type + " at " + address.ToString("X8") + ".");
                }
            }
        }