# How to loop procedural noise seamlessly

Hi guy’s, i am trying to loop seamlessly the noise W value and i did a search on this and found a few post but they are not clear enough for me to understand.

I found that CG cookie tip here but i don’t know how to apply it correctly :https://cgcookie.com/questions/11218-want-to-loop-a-noise-texture-here-s-a-way-to-do-that
I have include the CG cookie node setup in the file but it is not connected.
Here the file if someone would be kind enough to have a look at it
test_loop.blend (1022.4 KB)

I don’t think this is going to look what you expect though. Using only one parameter, a function returning back to base will have to do acceleration and deceleration and at some point stand completely still. What you want is a continuous motion around a circle, but that needs two parameters, and you can only get 2D noise. So instead of trying to use both cos and sin in a non working magical fashion into W, you use cos into a coordinate axis (say, Z) and sin into W. Something like this should work, at the cost of not having 3D output:

1 Like

Thank for replying Carl sorry for late reply since i got sick, when i feel better i will try your method and comment back.

I think you should be able to extend this at least a little bit in the 3rd dimension by mapping the texture’s Z coordinate (which you left open) onto an offset on the Amplitude value. As long as this offset is small compared to the Amplitude base value, the distortions should remain small.

Updated with using object.z → all 4 inputs, muting some, experiment with it.
Better than stretching maybe, but not ideal as you get a pulsating “motion” in the noise.
Mapping it on using triplanar blended approach didn’t work well either, as noise breaks its continuity.
Adding object.z to amplitude just made the front evolve more than the rear. Not best either.

Yeah, I observed the same, I think this only works if you multiply object.z with a factor much lower than the base amplitude value (maybe a factor 10 smaller) before adding it to the amplitude.

Maybe one could also rotate the coordinates additionally, to spread this issue around all coordinates? (Something like a twisted torus in 4D space)

In this particular case, I’d probably use the coordinate with the smallest object dimension to drive the amplitude, in order to minimize the distortions.

This is the setup that I tried now, it’s slightly faster on the front compared to the back and has a loop length of 250.

If you want to make the loop shorter, you will wither get more distortions (back slower than front) or a faster animation

test_loop_3D.blend (1.0 MB)

2 Likes

Thank a lot mate this work exactly the way i want and since i am not good enough at math i would never been able to figure it out on my own.

No problem! It’s basically the same setup as @CarlG proposed, though.

1 Like

Note that you can use something similar to loop non-loopable generators across at least one seam. UV in → some math → 3D vector out for 3D generator that loops perfectly across one seam. Very useful for bendable cylindrical shapes where you need to use UVs and you need looping noise over the seam. Since it loops at UV.x edge the UV has to fill the space and will impact density of cylinders with varying thickness and quite impossible to implement on branching shapes. But I use this all the time (for aniso rotation).

3 Likes

good to know, so you replace the time input of the animation with the UV coordinate that loops around, right (with the correct factor)?

See this for example of repeats:

So the UV version creates the surface of a 2D torus in 4D space, right? This means that if you embed the torus in 3D space instead, you could use the 4th dimension for animation, including, of course, some distortions along the way.

Edit: I tried it and, while it works, the distortions are probably too much for most cases:

UV_seamless_animatable.blend (130.1 KB)

Only purpose for me for the torus mapping was to use it to create seamless lookup textures. But I found it too hard to control what’s going in within that coordinate space. Obviously it would have been much better and easier if we had a repeat switch for the xyzw parameters. The cylinder (2D->3D, seamless over one axis) is much more useful and something I use all the time for real objects.

Yes thank to Carl also since he brought a lot of useful info in this thread.