add particles lighting
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include "graphics/core/Texture.hpp"
|
||||
#include "graphics/core/Mesh.hpp"
|
||||
#include "graphics/core/ImageData.hpp"
|
||||
#include "voxels/Chunks.hpp"
|
||||
#include "voxels/Chunk.hpp"
|
||||
|
||||
static const vattr attrs[] = {
|
||||
{3}, {2}, {3}, {1}, {0}
|
||||
@@ -62,3 +64,19 @@ void MainBatch::prepare(int vertices) {
|
||||
flush();
|
||||
}
|
||||
}
|
||||
|
||||
glm::vec4 MainBatch::sampleLight(
|
||||
const glm::vec3& pos, const Chunks& chunks, bool backlight
|
||||
) {
|
||||
light_t light = chunks.getLight(
|
||||
std::floor(pos.x),
|
||||
std::floor(std::min(CHUNK_H-1.0f, pos.y)),
|
||||
std::floor(pos.z));
|
||||
light_t minIntensity = backlight ? 1 : 0;
|
||||
return glm::vec4(
|
||||
glm::max(Lightmap::extract(light, 0), minIntensity) / 15.0f,
|
||||
glm::max(Lightmap::extract(light, 1), minIntensity) / 15.0f,
|
||||
glm::max(Lightmap::extract(light, 2), minIntensity) / 15.0f,
|
||||
glm::max(Lightmap::extract(light, 3), minIntensity) / 15.0f
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user