2

The official blender documentation for the musgrave texture states: Dimension: The difference between the magnitude of each two consecutive octaves. Larger values corresponds to smaller magnitudes for higher octaves.

But how is the magnitude calculated using the dimension input? One reasonable guess would be 1/dimension but that doesn't seem to be the case.

tempdev nova
  • 1,495
  • 4
  • 21

1 Answers1

2

EDIT: Replacing my original answer because of an off-by-one error.

It turns out that the Musgrave texture mapping includes a hidden input. If you enumerate the inputs you get:

0 Vector
1 W
2 Scale
3 Detail
4 Dimension
5 Lacunarity
6 Offset
7 Gain

So my original assumptions were off. Let's carefully track down the "dimension" input.

  1. In properties_texture.py it is defined, not as "dimension, but as dimension_max

  2. In rna_texture.c it is given the internal RNA mg_H

  3. In texture_procedural.c in various places it is used as the 4th argument to the indirect function mgravefunc, for example in this call.

  4. mgravefunc depends on the Musgrave type. In the previous step it might be BLI_noise_mg_multi_fractal or BLI_noise_mg_fbm.

  5. The various noise functions are defined in blender/source/blender/blenlib/intern/noise.c The 4th argument is always called H

Oddly enough this does bring us to the code I cited in the incorrect version of the answer, only we need to look at the variable H:

  float value = 0.0, pwr = 1.0, pwHL = powf(lacunarity, -H);

It is used as an exponent of lacunarity.

Marty Fouts
  • 33,070
  • 10
  • 35
  • 79
  • I don't think that this code snippit actually covers the dimension value. It rather looks like the code for generating the perlin noise iterartivelyusing octaves, which however refers to the detail value in the musgrave node not the dimension. – tempdev nova Mar 04 '22 at 14:17
  • After reading the code, I couldn't find where the dimension value turns into the octaves variable. The only thing I found is: "//``octaves'' is the number of frequencies in the fBm". WHich considering the nature of perlin noise (blender for some reason calls it musgrave) would be exactly what the detail input would be. – tempdev nova Mar 05 '22 at 18:00
  • I followed the code, but no matter how I look at it I can't see how the octaves variables could correspond to a input parameter other than 'detail'. – tempdev nova Mar 06 '22 at 15:17
  • @tempdevnova thanks for keeping me honest. Right code fragment wrong variable. I think the answer is right now. – Marty Fouts Mar 06 '22 at 17:07
  • Yes, H seems to be the dimension value, great! So as I understand the code, it does the following with the musgrave dimension value: First it uses the powf function to return a value to a variable called pwHL. The pwHL then multiplies the pwr variable every loop iteration, which then drives the values of the individual noise layers in line 1344. The only question now is where the powf function is specified. – tempdev nova Mar 07 '22 at 16:02
  • powf is a standard C function from the math library. To quote from a manual "The pow(), powf(), and powl() functions compute x raised to the power of y." – Marty Fouts Mar 07 '22 at 16:19
  • Now everything makes sense, thanks! Just curious since I'm not acquainted with the standart C function library but what is the difference between pow(), powf(), and powl()? – tempdev nova Mar 10 '22 at 14:54
  • 1
    The return value's size. pow returns a double precision float, powf returns a 'float' which can default to various sizes and powl returns a quad precision (long double) float. pow has details – Marty Fouts Mar 10 '22 at 17:02