UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

62 lines (61 loc) 2.13 kB
var gsplatCopyToWorkbuffer_default = ` #define GSPLAT_CENTER_NOPROJ #include "gsplatHelpersVS" #include "gsplatFormatVS" #include "gsplatStructsVS" #include "gsplatDeclarationsVS" #include "gsplatCenterVS" #include "gsplatEvalSHVS" #include "gsplatQuatToMat3VS" #include "gsplatReadVS" var<private> processOutput: FragmentOutput; #include "gsplatWorkBufferOutputVS" #include "gsplatWriteVS" #include "gsplatModifyVS" varying @interpolate(flat) vSubDraw: vec4i; uniform uColorMultiply: vec3f; uniform model_scale: vec3f; uniform model_rotation: vec4f; #ifdef GSPLAT_ID uniform uId: u32; #endif @fragment fn fragmentMain(input: FragmentInput) -> FragmentOutput { let localRow = i32(input.position.y) - input.vSubDraw.w; let localCol = i32(input.position.x) - input.vSubDraw.y; let originalIndex = u32(input.vSubDraw.x + localRow * input.vSubDraw.z + localCol); setSplat(originalIndex); var modelCenter = getCenter(); var worldCenter = (uniform.matrix_model * vec4f(modelCenter, 1.0)).xyz; var center: SplatCenter; initCenter(modelCenter, &center); let srcRotation = getRotation().yzwx; let srcScale = getScale(); var worldRotation = vec4f(quatMul(half4(uniform.model_rotation), half4(srcRotation))); if (worldRotation.w < 0.0) { worldRotation = -worldRotation; } var worldScale = uniform.model_scale * srcScale; let originalCenter = worldCenter; modifySplatCenter(&worldCenter); modifySplatRotationScale(originalCenter, worldCenter, &worldRotation, &worldScale); var color = getColor(); #if SH_BANDS > 0 let dir = normalize(center.view * mat3x3f(center.modelView[0].xyz, center.modelView[1].xyz, center.modelView[2].xyz)); var sh: array<half3, SH_COEFFS>; var scale: f32; readSHData(&sh, &scale); color = vec4f(color.xyz + vec3f(evalSH(&sh, dir) * half(scale)), color.w); #endif modifySplatColor(worldCenter, &color); color = vec4f(color.xyz * uniform.uColorMultiply, color.w); writeSplat(worldCenter, worldRotation, worldScale, color); #ifdef GSPLAT_ID writePcId(vec4u(uniform.uId, 0u, 0u, 0u)); #endif return processOutput; } `; export { gsplatCopyToWorkbuffer_default as default };