[Bf-blender-cvs] [3ff9e52] master: Fix T43380 modulo operation in GLSL does not return negatives.

Antony Riakiotakis noreply at git.blender.org
Tue Feb 3 15:08:55 CET 2015


Commit: 3ff9e52dca8ce9e5900eb89fd06842f41b817b3d
Author: Antony Riakiotakis
Date:   Tue Feb 3 15:08:28 2015 +0100
Branches: master
https://developer.blender.org/rB3ff9e52dca8ce9e5900eb89fd06842f41b817b3d

Fix T43380 modulo operation in GLSL does not return negatives.

Make it so by checking operand sign.

===================================================================

M	source/blender/gpu/shaders/gpu_shader_material.glsl

===================================================================

diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 229abd7..17f0c20 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)




More information about the Bf-blender-cvs mailing list