Fix T43380 modulo operation in GLSL does not return negatives.
Make it so by checking operand sign.
This commit is contained in:
parent
8186214c39
commit
3ff9e52dca
Notes:
blender-bot
2023-10-12 12:49:04 +02:00
Referenced by issue #43380, Math function "Modulo" in Cycles presents different result to the "GLSL material".
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue