UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

76 lines (75 loc) 3.91 kB
/** * @import { GraphNode } from '../graph-node.js' * @import { GraphicsDevice } from '../../platform/graphics/graphics-device.js' * @import { StorageBuffer } from '../../platform/graphics/storage-buffer.js' * @import { Texture } from '../../platform/graphics/texture.js' */ /** * Manages tile-based composites for the local compute gsplat renderer. Instead of blitting a * full-screen quad, only tiles that contain splats are drawn using indirect rendering. The vertex * shader procedurally generates tile quads from the built-in vertex index and a storage buffer * of non-empty tile indices populated by the classify pass. * * Owns two separate MeshInstance objects: a color instance (permanently in the layer, pick=false) * and a pick instance (never in any layer, returned on demand by prepareForPicking). * * @ignore */ export class GSplatTileComposite { /** * @param {GraphicsDevice} device - The graphics device. * @param {GraphNode} node - The graph node for the mesh instance. * @param {Function} isVisibleFunc - Visibility callback: `(camera) => boolean`. */ constructor(device: GraphicsDevice, node: GraphNode, isVisibleFunc: Function); /** @type {GraphicsDevice} */ device: GraphicsDevice; /** @type {ShaderMaterial} */ _material: ShaderMaterial; /** @type {Mesh} */ _mesh: Mesh; /** @type {MeshInstance} */ _meshInstance: MeshInstance; /** @type {ShaderMaterial|null} */ _pickMaterial: ShaderMaterial | null; /** @type {MeshInstance|null} */ _pickMeshInstance: MeshInstance | null; /** @type {GraphNode} */ _node: GraphNode; destroy(): void; get material(): ShaderMaterial; get meshInstance(): MeshInstance; /** * Per-frame update for color rendering: binds the indirect draw slot and updates material * parameters on the color mesh instance. * * @param {number} drawSlot - The indirect draw slot reserved for this frame. * @param {Texture} outputTexture - The compute-rasterized splat texture. * @param {StorageBuffer} rasterizeTileList - Buffer of non-empty tile indices. * @param {number} numTilesX - Number of tiles horizontally. * @param {number} screenWidth - Viewport width in pixels. * @param {number} screenHeight - Viewport height in pixels. */ update(drawSlot: number, outputTexture: Texture, rasterizeTileList: StorageBuffer, numTilesX: number, screenWidth: number, screenHeight: number): void; /** * Lazily creates the pick material and mesh instance, configures them with pick textures * and tile parameters, and returns the pick mesh instance for the picker to render. * * @param {number} drawSlot - The indirect draw slot. * @param {Texture} pickIdTexture - Compute-generated pick ID texture (r32uint). * @param {Texture} pickDepthTexture - Compute-generated pick depth texture (rgba16float). * @param {StorageBuffer} rasterizeTileList - Buffer of non-empty tile indices. * @param {number} numTilesX - Number of tiles horizontally. * @param {number} screenWidth - Viewport width in pixels. * @param {number} screenHeight - Viewport height in pixels. * @returns {MeshInstance} The configured pick mesh instance. */ prepareForPicking(drawSlot: number, pickIdTexture: Texture, pickDepthTexture: Texture, rasterizeTileList: StorageBuffer, numTilesX: number, screenWidth: number, screenHeight: number): MeshInstance; } import type { GraphicsDevice } from '../../platform/graphics/graphics-device.js'; import { ShaderMaterial } from '../materials/shader-material.js'; import { Mesh } from '../mesh.js'; import { MeshInstance } from '../mesh-instance.js'; import type { GraphNode } from '../graph-node.js'; import type { Texture } from '../../platform/graphics/texture.js'; import type { StorageBuffer } from '../../platform/graphics/storage-buffer.js';