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:
authorBrecht Van Lommel <brecht@blender.org>2021-07-19 19:39:43 +0300
committerBrecht Van Lommel <brecht@blender.org>2021-07-30 19:44:26 +0300
commit3848507511a7546ab396c80f069b48de3332860f (patch)
tree86c81ecfa6921b776931b4b952ec0a58a79da68f /source/blender/blenlib
parentb90887da5a37088d295fe86445cf62c9fc8fdea4 (diff)
Cleanup: clarify license and origin of voronoi and dithering code
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r--source/blender/blenlib/intern/math_color_inline.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/source/blender/blenlib/intern/math_color_inline.c b/source/blender/blenlib/intern/math_color_inline.c
index a5a687ef9fe..ad4b844175f 100644
--- a/source/blender/blenlib/intern/math_color_inline.c
+++ b/source/blender/blenlib/intern/math_color_inline.c
@@ -322,16 +322,14 @@ MINLINE int compare_rgb_uchar(const unsigned char col_a[3],
/* Return triangle noise in [-0.5..1.5[ range */
MINLINE float dither_random_value(float s, float t)
{
- /* Original code from https://www.shadertoy.com/view/4t2SDh */
- /* The noise reshaping technique does not work on CPU.
- * We generate and merge two distribution instead */
- /* Uniform noise in [0..1[ range */
- float nrnd0 = sinf(s * 12.9898f + t * 78.233f) * 43758.5453f;
- float nrnd1 = sinf(s * 19.9898f + t * 119.233f) * 43798.5453f;
- nrnd0 -= floorf(nrnd0);
- nrnd1 -= floorf(nrnd1);
+ /* Uniform noise in [0..1[ range, using common GLSL hash function.
+ * https://stackoverflow.com/questions/12964279/whats-the-origin-of-this-glsl-rand-one-liner. */
+ float hash0 = sinf(s * 12.9898f + t * 78.233f) * 43758.5453f;
+ float hash1 = sinf(s * 19.9898f + t * 119.233f) * 43798.5453f;
+ hash0 -= floorf(hash0);
+ hash1 -= floorf(hash1);
/* Convert uniform distribution into triangle-shaped distribution. */
- return nrnd0 + nrnd1 - 0.5f;
+ return hash0 + hash0 - 0.5f;
}
MINLINE void float_to_byte_dither_v3(