diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-02-03 17:08:28 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-02-03 17:08:42 +0300 |
commit | 3ff9e52dca8ce9e5900eb89fd06842f41b817b3d (patch) | |
tree | d4e64ac2ea841ee007a0369234cd0559d1df3d79 /source | |
parent | 8186214c390e91d20dd78fbee345e668c3364c71 (diff) |
Fix T43380 modulo operation in GLSL does not return negatives.
Make it so by checking operand sign.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 229abd7c5a6..17f0c20fad8 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -297,6 +297,10 @@ void math_modulo(float val1, float val2, out float outval) outval = 0.0; else outval = mod(val1, val2); + + /* change sign to match C convention, mod in GLSL will take absolute for negative numbers, + * see https://www.opengl.org/sdk/docs/man/html/mod.xhtml */ + outval = (val1 > 0) ? outval : -outval; } void math_abs(float val1, out float outval) |