2026-02-21 19:41:21 -08:00
|
|
|
#version 450
|
|
|
|
|
|
|
|
|
|
layout(set = 1, binding = 0) uniform sampler2D uTexture;
|
|
|
|
|
|
|
|
|
|
layout(push_constant) uniform Push {
|
|
|
|
|
vec2 tileCount;
|
|
|
|
|
int alphaKey;
|
|
|
|
|
} push;
|
|
|
|
|
|
|
|
|
|
layout(location = 0) in vec4 vColor;
|
|
|
|
|
layout(location = 1) in float vTile;
|
|
|
|
|
|
|
|
|
|
layout(location = 0) out vec4 outColor;
|
|
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
|
vec2 p = gl_PointCoord;
|
|
|
|
|
float tile = floor(vTile);
|
|
|
|
|
float tx = mod(tile, push.tileCount.x);
|
|
|
|
|
float ty = floor(tile / push.tileCount.x);
|
|
|
|
|
vec2 uv = (vec2(tx, ty) + p) / push.tileCount;
|
|
|
|
|
vec4 texColor = texture(uTexture, uv);
|
|
|
|
|
|
|
|
|
|
if (push.alphaKey != 0) {
|
|
|
|
|
float lum = dot(texColor.rgb, vec3(0.299, 0.587, 0.114));
|
|
|
|
|
if (lum < 0.05) discard;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-14 06:10:20 -07:00
|
|
|
// Soft circular falloff for point-sprite edges.
|
|
|
|
|
float edge = 1.0 - smoothstep(0.4, 0.5, length(p - 0.5));
|
|
|
|
|
float alpha = texColor.a * vColor.a * edge;
|
|
|
|
|
vec3 rgb = texColor.rgb * vColor.rgb * alpha;
|
|
|
|
|
outColor = vec4(rgb, alpha);
|
2026-02-21 19:41:21 -08:00
|
|
|
}
|