Files
MapLibreParticleLab/shaders/particle_gpu_validation.vertex.glsl
OpenAI Codex a0aae48ec8
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
feat: draw all raster particle states
2026-09-03 15:04:05 +08:00

35 lines
1.1 KiB
GLSL

layout (location = 0) in vec2 a_pos;
out vec2 v_uv;
out vec2 v_world;
layout (std140) uniform ParticleGpuValidationUBO {
highp vec4 u_pass;
highp vec4 u_marker;
highp vec4 u_mask;
highp mat4 u_matrix;
};
uniform sampler2D u_state_texture;
void main() {
v_uv = a_pos;
v_world = a_pos;
if (u_pass.x < 1.5) {
gl_Position = vec4(a_pos * 2.0 - 1.0, 0.0, 1.0);
} else if (u_pass.x > 3.5) {
// 40-03: a_pos is a static State texel index generated only when the
// particle capacity changes. The position itself remains GPU-owned.
vec2 stateUV = (a_pos + vec2(0.5)) / u_mask.xy;
vec2 position = texture(u_state_texture, stateUV).rg;
v_uv = position;
v_world = position;
gl_PointSize = 3.0;
gl_Position = vec4(position * 2.0 - 1.0, 0.0, 1.0);
} else {
// VALIDATION ONLY: a_pos is canonical z0 world geometry; u_matrix is
// PaintParameters::matrixForTile() for the selected MapLibre world copy.
gl_Position = u_matrix * vec4(a_pos * 8192.0, 0.0, 1.0);
}
}