From 9f70e14a13793a4a62ac869526b255520eb751c4 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 24 Oct 2024 14:03:05 +0300 Subject: [PATCH] update X sprites rendering randomization --- src/graphics/render/BlocksRenderer.cpp | 3 ++- src/graphics/render/BlocksRenderer.hpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/graphics/render/BlocksRenderer.cpp b/src/graphics/render/BlocksRenderer.cpp index eb3a134a..651675c5 100644 --- a/src/graphics/render/BlocksRenderer.cpp +++ b/src/graphics/render/BlocksRenderer.cpp @@ -227,7 +227,8 @@ void BlocksRenderer::blockXSprite( pickSoftLight({x + 1, y + 1, z}, {1, 0, 0}, {0, 1, 0}), pickSoftLight({x, y + 1, z}, {1, 0, 0}, {0, 1, 0}) }; - int rand = ((x * z + y) ^ (z * y - x)) * (z + y); + randomizer.setSeed((x * 52321) ^ (z * 389) ^ y); + short rand = randomizer.rand32(); float xs = ((float)(char)rand / 512) * spread; float zs = ((float)(char)(rand >> 8) / 512) * spread; diff --git a/src/graphics/render/BlocksRenderer.hpp b/src/graphics/render/BlocksRenderer.hpp index 60aa3a07..121190f0 100644 --- a/src/graphics/render/BlocksRenderer.hpp +++ b/src/graphics/render/BlocksRenderer.hpp @@ -11,6 +11,7 @@ #include "voxels/Chunk.hpp" #include "voxels/VoxelsVolume.hpp" #include "graphics/core/MeshData.hpp" +#include "maths/util.hpp" class Content; class Mesh; @@ -41,6 +42,8 @@ class BlocksRenderer { const Block* const* blockDefsCache; const ContentGfxCache* const cache; const EngineSettings* settings; + + util::PseudoRandom randomizer; void vertex(const glm::vec3& coord, float u, float v, const glm::vec4& light); void index(int a, int b, int c, int d, int e, int f);