Converting % to mod in SparkSL

Hello dear friends
Recently i was trying to port a shadertoy shader to SparkSL but apparently there’s something weird going on
although % is not supported by the current version of SparkSL and we have to use mod(x, y) instead, but in this particular case it doesn’t work. seems like mod is only works with floats not ints…
i would be highly appreciated if somebody helped me out about this.
here is my half converted code along with target shadertoy shader.

oil paint brush.sca (6.4 KB)

In your mod function calls, you would need to ensure everything is a float.

mod(float(someInt), someFloat)

oil paint brush.sca (6.5 KB)

FWIW, this shader probably isn’t going to work in spark because of performance, but you could try it in Lens Studio.

1 Like

Thank you so much ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

My experience shows that actually mod is not the same as %, although mod may be replaced by % in many shaders and it works well, but for example, in shaders that need to save frames, this formula cannot be used. Because the frame may not be seen in full And half of the previous frame and half of the current frame can be seen if the mod is used