UNPKG

playcanvas

Version:

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

68 lines (67 loc) 1.6 kB
var gsplat_default = ` #ifndef DITHER_NONE #include "bayerPS" #include "opacityDitherPS" varying float id; #endif #if defined(SHADOW_PASS) || defined(PICK_PASS) || defined(PREPASS_PASS) uniform float alphaClip; #endif #ifdef PREPASS_PASS varying float vLinearDepth; #include "floatAsUintPS" #endif #if !defined(SHADOW_PASS) && !defined(PICK_PASS) && !defined(PREPASS_PASS) uniform float alphaClipForward; #endif varying mediump vec2 gaussianUV; varying mediump vec4 gaussianColor; #if defined(GSPLAT_UNIFIED_ID) && defined(PICK_PASS) flat varying uint vPickId; #endif #ifdef PICK_PASS #include "pickPS" #endif const float EXP4 = exp(-4.0); const float INV_EXP4 = 1.0 / (1.0 - EXP4); float normExp(float x) { return (exp(x * -4.0) - EXP4) * INV_EXP4; } void main(void) { mediump float A = dot(gaussianUV, gaussianUV); if (A > 1.0) { discard; } mediump float alpha = normExp(A) * gaussianColor.a; #if defined(SHADOW_PASS) || defined(PICK_PASS) || defined(PREPASS_PASS) if (alpha < alphaClip) { discard; } #endif #ifdef PICK_PASS #ifdef GSPLAT_UNIFIED_ID pcFragColor0 = encodePickOutput(vPickId); #else pcFragColor0 = getPickOutput(); #endif #ifdef DEPTH_PICK_PASS pcFragColor1 = getPickDepth(); #endif #elif SHADOW_PASS gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); #elif PREPASS_PASS gl_FragColor = float2vec4(vLinearDepth); #else if (alpha < alphaClipForward) { discard; } #ifndef DITHER_NONE opacityDither(alpha, id * 0.013); #endif gl_FragColor = vec4(gaussianColor.xyz * alpha, alpha); #endif } `; export { gsplat_default as default };