playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
59 lines (58 loc) • 1.76 kB
JavaScript
var gsplatCopyToWorkbuffer_default = `
flat varying ivec4 vSubDraw;
uniform vec3 uColorMultiply;
uniform vec3 model_scale;
uniform vec4 model_rotation;
uniform uint uId;
void main(void) {
int localRow = int(gl_FragCoord.y) - vSubDraw.w;
int localCol = int(gl_FragCoord.x) - vSubDraw.y;
uint originalIndex = uint(vSubDraw.x + localRow * vSubDraw.z + localCol);
setSplat(originalIndex);
vec3 modelCenter = getCenter();
vec3 worldCenter = (matrix_model * vec4(modelCenter, 1.0)).xyz;
SplatCenter center;
initCenter(modelCenter, center);
vec4 srcRotation = getRotation().yzwx;
vec3 srcScale = getScale();
vec4 worldRotation = quatMul(model_rotation, srcRotation);
if (worldRotation.w < 0.0) {
worldRotation = -worldRotation;
}
vec3 worldScale = model_scale * srcScale;
vec3 originalCenter = worldCenter;
modifySplatCenter(worldCenter);
modifySplatRotationScale(originalCenter, worldCenter, worldRotation, worldScale);
vec4 color = getColor();
vec3 dir = normalize(center.view * mat3(center.modelView));
vec3 sh[SH_COEFFS];
float scale;
readSHData(sh, scale);
color.xyz += evalSH(sh, dir) * scale;
modifySplatColor(worldCenter, color);
color.xyz *= uColorMultiply;
writeSplat(worldCenter, worldRotation, worldScale, color);
writePcId(uvec4(uId, 0u, 0u, 0u));
}
`;
export {
gsplatCopyToWorkbuffer_default as default
};