5.55. ShaderSourceTexture (property)

<shader_source_texture> ‐ A texture bitmap used by shader programs

5.55.1. Attributes

NameTypeDefaults
idIDNone (required)
targetSTRINGfragment_texture
encodingSTRINGNone (required)
xlink:hrefURINone (required)
indexINTEGERNone (required)
mipmappedBOOLEANtrue

5.55.2. Description

This element defines a 2-dimensional texture that is used by a shader and defined as a child element of the shader_source element.

The string value of the target attribute is equal to fragment_texture or vertex_texture depending on whether the texture is used as an argument for the fragment program or for the vertex program.

The texture is copied from a file. The external file reference, given by the xlink:href attribute, defines the URI reference (Uniform Resource Identifier) of the file that contains the bitmap image.

The string value of the encoding attribute is equal to jpeg, tiff, png, pnga, png_gray, or pnga_gray depending on the image format. The formats png_gray, pnga_gray, png, and pnga are PNG formats; pnga and pnga_gray contain alpha (transparency) information while png and png_gray do not. The PNG format is accepted for RGB images with or without alpha channel (png and pnga), and gray level images with or without alpha channel (png_gray and pnga_gray). Indexed PNG images cannot be used for textures.

The boolean value of the mipmapped attribute controls whether mipmapping is used for computing textured pixels at different levels of detail.

The integer value of the index attribute defines the rank N of the texture that is given as uniform sampler2D lookupTableN parameter to the vertex program. or the fragment program if there is only one category of texture. If both vertex and fragment textures are given, the ranks are computed independently for each texture category: if there are 2 vertex and 3 fragment textures, the vertex texture with the lowest index will be associated with lookupTable1 vertex program parameter, and the other vertex texture with lookupTable2. Similarly the 3 fragment texture will be associated with lookupTable1 to lookupTable3 parameters according to their rank given by the value of the index attribute.

5.55.3. Expected child

None.

5.55.4. Example

The example below defines a PNG fragment texture without alpha value. It is the first texture in the texture list. The second one is a PNG vertex texture with alpha transparency. Both textures are mipmapped.

<shader_source_texture index="1" encoding="png" target="fragment_texture"
               mipmapped="true"
               xlink:href="textures/puddles.png" id="hand"/>
<shader_source_texture index="2" encoding="pnga" target="vertex_texture"
               mipmapped="true" 
               xlink:href="textures/checker.png" id="hand"/>