static XElement MapTextureOrColor(TextureRgb texture, string name) { if (texture.IsConstant) { var clr = texture.Lookup(Vector2.Zero); return(new XElement("rgb", MakeNameValue(name, $"{clr.R}, {clr.G}, {clr.B}"))); } else { texCounter++; string filename = $"Textures/texture-{texCounter:0000}.exr"; texture.Image.WriteToFile(filename); return(new("texture", new XAttribute("type", "bitmap"), new XAttribute("name", name), new XElement("string", MakeNameValue("filename", filename)) )); } }