Multi-Texture

Multi-Texturing is available, allowing up to three textures per material. Textures are accessed from the material texture panel, with the types Image and EnvMap.

 

Each can be blended together with blending modes: Mix, Add, Subtract, Multiply, and Screen. Textures are blended on top of the previous texture or material color.

 

Here is how:

-------------------------------------------------------------------------------

previous= texture unit(n) or material color

current = texture unit(n)

Mix = interpolate(previous, current, by color factor)

Add = previous+current-0.5

Subtract= previous-current

Multiply= previous*current

Screen = previous+current

-------------------------------------------------------------------------------

If the image is set to USEALPHA:

-------------------------------------------------------------------------------

previous= texture unit(n) or material color

current.alpha = texture unit(n)

 

Mix = interpolate(previous, current, current.alpha)

Add = previous+current.alpha-0.5

Subtract= previous-current.alpha

Multiply= previous*current.alpha

Screen = previous+current.alpha

-------------------------------------------------------------------------------

 

 

If the Image type is EnvMap, a GL Cube map will be generated by the image provided with the Load option. Some uses include:

-------------------------------------------------------------------------------

Mirror reflection mapping of the current scene(cube_map.blend)

and, texture lighting effects(dynamic_light.blend),

by generating texture coordinates from another objects position.

 

 

To get a mirror ball effect:

-------------------------------------------------------------------------------

Render your scene in the renderer with an EnvMap setup on an object.

Use the save option for the rendered image, then load that image with the load option.

In the material panel 'Map Input', set the mapping type to 'Refl'.

This will generate a sphere map from the image provided.

 

To generate the Cubemap's texture coordinates from another object:

-------------------------------------------------------------------------------

In the material panel 'Map Input', use the 'Object' option and specify the object to be copied. Then set the plane the coordinates are to be applied, X,Y,Z or None.

 

 

For any image provided you have the option to scale and offset the texture's coordinates by the size/offs options in the 'Map Input' panel

 

Multiple Materials

Up to sixteen materials are available per mesh object. Each material can have any of the multi-texture options assigned to it. Optionally, materials can have their own shaders applied.

 

Materials can be assigned per face with the Link and Materials panel in the edit buttons. Just add the desired materials with New, select the material number and faces for the material and, hit Assign.

Material-ipos

Material Ipos are used the same way other ipos are handled in the game engine. Set the desired ipo and hook up an ipo actuator to use it.

 

The options currently available are:

-------------------------------------------------------------------------------

RGB, Alpha, and All color.

 

The ipo is set in the material panel with I-Key. For now ipos are only available on the first material assigned to the mesh, and applies to the whole mesh.

Separate UV coordinates

An option is available to set a second set of UV coordinates. You set the desired coordinates, and which texture unit they will be applied to.

 

This can be useful for lighting effects.

 

To set the coordinates:

-------------------------------------------------------------------------------

code:

# --

import GameLogic

cont = GameLogic.getCurrentController()

obj = cont.getOwner()

 

mesh_index = 0

mesh = obj.getMesh(mesh_index)

while mesh != None:

for mat in range(mesh.getNumMaterials()):

for v_index in range(mesh.getVertexArrayLength(mat)):

vertex = mesh.getVertex(mat, v_index)

uvco = [1.0, 0.0]

unit = 1

vertex.setUV2(uvco, unit)

 

mesh_index +=1

mesh =obj.getMesh(mesh_index)

# --

-------------------------------------------------------------------------------

 

The second coordinates are initially the first, unless otherwise set.