feat(ugc): live accurate color variation (-6 to 6 per channel, opaque bricks only)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-30 22:49:47 -05:00
parent 030efdaa0f
commit 73600acb4e
9 changed files with 50 additions and 4 deletions

View File

@@ -208,6 +208,16 @@ namespace UgcPalette {
return color * (newValue / value);
}
int32_t LiveVariationStep(float random) {
return std::clamp(static_cast<int32_t>(std::floor(random * 13.0f)), 0, 12) - 6;
}
glm::vec3 ApplyLiveVariation(const glm::vec3& linear, float random) {
const auto step = static_cast<float>(LiveVariationStep(random));
const auto srgb = glm::round(LinearToSrgb(linear) * 255.0f);
return SrgbToLinear(glm::clamp(srgb + step, 0.0f, 255.0f) / 255.0f);
}
float BrickRandom(uint64_t seed, uint32_t brick, uint32_t material) {
const auto bits = SplitMix(SplitMix(seed ^ (static_cast<uint64_t>(brick) << 32)) ^ material);
return static_cast<float>(bits >> 40) / static_cast<float>(1ull << 24);