UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

73 lines (70 loc) 1.79 kB
var gsplatVS = ` #include "gsplatCommonVS" varying mediump vec2 gaussianUV; varying mediump vec4 gaussianColor; #ifndef DITHER_NONE varying float id; #endif mediump vec4 discardVec = vec4(0.0, 0.0, 2.0, 1.0); #ifdef PREPASS_PASS varying float vLinearDepth; #endif #ifdef GSPLAT_OVERDRAW uniform sampler2D colorRamp; uniform float colorRampIntensity; #endif void main(void) { SplatSource source; if (!initSource(source)) { gl_Position = discardVec; return; } #ifdef GSPLAT_WORKBUFFER_DATA loadSplatTextures(source); #endif vec3 modelCenter = readCenter(source); SplatCenter center; center.modelCenterOriginal = modelCenter; modifyCenter(modelCenter); center.modelCenterModified = modelCenter; if (!initCenter(modelCenter, center)) { gl_Position = discardVec; return; } SplatCorner corner; if (!initCorner(source, center, corner)) { gl_Position = discardVec; return; } vec4 clr = readColor(source); #if GSPLAT_AA clr.a *= corner.aaFactor; #endif #if SH_BANDS > 0 vec3 dir = normalize(center.view * mat3(center.modelView)); vec3 sh[SH_COEFFS]; float scale; readSHData(source, sh, scale); clr.xyz += evalSH(sh, dir) * scale; #endif modifyColor(modelCenter, clr); clipCorner(corner, clr.w); gl_Position = center.proj + vec4(corner.offset, 0, 0); gaussianUV = corner.uv; #ifdef GSPLAT_OVERDRAW float t = clamp(modelCenter.y / 20.0, 0.0, 1.0); vec3 rampColor = textureLod(colorRamp, vec2(t, 0.5), 0.0).rgb; clr.a *= (1.0 / 32.0) * colorRampIntensity; gaussianColor = vec4(rampColor, clr.a); #else gaussianColor = vec4(prepareOutputFromGamma(max(clr.xyz, 0.0)), clr.w); #endif #ifndef DITHER_NONE id = float(source.id); #endif #ifdef PREPASS_PASS vLinearDepth = -center.view.z; #endif } `; export { gsplatVS as default };