The YAR File Format

Return to the main Yar page


The YAR file format is a very simplistic ASCII scene description format. It contains a list of materials and a list of objects. No hierarchy is defined, and transforms are specified on a per object basis. Additionally, some object-material mapping is (optionally) contained in the objects themselves, which limits reusability. A full-fledged file format should address these issues, and later versions of Yar may change this format arbitrarily.

General Format

The Yar file begins with the keyword "YAR" on the first line by itself. The second line contains two ints, giving the number of materials nm and the number of objects no, respectively. The next nm lines each consist of the name of a YMT material file, as defined below. These materials are implicitly numbered 0 through nm - 1. The YMT file format is described below under Materials.

Following the materials are object entries. These take up four lines per object, with no objects in the file. The first line of the object entry consists of two ints, the first giving the type of the object, and the second the default material to use for the object. The default material is an index into the preceding list of materials. The second line contains the name of the file to use for the object. The type of this file depends upon the type of object, as described below under Objects. The third line of the object entry contains a translation to apply to the object, given as three doubles, x, y, and z, respectively. The fourth and final line contains an orientation for the object, given as a quaternion. The quaternion is specified with four doubles, x, y, z, and w, respectively.


Yar reads materials from a YMT (Yar MaTerial) file. The first line of the YMT file contains the keyword YMT, followed by a space, followed by an int indicating the type of the material: 0 is Solid, and 1 is Emissive.

A Solid material then contains two further lines, each consisting of three doubles. The first gives RGB values for the diffuse reflectance of the material, between 0.0 and 1.0. The second line gives RGB values for the specular reflectance of the material, also between 0.0 and 1.0. For each of these pairs, the sum of the diffuse and specular reflectance should be <= 1.0. These numbers indicate a percentage of the time that light of that color is reflected using that BRDF.

An Emissive material contains four lines after the header. The first two are identical to the Solid material. The third line is another RGB triple, indicating the color and strength of emitted light. This should also be between 0,0,0 and 1,1,1. The fourth line contains a single double, which is a power multiplier. This property only applies when using photon mapping in Yar. It is the total power that is emitted by the light source, and is split between all of the photons emitted from the light. Changing the number of photons in the scene, or the number of lights, will cause the strength of the light to change. This multiplier allows fine-tuning of how this particular light material works with the scene. Any positive value is permitted.

Example Blue Solid Material

This material diffusely reflects 40% of the red and green light that hits it, and 80% of the blue light. It never specularly reflects light.

.4 .4 .8
0 0 0 

Example Light Source Emissive Material

This material absorbs all light that hits it, but emits full-strength white light. It has a power multiplier of 100,000.

0 0 0
0 0 0
1.0 1.0 1.0


Yar currently supports two types of objects. The first is a triangle mesh in an OFF file, denoted as type 0. The second is a sphere in a non-standard SPH file, denoted as type 1.

Triangle Meshes

Yar supports OFF files containing pure triangle meshes only (No faces with more than three sides). Every triangle of the mesh is given the default material specified in the object entry in the Yar file, unless a specific material index is given in OFF file. Specific materials are given using the "one integer" face color notation described in the format specification given above. This allows easily creating an object with one or two of its faces emitting light, and the rest some default color.


The SPH file simply consists of the first line "SPHERE", and a double on the second line, containing the radius of the sphere. Spheres are centered on the origin, and then translated into place in the Yar file.

Valid XHTML 1.0!   Return to the main Yar page   Valid CSS!