UNPKG

playcanvas

Version:

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

3 lines (2 loc) 1.8 kB
declare const _default: "\n#include \"gsplatPackingPS\"\n\n// uniform declarations for dequantization\nuniform vec3 means_mins;\nuniform vec3 means_maxs;\n\nuniform float scales_mins;\nuniform float scales_maxs;\n\n// SH0 color uniforms and texture\nuniform float sh0_mins;\nuniform float sh0_maxs;\nuniform highp sampler2D packedSh0;\n\n// SH_C0 coefficient for 0th degree spherical harmonic\nconst float SH_C0 = 0.28209479177387814;\n\n// work value\nuvec4 packedSample;\n\nconst float norm = sqrt(2.0);\n\n// read the model-space center of the gaussian\nvec3 getCenter() {\n // read the packed texture sample using generated load function (uses global splat.uv)\n packedSample = loadPackedTexture();\n\n vec3 l = unpack8888(packedSample.x).xyz;\n vec3 u = unpack8888(packedSample.y).xyz;\n vec3 n = (l + u * 256.0) / 257.0;\n vec3 v = mix(means_mins, means_maxs, n);\n\n return sign(v) * (exp(abs(v)) - 1.0);\n}\n\nvec4 getColor() {\n vec3 clr = mix(vec3(sh0_mins), vec3(sh0_maxs), unpack111110(pack8888(texelFetch(packedSh0, splat.uv, 0))));\n float alpha = float(packedSample.z & 0xffu) / 255.0;\n return vec4(vec3(0.5) + clr * SH_C0, alpha);\n}\n\nvec4 getRotation() {\n // decode rotation quaternion\n vec3 qdata = unpack8888(packedSample.z).xyz;\n uint qmode = packedSample.w & 0x3u;\n vec3 abc = (qdata - 0.5) * norm;\n float d = sqrt(max(0.0, 1.0 - dot(abc, abc)));\n\n return (qmode == 0u) ? vec4(d, abc) :\n ((qmode == 1u) ? vec4(abc.x, d, abc.yz) :\n ((qmode == 2u) ? vec4(abc.xy, d, abc.z) : vec4(abc, d)));\n}\n\nvec3 getScale() {\n vec3 sdata = unpack101010(packedSample.w >> 2u);\n return exp(mix(vec3(scales_mins), vec3(scales_maxs), sdata));\n}\n\n#include \"gsplatSogSHVS\"\n"; export default _default;