playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
3 lines (2 loc) • 3.53 kB
TypeScript
declare const _default: "\n\n#define GSPLAT_CENTER_NOPROJ\n\n#include \"gsplatHelpersVS\"\n#include \"gsplatFormatVS\"\n#include \"gsplatStructsVS\"\n#include \"gsplatDeclarationsVS\"\n#include \"gsplatCenterVS\"\n#include \"gsplatEvalSHVS\"\n#include \"gsplatQuatToMat3VS\"\n#include \"gsplatReadVS\"\n\n// Module-scope output for write functions to access\nvar<private> processOutput: FragmentOutput;\n\n// Work buffer output write functions (generated by GSplatFormat.getOutputDeclarations)\n#include \"gsplatWorkBufferOutputVS\"\n\n#include \"gsplatWriteVS\"\n#include \"gsplatModifyVS\"\n\n// Packed sub-draw params: (sourceBase, colStart, rowWidth, rowStart)\nvarying @interpolate(flat) vSubDraw: vec4i;\n\nuniform uColorMultiply: vec3f;\n\n// pre-computed model matrix decomposition\nuniform model_scale: vec3f;\nuniform model_rotation: vec4f; // (x,y,z,w) format\n\n#ifdef GSPLAT_ID\n uniform uId: u32;\n#endif\n\n@fragment\nfn fragmentMain(input: FragmentInput) -> FragmentOutput {\n // Compute source index from packed sub-draw varying: (sourceBase, colStart, rowWidth, rowStart)\n let localRow = i32(input.position.y) - input.vSubDraw.w;\n let localCol = i32(input.position.x) - input.vSubDraw.y;\n let originalIndex = u32(input.vSubDraw.x + localRow * input.vSubDraw.z + localCol);\n\n // Initialize global splat for format read functions\n setSplat(originalIndex);\n\n // read center in local space\n var modelCenter = getCenter();\n\n // compute world-space center for storage\n var worldCenter = (uniform.matrix_model * vec4f(modelCenter, 1.0)).xyz;\n var center: SplatCenter;\n initCenter(modelCenter, ¢er);\n\n // Get source rotation and scale\n // getRotation() returns (w,x,y,z) format, convert to (x,y,z,w) for quatMul\n let srcRotation = getRotation().yzwx;\n let srcScale = getScale();\n\n // Combine: world = model * source (both in x,y,z,w format)\n var worldRotation = vec4f(quatMul(half4(uniform.model_rotation), half4(srcRotation)));\n // Ensure w is positive so sqrt() reconstruction works correctly\n // (quaternions q and -q represent the same rotation)\n if (worldRotation.w < 0.0) {\n worldRotation = -worldRotation;\n }\n var worldScale = uniform.model_scale * srcScale;\n\n // Apply custom center modification\n let originalCenter = worldCenter;\n modifySplatCenter(&worldCenter);\n\n // Apply custom rotation/scale modification\n modifySplatRotationScale(originalCenter, worldCenter, &worldRotation, &worldScale);\n\n // read color\n var color = getColor();\n\n // evaluate spherical harmonics\n #if SH_BANDS > 0\n // calculate the model-space view direction\n let dir = normalize(center.view * mat3x3f(center.modelView[0].xyz, center.modelView[1].xyz, center.modelView[2].xyz));\n\n // read sh coefficients\n var sh: array<half3, SH_COEFFS>;\n var scale: f32;\n readSHData(&sh, &scale);\n\n // evaluate\n color = vec4f(color.xyz + vec3f(evalSH(&sh, dir) * half(scale)), color.w);\n #endif\n\n // Apply custom color modification\n modifySplatColor(worldCenter, &color);\n\n color = vec4f(color.xyz * uniform.uColorMultiply, color.w);\n\n // write color + transform using format-specific encoding\n writeSplat(worldCenter, worldRotation, worldScale, color);\n\n #ifdef GSPLAT_ID\n writePcId(vec4u(uniform.uId, 0u, 0u, 0u));\n #endif\n\n return processOutput;\n}\n";
export default _default;