} // NOTE -- Ohana3DS had THREE unknown uints, but SPICA only reads TWO uints here public static RasterizationContainer Load(Utility utility) { var rc = new RasterizationContainer(); CGFXDebug.LoadStart(rc, utility); rc.IsPolygonOffsetEnabled = (utility.ReadU32() & 1) > 0; rc.FaceCulling = (CullMode)utility.ReadU32(); rc.PolygonOffsetUnit = utility.ReadFloat(); rc.FaceCullingCommand = utility.ReadUInts(2); return(rc); }
public override void Load(Utility utility) { base.Load(utility); MaterialFlags = utility.ReadU32(); TextureCoordinatesConfig = (TextCoordConfig)utility.ReadU32(); TranslucencyKind = (TranslucencyKind)utility.ReadU32(); MaterialColor = MaterialColorContainer.Load(utility); Rasterization = RasterizationContainer.Load(utility); FragmentOperation = FragmentOperationContainer.Load(utility); // Texture coordinates UsedTextureCoordinates = utility.ReadU32(); // ??? TextureCoords = new TextureCoord[3]; for (var i = 0; i < TextureCoords.Length; i++) { var textureCoord = new TextureCoord { SourceCoordIndex = utility.ReadI32(), MappingType = (TextureCoord.TextureMappingType)utility.ReadU32(), ReferenceCameraIndex = utility.ReadI32(), TransformType = (TextureCoord.TextureTransformType)utility.ReadU32(), Scale = Vector2.Read(utility), Rotation = utility.ReadFloat(), Translation = Vector2.Read(utility), Flags = utility.ReadU32(), Transform = Matrix.Read(utility), }; TextureCoords[i] = textureCoord; } // Texture mappers TextureMappers = new TextureMapper[4]; for (var i = 0; i < TextureMappers.Length; i++) { utility.LoadIndirect(() => { if (i < 3) { TextureMappers[i] = TextureMapper.Load(utility); } else { // FIXME -- "Procedural texture mapper" ??? // Not implemented at all in Ohana3DS // According to SPICA, this is what the fourth slot points to, however throw new NotImplementedException("Procedural texture mapper not implemented"); } }); } ShaderReference = utility.LoadDICTObj <ShaderReference>(); utility.LoadIndirect(() => { FragmentShader = FragmentShader.Load(utility); }); ShaderProgramDescIndex = utility.ReadI32(); // NOT SUPPORTED ShaderParametersCount = utility.ReadU32(); ShaderParametersPointerTableOffset = utility.ReadOffset(); if (ShaderParametersCount != 0 || ShaderParametersPointerTableOffset != 0) { throw new NotImplementedException($"ModelMaterial Load: Shader Parameters UNSUPPORTED"); } LightSetIndex = utility.ReadI32(); // Reference?? FogIndex = utility.ReadI32(); // Reference?? // NOTE -- See SPICA GfxMaterial.cs for computations involving these hash functions. // I ASSUME if I never change any values in the material these never need recomputed. // Let's try to get by without needing this support right now... MaterialFlagsHash = utility.ReadU32(); ShaderParamsHash = utility.ReadU32(); TextureCoordsHash = utility.ReadU32(); TextureSamplersHash = utility.ReadU32(); TextureMappersHash = utility.ReadU32(); MaterialColorsHash = utility.ReadU32(); RasterizationHash = utility.ReadU32(); FragLightHash = utility.ReadU32(); FragLightLUTHash = utility.ReadU32(); FragLightLUTSampHash = utility.ReadU32(); TextureEnvironmentHash = utility.ReadU32(); AlphaTestHash = utility.ReadU32(); FragOpHash = utility.ReadU32(); UniqueId = utility.ReadU32(); }