UNPKG

playcanvas

Version:

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

74 lines (73 loc) 1.81 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 #ifdef GSPLAT_USER_VARYINGS #include "gsplatUserVaryingsPS" #endif #include "gsplatModifyPS" 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(gl_FragCoord.z, 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 vec4 fragColor = vec4(gaussianColor.xyz, alpha); modifySplatColor(gaussianUV, fragColor); gl_FragColor = vec4(fragColor.xyz * fragColor.a, fragColor.a); #endif } `; export { gsplat_default as default };