fix emission buffer writing & fix entity shader

This commit is contained in:
MihailRis
2025-07-12 23:28:38 +03:00
parent 3f3f48eb6d
commit 2831d1c963
6 changed files with 34 additions and 18 deletions
+17 -8
View File
@@ -64,7 +64,8 @@ public:
const glm::vec2& uv,
const glm::vec4& light,
const glm::vec3& tint,
const glm::vec3& normal
const glm::vec3& normal,
float emission
) {
MainBatchVertex* buffer = this->buffer.get();
buffer[index].position = pos;
@@ -79,6 +80,7 @@ public:
buffer[index].normal[0] = static_cast<uint8_t>(normal.x * 128 + 127);
buffer[index].normal[1] = static_cast<uint8_t>(normal.y * 128 + 127);
buffer[index].normal[2] = static_cast<uint8_t>(normal.z * 128 + 127);
buffer[index].normal[3] = static_cast<uint8_t>(emission * 255);
index++;
}
@@ -90,7 +92,8 @@ public:
const glm::vec2& size,
const glm::vec4& light,
const glm::vec3& tint,
const UVRegion& subregion
const UVRegion& subregion,
float emission = 0.0f
) {
prepare(6);
vertex(
@@ -98,21 +101,24 @@ public:
{subregion.u1, subregion.v1},
light,
tint,
normal
normal,
emission
);
vertex(
pos + right * size.x * 0.5f - up * size.y * 0.5f,
{subregion.u2, subregion.v1},
light,
tint,
normal
normal,
emission
);
vertex(
pos + right * size.x * 0.5f + up * size.y * 0.5f,
{subregion.u2, subregion.v2},
light,
tint,
normal
normal,
emission
);
vertex(
@@ -120,21 +126,24 @@ public:
{subregion.u1, subregion.v1},
light,
tint,
normal
normal,
emission
);
vertex(
pos + right * size.x * 0.5f + up * size.y * 0.5f,
{subregion.u2, subregion.v2},
light,
tint,
normal
normal,
emission
);
vertex(
pos - right * size.x * 0.5f + up * size.y * 0.5f,
{subregion.u1, subregion.v2},
light,
tint,
normal
normal,
emission
);
}
+8 -1
View File
@@ -85,7 +85,14 @@ void ModelBatch::draw(
d = glm::dot(norm, SUN_VECTOR);
d = 0.8f + d * 0.2f;
}
batch->vertex(matrix * glm::vec4(vert.coord, 1.0f), vert.uv, lights*d, tint, norm);
batch->vertex(
matrix * glm::vec4(vert.coord, 1.0f),
vert.uv,
lights * d,
tint,
norm,
mesh.lighting ? 0.0f : 1.0f
);
}
}
}
+2 -2
View File
@@ -117,7 +117,6 @@ void ParticlesRenderer::renderParticles(const Camera& camera, float delta) {
light *= 0.9f + (particle.random % 100) * 0.001f;
}
glm::vec3 localRight = right;
glm::vec3 localUp = preset.globalUpVector ? glm::vec3(0, 1, 0) : up;
float angle = particle.angle;
@@ -138,7 +137,8 @@ void ParticlesRenderer::renderParticles(const Camera& camera, float delta) {
preset.size * scale,
light,
glm::vec3(1.0f),
particle.region
particle.region,
preset.lighting ? 0.0f : 1.0f
);
if (particle.lifetime <= 0.0f) {
iter = vec.erase(iter);