Skip to content
Christian Schlinkmann edited this page Oct 26, 2015 · 12 revisions

Textures

The <texture> tag specifies a texture in the XML3D scene. It may be used in <material> elements, <data> elements and <mesh> elements. The <texture> itself specifies the name, the wrapping parameters and the filtering parameters of the texture.

Pixel Source

The texture's pixel source is given by its children. Currently supported children are the HTML elements <img> and <video>.

Wrapping parameters

attribute values default description
wrap clamp, repeat clamp clamp Sets the wrap parameter for texture coordinates in the s and t dimensions. The values correspond to those available in OpenGL.

Filtering parameters

filter := (<min-filter-mode> <mag-filter-mode>) | <mag-filter-mode>

min-filter-mode := nearest | linear | nearest-mipmap-nearest | nearest-mipmap-linear | linear-mipmap-nearest | linear-mipmap-linear

mag-filter-mode := nearest | linear

If only the mag-filter-mode is given, the specified function is used for both, minifying and magnification. Otherwise, the min-filter-mode is used for minifying and the mag-filter-mode is used for magnification. The functions specified by the filter modes correspond to those in OpenGL (NEAREST, LINEAR, NEAREST_MIPMAP_NEAREST, NEAREST_MIPMAP_LINEAR, LINEAR_MIPMAP_NEAREST, and LINEAR_MIPMAP_LINEAR). The default filter mode is "linear-mipmap-linear linear".

Power of Two Textures

In WebGL a power of two (POT) texture is one where both dimensions (x and y) are a power of two (eg. 256x512 or 64x64). Any other texture is considered non-power of two (NPOT).

This distinction is important because in WebGL NPOT textures may only be used with "clamp" wrapping and "linear" filtering, while POT textures support all wrapping and filtering modes. For this reason XML3D will internally scale any NPOT texture to a POT texture if any of the filtering or wrapping parameters are set to an invalid value.

Generation of Mipmaps

Mipmaps are generated automatically if any of the set filter parameters require them. In case of an NPOT texture it will first be scaled appropriately.

Clone this wiki locally