UNPKG

playcanvas

Version:

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

77 lines (76 loc) 2.01 kB
var gsplat_default = ` #ifndef DITHER_NONE #include "bayerPS" #include "opacityDitherPS" varying id: f32; #endif #if defined(SHADOW_PASS) || defined(PICK_PASS) || defined(PREPASS_PASS) uniform alphaClip: f32; #endif #ifdef PREPASS_PASS varying vLinearDepth: f32; #include "floatAsUintPS" #endif #if !defined(SHADOW_PASS) && !defined(PICK_PASS) && !defined(PREPASS_PASS) uniform alphaClipForward: f32; #endif 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; #if defined(GSPLAT_UNIFIED_ID) && defined(PICK_PASS) varying @interpolate(flat) vPickId: u32; #endif #ifdef PICK_PASS #include "pickPS" #endif #ifdef GSPLAT_USER_VARYINGS #include "gsplatUserVaryingsPS" #endif #include "gsplatModifyPS" @fragment fn fragmentMain(input: FragmentInput) -> FragmentOutput { var output: FragmentOutput; let A: half = dot(gaussianUV, gaussianUV); if (A > half(1.0)) { discard; } var alpha: half = normExp(A) * gaussianColor.a; #if defined(SHADOW_PASS) || defined(PICK_PASS) || defined(PREPASS_PASS) if (alpha < half(uniform.alphaClip)) { discard; return output; } #endif #ifdef PICK_PASS #ifdef GSPLAT_UNIFIED_ID output.color = encodePickOutput(vPickId); #else output.color = getPickOutput(); #endif #ifdef DEPTH_PICK_PASS output.color1 = getPickDepth(); #endif #elif SHADOW_PASS output.color = vec4f(input.position.z, 0.0, 0.0, 1.0); #elif PREPASS_PASS output.color = float2vec4(vLinearDepth); #else if (alpha < half(uniform.alphaClipForward)) { discard; } #ifndef DITHER_NONE opacityDither(f32(alpha), id * 0.013); #endif var fragColor: vec4f = vec4f(vec3f(gaussianColor.xyz), f32(alpha)); modifySplatColor(vec2f(gaussianUV), &fragColor); output.color = vec4f(fragColor.xyz * fragColor.a, fragColor.a); #endif return output; }`; export { gsplat_default as default };