Hilo3d API - v2.0.0
    Preparing search index...

    Class ShaderMaterial

    Native GLSL ES 3.00 shader material.

    Numeric, vector and matrix data must be supplied through registered std140 uniform blocks. Opaque sampler types are the only uniforms permitted outside a block.

    Hilo3d.registerUniformBlockBinding('EffectBlock');
    const effectLayout = Hilo3d.createStd140Layout({
    effectColor: 'vec4',
    strength: 'float'
    });
    const effectBlock = Hilo3d.UniformBuffer.fromSchema(effectLayout, {
    effectColor: [0.6, 0.8, 1, 1],
    strength: 0.75
    });

    const material = new Hilo3d.ShaderMaterial({
    attributes: { a_position: 'POSITION' },
    uniformBlocks: { EffectBlock: effectBlock },
    vs: `#version 300 es
    layout(std140) uniform EffectBlock {
    vec4 effectColor;
    float strength;
    };
    in vec3 a_position;
    out vec4 v_color;
    void main() {
    v_color = vec4(effectColor.rgb * strength, effectColor.a);
    gl_Position = vec4(a_position, 1.0);
    }`,
    fs: `#version 300 es
    precision highp float;
    layout(std140) uniform EffectBlock {
    vec4 effectColor;
    float strength;
    };
    in vec4 v_color;
    layout(location = 0) out vec4 outColor;
    void main() {
    outColor = v_color;
    }`
    });

    effectBlock.set('strength', 1);

    Hierarchy (View Summary)

    Index
    alphaCutoff: number = 0

    透明度剪裁,如果渲染的颜色透明度大于等于这个值的话渲染为完全不透明,否则渲染为完全透明

    attributes: MaterialBindingMap = {}
    blend: boolean = false

    是否开启颜色混合

    blendDst: number = ZERO

    颜色混合目标比例

    blendDstAlpha: number = ZERO

    透明度混合目标比例

    blendEquation: number = FUNC_ADD

    颜色混合方式

    blendEquationAlpha: number = FUNC_ADD

    透明度混合方式

    blendSrc: number = ONE

    颜色混合来源比例

    blendSrcAlpha: number = ONE

    透明度混合来源比例

    castShadows: boolean = true

    是否投射阴影

    className: string = 'ShaderMaterial'
    depthFunc: number = LEQUAL

    深度测试方法

    depthMask: boolean = true

    是否开启depthMask

    depthRange: [number, number] = ...

    深度测试Range

    depthTest: boolean = true

    是否开启深度测试

    emission: MaterialTextureValue = null
    enableDrawBuffers: boolean = false

    是否开启 drawBuffers

    enableTextureLod: boolean = false

    是否开启 texture lod

    exposure: number = 1

    曝光度,仅在 useHDR 为 true 时生效

    frontFace: number = CCW

    front face winding orientation

    fs: string = ''

    fragment shader 代码

    gammaCorrection: boolean = false

    是否开启 gamma 矫正

    gammaFactor: number = 2.2

    gamma值

    getCustomRenderOption: CustomRenderOptionProvider | null = null

    获取定制的渲染参数

    id: string
    ignoreTransparent: boolean = false

    是否忽略透明度

    isDiffuseEnvAndAmbientLightWorkTogether: boolean = false

    是否环境贴图和环境光同时生效

    isMaterial: true
    isShaderMaterial: boolean = true
    lightType: string = 'NONE'

    光照类型

    name: string | null = null

    name

    needBasicAttributes: boolean = true

    是否需要加基础 attributes

    needBasicUniforms: boolean = true

    是否需要加基础 uniforms

    normalMap: Texture<TextureImageSource> | null = null

    法线贴图

    normalMapScale: number = 1

    法线贴图scale

    onBeforeCompile: MaterialBeforeCompile | null = null
    parallaxMap: Texture<TextureImageSource> | null = null

    视差贴图

    receiveShadows: boolean = true

    是否接受阴影

    renderOrder: number = 0

    渲染顺序数字小的先渲染(透明物体和不透明在不同的队列)

    sampleAlphaToCoverage: boolean = false

    SAMPLE_ALPHA_TO_COVERAGE

    shaderCacheId: string | null = null

    shader cache id

    shaderName: string | null = null

    shader name,会在 shader 中加个 SHADER_NAME 宏,不填用 className 代替。

    stencilFunc: number = ALWAYS

    stencilFunc func

    stencilFuncMask: number = 0xff

    stencilFunc mask

    stencilFuncRef: number = 1

    stencilFunc ref

    stencilMask: number = 0xff

    stencilMask

    stencilOpFail: number = KEEP

    stencilOp fail

    stencilOpZFail: number = KEEP

    stencilOp zfail

    stencilOpZPass: number = KEEP

    stencilOp zpass

    stencilTest: boolean = false

    stencilTest

    transparency: number | Texture<TextureImageSource> = 1

    透明度 0~1

    uniformBlocks: Record<string, UniformBuffer> = {}

    Registered std140 blocks keyed by GLSL block name.

    uniforms: MaterialBindingMap = {}

    Semantic resolvers for canonical block fields and sampler bindings. Program linking rejects every active classic uniform that is not an opaque sampler.

    useHDR: boolean = false

    是否使用HDR

    useHeaderCache: boolean = false

    是否使用 header cache shader

    usePhysicsLight: boolean = false

    是否使用物理灯光

    userData: unknown = null

    用户数据

    uvMatrix: Matrix3 | null = null

    uv transform eg:new Matrix3().fromRotationTranslationScale(Math.PI/2, 0, 0, 2, 2)

    uvMatrix1: Matrix3 | null = null

    uv1 transform eg:new Matrix3().fromRotationTranslationScale(Math.PI/2, 0, 0, 2, 2)

    vs: string = ''

    vertex shader 代码

    wireframe: boolean = false

    是否开启网格模式

    • get cullFace(): boolean

      是否开启 CullFace

      Returns boolean

    • set cullFace(value: boolean): void

      是否开启 CullFace

      Parameters

      • value: boolean

      Returns void

    • get cullFaceType(): number

      CullFace 类型

      Returns number

    • set cullFaceType(value: number): void

      CullFace 类型

      Parameters

      • value: number

      Returns void

    • get isDirty(): boolean

      当前是否需要强制更新

      Returns boolean

    • set isDirty(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get premultiplyAlpha(): boolean

      是否预乘 alpha

      Returns boolean

    • set premultiplyAlpha(value: boolean): void

      是否预乘 alpha

      Parameters

      • value: boolean

      Returns void

    • get revision(): number

      Monotonic material-data revision observed independently by every backend.

      Returns number

    • get side(): number

      显示面,可选值 FRONT, BACK, FRONT_AND_BACK

      Returns number

    • set side(value: number): void

      显示面,可选值 FRONT, BACK, FRONT_AND_BACK

      Parameters

      • value: number

      Returns void

    • get transparent(): boolean

      是否需要透明

      Returns boolean

    • set transparent(value: boolean): void

      是否需要透明

      Parameters

      • value: boolean

      Returns void

    • 增加贴图 uniforms

      Parameters

      • textureUniforms: Readonly<Record<string, string>>

        textureName:semanticName 键值对

      Returns void