palette.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "palette.h"
  2. #include "geom/math_utils.h"
  3. #include "humanoid_math.h"
  4. namespace Render::GL {
  5. using Render::Geom::clamp01;
  6. using Render::Geom::clampVec01;
  7. HumanoidPalette makeHumanoidPalette(const QVector3D &teamTint, uint32_t seed) {
  8. HumanoidPalette p;
  9. float variation = (hash01(seed) - 0.5f) * 0.08f;
  10. p.cloth = clampVec01(teamTint * (1.0f + variation));
  11. p.skin = QVector3D(0.96f, 0.80f, 0.69f);
  12. float leatherVar = (hash01(seed ^ 0x1234u) - 0.5f) * 0.06f;
  13. float r = teamTint.x();
  14. float g = teamTint.y();
  15. float b = teamTint.z();
  16. float saturation = 0.6f;
  17. float brightness = 0.5f;
  18. QVector3D desaturated(r * saturation + (1.0f - saturation) * brightness,
  19. g * saturation + (1.0f - saturation) * brightness,
  20. b * saturation + (1.0f - saturation) * brightness);
  21. p.leather = clampVec01(desaturated * (0.7f + leatherVar));
  22. p.leatherDark = p.leather * 0.85f;
  23. p.wood = QVector3D(0.16f, 0.10f, 0.05f);
  24. QVector3D neutralGray(0.70f, 0.70f, 0.70f);
  25. p.metal = clampVec01(teamTint * 0.25f + neutralGray * 0.75f);
  26. return p;
  27. }
  28. } // namespace Render::GL