Skip to content
thothbot edited this page Mar 4, 2016 · 19 revisions

Materials

Materials are a critical part of creating attractive images and animation in a 3D program. Materials interact with lights, so lighting drives some material choices; for example, if your overall lighting is bright, you might need to make your scene materials somewhat darker.

Applying materials and rendering the scene again is a snap.

Materials are top-level implementation of shaders. Each material uses specific predefined shader, except ShaderMaterial, where can be defined custom shaders.

Interfaces

Each material implements some predefined interfaces, which determine the behavior of materials.

HasAmbientEmissiveColor

HasBumpMap

Bump map is one of the most basic ways to create different types of “bumps” on a surface such as indentations and ridges.

A bump map simulates relief on objects by perturbing the shading normals according to a texture. The result is the illusion of bumps, ridges, and imperfections. However, there is no change to the objects’ geometry, so there is no change to an object’s silhouette or the shadow it casts.

material.setBumpMap(texture);
material.setBumpScale(1.0);

HasColor

HasEnvMap

HasFog

HasLightMap

A lightmap is just a texture for blending. Normally, the lightmap textures are a grayscale textures. The black area will be the shadowed and in the white are, the obejct will be illuminated.

material.setLightMap(texture);

HasMap

For most of the time we can't just use reflection and refraction to create a material for an object. For example: stone, wood, painting, package, sticky back paper and textile. We must use some textures to create these materials.

material.setMap(texture);

HasNormalMap

HasSkinning

HasSpecularMap

Specular map is a texture that shows the ability of reflecting. Specular map does not show the reflection of the scene objects. It shows the reflection of light falling on object. Specular Map contains grayscale pixels. The lighter a pixel, the greater the ability of a material to reflect the light. Accordingly, the darker a pixel, the more material becomes a matte and loses property to reflect light. Materials for ceramic tiles and polished metal can use lighter tones.

material.setSpecularMap(texture);

HasVertexColors

Defines how to apply colors: face, vertex or none.

material.setVertexColors(Material.COLORS.VERTEX);

HasWireframe

Defines wireframe structure of the mesh materials.

material.setWireframe(true);
material.setWireframeLineWidth(2);

HasWrap

Mesh materials

Those materials are used by Mesh objects.

The following materials are used by Mesh objects.

Basic

A material for drawing geometries in a simple shaded (flat or wireframe) way.

Implements the following interfaces:

  • HasWireframe
  • HasVertexColors
  • HasSpecularMap
  • HasMap
  • HasLightMap
  • HasEnvMap
  • HasFog
  • HasColor
  • HasSkinning
MeshBasicMaterial material = new MeshBasicMaterial();

The default will render as flat polygons. To draw the mesh as wireframe, simply set

material.setWireframe(true);

Lambert

Lambert is a flat material type that yields a smooth look without highlights. It calculates without taking into account surface reflectivity, which gives a matte, chalk-like appearance. Lambert material is ideal for surfaces that don't have highlights: pottery, chalk, matte paint, and so forth.

Implements the following interfaces:

  • HasWireframe
  • HasVertexColors
  • HasSpecularMap
  • HasMap
  • HasLightMap
  • HasEnvMap
  • HasFog
  • HasColor
  • HasAmbientEmissiveColor
  • HasSkinning
  • HasWrap
MeshLambertMaterial material = new MeshLambertMaterial();

Phong

The Phong material type takes into account the surface curvature, amount of light, and camera angle to get accurate shading and highlights. The algorithm results in tight highlights that are excellent for polished shiny surfaces, such as plastic, porcelain, and glazed ceramic.

Implements the following interfaces:

  • HasWireframe
  • HasVertexColors
  • HasSpecularMap
  • HasMap
  • HasNormalMap
  • HasLightMap
  • HasEnvMap
  • HasBumpMap
  • HasFog
  • HasColor
  • HasAmbientEmissiveColor
  • HasSkinning
  • HasWrap
MeshPhongMaterial material = new MeshPhongMaterial();

Particle material

Implements the following interfaces:

  • HasVertexColors
  • HasMap
  • HasFog
  • HasColor
ParticleBasicMaterial material = new ParticleBasicMaterial();
material.setColor( new Color(0x888888) );
ParticleSystem particles = new ParticleSystem( geometry, material );

Line material

Implements the following interfaces:

  • HasVertexColors
  • HasFog
  • HasColor
LineBasicMaterial material = new LineBasicMaterial();
material.setColor( new Color( 0xffffff) );
material.setOpacity( 0.2 );

Line line = new Line( geometry, material, Line.TYPE.PIECES );

Shader material

Implements the following interfaces:

  • HasWireframe
  • HasVertexColors
  • HasFog
  • HasColor
  • HasSkinning