Texture Attributes

From Official Kodi Wiki
Jump to navigation Jump to search

For the <texture> tags, and for all <texture> tags in other controls, there are a small set of rules concerning their attributes that you should follow if at all possible. They are explained below.

Restrictions

Size

Image dimensions should be as close as they can be to the highest n2px in width and height possible without upscaling. The reason for this is that Kodi uses swizzled textures which are quicker to render and quicker to load once they're compressed into the Textures.xbt file. Note that the image does not need to be square, and will not be scaled into an n2 size. Rather, any pixels outside of a n2 size will simply be dead space (and more importantly, wasted memory). If you cannot manage this, then TexturePacker will opt for a linear (non-swizzled) texture format which must be aligned to 64 pixels on the x-axis, but has no restrictions on the y-axis. These are slightly slower to load and render, but for the most part there's not a lot of difference. As TexturePacker does the image injection into Textures.xbt it will tell you what format it's using, and how much pixel waste (i.e. extra memory) is created by each one.

Format

If you wish to use full 8-bit transparency, then use the PNG file format. If you only need a single transparent colour, then you can specify this in the <colorkey> tag, so any image will be fine, but it is suggested that you use PNG and JPEG as much as possible. Be aware that once the images are injected into Textures.xbt, they are no longer stored as a JPEG or PNG—rather they are stored in a format for faster loading. The size of the images (in KiB) is therefore not as important as the size of the images in pixels—so feel free to store them in a lossless (e.g. PNG) container format if you wish.

The only exception to this is when you require an animated texture. In this case, Kodi only supports animated GIFs. There are also some animated GIFs that may not work. If issues arise, use software such as Adobe Photoshop CS3 or later (Adobe ImageReady prior to that), or Mooii PhotoScape X and make sure you set the file's gif-anim attribute to restore to background and they should work fine.

TexturePacker

For TexturePacker to work correctly, make sure your images:

  • are at least 4x4px in size
  • use an RGB colorspace (do not use grayscale or an indexed color palette)
  • use 8-bit integer bit depth

Attributes

The following attributes can be used to alter how a texture is rendered. These apply to all texture tags (for example <texturefocus> and so on). Note that they're all lower-case, as XML is case-sensitive.

Attribute Description
border Used to specify a region of the texture to be considered a border that should not be scaled when the texture is scaled to fit a control's dimensions. The portion in the border region will remain unscaled. Particularly useful to achieve rounded corners that do not change size when a control is resized. Note that zoom animations and GUI rescaling will still affect the border region - it is just the scaling of the texture to the control size which is unaffected. Using border="5" will give a 5 pixel border all around the texture. You can specify each of the border amounts on each edge individually using border="left,top,right,bottom".
flipx Specifies that the texture should be flipped in the horizontal direction, useful for reflections.
flipy Specifies that the texture should be flipped in the vertical direction, useful for reflections.
background Used on the <imagepath> tag. When set to "true", this forces the image to be loaded via the large texture manager (except for textures located in Textures.xbt). See: Background Image Loader
diffuse Specifies a diffuse texture which is "modulated" or multiplied with the texture in order to give specific effects, such as making the image gain transparency, or tint it in various ways. As it's applied per-pixel many effects are possible, the most popular being by a transparent reflection which slowly gets more and more opaque. This is achieved using a WHITE image where the transparency increases as you move down the texture.
colordiffuse This specifies the color to be used for the texture basis. It's is specified in hexadecimal notation using the AARRGGBB format. If you define <texture colordiffuse="FFFFAAFF">texture.png</texture> (magenta), the image will be given a magenta tint when rendered. You can also specify this as a name from the colour theme, or you can also use $VAR and $INFO for dynamic values.

See also

Development: