2. Material files

1. Language files | | 3. Minfig generator file

Material files are for defining (additional) LDraw color information for use in both LD4DStudio previews and POV-Ray exports.

There are two official material files located in the material folder, namely "official.xml" and "povray.xml". It is not recommended to edit these files. Instead create an additional one with your custom additions and / or changes.

This is possible because LD4DStudio merges all material files whom you choose to load by way of inheritance. So if you define color 100 in a custom file it values will overwrite any existing definition of it made in files loaded before yours. The configuration dialog let you choose which files to load and in what order to do so. This way you have full control of your LDraw color configuration while still having a pretty good default in place out of the box.

The generic structure is as follows:

  <Macro />
  <Macro />
  <Macro />

  <Material />
  <Material />
  <Material />

The materials block

In the file the "Macros" element block is defined first. But for a better understanding of the whole, it is better if I explain the "Materials" block first.

This block is started with the "Materials" element and encloses an unlimited number of "Material" elements. The "Materials" element has no attributes so lets concentrate on the huge list of attributes available for the "Material" element.

Most attributes are POV-Ray specific and I'll go over them in fair limitation just to point out you can set those features from within the material files. So for their precise meaning I refer you to the excellent POV-Ray documentation on

The below table states all available attributes in the "Material" element, most of them are optional, if you leave them out the element the value in the second column will be used.

