# How does the noise texture keep it's values between a 0 to 1 range

When using both the fac output and the color output (which is the same as three different fac outputs in RGB) the values somehow are always between a 0 to 1 value range. If we use a reguralar perlin noise like the musgrave texture in Blender we see that for high detail values the output values quickly go above 1 and below 0. So the noise texture, which like the musgrave texture also evaluates a perlin noise, obviously remaps the perlin noise so that it always stays in the 0 to 1 range.

Could somebody please explain how the noise texture does that and link the source code, which controls this remapping?

• Looks like it just divides it by the maximum possible amplitude. src May 21, 2022 at 14:45
• Wait how did you figure that out? May 21, 2022 at 14:55
• Cause I just found that out simultaneously XD May 21, 2022 at 14:59
• But do you know why Blender seems to have the same code in multiple locations? Because I found it in a completely different folder May 21, 2022 at 15:01
• There are at least two implementations of nodes; Eevee, that uses OpenGL and is written in GLSL, and Cycles that uses OSL. For simple nodes I generally I find Cycles easier to understand. They differ for things like Principled (Eevee uses an approximation IIUC). May 21, 2022 at 15:06

The difference is actually only that for example Musgrave Texture initializes perlin noise as signed integer, and the Noise Texture as unsigned integer.

Therefore only the range from $$-1$$ to $$1$$ or $$0$$ - $$1$$ changes at the base.

The following example illustrates this a bit better:

On the left, the values have simply been mapped to a new range using the Map Range node, and on the right is the normal Noise Texture (the contrast here is just to make the result stand out more).

You can find the corresponding places in the source code here:

Musgrave Texture:

Noise Texture:

• Wow, this again is in a completely different location than what scurest and I found. May 21, 2022 at 15:20
• Small correction: musgrave node also doesn't divide by maximal amplitude May 21, 2022 at 15:34
• @tempdevnova Yes, in further consequence these function differently, you are absolutely right, but the decisive factor is primarily the basis with which the calculation is started. May 21, 2022 at 15:37
• @quellenform Sorry. Am I correct for saying this: The actual range of Perlin Noise is [-1,1], but in Blender, the range is remapped to [0,1] (for whatever reason) by using a Map Range (aka Linear Interpolation) function? Jul 31, 2023 at 21:07

Scurest found the corresponding source code, linked in his comment.

Apart from that I also found the source code in question in a different folder: