/// Adds a texture parameter + uniform to the specified material.
    /// As a side effect, auto-creates textures, images, and maybe a sampler if necessary.
    /// Pass:
    ///   matObjName - the material
    ///   texParam - name of the material parameter to add
    ///   fileRef - file containing texture data
    public void AddTextureToMaterial(
        IExportableMaterial exportableMaterial, string texParam, ExportFileReference fileRef)
    {
        GlTF_Material material = G.materials[exportableMaterial];

        GlTF_Sampler sampler = GlTF_Sampler.LookupOrCreate(
            G, GlTF_Sampler.MagFilter.LINEAR, GlTF_Sampler.MinFilter.LINEAR_MIPMAP_LINEAR);

        // The names only matter for gltf1, so keep them similar for easier diffing.
        // Essentially, this names the image and texture after the first material that wanted them.
        string matNameAndParam = $"{exportableMaterial.UniqueName:D}_{texParam}";
        var    img             = GlTF_Image.LookupOrCreate(G, fileRef, proposedName: matNameAndParam);
        var    tex             = GlTF_Texture.LookupOrCreate(G, img, sampler, proposedName: matNameAndParam);

        material.values.Add(new GlTF_Material.TextureKV(key: texParam, texture: tex));

        // Add texture-related parameter and uniform.
        AddUniform(exportableMaterial,
                   texParam, GlTF_Technique.Type.SAMPLER_2D, GlTF_Technique.Semantic.UNKNOWN, null);
    }