Create a new Texture instance.
The graphics device used to manage this texture.
Optional
options: {Object for passing optional arguments.
Optional
addressU?: numberThe repeat mode to use in the U direction. Defaults to ADDRESS_REPEAT.
Optional
addressV?: numberThe repeat mode to use in the V direction. Defaults to ADDRESS_REPEAT.
Optional
addressW?: numberThe repeat mode to use in the W direction. Defaults to ADDRESS_REPEAT.
Optional
anisotropy?: numberThe level of anisotropic filtering to use. Defaults to 1.
Optional
arrayLength?: numberSpecifies whether the texture is to be a 2D texture array. When passed in as undefined or < 1, this is not an array texture. If >= 1, this is an array texture. (not supported by WebGL1). Defaults to undefined.
Optional
compareFunc?: numberComparison function when compareOnRead is enabled (not supported by WebGL1). Can be:
Defaults to FUNC_LESS.
Optional
compareOnRead?: booleanWhen enabled, and if texture format is PIXELFORMAT_DEPTH or PIXELFORMAT_DEPTHSTENCIL, hardware PCF is enabled for this texture, and you can get filtered results of comparison using texture() in your shader (not supported by WebGL1). Defaults to false.
Optional
cubemap?: booleanSpecifies whether the texture is to be a cubemap. Defaults to false.
Optional
depth?: numberThe number of depth slices in a 3D texture (not supported by WebGl1).
Optional
fixCubemapSeams?: booleanSpecifies whether this cubemap texture requires special seam fixing shader code to look right. Defaults to false.
Optional
flipY?: booleanSpecifies whether the texture should be flipped in the Y-direction. Only affects textures with a source that is an image, canvas or video element. Does not affect cubemaps, compressed textures or textures set from raw pixel data. Defaults to false.
Optional
format?: numberThe pixel format of the texture. Can be:
Defaults to PIXELFORMAT_RGBA8.
Optional
height?: numberThe height of the texture in pixels. Defaults to 4.
Optional
levels?: Array of Uint8Array or other supported browser interface; or a two-dimensional array of Uint8Array if options.arrayLength is defined and greater than zero.
Optional
magFilter?: numberThe magnification filter type to use. Defaults to FILTER_LINEAR.
Optional
minFilter?: numberThe minification filter type to use. Defaults to FILTER_LINEAR_MIPMAP_LINEAR.
Optional
mipmaps?: booleanWhen enabled try to generate or use mipmaps for this texture. Default is true.
Optional
name?: stringThe name of the texture. Defaults to null.
Optional
premultiplyAlpha?: booleanIf true, the alpha channel of the texture (if present) is multiplied into the color channels. Defaults to false.
Optional
projection?: stringThe projection type of the texture, used when the texture represents an environment. Can be:
Defaults to TEXTUREPROJECTION_CUBE if options.cubemap is true, otherwise TEXTUREPROJECTION_NONE.
Optional
storage?: booleanDefines if texture can be used as a storage texture by a compute shader. Defaults to false.
Optional
type?: stringSpecifies the texture type. Can be:
Defaults to TEXTURETYPE_DEFAULT.
Optional
volume?: booleanSpecifies whether the texture is to be a 3D volume (not supported by WebGL1). Defaults to false.
Optional
width?: numberThe width of the texture in pixels. Defaults to 4.
// Create a 8x8x24-bit texture
const texture = new pc.Texture(graphicsDevice, {
width: 8,
height: 8,
format: pc.PIXELFORMAT_RGB8
});
// Fill the texture with a gradient
const pixels = texture.lock();
const count = 0;
for (let i = 0; i < 8; i++) {
for (let j = 0; j < 8; j++) {
pixels[count++] = i * 32;
pixels[count++] = j * 32;
pixels[count++] = 255;
}
}
texture.unlock();
Protected
_invalidProtected
_lockedProtected
_lockedProtected
_storageProtected
idThe name of the texture.
Gets the addressing mode to be applied to the texture horizontally.
Sets the addressing mode to be applied to the texture horizontally. Can be:
Gets the addressing mode to be applied to the texture vertically.
Sets the addressing mode to be applied to the texture vertically. Can be:
Gets the addressing mode to be applied to the 3D texture depth.
Sets the addressing mode to be applied to the 3D texture depth. Can be:
Gets the integer value specifying the level of anisotropy to apply to the texture.
Sets the integer value specifying the level of anisotropy to apply to the texture ranging from 1 (no anisotropic filtering) to the GraphicsDevice property maxAnisotropy.
Returns true if this texture is a 2D texture array and false otherwise.
Returns the number of textures inside this texture if this is a 2D array texture or 0 otherwise.
Sets the comparison function when compareOnRead is enabled.
Sets the comparison function when compareOnRead is enabled. Possible values:
Gets whether you can get filtered results of comparison using texture() in your shader.
When enabled, and if texture format is PIXELFORMAT_DEPTH or PIXELFORMAT_DEPTHSTENCIL, hardware PCF is enabled for this texture, and you can get filtered results of comparison using texture() in your shader (not supported on WebGL1).
Returns true if this texture is a cube map and false otherwise.
The number of depth slices in a 3D texture.
Gets whether the texture should be flipped in the Y-direction.
Sets whether the texture should be flipped in the Y-direction. Only affects textures with a source that is an image, canvas or video element. Does not affect cubemaps, compressed textures or textures set from raw pixel data. Defaults to true.
The pixel format of the texture. Can be:
The height of the texture in pixels.
Gets the magnification filter to be applied to the texture.
Sets the magnification filter to be applied to the texture. Can be:
Gets the minification filter to be applied to the texture.
Sets the minification filter to be applied to the texture. Can be:
Gets whether the texture should generate/upload mipmaps.
Sets whether the texture should generate/upload mipmaps.
Returns true if all dimensions of the texture are power of two, and false otherwise.
Defines if texture can be used as a storage texture by a compute shader.
Returns true if this texture is a 3D volume and false otherwise.
The width of the texture in pixels.
Get the pixel data of the texture. If this is a cubemap then an array of 6 images will be returned otherwise a single image.
Optional
mipLevel: number = 0A non-negative integer specifying the image level of detail. Defaults to 0, which represents the base image source. A level value of N, that is greater than 0, represents the image source for the Nth mipmap reduction level.
The source image of this texture. Can be null if source not assigned for specific image level.
Locks a miplevel of the texture, returning a typed array to be filled with pixel data.
Optional
options: { face?: number; level?: number; mode?: number } = {}Optional options object. Valid properties are as follows:
Optional
face?: numberIf the texture is a cubemap, this is the index of the face to lock.
Optional
level?: numberThe mip level to lock with 0 being the top level. Defaults to 0.
Optional
mode?: numberThe lock mode. Can be:
A typed array containing the pixel data of the locked mip level.
Set the pixel data of the texture from a canvas, image, video DOM element. If the texture is a cubemap, the supplied source must be an array of 6 canvases, images or videos.
A canvas, image or video element, or an array of 6 canvas, image or video elements.
Optional
mipLevel: number = 0A non-negative integer specifying the image level of detail. Defaults to 0, which represents the base image source. A level value of N, that is greater than 0, represents the image source for the Nth mipmap reduction level.
Forces a reupload of the textures pixel data to graphics memory. Ordinarily, this function is called by internally by Texture#setSource and Texture#unlock. However, it still needs to be called explicitly in the case where an HTMLVideoElement is set as the source of the texture. Normally, this is done once every frame before video textured geometry is rendered.
A texture is a container for texel data that can be utilized in a fragment shader. Typically, the texel data represents an image that is mapped over geometry.