texture

A texture is an image used by Minetest to render an item or node in inventory or in the world. May be a 2D picture or a UV-mapped image cut and wrapped onto the faces of a 3D mesh.

Specification
There are various texture modifiers that can be used to generate textures on-the-fly.

Texture overlaying

 * Textures can be overlaid by putting a ^ between them.
 * Example: default_dirt.png^default_grass_side.png default_grass_side.png is overlayed over default_dirt.png

Texture grouping

 * Textures can be grouped together by enclosing them in ( and ).
 * Example: cobble.png^(thing1.png^thing2.png)
 * A texture for 'thing1.png^thing2.png' is created and the resulting texture is overlaid over cobble.png.
 * Notice that texture grouping doesn't work after e.g. "combine[…]="

Where each imageComponentN is either an image filename or a special command. If it is a filename, the image is blitted over the base image to its left—which is the entire sequence up to the current "^" (caret) character—if there is one, or used for further components to its right if it is the first one. A special command begins with the "[" (left square bracket) character and is one of the following:


 * [combine:WxH:x1,y1=filename1:x2,y2=filename2:...
 * Copies image from file filename1 to x1, y1 of the base image (blitted), filename2 to x2, y2, etc. The base image is created with dimensions W x H if it doesn't exist.


 * [brighten
 * The base image is brightened by averaging each color component with 255 (full brightness)


 * [colorize:#RGB
 * Colorizes the textures with given color. (Possible formats: #RGB, #RGBA, #RRGGBB, #RRGGBBAA)


 * [mask:foorbar.png
 * Applies a mask to the base image, using binary AND.


 * [noalpha
 * All pixels of the base image are set to fully opaque, as if the original image had no alpha channel.


 * [makealpha:R,G,B
 * Converts any pixel with the exact color value R, G, B (each from 0 to 255) to fully transparent (alpha = 0).


 * [transformT1T2...
 * Rotates or flips an image, depending on each Ti (applied from left to right, though it is always possible to represent any such combination using only a single transformation). Possible values for each Ti are:
 * 0 or I: Identity (no-op)
 * 1 or R90: Rotate by 90 degrees
 * 2 or R180: Rotate by 180 degrees
 * 3 or R270: Rotate by 270 degrees
 * 4 or FX: Flip X
 * 5 or FXR90: Flip X then rotate by 90 degrees
 * 6 or FY: Flip Y
 * 7 or FYR90: Flip Y then rotate by 90 degrees


 * [inventorycube{topImageSpec{leftImageSpec{rightImageSpec
 * Create an orthographically projected cube from the top, left, and right images, replacing each "&" (ampersand) character with "^" (carat) in each of topImageSpec, leftImageSpec, and rightImageSpec and then parsing each of them recursively as described in this article. From tile.cpp: "This should be used only on its own."
 * Can be created in mods via.


 * [lowpart:P:filename
 * Copies the lower P% (from 0 to 100) part of filename over the base image. (This is used for the flame in furnaces to show how much of the fuel's burn time is left.)


 * [resize:WxH
 * Resizes the base image. Can be chained, e.g. if you specify foobar1.png^[resize:2x2^[combine:8x8:1,1=foobar2.png^[resize:2x2 you will first scale the base image foobar1.png by 2, the you will overlay foobar2.png on top of the scaled foobar1.png and then scale the result of that (foobar1.png with foobar2.png overlay) again by 2 (foobar1.png being 4 times bigger, foobar2.png being 2 times bigger)

Examples:

tiles = {'mytexture.png^[colorize:red:120'}, Colorizes the texture with a ratio of 120 and a red color.

tiles = {"default_grass.png", "default_dirt.png", "default_dirt.png^default_grass_side.png^[colorize:yellow:75"}, You can run multiple transforms on a texture, as in the last texture on the cube above.

Engine-internal (do not use in mods)

 * [crack:N:P / [cracko:N:P
 * Adds a cracking texture on top of the base image, scaled by xP (from 0 to 9) in each dimension. [crack blits the crack texture on top of the base image with alpha blending.  [cracko overlays it instead (the crack texture's color is interpolated with the base image's according to its alpha value if the base pixel is fully opaque; otherwise the base pixel is left unmodified). N is the number of frames in the base image (1 if not animated).


 * [verticalframe:N:I
 * Crops the base (animation) image to a single frame I out of N total frames.

Animations
For animated textures, see e.g. the default:water_source. There are scripts for gimp which allow changing verticalframe animations to layers and the other way round. They allow changing gif animations to verticalframe pngs for minetest and the other way round, you can find them there: Animation Unstrip (filter→animation→unstrip) Make Sprite Sheet (file→create→Make[…)]