playcanvas
Version:
PlayCanvas WebGL game engine
58 lines (56 loc) • 1.56 kB
JavaScript
var gsplatVS = `
varying gaussianUV: vec2f;
varying gaussianColor: vec4f;
varying id: f32;
const discardVec: vec4f = vec4f(0.0, 0.0, 2.0, 1.0);
varying vLinearDepth: f32;
@vertex
fn vertexMain(input: VertexInput) -> VertexOutput {
var output: VertexOutput;
var source: SplatSource;
if (!initSource(&source)) {
output.position = discardVec;
return output;
}
let modelCenter: vec3f = readCenter(&source);
var center: SplatCenter;
if (!initCenter(modelCenter, ¢er)) {
output.position = discardVec;
return output;
}
var corner: SplatCorner;
if (!initCorner(&source, ¢er, &corner)) {
output.position = discardVec;
return output;
}
var clr: vec4f = readColor(&source);
clr.a = clr.a * corner.aaFactor;
let modelView3x3 = mat3x3f(center.modelView[0].xyz, center.modelView[1].xyz, center.modelView[2].xyz);
let dir = normalize(center.view * modelView3x3);
var sh: array<vec3f, SH_COEFFS>;
var scale: f32;
readSHData(&source, &sh, &scale);
clr = vec4f(clr.xyz + evalSH(&sh, dir) * scale, clr.a);
clipCorner(&corner, clr.w);
output.position = center.proj + vec4f(corner.offset, 0.0, 0.0);
output.gaussianUV = corner.uv;
output.gaussianColor = vec4f(prepareOutputFromGamma(max(clr.xyz, vec3f(0.0))), clr.w);
output.id = f32(source.id);
output.vLinearDepth = -center.view.z;
return output;
}
`;
export { gsplatVS as default };