AdvancedOptional_GC tracking data, undefined if not being tracked
the alpha mode of the texture
Only really affects RenderTextures. Should we use antialiasing for this texture. It will look better, but may impact performance as a Blit operation will be required to resolve the texture.
how many array layers this texture has; 1 for a 3D texture
If true, the Garbage Collector will unload this texture if it is not used after a period of time
Should we auto generate mipmaps for this texture? This will automatically generate mipmaps for this texture when uploading to the GPU. Mipmapped textures take up more memory, but can look better when scaled down.
For performance reasons, it is recommended to NOT use this with RenderTextures, as they are often updated every frame.
If you do, make sure to call updateMipmaps after you update the texture.
A 3D texture on WebGPU needs TextureSourceOptions.storage and rgba8unorm or rgba16float,
because a compute shader writes the mips. WebGL fills the chain with gl.generateMipmap.
the depth of a 3D texture in texels; 1 for every other texture
ReadonlydestroyedHas the source been destroyed?
how the texture is stored (WebGPU texture dimension), derived from TextureSource#viewDimension
the format that the texture data has
the height of this texture source, accounting for resolution eg pixelHeight 200, resolution 2, then height will be 100
optional label, can be used for debugging
The number of mip levels to generate for this texture. this is overridden if autoGenerateMipmaps is true. it is read only!
the pixel height of this texture source. This is the REAL pure number, not accounting resolution
the pixel width of this texture source. This is the REAL pure number, not accounting resolution
the resource that will be uploaded to the GPU. This is where we get our pixels from eg an ImageBimt / Canvas / Video etc
Whether compute shaders can write to this texture on WebGPU. See TextureSourceOptions.storage. Read when the GPU texture is created.
Readonlyuidunique id for this Texture source
how this texture is viewed/sampled by shaders (WebGPU view dimension)
the width of this texture source, accounting for resolution eg pixelWidth 200, resolution 2, then width will be 100
StaticdefaultThe default options used when creating a new TextureSource. override these to add your own defaults
StaticextensionStaticfromA helper function that creates a new TextureSource based on the resource you provide.
The resource to create the texture source from.
The size along z that the GPU allocates: TextureSource#depth for a 3D texture,
TextureSource#arrayLayerCount otherwise. WebGPU's depthOrArrayLayers.
Specifies the minimum and maximum levels of detail, respectively, used internally when sampling a texture.
Specifies the minimum and maximum levels of detail, respectively, used internally when sampling a texture.
Specifies the sampling behavior when the sample footprint is smaller than or equal to one texel.
Specifies the maximum anisotropy value clamp used by the sampler.
Specifies the sampling behavior when the sample footprint is larger than one texel.
Specifies behavior for sampling between mipmap levels.
the resolution of the texture. Changing this number, will not change the number of pixels in the actual texture but will the size of the texture when rendered.
changing the resolution of this texture to 2 for example will make it appear twice as small when rendered (as pixel density will have increased)
the height of the resource. This is the REAL pure number, not accounting resolution
the width of the resource. This is the REAL pure number, not accounting resolution
setting this will set magFilter,minFilter and mipmapFilter all at once!
returns itself
the style of the texture
Destroys this texture source
Resize the texture, this is handy if you want to use the texture as a render texture
Optionalwidth: number
the new width of the texture
Optionalheight: number
the new height of the texture
Optionalresolution: number
the new resolution of the texture
This will unload the Texture source from the GPU. This will free up the GPU memory As soon as it is required fore rendering, it will be re-uploaded.
Uploads the buffer to the GPU. Call this after changing the data in TextureSource#resource.
The buffer is a flat list of texels in row-major order, so texel i sits at
x = i % width, y = floor(i / width). Pass a texel range to upload only that part of
the texture; leave it out to upload everything.
The upload happens immediately for every renderer that already holds the texture, and the
range applies to this call only. If you change several parts of the buffer, track the dirty
span yourself and call update once with the combined range. Each call has a fixed cost on
top of the bytes it moves, which reaches tens of microseconds on some mobile GPUs. One span
usually beats many small calls.
Partial uploads assume the buffer holds exactly width * height texels. A 3D texture or 2D array
always uploads whole, so it takes no range.
index of the first texel to upload
index one past the last texel to upload (exclusive, like TypedArray.subarray)
Lets the renderer know that this texture has been updated and its mipmaps should be re-generated. This is only important for RenderTexture instances, as standard Texture instances will have their mipmaps generated on upload. You should call this method after you make any change to the texture
The reason for this is is can be quite expensive to update mipmaps for a texture. So by default, We want you, the developer to specify when this action should happen.
Generally you don't want to have mipmaps generated on Render targets that are changed every frame,
Statictest
A texture source that uses a TypedArray or ArrayBuffer as its resource
Without a
format, the array type picks it:Float32Arraygivesrgba32float, 32-bit integer arrays givergba32uint, 16-bit integer arrays givergba16uint, anything elsebgra8unorm. Integer formats default toalphaMode: 'no-premultiply-alpha', since integer data can't be premultiplied on upload; an explicitalphaModestill wins.Pass
depthfor a 3D texture, orarrayLayerCountfor a 2D array. The buffer holds the slices (or layers) one after another, each in row-major order, so texel(x, y, z)sits at indexx + (y * width) + (z * width * height). These upload whole, so BufferImageSource#update takes no range.rgba32float, the default for aFloat32Array, needs an optional feature for linear filtering that PixiJS doesn't request on WebGPU. UsescaleMode: 'nearest'with it, or pickrgba8unorm,r8unormorrgba16floatfor smooth sampling.Example
Example
A 3D noise texture for volumetric effects, sampled with
sampler3D(GLSL) ortexture_3d<f32>(WGSL):