[Bf-blender-cvs] [9a117fcdaea] master: GPencil: Add more randomness to random stroke color

Antonio Vazquez noreply at git.blender.org
Fri Jul 24 16:24:18 CEST 2020


Commit: 9a117fcdaeac1b454eb688c4700c0622de95c26e
Author: Antonio Vazquez
Date:   Fri Jul 24 16:24:04 2020 +0200
Branches: master
https://developer.blender.org/rB9a117fcdaeac1b454eb688c4700c0622de95c26e

GPencil: Add more randomness to random stroke color

The old method produce a small range of similar colors.

===================================================================

M	source/blender/blenkernel/intern/gpencil_geom.c

===================================================================

diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c
index 5b7753428f7..53bfd3aa8ff 100644
--- a/source/blender/blenkernel/intern/gpencil_geom.c
+++ b/source/blender/blenkernel/intern/gpencil_geom.c
@@ -2599,10 +2599,9 @@ void BKE_gpencil_stroke_set_random_color(bGPDstroke *gps)
 
   float color[4] = {1.0f, 1.0f, 1.0f, 1.0f};
   bGPDspoint *pt = &gps->points[0];
-  color[0] *= BLI_hash_int_01(BLI_hash_int_2d(gps->totpoints, pt->x));
-  color[1] *= BLI_hash_int_01(BLI_hash_int_2d(gps->totpoints, pt->y));
-  color[2] *= BLI_hash_int_01(BLI_hash_int_2d(gps->totpoints, pt->z));
-
+  color[0] *= BLI_hash_int_01(BLI_hash_int_2d(gps->totpoints / 5, pt->x + pt->z));
+  color[1] *= BLI_hash_int_01(BLI_hash_int_2d(gps->totpoints + pt->x, pt->y * pt->z + pt->x));
+  color[2] *= BLI_hash_int_01(BLI_hash_int_2d(gps->totpoints - pt->x, pt->z * pt->x + pt->y));
   for (int i = 0; i < gps->totpoints; i++) {
     pt = &gps->points[i];
     copy_v4_v4(pt->vert_color, color);



More information about the Bf-blender-cvs mailing list