Skip to content

Commit

Permalink
fix particles lighting
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailRis committed Dec 23, 2024
1 parent c6de7f6 commit 6be6404
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/graphics/render/ParticlesRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,34 @@ void ParticlesRenderer::renderParticles(const Camera& camera, float delta) {
}
update_particle(particle, delta, chunks);

float scale = 1.0f + ((particle.random ^ 2628172) % 1000) *
0.001f * preset.sizeSpread;

glm::vec4 light(1, 1, 1, 0);
if (preset.lighting) {
light = MainBatch::sampleLight(
particle.position, chunks, backlight
particle.position,
chunks,
backlight
);
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
light = glm::max(
light,
MainBatch::sampleLight(
particle.position - preset.size * scale *
glm::vec3(x, y, z),
chunks,
backlight
)
);
}
}
}
light *= 0.9f + (particle.random % 100) * 0.001f;
}
float scale = 1.0f + ((particle.random ^ 2628172) % 1000) *
0.001f * preset.sizeSpread;


glm::vec3 localRight = right;
glm::vec3 localUp = preset.globalUpVector ? glm::vec3(0, 1, 0) : up;
Expand Down

0 comments on commit 6be6404

Please sign in to comment.