we
    Preparing search index...

    纹理与材质可以公用的的初始化参数

    premultipliedAlpha:是否预乘alpha,默认为true,只有在有透明的情况下有效。

    upsideDownY:是否上下翻转Y轴,默认为true

    format:纹理的格式,默认为rgba8unorm-srgb

    usage:纹理的使用方式,默认为TEXTURE_BINDING | COPY_SRC | COPY_DST | RENDER_ATTACHMENT

    interface I_Texture2D {
        format: GPUTextureFormat;
        mipmap?: I_mipmap;
        name?: string;
        premultipliedAlpha?: boolean;
        sampler?: GPUFilterMode | GPUSamplerDescriptor;
        samplerBindingType?: GPUSamplerBindingType;
        size: { height: number; width: number };
        source: ArrayBuffer;
        update?: (scope: any) => any;
        updateAtEnd?: (scope: any) => any;
        upsideDownY?: boolean;
        usage?: number;
    }

    Hierarchy (View Summary)

    Index

    Properties

    format: GPUTextureFormat

    纹理的格式,默认=rgba8unorm

    mipmap?: I_mipmap

    mipmap:是否生成mipmap

    name?: string
    premultipliedAlpha?: boolean

    纹理的premultipliedAlpha,默认:false(只有color类纹理才需要预乘,数据类纹理不需要预乘) 1、如果为true,copyExternalImageToTexture()时,预乘alpha。 2、如果为false,copyExternalImageToTexture()时,不预乘alpha。

    何时使用: 1、用标准透明混合(Blending)的纹理。 标准混合方程:src × 1 + dst × (1−srcA):要求 src 是预乘的,否则混合结果错误。 非预乘混合方程:src × srcA + dst × (1−srcA):要求 src 是非预乘的,否则混合结果错误。(如果这时预乘,则变暗,相当于2次乘法了) 2、过滤 / 插值更正确(抗锯齿、mipmap) 预乘:RGB 与 A 同步缩放,过滤 / 插值结果自然正确,无异常色边。 非预乘:透明边缘插值会出现灰边、黑边(RGB 与 A 插值不同步) 3、透明度叠加更自然 多层透明叠加时,预乘能保证: 半透明物体亮度衰减线性合理 避免 “透明越叠越暗” 何时不用: 1、不透明纹理 2、alphaTest

    sampler?: GPUFilterMode | GPUSamplerDescriptor

    采样器有两种采样器设置方式 1、简单设置采样器模式( "linear" | "nearest");采样器过滤模式,默认为linear 2、采用完整的GPUSamplerDescriptor设置

    samplerBindingType?: GPUSamplerBindingType

    采样器绑定类型,默认是filtering ("comparison" | "filtering" | "non-filtering") 如果指定了samplerDescriptor,则必须指定samplerBindingType

    size: { height: number; width: number }
    source: ArrayBuffer

    纹理的源数据,由后续的基础类再次定义使用

    update?: (scope: any) => any

    自定义更新functon()

    updateAtEnd?: (scope: any) => any

    在最后执行调用

    upsideDownY?: boolean

    是否上下翻转Y轴 默认=true;

    usage?: number

    纹理的使用方式:使用GPUTextureUsage 默认为:GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC | GPUTextureUsage.COPY_DST