UNPKG

playcanvas

Version:

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

3 lines (2 loc) 1.56 kB
declare const _default: "\nattribute vertex_position: vec3f; // xy: cornerUV, z: render order offset within instance\n\n#ifdef GSPLAT_INDIRECT_DRAW\n // When using indirect draw with compaction, numSplats is written by the\n // write-indirect-args compute shader and read from a storage buffer.\n var<storage, read> numSplatsStorage: array<u32>;\n // Sorted visible splat IDs\n var<storage, read> compactedSplatIds: array<u32>;\n#else\n uniform numSplats: u32; // total number of splats\n\n var<storage, read> splatOrder: array<u32>;\n#endif\n\n// initialize the splat source structure\nfn initSource(source: ptr<function, SplatSource>) -> bool {\n // calculate splat order from instance index and vertex position offset\n source.order = pcInstanceIndex * {GSPLAT_INSTANCE_SIZE}u + u32(vertex_position.z);\n\n // return if out of range (since the last block of splats may be partially full)\n #ifdef GSPLAT_INDIRECT_DRAW\n let numSplats = numSplatsStorage[0];\n #else\n let numSplats = uniform.numSplats;\n #endif\n if (source.order >= numSplats) {\n return false;\n }\n\n // read splat id and initialize global splat for format read functions\n var splatId: u32;\n #ifdef GSPLAT_INDIRECT_DRAW\n splatId = compactedSplatIds[source.order];\n #else\n splatId = splatOrder[source.order];\n #endif\n setSplat(splatId);\n\n // get the corner\n source.cornerUV = half2(vertex_position.xy);\n\n return true;\n}\n"; export default _default;