UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

4 lines (2 loc) 1.06 kB
var gsplatSourceVS = "\nattribute vec3 vertex_position; // xy: cornerUV, z: render order offset\nattribute uint vertex_id_attrib; // render order base\n\nuniform uint numSplats; // total number of splats\nuniform highp usampler2D splatOrder; // per-splat index to source gaussian\n\n// initialize the splat source structure\nbool initSource(out SplatSource source) {\n uint w = uint(textureSize(splatOrder, 0).x);\n\n // calculate splat order\n source.order = vertex_id_attrib + uint(vertex_position.z);\n\n // return if out of range (since the last block of splats may be partially full)\n if (source.order >= numSplats) {\n return false;\n }\n\n ivec2 orderUV = ivec2(source.order % w, source.order / w);\n\n // read splat id\n source.id = texelFetch(splatOrder, orderUV, 0).r;\n\n // map id to uv\n source.uv = ivec2(source.id % w, source.id / w);\n\n // get the corner\n source.cornerUV = vertex_position.xy;\n\n return true;\n}\n"; export { gsplatSourceVS as default };