3
$\begingroup$

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?

$\endgroup$
7
  • $\begingroup$ Looks like it just divides it by the maximum possible amplitude. src $\endgroup$
    – scurest
    May 21, 2022 at 14:45
  • $\begingroup$ Wait how did you figure that out? $\endgroup$ May 21, 2022 at 14:55
  • $\begingroup$ Cause I just found that out simultaneously XD $\endgroup$ May 21, 2022 at 14:59
  • $\begingroup$ But do you know why Blender seems to have the same code in multiple locations? Because I found it in a completely different folder $\endgroup$ May 21, 2022 at 15:01
  • 1
    $\begingroup$ 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). $\endgroup$
    – scurest
    May 21, 2022 at 15:06

2 Answers 2

5
+50
$\begingroup$

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:

enter image description here

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:

$\endgroup$
4
  • $\begingroup$ Wow, this again is in a completely different location than what scurest and I found. $\endgroup$ May 21, 2022 at 15:20
  • 1
    $\begingroup$ Small correction: musgrave node also doesn't divide by maximal amplitude $\endgroup$ May 21, 2022 at 15:34
  • $\begingroup$ @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. $\endgroup$
    – quellenform
    May 21, 2022 at 15:37
  • $\begingroup$ @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? $\endgroup$
    – Orange Cat
    Jul 31, 2023 at 21:07
2
$\begingroup$

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:

https://github.com/blender/blender/blob/dfb8c90324c018068f12ca41543c3c311dff6d21/source/blender/gpu/shaders/material/gpu_shader_material_fractal_noise.glsl#L29

So, yeah basically it just divides by the maximal possible amplitude.

$\endgroup$
1
  • $\begingroup$ 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 function? The highest upvotes answer mentioned Map Range (aka Linear Interpolation). $\endgroup$
    – Orange Cat
    Jul 31, 2023 at 21:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .