Page MenuHome

[Cycles/Material view] Modulo function in material doesn't match cycles.
Closed, ResolvedPublic


System Information

Blender Version
Broken: latest master
Worked: probably always has been broken.

Short description of error
the math_modulo shader in gpu_shader_material.glsl has a small bug, it makes up for the sign being wrong, but that is not enough

void math_modulo(float val1, float val2, out float outval)
	if (val2 == 0.0)
		outval = 0.0;
		outval = mod(val1, val2);

	/* change sign to match C convention, mod in GLSL will take absolute for negative numbers,
	 * see */
	outval = (val1 > 0.0) ? outval : -outval;

last line should probably be

	outval = (val1 > 0.0) ? outval : -(val2-outval);

Exact steps for others to reproduce the error
Based on a (as simple as possible) attached .blend file with minimum amount of steps

render with cycles, compare with material view... not the same

Revisions and Commits