Mapping/Materialsystem

From UFO:AI

Jump to: navigation, search

Contents

General

Since version 2.3 we have a material system. You can easily and flexible enhance your maps with it. The map loader searches them in base/materials - they have to have the same basename as the map - just not bsp as extension, but mat. In case of random map assemblies, use the same name as the ump (you cannot set material properties per tile, only per whole map).

You can think about materials as a set of properties for individual world textures. You can create animations, terrain blending, scrolling, zooming and environment reflections with them. Each material is defined on one texture (the material texture). All the textures on the map will then have the properties of that material. The material can have one or multiple properties. Sometimes a property references another texture (the property texture). Note that all properties apply at the same time, not in succession!

Here are some properties with their explanations.

# scrolling texture
{
	material tex_pics/tonight_honuda
	{
		texture tex_pics/tonight_honuda
		scroll.s 0.25
	}
}

This one will scroll the texture horizontally - the scroll.s parameter is the speed. Note that the texture displayed is the texture in the property, not the texture the property is defined for! You can use this to make the same texture scroll at different speeds on the same map by using a placeholder texture.

  • How can we decide in which direction the texture scrolls? Is this related to the texture rotation? --BTAxis 23:11, 22 December 2008 (UTC)
# terrain with two stages
{
	material tex_nature/desert006
	{
		texture tex_nature/desert001
		terrain 0 64
		lightmap
	}
	{
		texture tex_nature/desert002
		terrain 128 192
		lightmap
	}
}

This property makes a gradient with multiple textures. The terrain parameter determines at which heights the texture given in the property will be displayed. The texture will blend with the material texture. In this example, the material texture makes a gradient with two property textures. The orientation the texture scroll into depends on the texture rotation you set in radiant.

The lightmap parameter indicates that the property textures should use the map's lightmap. If this parameter is absent, the property textures will no be blended against the brush's lightmap.


# a metal surface with reflections
{
	material tex_material/metal
	{
		envmap 0
	}
}

This is a metal surface with reflections using the built-in envmap (valid built-in envmaps are envmap 0 and envmap 1) - you can also define another texture as envmap.

  • What's the difference between envmap 0 and 1?
# a pulsating surface
{
	material tex_misc/pulse
	{
		texture tex_misc/pulse_blend
		pulse 2
	}
}

The pulse parameter makes the material texture alternate with the property texture. If no property texture is specified, the material texture alternates with itself. Again, the lightmap parameter governs whether or not to light the property textures with the map's lightmap.

# A general surface parameter
{
	material tex_misc/pulse
	bump 1.5
	{
		texture tex_misc/pulse_blend
		pulse 2
	}
}

This example shows that materials can also have general surface parameters. These parameters are not defined in a property.

You can find more examples at base/materials.

Reference

General surface parameters

  • bump b

Bump amplification is used to tune bump mapping effects. Higher values increase the "bumpiness" of surfaces. The b parameter is required, and must be a positive floating point value, or 0.0. The default value is 1.0.

  • parallax p

Parallax amplification is used to tune the depth of bump mapped surfaces. Using values higher than 1.0 requires high-quality normalmaps, with properly encoded height values. The p parameter is required, and must be a positive floating point value, or 0.0. The default value is 1.0.

  • hardness h

Hardness is a multiplier for the specular component of bump mapped surfaces, and can be used to amplify or mute a material's reflectiveness. Organic materials benefit from lower values, while polished metals and glass benefit from higher ones. The h parameter is required, and must be a positive floating point value, or 0.0. The default value is 1.0.

  • specular s

Specular amplification is used to tune the specularity of bump mapped surfaces. The s parameter is required, and must be a positive floating point value, or 0.0. The default value is 1.0.

Parameters for property textures

These parameters affect property textures only.

  • anim frames hz

Frame-based animations are used to animate surfaces like computer screens. The stage texture name should end in 1, e.g. lunaran/computer1, with subsequent frames following in sequence. The frames parameter specifies the number of textures which comprise the animation. The hz parameter specifies the frequency of the effect. Both are required, and must be a positive integer and positive floating point number respectively.

  • blend src dest

The blend directive exposes OpenGL's GL_BLEND function. This is used for textures which lack an alpha channel, where additive blending is typically required. The src and dest parameters are GL constants, e.g. blend GL_ONE GL_SRC_ALPHA. The default blend function is GL_ONE GL_ONE_MINUS_SRC_ALPHA. See Blendmodes for examples.

  • color r g b

The color directive is used to influence the stage's default color. This directive is often used in conjunction with other directives such as pulse or stretch. The parameters r g b are each required, and must each be floating point numbers between 0.0 and 1.0.

  • pulse hz

Pulses are used to animate surfaces like jump pads or light fixtures. The stage texture is interpolated over the base material using a sin function. The hz parameter specifies the frequency of the effect. It is required and must be a positive floating point number.

  • rotate hz

Rotation directives are used for fan blades, Yin-Yangs, and other surfaces which should appear to rotate. The hz parameter specifies the speed of the rotation. It is required, and must be a positive floating point number.

  • scroll.s s, scroll.t t

The scroll directives are used to slide texture stages across the underlying base material. This is used for computer screen redraw lines, layered water surfaces, and trim lighting. S and T are the two texture coordinate axis. Each directive takes exactly one required parameter, which must be a floating point number.

  • stretch amp hz

Stretch directives are used to create continuous expanding and contracting effects. The amp parameter specifies the scale of the stretch, while hz specifies the frequency. Both are required, and must be positive floating point numbers.

  • terrain ceil floor

Terrain directives are used to achieve simple height-based terrain blending. The ceil and floor parameters specify the highest and lowest Z-axis coordinates where blending will occur. At Z coordinates less than floor, the base material texture will appear; at Z coordinates greater than ceil, the stage texture will appear. Linear interpolation is used to blend the two textures at Z coordinates between ceil and floor. Both parameters are required, and must be floating point numbers.

  • dirtmap factor

Defining this in a texture stage will result in blending in a dirtmap. To make this effect look good you have to keep some little things in mind. The alpha value for the dirtmap blending is calculated along the vertices. That means that touching brushes must have overlapping vertices to get the same alpha values (see the attached image). The parameter factor is a blending factor that globally influences the blending of the dirtmap for all vertices. Its default value is 1.0. Values lower than this will make the dirtmap less visible, values higher than this will make it more visible.

Envmap parameters

Environment map stages are used to simulate reflections on metal, water, glass, etc. For convenience, they may be declared with numeric values to take advantage of several built-in effect textures, e.g. envmap 0. Alternatively, a unique texture can also be provided, e.g. envmap envmaps/my_envmap. Environment map stages do not currently support any unique directives, but do support color scroll.s scroll.t, described above.

Lightmap Stages

Lightmap stages are used to blend in statically computed lighting information. This is typically applied as the last drawn stage. Lightmap stages are declared by simply beginning the stage with the lightmap type name. Lightmap stages do not support any unique directives.

Personal tools
project-navigation