diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2017-11-23 18:10:38 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2017-11-23 19:14:04 +0300 |
commit | e50ed90e4dff3a01fd5e3211f3571a34e1d6855d (patch) | |
tree | 1abb64adb659871779ea627445d487cb69b48805 /source/blender/gpu | |
parent | e704d8a616376d3e0a0796396133dfe5c4df6cd5 (diff) |
Fix T53348: Cycles difference between gradient texture on CPU and GPU.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 4ac69119a6c..0a63fc216a0 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2971,7 +2971,10 @@ float calc_gradient(vec3 p, int gradient_type) return atan(y, x) / (M_PI * 2) + 0.5; } else { - float r = max(1.0 - sqrt(x * x + y * y + z * z), 0.0); + /* Bias a little bit for the case where p is a unit length vector, + * to get exactly zero instead of a small random value depending + * on float precision. */ + float r = max(0.999999 - sqrt(x * x + y * y + z * z), 0.0); if (gradient_type == 5) { /* quadratic sphere */ return r * r; } |