Highlighted trainings

Training types

Training categories

You can join Blender Studio for €11.50/month and get access to all of our training & film content instantly!

2: Procedural Textures

July 9th, 2020

License: CC-BY
Simon Thommes
Publisher

You can get the file for the Value Graph Tool here: https://cloud.blender.org/p/procedural-shading/5f075c60f11c51bf02b95fa1

Download the resulting file here: chapter_2-2.blend

Join to comment publicly.

## 31 comments

Hello Simon, can i know how blender process when i divide some value by 0 ?

@MOHAMMED AIMAN IZZUDDIN BIN ABD MALIK You should always try to avoid this. As correct behavior for this is not defined you will get unintended results in any case. In a shader this usually results in incredibly high/low values that are different per pixel.

@Simon Thommes i see, thank you Simon

Are there any books that you can recommend for beginners to familiarize themselves with application of these math subjects?

@Bora Semiz Besides my general math education from school/university I'm primarily self-taught, so I don't have specific literature that I can recommend fro my own experience, sorry. A resource that people kept bringing up when it came to this question in the past it thebookofshaders.com and from browsing it a bit it seems to be a fantastic resource. Even though it is not blender-specific, the concepts are universal.

@Simon Thommes Thank you very much. I just skimmed through the book you sent, it looks like something like what I am looking for.

Thnaks for this tutorial :)))

I can't seem to download the chapter_2-2.blend file, I get an access denied. Other than that tutorial is fantastic! Thank you!

@Chidi Jenkins-Johnston Hm, for me it works, even without being logged in... Can you maybe report this as a bug? Instructions are here: https://cloud.blender.org/contact/

Why does Arctan2(X/Y) provide values outside the functions range of [-pi/2, pi/2]. Also how does it handle it when Y is 0?

@Tyler Stephens The great thing about arctan2 is that you don't only pass in the quotient of the coordinates

`x/y`

but both coordinates individually. That's how you don't have to worry about the divisor being`0`

and that's also how it's possible to gain values of the full 2pi range.How it works is basically that the function is evaluated differently depending on what quadrant the coordinates are in.

@Simon I'm just about through this episode. It's taken me on a journey of basic trig, arctan2, polar coordinates. Circling back, I just wanted to confirm why removing the z coordinate to work with cylindrical coords vs spherical coords matters. After testing this on a cube instead of a plane, if I don't drop the z coordinate, everthing is black (or white, depending on the operation between the angle and radius). Is this because the third additional component causes the length to be too large? The angle is mapped to 0-1, but the length could then be greater than 1 or less than -1. Then again, there should be some intermittent values that would result in 0-1 output in the shader. So, I don't fully understand why keeping the z component would cause problems with spherical coordinates.

@Tighe Racicot The length of 3D coordinates is simply their distance from the origin. So on a cube that has a dimension on the z axis the z component also contributes to that distance. On a plane, where z=0 this does not matter but with the cube for example it does, as the z-component distorts the distance from the center. You can see the effect gradually have an effect when you scale the cube on the z-axis in edit mode down to a plane.

By ignoring the z-component you essentially use the distance from the z-axis, instead of the distance to the origin point. (cylindric vs spherical)

I realize I'm going to need to dive into some math if I want to level up in this area. @Simon, when you graph the arctan2 result of x and y, I can't wrap my head around why it's 3D (z values). The z coordinate was dropped off at the Separate XYZ. I had to research the arctan2 function itself. Given two coordinates, it can determine the signed angle (specific quadrant), starting at the positive x axis, outputting a range of values from -pi to +pi. But... why does it spiral vertically?

@Tighe Racicot The graph that is shown is simply a representation of the value that is shown. With this you are not looking at actual 3D data. Just the one-dimensional result of arctan2 on a two-dimensional plane (x,y). The fact that this is displayed along the z axis is due to the value graph tool that I introduced in Chapter 1-4 https://cloud.blender.org/training/procedural-shading/5f07557cb710f162b1d6b5a3

@Simon Thommes Thanks so much. I reviewed the video and it clicked.

Hello Simon, thanks for this fantastic tutorial series. It's saving my life this #nodevember ! Question, could you explain why the Multiply Add mode does the same thing as the Map Range nodes in vector terms? I understand that both operations are re-mapping the limited 0-1 range to a wider range (-1 to 1). But how does one multiply and add the vectors here to achieve that same end? Thank you!

@Ellie MacQueen I'm glad you're enjoying it! Basically the 'Map Range' node, under the hood, does the same thing as the multiply add node. It is just much more convenient due to the inputs that it takes.

In this example: Multiplying by 0.5 brings values from a range [-1 : 1] to a range [-0.5 : 0.5]. Then adding 0.5 brings it from there to [0 : 1]. So in total from [-1 : 1] to [0 : 1], which can directly specify as limits in the 'Map Range' node. The 'Map Range' node essentially just uses its inputs to find out what values it needs to multiply and add.

To be honest, if I made this video today, I wouldn't have included the 'Multiply Add' node at all here, as it just unnecessarily complicates things. But I hope this helps!

I'm not sure what you mean with 'in vector terms' here. Both nodes operate on values and a vector in Blender is just a container of 3 independent values. So to apply the same mapping to vectors you would have to either separate the components and control them individually or use vector math operations. (there is also a 'Vector Curves' node that I keep forgetting about)

It would be nice to see either an image with the finished node tree or a Blender file containing the final material

*

@Greg McKim* You are right, I added the file in the description*

@Simon Thommes* Thanks much!So much good info here, but I'm going to need to watch it about 10 times, lol

Using the Map Range Node before the RGB Curves node leads to negative values at the output of the RGB Curves node. Is that correct? (Min 2:16)

*

@Michael Schwarz* The optput of the map range node, because clamping is activated, is strictly between its 'To' range (0 and 1). And because the RGB Curves node operates between 0 and 1 as well, the output of that node is also in that range.The map range node is there to map the range of coordinates that the shape will be created on to the range in which the RGB Curves node operates.

*

@Simon Thommes* Thanks for the reply. It took me some time and some trying but now I'd got it.Hi Simon, in the latest version 2.83.4 the absolute node doesn´t works as expected (exactly , it does nothing) Is that hapend to you also? or I´m doing somethin wrong

*

@Pablo Gonzalez* There should not have been any changes regarding the absolute node. I tested it on 2.83.5 and it works fine. My guess would be that you are accidentally clamping the negative values to 0 in an operation before, but that is hard to pin down without seeing the setup. You can post a screenshot and I'll take a look.@Simon Thommes what is the function of CLAMP? I also made the same mistake.

@fu233 Clamping makes sure that your values don't go beyond a certain maximum/minimum. Usually in Blender nodes that is [0-1]. That is sometimes useful to make sure you are not working with values outside of the visible range, but oftentimes also a math operation requires the values outside of those bounds and clamping can give an incorrect result.

*

@Simon Thommes* Exactly !! It was clamped. Thank you for your fast answerSimon, this series is pure gold, but I'd encourage everybody who isn't a genius to play it at 0.75x speed, my brain can process it that way!