UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

3 lines (2 loc) 1.1 kB
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\nvar splatOrder: texture_2d<u32>; // per-splat index to source gaussian\n\n// initialize the splat source structure\nfn initSource(source: ptr<function, SplatSource>) -> bool {\n let w: u32 = textureDimensions(splatOrder, 0).x;\n\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 let orderUV = vec2i(vec2u(source.order % w, source.order / w));\n\n // read splat id\n source.id = textureLoad(splatOrder, orderUV, 0).r;\n\n // map id to uv\n source.uv = vec2i(vec2u(source.id % w, source.id / w));\n\n // get the corner\n source.cornerUV = vertex_position.xy;\n\n return true;\n}\n"; export default _default;