Fix glow sprite flashing, move fadeAlpha to push constants, throttle character bones

- Glow sprites now use dedicated vertex buffer (glowVB_) separate from
  M2 particle buffer to prevent data race when renderM2Particles()
  overwrites glow data mid-flight
- Move fadeAlpha from shared material UBO to per-draw push constants,
  eliminating cross-instance alpha race on non-double-buffered UBOs
- Smooth adaptive render distance transitions to prevent pop-in/out
  at instance count thresholds (1000/2000)
- Distance-tiered character bone throttling: near (<30u) every frame,
  mid (30-60u) every 3rd, far (60-120u) every 6th frame
- Skip weapon instance animation updates (transforms set by parent bones)
This commit is contained in:
Kelsi 2026-03-04 08:17:32 -08:00
parent 3482dacea8
commit 30fa9836d9
8 changed files with 87 additions and 31 deletions

View file

@ -34,6 +34,7 @@ layout(location = 1) in vec3 Normal;
layout(location = 2) in vec2 TexCoord;
layout(location = 3) flat in vec3 InstanceOrigin;
layout(location = 4) in float ModelHeight;
layout(location = 5) in float vFadeAlpha;
layout(location = 0) out vec4 outColor;
@ -175,16 +176,16 @@ void main() {
float fogFactor = clamp((fogParams.y - dist) / (fogParams.y - fogParams.x), 0.0, 1.0);
result = mix(fogColor.rgb, result, fogFactor);
float outAlpha = texColor.a * fadeAlpha;
float outAlpha = texColor.a * vFadeAlpha;
// Cutout materials should not remain partially transparent after discard,
// otherwise foliage cards look view-dependent.
if (alphaTest != 0 || colorKeyBlack != 0) {
outAlpha = fadeAlpha;
outAlpha = vFadeAlpha;
}
// Foliage cutout should stay opaque after alpha discard to avoid
// view-angle translucency artifacts.
if (alphaTest == 2 || alphaTest == 3) {
outAlpha = 1.0 * fadeAlpha;
outAlpha = 1.0 * vFadeAlpha;
}
outColor = vec4(result, outAlpha);
}

Binary file not shown.

View file

@ -19,6 +19,7 @@ layout(push_constant) uniform Push {
int texCoordSet;
int useBones;
int isFoliage;
float fadeAlpha;
} push;
layout(set = 2, binding = 0) readonly buffer BoneSSBO {
@ -37,6 +38,7 @@ layout(location = 1) out vec3 Normal;
layout(location = 2) out vec2 TexCoord;
layout(location = 3) flat out vec3 InstanceOrigin;
layout(location = 4) out float ModelHeight;
layout(location = 5) out float vFadeAlpha;
void main() {
vec4 pos = vec4(aPos, 1.0);
@ -86,6 +88,7 @@ void main() {
InstanceOrigin = push.model[3].xyz;
ModelHeight = pos.z;
vFadeAlpha = push.fadeAlpha;
gl_Position = projection * view * worldPos;
}

Binary file not shown.