pixi.js
    Preparing search index...

    Interface TextureSourceOptions<T>Advanced

    options for creating a new TextureSource

    depth, which makes a 3D texture, is on TextureShapeOptions; the constructor takes both.

    interface TextureSourceOptions<T extends Record<string, any> = any> {
        _resourceId?: number;
        addressMode?: WRAP_MODE;
        addressModeU?: WRAP_MODE;
        addressModeV?: WRAP_MODE;
        addressModeW?: WRAP_MODE;
        alphaMode?: ALPHA_MODES;
        antialias?: boolean;
        arrayLayerCount?: number;
        autoGarbageCollect?: boolean;
        autoGenerateMipmaps?: boolean;
        compare?: COMPARE_FUNCTION;
        destroyed?: boolean;
        dimensions?: TEXTURE_DIMENSIONS;
        dynamic?: boolean;
        format?: TEXTURE_FORMATS;
        height?: number;
        label?: string;
        lodMaxClamp?: number;
        lodMinClamp?: number;
        magFilter?: SCALE_MODE;
        maxAnisotropy?: number;
        minFilter?: SCALE_MODE;
        mipLevelCount?: number;
        mipmapFilter?: SCALE_MODE;
        resolution?: number;
        resource?: T;
        scaleMode?: SCALE_MODE;
        storage?: boolean;
        transient?: boolean;
        viewDimension?: TEXTURE_VIEW_DIMENSIONS;
        width?: number;
        wrapMode?: WRAP_MODE;
        destroy?(): void;
        update?(): void;
    }

    Type Parameters

    • T extends Record<string, any> = any

    Hierarchy (View Summary)

    Index
    _resourceId?: number
    addressMode?: WRAP_MODE

    setting this will set wrapModeU,wrapModeV and wrapModeW all at once!

    addressModeU?: WRAP_MODE

    specifies the {{GPUAddressMode|address modes}} for the texture width, height, and depth coordinates, respectively.

    addressModeV?: WRAP_MODE

    specifies the {{GPUAddressMode|address modes}} for the texture width, height, and depth coordinates, respectively.

    addressModeW?: WRAP_MODE

    Specifies the {{GPUAddressMode|address modes}} for the texture width, height, and depth coordinates, respectively.

    alphaMode?: ALPHA_MODES

    the alpha mode of the texture

    antialias?: boolean

    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.

    arrayLayerCount?: number

    The number of array layers for this texture source. Setting it above 1 makes a '2d-array' texture.

    This maps to WebGPU's GPUTextureDescriptor.size.depthOrArrayLayers and is used for array-backed textures such as cube maps (6 layers). Can't be combined with depth.

    1
    @advanced
    autoGarbageCollect?: boolean

    If true, the Garbage Collector will unload this texture if it is not used after a period of time

    autoGenerateMipmaps?: boolean

    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.

    When provided the sampler will be a comparison sampler with the specified COMPARE_FUNCTION. Note: Comparison samplers may use filtering, but the sampling results will be implementation-dependent and may differ from the normal filtering rules.

    destroyed?: boolean = false

    Has the style been destroyed?

    dimensions?: TEXTURE_DIMENSIONS

    How the texture is stored. Derived from TextureSourceOptions.viewDimension: '3d' and '1d' views are stored as themselves, every other view as '2d'.

    since 8.22.0 - derived from viewDimension and depth, so leave it out. A value that disagrees with the view throws in debug builds.

    dynamic?: boolean

    Used by RenderTexture.create to allow resizing. Not used by TextureSource itself.

    the format that the texture data has

    height?: number

    the pixel height of this texture source. This is the REAL pure number, not accounting resolution

    label?: string

    optional label, can be used for debugging

    lodMaxClamp?: number

    Specifies the minimum and maximum levels of detail, respectively, used internally when sampling a texture.

    lodMinClamp?: number

    specifies the minimum and maximum levels of detail, respectively, used internally when sampling a texture.

    magFilter?: SCALE_MODE

    specifies the sampling behavior when the sample footprint is smaller than or equal to one texel.

    maxAnisotropy?: number

    Specifies the maximum anisotropy value clamp used by the sampler. Note: Most implementations support TextureStyle#maxAnisotropy values in range between 1 and 16, inclusive. The used value of TextureStyle#maxAnisotropy will be clamped to the maximum value that the platform supports.

    setting this to anything higher than 1 will set scale modes to 'linear'

    minFilter?: SCALE_MODE

    specifies the sampling behavior when the sample footprint is larger than one texel.

    mipLevelCount?: number

    The number of mip levels to generate for this texture. this is overridden if autoGenerateMipmaps is true

    mipmapFilter?: SCALE_MODE

    specifies behavior for sampling between mipmap levels.

    resolution?: number

    the resolution of the texture.

    resource?: T

    the resource that will be uploaded to the GPU. This is where we get our pixels from eg an ImageBimt / Canvas / Video etc

    scaleMode?: SCALE_MODE

    setting this will set magFilter,minFilter and mipmapFilter all at once!

    storage?: boolean

    WebGPU only. Lets compute shaders write to this texture as a storage texture (a texture_storage_2d or texture_storage_3d binding in WGSL). PixiJS still samples it as a normal texture. WebGL has no storage textures and ignores this.

    Only some formats can be storage textures: every device supports rgba8unorm, rgba16float, r32float, rg32float, rgba32float and the matching rgba8, rgba16, r32, rg32 and rgba32 integer formats. bgra8unorm needs the bgra8unorm-storage feature and formats such as r8unorm or r16float need texture-formats-tier1; PixiJS enables both when the GPU has them. WebGPU rejects any other format when the texture is created.

    const volume = new TextureSource({ width: 64, height: 64, depth: 64, format: 'rgba8unorm', storage: true });

    // write it from your own compute pass (renderer is a WebGPURenderer)
    const view = renderer.texture.getGpuSource(volume).createView();
    // ... bind `view` to a `texture_storage_3d<rgba8unorm, write>`, dispatch, submit

    // then sample it in any PixiJS shader as a texture_3d
    false
    
    transient?: boolean

    WebGPU only. Marks an antialiased render target as single-pass: it is never rendered into again with clear: false, never has a filter or mask pop back onto it, and its depth/stencil is never needed after the pass. PixiJS then discards its multisample buffers at the end of the pass instead of writing them to memory: depth/stencil, and on GPUs that aren't tile-based also colour (tile-based GPUs already discard colour; see GpuExtensions.tileBased). If the target is reopened anyway, the colour is restored from the resolved texture but the depth/stencil is lost.

    false
    
    viewDimension?: TEXTURE_VIEW_DIMENSIONS

    How this texture is viewed/sampled by shaders.

    This aligns with WebGPU's GPUTextureViewDescriptor.dimension. It defaults from the size: depth gives '3d', arrayLayerCount > 1 gives '2d-array', anything else '2d'. Pass it only when the size doesn't decide it, e.g. 'cube' for 6 layers viewed as a cube map.

    width?: number

    the pixel width of this texture source. This is the REAL pure number, not accounting resolution

    wrapMode?: WRAP_MODE