diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-30 14:07:11 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2016-06-08 22:45:40 +0300 |
commit | 836fc68c526bc5a15d628ba282fc401cbe824902 (patch) | |
tree | 9d351bea494b0015dc2f4784a5fdf9ed72de29e9 | |
parent | ace9a3132e657c954443d1a500c01334463b335d (diff) |
GLSL: Fix voronoi texture giving different results form rendered
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index a3b05803063..91ca6a51bbb 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2403,6 +2403,12 @@ int floor_to_int(float x) { return int(floor(x)); } + +int quick_floor(float x) +{ + return int(x) - ((x < 0) ? 1 : 0); +} + #ifdef BIT_OPERATIONS float integer_noise(int n) { @@ -2453,9 +2459,9 @@ float bits_to_01(uint bits) float cellnoise(vec3 p) { - int ix = floor_to_int(p.x); - int iy = floor_to_int(p.y); - int iz = floor_to_int(p.z); + int ix = quick_floor(p.x); + int iy = quick_floor(p.y); + int iz = quick_floor(p.z); return bits_to_01(hash(uint(ix), uint(iy), uint(iz))); } |