Latest version:
Tramway SDK 0.0.9
Github
Quick links
Home
Get Started

Adding Materials


If you followed the last guide and made your own teapot, you might have noticed that the teapot is not shiny. Not shiny at all! Also the texture was pixelated. Very pixelated!

The reason for this is very simple – by default all materials are matte and not at all shiny. However, we can override this behavior by adding a material definition ourselves, instead of letting the framework create a default one.

Open up the /data/material.list file in a text editor. What you will notice is a table of material definitions. Somewhere near the end you should find the teapot material that we gave the monkey 3D model.

What do all of the values do?


Material name

This is the name of the material. It is used to reference it, such as by 3D models. It is also used to lookup the texture image for the material.

Type

This tells the renderer how to render the material. For the OpenGL backend this also determines which shader will be used to render this material.

Filter

This tells the renderer whether to blur the textures when upscaling them. This is why they look pixelated &endash; by default blurring is disabled.

Property

This describes aural and other physical properties about the material. This is not directly used by the renderer. We can ignore this for now.

Color

This is the color of the material. You might have noticed that a lot of materials have the white color. This is because if you use a texture image and if you want it to look exactly it looks in your image editor, you need to set it to white, since the material color and the texture color is multiplied together. Changing this will tint the texture image, or just set the material's color if there is no texture.

Specularity

This determines how intense the specularity of the material will be. Can be set in the range from 0.0 to 1.0.

Specularity

This determines how narrow or wide the specular reflection will be. Needs to be set to at least 1.0 or higher.

Specular Transparency

This determines whether the specular reflection will be multiplied with the material's color, or added to it. Can be set in the range from 0.0 to 1.0.

Source

This determines the source of the material's texture image. If set to same, the material's name will be used to lookup an image from the /data/materials, directory. If set to none, the material will have no texture and instead will use its color for display. Finally, if this parameter is set to anything else, this will be interpreted as the name of another material and this material will use the other's texture image.

This is useful if, for example, you want to create multiple materials with the same texture, but with different specular, color or other parameters. This way all of the materials will share the same texture image in GPU memory, thereby saving some space there.

Fixing the teapot material


An easy way to do this would be to duplicate the teapot material's line in the file and to replace the material's name with you material's name. Also don't forget to change the source from none to same. Perhaps also change the transparency from 0.0 to 1.0, to make the teapot look less metallic.


My best work: now shiny again.

Exercise


Try changing your teapot's material's properties. See what changing them to different values does.

Exercise


Use the texture source option and the color parameter to create different colored variations of your material.