UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

54 lines (52 loc) 1.23 kB
var gsplatPS = ` #ifndef DITHER_NONE #include "bayerPS" #include "opacityDitherPS" varying float id; #endif #ifdef PICK_PASS #include "pickPS" #endif #if defined(SHADOW_PASS) || defined(PICK_PASS) || defined(PREPASS_PASS) uniform float alphaClip; #endif #ifdef PREPASS_PASS varying float vLinearDepth; #include "floatAsUintPS" #endif varying mediump vec2 gaussianUV; varying mediump vec4 gaussianColor; 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 gl_FragColor = getPickOutput(); #elif SHADOW_PASS gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); #elif PREPASS_PASS gl_FragColor = float2vec4(vLinearDepth); #else if (alpha < 1.0 / 255.0) { discard; } #ifndef DITHER_NONE opacityDither(alpha, id * 0.013); #endif gl_FragColor = vec4(gaussianColor.xyz * alpha, alpha); #endif } `; export { gsplatPS as default };