Materials in Oolite
- This section applies to Oolite 1.69 and later.
Traditionally, the surface appearance of ships in Oolite has been defined entirely by textures specified in the ship’s model file and the smooth attribute. Test release 1.67 added support for shaders, and test release 1.69 expands this to a more flexible material model. Under the new model, the texture file names in model files have been repurposed as material keys. A material key specifies an entry in the ship’s material dictionary, specified in the ship’s shipdata.plist entry. For backwards compatibility, if no material of a given name is found, a material is generated using the material key as a diffuse texture name – providing the same functionality as previous versions of Oolite.
The materials and shaders dictionary
The material dictionary is actually specified as two separate dictionaries in the shipdata.plist entry. The first is called materials, the second shaders. If shader support is available and enabled, the entries in shaders are used in preference to those in materials. Otherwise, shaders is ignored. The entries in the two dictionaries take exactly the same form, however; it is possible to specify a shader in the materials dictionary, and it will simply be ignored if shader support is not available. The rest of this article shall refer to the merged materials and shaders dictionaries as “the material dictionary”.
Material attributes dictionaries
The material dictionary is a property list dictionary whose keys are material keys as defined above, and whose values are material attribute dictionaries. Currently-supported material attribute dictionary keys are listed here; “texture specifier” and similar are defined below.
Name | Type | Description |
---|---|---|
ambient | colour specifier | The ambient colour of the entity, that is, the colour reflected evenly in all directions by starlight. By default, this is the same as diffuse. |
diffuse | colour specifier | Overall diffuse colour of the entity; that is, the colour reflected in a “non-shiny” way on the sunlit side of the entity. If both diffuse and diffuse_map are specified, the texture is “dyed” with this colour. Default: white (1.0, 1.0, 1.0, 1.0). |
diffuse_map | texture specifier | A texture specifying the basic colour of the material. This is a “normal” texture, the same as you get without a material dictionary. If not specified, the material key will be used. To specify no texture, use an empty string for diffuse_map. Ignored when using shaders. |
emission | colour specifier | The emitted (glow) colour of the material. Default: black (0.0, 0.0, 0.0, 1.0). |
shininess | integer | The “tightness” of specular reflect, ranging from 0 to 128. 0 means no specular highlight. Default: 0, may change in future. |
specular | colour specifier | The specular (shiny reflection) colour of the material. This is ignored if shininess is not 1 or more. Default: black (0.0, 0.0, 0.0, 1.0), may change in future. |
textures | array of texture specifiers | Textures to use in shader program. |
The following attributes are only supported if shader support is active:
Name | Type | Description |
---|---|---|
fragment_shader | file name | name of GLSL fragment program to use. |
textures | array of texture specifiers | Textures to use in shader program. |
uniforms | dictionary of uniform variable specifiers | uniform variables to use in shader program. |
vertex_shader | file name | name of GLSL vertex program to use. |
Under construction, will continue this evening. -Ahruman 12:29, 28 June 2007 (BST)