playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
3 lines (2 loc) • 1.12 kB
TypeScript
declare const _default: "\n#if SH_BANDS > 0\n #ifndef SOG_V2\n uniform float shN_mins;\n uniform float shN_maxs;\n #endif\n\n void readSHData(out vec3 sh[SH_COEFFS], out float scale) {\n // extract the 16-bit centroid palette index from sh_labels bytes 0 and 1\n vec4 labels = texelFetch(sh_labels, splat.uv, 0);\n int n = int(labels.x * 255.0 + 0.5) + int(labels.y * 255.0 + 0.5) * 256;\n\n // calculate offset into the centroids texture (64 centroids per row, SH_COEFFS texels each)\n int u = (n % 64) * SH_COEFFS;\n int v = n / 64;\n\n // read consecutive texels for this centroid\n for (int i = 0; i < SH_COEFFS; i++) {\n vec4 t = texelFetch(sh_centroids, ivec2(u + i, v), 0);\n #ifdef SOG_V2\n ivec3 idx = ivec3(t.xyz * 255.0 + 0.5);\n sh[i] = vec3(lutShN(idx.x), lutShN(idx.y), lutShN(idx.z));\n #else\n sh[i] = mix(vec3(shN_mins), vec3(shN_maxs), t.xyz);\n #endif\n }\n\n scale = 1.0;\n }\n#endif\n";
export default _default;