Spikey's Math Lab

Contests and Challenges

Get it? Math Lab.... sounds like Me.... Lab?.... No? ok

So spikeyxxx  you're like a super mathematician, I'm doing the Blender Cloud Procedural Shading course and it is super heavy dense in tough, difficult and impossible things and worst of all there's like a lot of math involved. I wanted to use this to bother you a lot and ask you math questions when it comes to procedural shading. 

The course is good but Simon goes way too fast and doesn't get into the really basics and assumes you know what happens mathematically under the hood. 


*WARNING, HERE BE MATH*

  • spikeyxxx replied

    duerer I don't know why, it depends on the situation  I guess. They are not exactly the same:

    Vector Curves consider the inputs between -1 and 1 and outputs values between -1 and 1. Outside of that range it just keeps going in the direction it has (linear extrapolation:

    RGB Curves does the same on the interval 0 to 1:

    Now, if you use Generated Coordinates, that go from 0 to 1, Vector Curves only considers that part of the Curve:

    While RGB Curves uses the whole Curve:


  • Ingmar Franz(duerer) replied

    spikeyxxx So, instead of mapping to the interval [0, 1] and then using an "RGB Curves" node, Simon Thommes could have directly used a "Vector Curves" node ?

    One main difference between both nodes is obviously that the "RGB Curves" node has the "C" button to operate on all three channels at the same time.

  • spikeyxxx replied

    duerer that depends on what he was doing., what values he was mapping to [0, 1]..(I am not (yet) a Cloud member...)


    Yes, you are right of course; that C(olor) button is a major difference, but I thought that so obvious, that I didn't mention it ;)



  • Ingmar Franz(duerer) replied

    Thanks, spikeyxxx, your answer was the 123rd reply. Just mention it since we're in a "Math Lab" 😉😁!

  • Omar Domenech(dostovel) replied

    Chapter 2-1: Noise Textures takeaways:

    - It was just describing each noise textures and what they do, giving an advice here and there

    - The thing that stood out the most was the noise texture centered around 0.5. I saw Ingmar asking about that and Spikey giving an explanation, but that is to advanced for me right now. For the moment I'll keep in mind that Noise Value Texture values are around 0.5

  • Kent Trammell replied

    This is next level! I've got my note pad out

    Also very cool that you're writing an insta-cloud script @adrian2301 🙌

  • Ingmar Franz(duerer) replied

    spikeyxxx I have recently seen a node setup in the "Shader Editor" where someone plugged the "Normal" output socket of a "Geometry Node" into one of the two "Value" input sockets of a "Math" node (set to "Add"). Besides the question whether this makes sense I'm wondering how the vector is converted into a single number? 

  • spikeyxxx replied

    duerer I would love to see that node setup! (Maybe it makes sense in some cases...)

    Maybe that is a genius, but it is also possible, that this was done by someone who has no idea what he/she is doing ;)

    I took me some time to figure out what is happening, because unlike when you plug a color into a value and Blender uses the Luminasnce of the color, when you plug a vector into a value, Blender takes the average of the X, Y and Z. Like this:

    But things get curiouser and curiouser; When you plug the Vector into a MixRGB Node first, then the output of that MixRGB Node is a vector, but when you plug that into a grey socket, Blender uses the Luminance formula on the X, Y  and Z values!

    So these two flows are the same:


  • Ingmar Franz(duerer) replied

    Thank you, spikeyxxx, for your answer 😀! The Blender 2.93 Manual here is unfortunately incomplete since it doesn't explain what conversion happens when plugging a "Vector" output socket into a "Value" input socket. I wish there would be a "Socket Output Display" node that you could connect to an output socket  so that it shows the value or the array of values that this socket provides.  This node should also have some checkboxes which you can choose in in order to show how this value is converted into other data types.

    PS: This is the node setup I mentioned:


    Interestingly, I've learned in that context that a "Normal Map" node with default settings ("Tangent Space") and no "Normal Texture" plugged into it outputs the same result as the "Normal" output socket of a "Texture Coordinate" node.

  • spikeyxxx replied

    duerer that node setup is definitely not made by a genius ;)

    Plugging a value (output from the Math Node) into a vector socket, means that the X, Y and Z of that vector all get that same value. To then separate the X, Y and Z and only use the Z....That person has absolutely no idea what he/she is doing.

    Without the separate XYZ, it would be something like this:

    Both 'paths' give the exact same result. I muted the Add node and subtracted 0.5 from the 'From Min' and 'From Max' in the Map Range (which you cannot do with the ColorRamp).

    In words: the creator of this node setup has made an (imaginary) diagonal plane (which has a Normal Vector pointing in the direction (1, 1, 1)) and looks at how close the Normal of each polygon of the Object that uses this shader, is to that Vector (1, 1, 1). And all this in, what I would call, a clumsy and very unintelligible way...

  • spikeyxxx replied

    And here is how I would do it:

  • Ingmar Franz(duerer) replied

    spikeyxxx One question to your last image in your post here (with an orange frame): At the "MixRGB" node (set to "Add") you put a label that the output vector still has "negative values". But since it's a "Color Output" socket, isn't it clamped to the interval [0, 1]? 

    In the node setup screenshot that I've posted above, I think that the guy who has created this, maybe just by habit used the "Math" node instead of the "Vector" Math" node since the first one, at least to my perception, is more often used in tutorials than the second one (oh, a pun 😉!). With a "Vector Math" node, the "Separate XYZ" node would really just isolate the Z-component.

  • spikeyxxx replied

    But since it's a "Color Output" socket, isn't it clamped to the interval [0, 1]?

    No, but that is what you would expect, so that is why I explicitly mention that.

    Simple example, showing this:

    And not:

    With a "Vector Math" node, the "Separate XYZ" node would really just isolate the Z-component.

    Yes, but he puts a value (from the Math Node) into a Vector socket, turning it into a vector with three the same values and then he uses one of them....So, like: a is a number, then make a vector (a, a, a) and then consider the third position of that vector (the Z)..

    Personally, I think that is stupid ;)

  • Ingmar Franz(duerer) replied

    spikeyxxx That's really strange that the manual setting of a color only allows values from 0 to 1 for R, G and B but if you take the values from a vector it allows negative values:

  • spikeyxxx replied

    duerer I know, right?

    But actually, the upper bound of 1 is a soft limit; you can manually type in a number higher than 1. (But not below 0.) This is for instance useful when using 'complex' Fresnel with metals:

  • Michael Mirn(michaelmirn) replied

    No funny gifs or deep questions here, just a simple statement: that thread is solid gold and should be baked as a constant part of CG archives.

    A couple of years ago I was watching one of Kent's streams and asked exactly for that: I want to understand why this does that, not to do it in a "prey the lord" way. I really think that this kind of info should be gathered in a special Blender section. I know that we have that Blender Manual but it's way too scarce.
    Call that section "stats for nerds" if you will but that is really valuable and decent research for those who dig that shit.

    Cheers, guys, and hats off.

  • Omar Domenech(dostovel) replied

    Your picture and user name look very familiar Michael, I believe like me you have been around here for a long time. 

    You revived this thread, I wanted to continue but there's only so many hours in the day and the house collab has taken work hours entirely. I think Spikey needs to teach this stuff like he helped us here.