From 3232d8ec8f15ad00ff16fd4326258de0b0b83486 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 2 Jul 2017 21:53:23 +0200 Subject: Fix T51951: cell noise texture precision issue at unit vertex coordinates. Solution is to bias the coordinates a little, same as Cycles checker texture. --- source/blender/blenlib/intern/noise.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/blender/blenlib/intern/noise.c') diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index f834c5b4c74..347640aae0d 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -1394,6 +1394,11 @@ static float voronoi_CrS(float x, float y, float z) /* returns unsigned cellnoise */ static float cellNoiseU(float x, float y, float z) { + /* avoid precision issues on unit coordinates */ + x = (x + 0.000001f)*0.999999f; + y = (y + 0.000001f)*0.999999f; + z = (z + 0.000001f)*0.999999f; + int xi = (int)(floor(x)); int yi = (int)(floor(y)); int zi = (int)(floor(z)); @@ -1411,6 +1416,11 @@ float cellNoise(float x, float y, float z) /* returns a vector/point/color in ca, using point hasharray directly */ void cellNoiseV(float x, float y, float z, float ca[3]) { + /* avoid precision issues on unit coordinates */ + x = (x + 0.000001f)*0.999999f; + y = (y + 0.000001f)*0.999999f; + z = (z + 0.000001f)*0.999999f; + int xi = (int)(floor(x)); int yi = (int)(floor(y)); int zi = (int)(floor(z)); -- cgit v1.2.3