Library Palettes

Library Palettes

Templates are the basic building blocks of shaders created in Slim, and are designed to be used and reused. As you use templates, you will find yourself creating shaders and pieces of shaders that you want to reuse. With Library Palettes, you can access and reuse these just as easily as you can templates. And unlike Slim templates, Library Palettes and their contents can be edited right within the Slim interface.

Using Library Palettes

Members of Library Palettes are shown when the Palette View is in Create Mode and (by default) are displayed along with templates in Global Smart Palettes. You can also view just the contents of Library Palette by selecting it in the Palette View.

Like a template, you can add a member of a Library Palette to your current palette by clicking on it. Depending on how that Library Palette is configured, adding will take the form of copying or instancing.

Editing Library Palettes

Fundamentally, Library Palettes are no different than ordinary palette files. In normal use, they are effectively read-only. To make changes to the contents of a Library Palette, simply tell Slim you wish to edit it. In Create Mode, select the Library Palette you wish to edit and then:

Palette -> Edit Library Palette

This will remove the Library Palette from Create Mode and place it in Browse Mode. You may then make changes to that palette as if it were any other palette. Inform Slim when you are done:

Palette -> Done Editing Library Palette

This will return the Library Palette to Create Mode.

Note: Like any other palette file, you may have to worry about write-permissions on the file that is storing your Library Palette. If after placing your Library Palette in edit mode the palette is still read-only, check that you have appropriate permissions to edit the file.

Specifying Library Palettes

Library Palettes are loaded with every Slim session, so they are specified within a Slim initialization file. By default, Slim ships with this specification for library palettes:

SetPref LibraryPaletteSets { personal }

SetPref LibraryPaletteDir(personal) $personalLibDir
SetPref LibraryPalettes(personal) {
    MyLibrary.splt {
        mode copy
        create 1
    }
}

The LibraryPaletteSets preference specifies the list of Library Palette sets. A set is a group of palettes that live in the same directory and are loaded at the same time.

The second and third preferences specify the location and contents of the personal set of Library Palettes. LibraryPaletteDir specifies the directory containing Library Palettes for the specified set. LibraryPalettes specifies the list of Library Palette files to find in that directory. These will be loaded in the order specified.

Each palette file listed in the LibraryPalettes preference is followed by a list of configuration options for the library palette:

mode (copy or instance)

Action to perform when a user selects a member of the palette. By default, the appearance will be copied.

create (0 or 1)

Whether the palette should be created if it doesn't exist already.

For default configuration, follow the palette file with an empty list "{}".

To specify additional sets of Library Palettes, you'll need to first override the definition of LibraryPaletteSets, e.g.:

SetPref LibraryPaletteSets { shared personal }

Sets will be loaded in the order specified. An example definition for a shared set is shown below. Note there is nothing inherently special about the palette file specified. Any palette file can be a Library Palette, so long as it is specified here.

The default listing above specifies that a personal library palette should exist in the user's preference directory, and that it should be created if it doesn't exist already. The copy specification means that when the user selects an entry from the Library Palette, it will be copied into her current palette. This is the recommended action for Library Palettes such as this one which are not guaranteed to be loaded by other users. This Library Palette, then, is best used for a user's personal favorite appearances and networks.

To share a Library Palette among many users, it should exist in a shared location. If the palette is guaranteed to be loaded for all users, you can specify the action as instance. When a user selects an entry in such a palette, an instance of the selected node will be added to the user's current palette.

A palette specification for this sort of behavior might look something like the following:

SetPref LibraryPaletteDir(shared) /path/to/shared/directory
SetPref LibraryPalettes(shared) {
    Commonマテリアル.splt {
        mode instance
    }
    CharacterShaders.splt {
        mode instance
    }
}

Using instances allows for more dynamic behavior. You can make changes to the global Library Palette and they will be automatically integrated into the palettes containing instances. This flexibility does require some care, however. For palettes with instances to function properly, the Library Palette must be loaded at all times. Be cautious about actions such as Uniqueify, which will reassign unique identifiers and may cause instances to lose their connection to their original appearances.

As mentioned above, contents of Library Palettes are by default displayed along with templates in Global Smart Palettes. To disable this behavior, set the following preference:

SetPref IncludeLibraryInSmartPalettes 0