playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
49 lines (37 loc) • 1.44 kB
JavaScript
var gsplatProcess_default = (
/* glsl */
`
// Texture size and splat count uniforms
uniform uint splatTextureSize;
uniform uint dstTextureSize;
uniform uint srcNumSplats;
uniform uint dstNumSplats;
// Shared splat identification (index, uv) and setSplat() helper
// Input stream declarations (generated by GSplatFormat.getInputDeclarations)
// Output write functions (generated by GSplatFormat.getOutputDeclarations)
// Format-specific read code (included when "default" stream is used)
// User's process code - defines process() function and any declarations
void main(void) {
// Fragment coordinates give us the destination splat index
ivec2 fragCoords = ivec2(gl_FragCoord.xy);
// Linear index of the destination splat
uint splatIndex = uint(fragCoords.y * int(dstTextureSize) + fragCoords.x);
// Skip padding pixels (texture may be larger than actual splat count)
if (splatIndex >= dstNumSplats) discard;
// Initialize global splat for sampling
// Note: splat.uv assumes 1:1 mapping using splatTextureSize. When sizes differ,
// call setSplat() with a different index in user code.
setSplat(splatIndex);
// Call user's process function
process();
}
`
);
export {
gsplatProcess_default as default
};