playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
73 lines (72 loc) • 1.82 kB
JavaScript
var gsplat_default = `
varying id: f32;
uniform alphaClip: f32;
varying vLinearDepth: f32;
uniform alphaClipForward: f32;
const EXP4: half = exp(half(-4.0));
const INV_EXP4: half = half(1.0) / (half(1.0) - EXP4);
fn normExp(x: half) -> half {
return (exp(x * half(-4.0)) - EXP4) * INV_EXP4;
}
varying gaussianUV: half2;
varying gaussianColor: half4;
varying @interpolate(flat) vPickId: u32;
@fragment
fn fragmentMain(input: FragmentInput) -> FragmentOutput {
var output: FragmentOutput;
let A: half = dot(gaussianUV, gaussianUV);
if (A > half(1.0)) {
discard;
return output;
}
var alpha: half = normExp(A) * gaussianColor.a;
if (alpha < half(uniform.alphaClip)) {
discard;
return output;
}
output.color = encodePickOutput(vPickId);
output.color = getPickOutput();
output.color1 = getPickDepth();
output.color = vec4f(0.0, 0.0, 0.0, 1.0);
output.color = float2vec4(vLinearDepth);
if (alpha < half(uniform.alphaClipForward)) {
discard;
return output;
}
opacityDither(f32(alpha), id * 0.013);
output.color = vec4f(vec3f(gaussianColor.xyz * alpha), f32(alpha));
return output;
}`;
export {
gsplat_default as default
};