Cleanup: clarify license and origin of voronoi and dithering code

This commit is contained in:
Brecht Van Lommel 2021-07-19 18:39:43 +02:00
parent b90887da5a
commit 3848507511
4 changed files with 29 additions and 16 deletions

View File

@ -54,14 +54,18 @@ vector4 safe_divide(vector4 a, float b)
}
/*
* Smooth Voronoi:
* Original code is under the MIT License, Copyright (c) 2013 Inigo Quilez.
*
* Smooth Voronoi:
* - https://wiki.blender.org/wiki/User:OmarSquircleArt/GSoC2019/Documentation/Smooth_Voronoi
*
* Distance To Edge:
* Distance To Edge based on:
*
* - https://www.shadertoy.com/view/llG3zy
* - https://www.iquilezles.org/www/articles/voronoilines/voronoilines.htm
* - https://www.shadertoy.com/view/ldl3W8
*
* With optimization to change -2..2 scan window to -1..1 for better performance,
* as explained in https://www.shadertoy.com/view/llG3zy.
*/
/* **** 1D Voronoi **** */

View File

@ -17,14 +17,19 @@
CCL_NAMESPACE_BEGIN
/*
* Original code is under the MIT License, Copyright (c) 2013 Inigo Quilez.
*
* Smooth Voronoi:
*
* - https://wiki.blender.org/wiki/User:OmarSquircleArt/GSoC2019/Documentation/Smooth_Voronoi
*
* Distance To Edge:
* Distance To Edge based on:
*
* - https://www.shadertoy.com/view/llG3zy
* - https://www.iquilezles.org/www/articles/voronoilines/voronoilines.htm
* - https://www.shadertoy.com/view/ldl3W8
*
* With optimization to change -2..2 scan window to -1..1 for better performance,
* as explained in https://www.shadertoy.com/view/llG3zy.
*/
/* **** 1D Voronoi **** */

View File

@ -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(

View File

@ -1,11 +1,17 @@
/*
* Original code is under the MIT License, Copyright (c) 2013 Inigo Quilez.
*
* Smooth Voronoi:
*
* - https://wiki.blender.org/wiki/User:OmarSquircleArt/GSoC2019/Documentation/Smooth_Voronoi
*
* Distance To Edge:
* Distance To Edge based on:
*
* - https://www.shadertoy.com/view/llG3zy
* - https://www.iquilezles.org/www/articles/voronoilines/voronoilines.htm
* - https://www.shadertoy.com/view/ldl3W8
*
* With optimization to change -2..2 scan window to -1..1 for better performance,
* as explained in https://www.shadertoy.com/view/llG3zy.
*
*/