Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606@gmail.com>2020-03-12 22:43:01 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-03-12 22:43:38 +0300
commitb0271c6e408f66a7265dccc6e12ca21a9332a9dc (patch)
treeb5d0dbfa38da95fac08ad0b96fb756cd9a9a0e58 /source/blender/gpu
parent53c03d4679f6ed94cac341af0d11a3a8495083a7 (diff)
Use golden ratio conjugate for Face Sets hue generation
The face set ID is sequential, so implementing this was straightforward. Suggested by Jeroen Bakker Reviewed By: jbakker Differential Revision: https://developer.blender.org/D7123
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 5eae86e50f0..33f61b5f5f4 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -189,15 +189,17 @@ static void gpu_pbvh_batch_init(GPU_PBVH_Buffers *buffers, GPUPrimType prim)
* \{ */
/* Returns the Face Set random color for rendering in the overlay given its ID and a color seed. */
+#define GOLDEN_RATIO_CONJUGATE 0.618033988749895f
static void face_set_overlay_color_get(const int face_set, const int seed, uchar *r_color)
{
float rgba[4];
- const float random_mod_hue = BLI_hash_int_01(abs(face_set) + seed);
+ float random_mod_hue = GOLDEN_RATIO_CONJUGATE * (abs(face_set) + (seed % 10));
+ random_mod_hue = random_mod_hue - floorf(random_mod_hue);
const float random_mod_sat = BLI_hash_int_01(abs(face_set) + seed + 1);
const float random_mod_val = BLI_hash_int_01(abs(face_set) + seed + 2);
hsv_to_rgb(random_mod_hue,
- 0.45f + (random_mod_sat * 0.35f),
- 1.0f - (random_mod_val * 0.45f),
+ 0.6f + (random_mod_sat * 0.25f),
+ 1.0f - (random_mod_val * 0.35f),
&rgba[0],
&rgba[1],
&rgba[2]);