-
Notifications
You must be signed in to change notification settings - Fork 26
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.
Each material implements some predefined interfaces, which determine the behavior of materials.
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);
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);
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);
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);
Defines how to apply colors: face, vertex or none.
material.setVertexColors(Material.COLORS.VERTEX);
Defines wireframe structure of the mesh materials.
material.setWireframe(true);
material.setWireframeLineWidth(2);
Those materials are used by Mesh
objects.
The following materials are used by Mesh objects.
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 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();
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();
Implements the following interfaces:
- HasVertexColors
- HasMap
- HasFog
- HasColor
ParticleBasicMaterial material = new ParticleBasicMaterial();
material.setColor( new Color(0x888888) );
ParticleSystem particles = new ParticleSystem( geometry, 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 );
Implements the following interfaces:
- HasWireframe
- HasVertexColors
- HasFog
- HasColor
- HasSkinning