acdream/src/AcDream.App/Rendering/Shaders/particle.frag
Erik 2cbf34a668 perf(rendering): preserve alpha order with bindless particles
Carry each billboard particle's resident texture handle in the instance ABI so stable retail alpha ordering can batch mixed textures without rebinding and redrawing each short texture run. Keep DAT blend transitions as the only billboard draw boundary.

The connected 0xC95B stress scene improved from 6 FPS / 171 ms to about 153 FPS / 6.6 ms at the same roughly 21,000 visible entities. Release build succeeds and all 5,916 tests pass with five intentional skips.

Co-authored-by: OpenAI Codex <codex@openai.com>
2026-07-18 08:32:21 +02:00

26 lines
648 B
GLSL

#version 430 core
#extension GL_ARB_bindless_texture : require
in vec2 vTex;
in vec4 vColor;
flat in uvec2 vTextureHandle;
out vec4 fragColor;
void main() {
vec4 texel;
if (any(notEqual(vTextureHandle, uvec2(0)))) {
sampler2DArray particleTexture = sampler2DArray(vTextureHandle);
texel = texture(particleTexture, vec3(vTex, 0.0));
} else {
vec2 d = vTex - vec2(0.5, 0.5);
float r = length(d) * 2.0;
float falloff = smoothstep(1.0, 0.4, r);
texel = vec4(1.0, 1.0, 1.0, falloff);
}
vec4 color = texel * vColor;
if (color.a < 0.02)
discard;
fragColor = color;
}