- Home /
Mathf.Repeat in ShaderLab?
Hello, i looked around but couldn't find a shader intrinsic function that does what mathf.repeat does. Do you know if there is one?
Comment
Answer by Bunny83 · Apr 17, 2018 at 11:58 AM
There are several solutions:
Note while fmod and modf directly returns the remainder, frac has to be used like this:
num = frac(num/range) * range;
floor could be used like this:
num /= range;
num = (num - floor(num)) * range;
Though fmod would be the simplest implementation
num = fmod(num, range);
Your answer
Follow this Question
Related Questions
How is _WorldSpaceLightPos0 calculated for a directional light? 0 Answers
Cell Shading Using 2D Renderer? 0 Answers
Set list in shader (uniform) 1 Answer
How can I add Color property To This Shader 1 Answer
ShaderLab on Unity3d Indie 2 Answers