Texture Maps

Texture maps are 2d functions that produce a color when given a coordinate. The most common usage for these maps is to add detail to polygonal mesh surfaces. For example, one may use a wood texture on top of a box to create an illusion that a box is made of wood. Textures are also used to provide meta-information about a surface. For example, a normal or bump map provides information about which way a surface is pointing at any given location, or a hair length map might determine the length of hair at any point on a surface.


Coden allows developers a lot of freedom over how they define their maps. The simplest way to do it is through a function. For example:

public static Graphics.Color Checker( Vector2 coordinate, float cellWidth, float cellHeight, Color color1, Color color2 )
	bool oddX = (int)( coordinate.x / cellWidth ) % 2 == 0;
	bool oddY = (int)( coordinate.y / cellHeight ) % 2 == 0;
	return oddX ? ( oddY ? color1 : color2 ) : ( oddY ? color2 : color1 );

Here we define a function Checker that takes a Vector2 coordinate, some extra parameters, and outputs a color value. The resulting color value is calculated based on the coordinate, width and height, of the cells, and the colors used for alternating cells.

Coden will detect this function as a texture and use it to calculate values for each pixel (or sample) of a texture map:



For an example of a texture map plug-in see Checkers.cs file available in the samples project.