Main attributes
nr16The LDraw color number you wish to define / modify.
descr Name and or description for the color. This only resurfaces in the POV-Ray script generated by the exporter.
overridesallThis determines what part of a possible previous definition of this color number should be overwritten. More on this in the macro paragraph below.
macro This lets you assign all attributes set in the macro element with the given name to this "Material" element. More about this in the macro paragraph below.
colRGB0.0, 0.0, 0.0The main red, green and blue color values. Defined as three numbers between 0 and 1 separated by a comma, like e.g. "1.0, 1.0, 1.0" for white.
pigFT0.0, 0.0The transparency information (POV-Ray style) defined as two numbers between 0 and 1 separated by a comma. The first number represents filter and the second transparency. The two numbers usually add up to 1.0, in matter affect if you omit the second value LD4DStudio will calculate it from the first (if it's none zero). By default most transparent parts have the value "0.9, 0.1" meaning 90% opaque. The preview panels of LD4DStudio only support one grade of transparent (50%) therefore all material with a filter of above "0.0" will render transparent in the previews no matter their exact value. But in POV-Ray 0.9 or 0.8 might result in a world of difference.

POV-Ray normal attributes

Normals in POV-Ray are used to define the details of a surface. By default everything is perfectly smooth, but in reality this is nearly impossible. Therefore to get more realistic results you should define the kind and roughness of the surface using a normal.
norPatnoneThe base pattern of the surface. Valid values for this attribute are: "none", "bumps", "dents" and "wood". POV-Ray supports lots more but at the moment I think these are the only 'simple' ones whom are appropriate for LDraw parts.
norPatVal1The "amount of patterniness".
norScale1You can scale the pattern down or up resulting in more or less dens patterns.
norTurb0The amount of turbulence used in the pattern, this helps to randomize the spread of e.g. bumps or dents.

POV-Ray main finish attributes

Used to define the behavior of the surface in respect to light falling on it.
finAmb1.0, 1.0, 1.0Ambiance light, base amount of color for this material, so it's visible even when there is no light at all.
finDiff1Diffuse, how does this material respond to diffused light.
finBril1Brilliance, how bright is this material.
finConsEngfalseConserve energy true or false. Determines how the 'energy' of light is affected when it bounces of this material.
finIOR1IOR value, this determines how light goes 'through' the material. For example when light enters glass it will bend a little. This value determines how much it bends.

POV-Ray highlighting attributes

Highlights are the reflections of light sources on surfaces when looked upon from a certain angle.

finHLKindnoneKind of highlighting to be used, possible values are: "none", "phong", "specular" and "both".
finHLPhong0Phong highlighting value.
finHLPhongSize40Phong highlight size.
finHLSpec0Specular highlight value.
finHLSpecRough0.05Specular highlight roughness.
finHLMetal0Determins the 'metaliness' of the highlight.

POV-Ray reflection attributes

How does the surface handle reflections.

finRefl0.08, 0.08, 0.08Amount of reflection, the higher the more reflective with 1.0 beeing a perfect mirror.
finReflMin0.08, 0.08, 0.08Optional minimum. Only used when different from finRefl. The default is only used if finRefl isn't set, if it has been set it will default to that value.
finReflExp1Falloff exponent
finReflMetal0Amount of metaliness.

POV-Ray irid attributes

Irid is the effect you get when e.g. oil is spilled on the road. You'll see a purple rainbowy effect when light hits it.

finIrid0The amount of Irid effect needed.
finIridThick0The thickness of the 'oil spill'
finIridTurb0.001The turbulence of the effect.

Above may be a lot to take on if you not familiar with POV-Ray materials. Therefore it might be a good idea to start reading the corresponding POV-Ray documentation first.

The macros block

In theory all you need is a "Material" block for every LDraw color number to get you going with correct colors in both LD4DStudio and POV-Ray exports. But in practice many attributes will be nearly the same for large groups of color numbers. Take for example number 0 through 15 all should be 'plain slightly reflective plastic', so wouldn't it be nice if you could manage the needed properties of all these 16 colors in one place?

This can be done by using a "Macro" element in the "Macros" block above the "Materials" block. Within the Macro element you can use most of the attributes available for "Material" and assign them to a "Material" element using a single attribute, namely the mentioned "macro" attribute pointed out in above "Material" attributes table.

A "Macro" element has all attributes used in "Material" element except for "macro", "overrides", "nr" and "descr". And in addition it has an "name" and "copyFrom" attribute. The first lets you define the name you want to use to refer to this "Macro" element from within a "Material" el element's "macro" attribute.

For a better understanding of this open the povray.xml file in the material directory of your LD4DStudio installation. In it you'll find the "plastic" macro it defines all the attributes needed to get a nice plastic effect in POV-Ray. Now scroll down and you'll see the "Material" elements for color numbers 0 through 15 all have the attribute "macro" set to "plastic", therefor all these 16 colors will look like plastic in POV-Ray renderings.

To make things even more dynamic the "Macro" element's "copyFrom" attribute let's you start a macro with a copy of the named previously defined macro. This is handy if two kinds of material are very simular like normal 'plastic' and 'transparent plastic'. So by using "copyFrom" for a generic transparent macro you'll only need to define the basic plastic material properties once. Like done in the "plasticTrans" macro in povray.xml

Inheritance system

You might also have noticed the "overrides" attribute in the povray.xml file "Material" definitions. This determines how previous set values are overwritten for this LDraw color number. For example: By default the official.xml file is loaded first to get basic RGB values for common LDraw colors as dictated by But when the povray.xml file is loaded those values would be overwritten due to redefining existing color numbers. This off course is unwanted, because it would mean you'll have to specify the RGB values again in the povray.xml or all will be set to 0, 0, 0 making the information in official.xml useless.

To prevent this, and thus creating a very dynamic material management, you can choose to only overwrite the POV-Ray specific properties for the chosen LDraw color. This way you can leave the RGB values upto and concentrate only on things like reflection and normals in the povray.xml file.

What to override is controlled by the "overrides" attribute in the "Material" element. Valid values for this attribute are:

allThe default, override everything even things not specified (the default will be used for those.)
colorOverride only color specific properties, meaning the "colRGB" and "pigFT" attributes.
povrayOverride all POV-Ray specifics, meaning everything except the "colRGB" and "pigFT" attributes.
prPigmentOverride only the POV-Ray pigment properties, meaning the "pigFT" attribute.
prNormalOverride only the POV-Ray normal properties, meaning the "norPat", "norPatVal", "norScale" and "norTurb" attributes.
prFinishOverride only the POV-Ray finish properties, meaning the main finish, highlighting, reflection and irid related attributes.
prFinBaseOverride only the POV-Ray main finish properties, meaning the "finAMB", "finDiff", "finBril", "finConsEng" and "finIOR" attributes.
prFinHighlightOverride only the POV-Ray highlight properties, meaning the "finHLKind", "finHLPhong", "finHLPhongSize", "finHLSpec", "finHLSpecSize" and "finHLMetal" attributes.
prFinReflectionOverride only the POV-Ray reflection properties, meaning the "finRefl", "finRefMin", "finReflFallOff", "finReflExp" and "finReflMetal" attributes.
prFinIridOverride only the POV-Ray irid properties, meaning the "finIrid", "finIridThick" and "finIridTurb" attributes.

Using custom material files

When done creating a custom material file you must enable it by adding it to the matrial loading list controled in the configuration dialog. For details on this read the chapter on configuration in the manual.

If you are an POV-Ray expert and think you have created better material for the common LDraw color numbers, feel free to contact me about modifing the default material files so everybody can enjoy even more realistic POV-Ray renderings.

1. Language files | | 3. Minfig generator file
Best viewed with Firefox 2, Seamonkey or IE 7 at 1024x768 or higher resolution.
LEGO is a registered trademark of the LEGO Group, which does not sponsor, endorse, or authorize this website.