Engine API Reference - v2.16.1
    Preparing search index...

    Class GSplatProcessor

    GSplatProcessor enables GPU-based processing of Gaussian Splat data using custom shader code. Gaussian Splats store per-splat attributes (position, rotation, scale, color, spherical harmonics) in texture streams. This processor reads from source streams and writes results to destination streams, enabling operations like painting, selection marking, or custom data transforms.

    Custom streams can be added to loaded gsplat resources via GSplatFormat#addExtraStreams, or you can create fully procedural splat data using GSplatContainer.

    The source and destination can reference the same resource or component, as long as the read and write streams don't overlap (you cannot read and write the same stream in one pass).

    By default (when source streams are not specified), the processor provides access to the format's built-in getCenter(), getRotation(), getScale(), and getColor() functions for reading splat data. Note: getCenter() must be called first as it loads shared data used by the other functions.

    Custom uniforms can be passed to the shader via setParameter, including scalar values, vectors, and additional textures for effects like brush patterns or lookup tables.

    The following built-in uniforms are available in processing shaders:

    • srcNumSplats (uint) - Number of splats in source resource
    • dstNumSplats (uint) - Number of splats in destination resource
    // Create a processor that reads splat positions and writes to a customColor texture
    const processor = new pc.GSplatProcessor(
    app.graphicsDevice,
    { component: entity.gsplat }, // source: all streams auto-bound
    { component: entity.gsplat, streams: ['customColor'] }, // destination: customColor stream only
    {
    processGLSL: `
    uniform vec4 uPaintSphere;
    uniform vec4 uPaintColor;

    void process() {
    vec3 center = getCenter();
    float dist = distance(center, uPaintSphere.xyz);
    if (dist < uPaintSphere.w) {
    writeCustomColor(uPaintColor);
    } else {
    writeCustomColor(vec4(0.0));
    }
    }
    `,
    processWGSL: `
    uniform uPaintSphere: vec4f;
    uniform uPaintColor: vec4f;

    fn process() {
    let center = getCenter();
    let dist = distance(center, uniform.uPaintSphere.xyz);
    if (dist < uniform.uPaintSphere.w) {
    writeCustomColor(uniform.uPaintColor);
    } else {
    writeCustomColor(vec4f(0.0));
    }
    }
    `
    }
    );

    // Set uniforms and execute
    processor.setParameter('uPaintSphere', [0, 1, 0, 0.5]);
    processor.setParameter('uPaintColor', [1, 0, 0, 1]);
    processor.process();
    Index

    Constructors

    • Creates a new GSplatProcessor instance.

      Parameters

      • device: GraphicsDevice

        The graphics device.

      • source: GSplatProcessorBinding

        Source configuration specifying where to read from. Can specify resource directly or component (for instance textures).

      • destination: GSplatProcessorBinding

        Destination configuration specifying where to write. Can specify resource directly or component (for instance textures).

      • options: { processGLSL?: string; processWGSL?: string }

        Shader options for the processing logic.

        • OptionalprocessGLSL?: string

          GLSL code at module scope. Must define a void process() function that implements the processing logic. Can include uniform declarations and helper functions.

        • OptionalprocessWGSL?: string

          WGSL code at module scope. Must define a fn process() function that implements the processing logic. Can include uniform declarations and helper functions.

      Returns GSplatProcessor

    Properties

    blendState: BlendState = BlendState.NOBLEND

    The blend state to use when processing. Allows accumulation of results (e.g., additive blending for painting). Defaults to no blending.

    Methods

    • Gets a shader parameter value previously set with setParameter.

      Parameters

      • name: string

        The name of the parameter.

      Returns
          | number
          | number[]
          | ArrayBufferView<ArrayBufferLike>
          | StorageBuffer
          | Texture
          | undefined

      The parameter value, or undefined if not set.

    • Sets a shader parameter for this processor. Parameters are applied during processing.

      Parameters

      • name: string

        The name of the parameter (uniform name in shader).

      • data: number | number[] | ArrayBufferView<ArrayBufferLike> | StorageBuffer | Texture

        The value for the parameter.

      Returns void