10
$\begingroup$

When I create a Cycles shader, I often take the 'Fac' output from a Texture node and feed it to the 'Fac' input on a Mix Shader. I'd like to know the exact range of values that this output produces so that I can transform it with Math nodes and not have clipped values.

Is there any documentation on the range of values that each of these texture nodes produce?

$\endgroup$
  • 4
    $\begingroup$ It ranges from 0 to 1, 0 representing black and 1 representing white. $\endgroup$ – Ezra Aug 9 '16 at 19:32
  • 2
    $\begingroup$ I am not sure this is perfectly correct: The Cycles Noise texture seems to have a range of [a, b] where a > 0 and b < 1. You can plug the ouput of the texture into the background with strength 1 on an empty scene, and render it out, and analize the values of the resulted image. $\endgroup$ – Róbert László Páli Aug 9 '16 at 20:03
  • $\begingroup$ By plugging the the output to a math node, I have seen the musgrave texture output values from -1.3 to 1.4. $\endgroup$ – Scott VanKirk Dec 23 '16 at 20:09
  • $\begingroup$ If you want to ensure the values are between 0 and 1 there's a "clamp" checkbox in the math node. $\endgroup$ – Steve Jul 15 '18 at 18:22
  • 1
    $\begingroup$ @Steve That would work, but if the range is substantially larger than [0, 1], you'll end up with clipping artifacts. I'd rather know the range, then remap it to [0, 1] so I lose less information. $\endgroup$ – Justin Jul 17 '18 at 13:08
1
$\begingroup$

Rather than list the specific ranges of the texture nodes it is more useful to provide the tools you can use to analyse them yourself - partly so that you could apply the same technique to any other texture or shader function you made create in future, but also because stating specific upper and lower ranges is meaningless unless you also appreciate how the values are distributed over that range.

For example, consider a mathematical 'normal' distribution (https://en.wikipedia.org/wiki/Normal_distribution) :

normal distribution

In a normal distribution, the values are centred around a specific place - there is more chance than any particular sample will be near that centre and progressively less chance the further away from the centre you go. However, where does it end? Technically the range is actually -infinity to infinity as there is a chance of any value being returned by the normal function - just progressively less chance, the further from the centre you move. How could you measure such a boundary?

From a practical point of view, however, we may just that we've reached the limit whenever the chance of a result of a certain value is below a particular threshold. ie, it becomes very relevant to know the shape of the distribution to be able to determine where the practical limits are.

The built-in Blender UV/Image Editor window includes tools that can show the distribution of values and we can use that to analyse the output from any node. Open a UV/Image Editor window and press T to open the tools panel. You should see a Scopes panel with a number of graphs. The most useful for this situation is the Histogram panel :

histogram

The histogram shows an analysis of the pixels in the image over the range 0.0 to 1.0 for each channel R, G, B, A in addition to 'combined' channels Luma and RGB, with the shape of the graph showing how those values are distributed throughout the image. The peak shows what the most common value is, the lower the occurrance, the lower that point in the graph.

The histogram shows the analysis of the image after any color management has taken place on the image. Therefore, to avoid skewing the results we need to first disable color management. This can be achieved by opening the Scene properties and selecting 'None' in the Display Device setting of the Color Management properties.

color management

Since the histogram only shows values in the range 0.0 to 1.0 and some of our textures (such as Musgrave) produce values outside that range, we'll need to apply some maths to shift and scale the values to something more useful. Since the Histogram window includes grid lines to split the graph into 4 we can use the centre line as 'zero' with a range of -2.0 to +2.0 using the following nodes :

nodes

Note that this shows the nodes for the Environment rather than a specific material. By removing all the objects from the scene and simply rendering the environment we can get a clean image that only contains the results of the texture being tested.

Now simply plugging different texture's Fac output into the Color input of the Background node and pressing F12 to render should produce an analysis of the texture as a histogram. For example, Noise produces the following :

noise

Note : Varying the Scale of the texture node will affect the smoothness of the curve.

For the Noise example above the vertical grid line in the centre of the histogram represents 0.0. Values to the left of this are increasingly negative (with the 1/4 grid line representing -1.0) to the left-hand edge, representing values of -2.0. Similarly, the 3/4 vertical grid line represents 1.0 while the right-hand edge represents 2.0. As can be seen from the graph, the values of the Noise texture centre around 0.5 and vary down to about 0.25 and up to about 0.75. However, there is a 'tail' that theoretically extends indefinitely - presumably down to 0.0 and up to 1.0 but with ever decreasing frequency. So, for practical purposes the Noise texture varies from 0.25 to 0.75 with approximately a normal distribution.

Plugging other textures produces the following :

Voronoi - varies between 0.0 and 1.0, biassed towards the lower end and gradually dropping off : voronoi

Musgrave - centred around 0.0 and tailing off to -1.5 and +1.5 : musgrave

Magic (Fac) - between 0.0 and 1.0 with a high peak at about 0.3 : magic

Wave - Between 0.0 and 1.0 with more values at either end (the peak and trough of the wave) : wave

Similar methods can be used to analyse the Color output of the textures by splitting the color into individual channels and performing the same calculations before combining back into a single color. The histogram can then be used to split the channels to compare :

nodes - 3 channels

magic - 3 channels

$\endgroup$
0
$\begingroup$

Color outputs have R G & B values that range from 0 to 1 and factor values range from 0 to 1. The exception is Musgrave whose values can be mapped from 0 to 1 by applying this node group

$\endgroup$
  • $\begingroup$ I don't think this is true for all non-Musgrave nodes. See Robert Laszlo Pali's comment on my original post. $\endgroup$ – Justin Jul 18 '18 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.