playcanvas
Version:
PlayCanvas WebGL game engine
64 lines (62 loc) • 1.8 kB
JavaScript
var gsplatEvalSHVS = `
const float SH_C1 = 0.4886025119029199f;
const float SH_C2_0 = 1.0925484305920792f;
const float SH_C2_1 = -1.0925484305920792f;
const float SH_C2_2 = 0.31539156525252005f;
const float SH_C2_3 = -1.0925484305920792f;
const float SH_C2_4 = 0.5462742152960396f;
const float SH_C3_0 = -0.5900435899266435f;
const float SH_C3_1 = 2.890611442640554f;
const float SH_C3_2 = -0.4570457994644658f;
const float SH_C3_3 = 0.3731763325901154f;
const float SH_C3_4 = -0.4570457994644658f;
const float SH_C3_5 = 1.445305721320277f;
const float SH_C3_6 = -0.5900435899266435f;
vec3 evalSH(in vec3 sh[SH_COEFFS], in vec3 dir) {
float x = dir.x;
float y = dir.y;
float z = dir.z;
vec3 result = SH_C1 * (-sh[0] * y + sh[1] * z - sh[2] * x);
float xx = x * x;
float yy = y * y;
float zz = z * z;
float xy = x * y;
float yz = y * z;
float xz = x * z;
result +=
sh[3] * (SH_C2_0 * xy) +
sh[4] * (SH_C2_1 * yz) +
sh[5] * (SH_C2_2 * (2.0 * zz - xx - yy)) +
sh[6] * (SH_C2_3 * xz) +
sh[7] * (SH_C2_4 * (xx - yy));
result +=
sh[8] * (SH_C3_0 * y * (3.0 * xx - yy)) +
sh[9] * (SH_C3_1 * xy * z) +
sh[10] * (SH_C3_2 * y * (4.0 * zz - xx - yy)) +
sh[11] * (SH_C3_3 * z * (2.0 * zz - 3.0 * xx - 3.0 * yy)) +
sh[12] * (SH_C3_4 * x * (4.0 * zz - xx - yy)) +
sh[13] * (SH_C3_5 * z * (xx - yy)) +
sh[14] * (SH_C3_6 * x * (xx - 3.0 * yy));
return result;
}
`;
export { gsplatEvalSHVS as default };