Page MenuHomePhorge

Materials
Updated 3,321 Days AgoPublic

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.

MultiPassLowAlpha.png (300×400 px, 8 KB)

MultiPassHighAlpha.png (300×400 px, 9 KB)

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

LightMap.png (64×64 px, 7 KB)

EchoLogo.png

EchoLogo.png (256×256 px, 8 KB)

pass
{
	texture_unit
	{
		image: "data/LightMap.png"
	}
	texture_unit
	{
		image: "data/EchoLogo.png"
		blend_mode: MODULATE
	}
}

And here is the blended result:

Blended.png (337×356 px, 70 KB)

Referenced Files
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
Subscribers
None
Last Author
0xseantasker
Last Edited
Oct 21 2015, 1:20 AM

Event Timeline

0xseantasker edited the content of this document. (Show Details)
0xseantasker changed the visibility from "All Users" to "Public (No Login Required)".Mar 6 2019, 5:21 PM