def to_material(name, singleton):
    """Wrapper for initializing and registering materials."""

    if singleton:
        name += " (no gc)"

    def registration_fn(fn):
        def init_fn(*args, **kwargs):
            if singleton and name in bpy.data.materials:
                return bpy.data.materials[name]
            else:
                return surface.shaderfunc_to_material(fn, *args, name=name, *kwargs)

        return init_fn

    return registration_fn
Wrapper for initializing and registering materials.
infinigen/core/nodes/node_utils.py