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:
authorSergey Sharybin <sergey.vfx@gmail.com>2016-05-30 14:07:11 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2016-05-30 14:07:11 +0300
commitda975c59c2a0f5844ba01031aa6843c09dc4fddc (patch)
tree69f40d2cc9b0b6e514e57dcc403486985acb340e /source/blender/gpu
parent673fabbb64092f8a3fd5bf87f4b3ce0e80760aa5 (diff)
GLSL: Fix voronoi texture giving different results form rendered
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl12
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)));
}