playcanvas
Version:
PlayCanvas WebGL game engine
3 lines (2 loc) • 1.4 kB
TypeScript
declare const _default: "\nattribute vertex_position: vec3f; // xy: cornerUV, z: render order offset\nattribute vertex_id_attrib: u32; // render order base\n\nuniform numSplats: u32; // total number of splats\nuniform splatTextureSize: u32; // texture size for splat data\n\n#ifdef STORAGE_ORDER\n var<storage, read> splatOrder: array<u32>;\n#else\n // support texture for non-unified gsplat rendering\n var splatOrder: texture_2d<u32>;\n#endif\n\n// initialize the splat source structure\nfn initSource(source: ptr<function, SplatSource>) -> bool {\n // calculate splat order\n source.order = vertex_id_attrib + u32(vertex_position.z);\n\n // return if out of range (since the last block of splats may be partially full)\n if (source.order >= uniform.numSplats) {\n return false;\n }\n\n // read splat id\n #ifdef STORAGE_ORDER\n source.id = splatOrder[source.order];\n #else\n let uv = vec2u(source.order % uniform.splatTextureSize, source.order / uniform.splatTextureSize);\n source.id = textureLoad(splatOrder, vec2i(uv), 0).r;\n #endif\n\n // map id to uv\n source.uv = vec2i(vec2u(source.id % uniform.splatTextureSize, source.id / uniform.splatTextureSize));\n\n // get the corner\n source.cornerUV = vertex_position.xy;\n\n return true;\n}\n";
export default _default;