API

Function ThinWalledScatterWeightsAsync

  • Compute the OpenPBR thin-walled scatter weights from a transmission operand (T) and a scatter-strength operand (S). Both operands are read from their R channel (after the operand's channel swizzle and factor), and each weight is broadcast to all four output channels.

    For each texel:

      transmission_weight = T * (1 - S)
    subsurface_weight = T * S / (1 - T*(1-S))

    These are the OpenPBR weight values when a thin-walled glTF material combines KHR_materials_transmission (T = transmissionFactor * transmissionTexture) and KHR_materials_scatter (S = scatterStrengthFactor * scatterStrengthTexture): scatterStrengthFactor converts a fraction of the coherent transmission budget into scattered (subsurface) transmission while keeping the total translucency constant.

    When both operands are constants the computation is performed entirely on the CPU. When either operand has a texture, each weight is computed from T and S in a single GPU pass, so only the two outputs are quantized. Near T = 1 the subsurface weight divides two small values, and quantizing intermediates (e.g. T * S or 1 - S to 8 bits) would change it drastically.

    Parameters

    • name: string

      Base name for any procedural textures created

    • transmission: ITextureProcessOperand

      T operand (transmissionFactor × optional transmissionTexture, R channel)

    • scatter: ITextureProcessOperand

      S operand (scatterStrengthFactor × optional scatterStrengthTexture, R channel)

    • scene: Scene

      Scene used for GPU passes when textures are involved

    Returns Promise<
        {
            subsurface: ITextureProcessOperand;
            transmission: ITextureProcessOperand;
        },
    >

    { transmission, subsurface } – two operands ready to assign to transmissionWeightTexture / subsurfaceWeightTexture (and the corresponding scalar factors)