add blend

This commit is contained in:
Vlad 2025-12-12 17:12:03 +06:00
parent d2605d9108
commit bc49540a95

View File

@ -54,9 +54,22 @@ namespace ZL {
return; return;
} }
for (const auto& particle : particles) { std::vector<std::pair<const SparkParticle*, float>> sortedParticles;
if (!particle.active) continue; sortedParticles.reserve(getActiveParticleCount());
for (const auto& particle : particles) {
if (particle.active) {
sortedParticles.push_back({ &particle, particle.position.v[2] });
}
}
std::sort(sortedParticles.begin(), sortedParticles.end(),
[](const auto& a, const auto& b) {
return a.second > b.second;
});
for (const auto& [particlePtr, depth] : sortedParticles) {
const auto& particle = *particlePtr;
Vector3f pos = particle.position; Vector3f pos = particle.position;
float size = 0.04f * particle.scale; float size = 0.04f * particle.scale;
@ -116,6 +129,9 @@ namespace ZL {
glBindTexture(GL_TEXTURE_2D, texture->getTexID()); glBindTexture(GL_TEXTURE_2D, texture->getTexID());
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);// Аддитивное смешивание для эффекта свечения
renderer.PushMatrix(); renderer.PushMatrix();
renderer.LoadIdentity(); renderer.LoadIdentity();
renderer.TranslateMatrix({ 0, 0, -1.0f * zoom }); renderer.TranslateMatrix({ 0, 0, -1.0f * zoom });
@ -124,6 +140,9 @@ namespace ZL {
renderer.PopMatrix(); renderer.PopMatrix();
renderer.PopProjectionMatrix(); renderer.PopProjectionMatrix();
glDisable(GL_BLEND);
renderer.DisableVertexAttribArray(vPositionName); renderer.DisableVertexAttribArray(vPositionName);
renderer.DisableVertexAttribArray(vTexCoordName); renderer.DisableVertexAttribArray(vTexCoordName);
renderer.shaderManager.PopShader(); renderer.shaderManager.PopShader();