Files
playcanvas--supersplat/src/shaders/debug-shader.ts
T
wehub-resource-sync 2e0fafcb4e
CI / Build (22.x) (push) Failing after 1s
CI / Lint (22.x) (push) Failing after 1s
chore: import upstream snapshot with attribution
2026-07-13 12:24:51 +08:00

38 lines
858 B
TypeScript

const vertexShader = /* glsl */ `
attribute vec3 vertex_position;
attribute vec4 vertex_color;
varying vec4 vColor;
varying vec2 vZW;
uniform mat4 matrix_model;
uniform mat4 matrix_viewProjection;
void main(void) {
gl_Position = matrix_viewProjection * matrix_model * vec4(vertex_position, 1.0);
// store z/w for later use in fragment shader
vColor = vertex_color;
vZW = gl_Position.zw;
// disable depth clipping
gl_Position.z = 0.0;
}
`;
const fragmentShader = /* glsl */ `
precision highp float;
varying vec4 vColor;
varying vec2 vZW;
void main(void) {
gl_FragColor = vColor;
// clamp depth in Z to [0, 1] range
gl_FragDepth = max(0.0, min(1.0, (vZW.x / vZW.y + 1.0) * 0.5));
}
`;
export { vertexShader, fragmentShader };