Materials
Materials define how a mesh is going to be rendered. Materials are more than just a texture that is applied to the mesh. It also defines other things such as how the mesh will interact with the existing scene, whether it will be affected by lighting, the objects base colour, and a variety of other settings.
RenderPass
Materials are actually a little more complicated than just defining properties that apply to the render system, in fact Material objects are just containers for RenderPass objects. For each RenderPass the Mesh is also rendered. Why is this useful? By defining multiple render passes you can set up the second pass to interact with the first pass to create effects.
These two images show the output of the MultiPassRenderTest where the alpha of the second pass loops from full alpha to no alpha. The second pass is rendered with additive blending which gives a more intense glow effect.
You can accomplish the same thing by using two meshes and even multiple texture units. This is just a trivial example though.
TextureUnits
A RenderPass may be made up of one or more TextureUnit objects. These define an image that will be rendered to the object. The image will be "wrapped" around the mesh based on the mesh's texture coordinates. A simple Material that has a single RenderPass which has a single TextureUnit would normally just define the image. For example:
pass { texture_unit { image: "resources/EchoLogo.png" } }
This is probably one of the simplest materials you can define. It defines a single RenderPass with a single TextureUnit and what image that texture unit should use.
Using multiple TextureUnits can be useful for performing effects such as static lighting, also known as "baked lighting". The following example is adapted from the "MultiStageTexturing" test. Here are the textures to give you a better idea of how the textures are combined.
LightMap.png
EchoLogo.png
pass { texture_unit { image: "data/LightMap.png" } texture_unit { image: "data/EchoLogo.png" blend_mode: MODULATE } }
And here is the blended result:
F1600: EchoLogo.png | |
Oct 21 2015, 1:20 AM |
F1598: LightMap.png | |
Oct 21 2015, 1:20 AM |
F1602: Blended.png | |
Oct 21 2015, 1:20 AM |
F1139: MultiPassLowAlpha.png | |
Jul 9 2015, 2:02 PM |
F1141: MultiPassHighAlpha.png | |
Jul 9 2015, 2:02 PM |
- Last Author
- 0xseantasker
- Last Edited
- Oct 21 2015, 1:20 AM