UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

73 lines (56 loc) 1.56 kB
var gsplatVS = /* glsl */ ` #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 void main(void) { // read gaussian details SplatSource source; if (!initSource(source)) { gl_Position = discardVec; return; } vec3 modelCenter = readCenter(source); SplatCenter center; if (!initCenter(modelCenter, center)) { gl_Position = discardVec; return; } // project center to screen space SplatCorner corner; if (!initCorner(source, center, corner)) { gl_Position = discardVec; return; } // read color vec4 clr = readColor(source); #if GSPLAT_AA // apply AA compensation clr.a *= corner.aaFactor; #endif // evaluate spherical harmonics #if SH_BANDS > 0 // calculate the model-space view direction vec3 dir = normalize(center.view * mat3(center.modelView)); clr.xyz += evalSH(source, dir); #endif clipCorner(corner, clr.w); // write output gl_Position = center.proj + vec4(corner.offset, 0, 0); gaussianUV = corner.uv; gaussianColor = vec4(prepareOutputFromGamma(max(clr.xyz, 0.0)), clr.w); #ifndef DITHER_NONE id = float(source.id); #endif #ifdef PREPASS_PASS vLinearDepth = -center.view.z; #endif } `; export { gsplatVS as default };