Hi there, bit of a general question but thought it worth asking, I’m trying to understand what the derivative node in Node Material Editor does?
I’ve seen it used for distorting UVs, and playing about with putting it on a texture output i see it creates a sort of ‘edge detection’-like effect, but cant wrap my head around how it takes a single input and returns two (dx and dy)
For what its worth my math skills are not that strong, I did a bit of research and understand that derivatives can get a sort of ‘rate of change at a certain point in time’(?) but might have misunderstood. Is it that the single input it takes is actually compared with previous and later inputs to get that x/y vector?
Any help or links to resources would be much appreciated (preferably use cases and not calculus textbooks…)
It is dFdx and dFdy in opengl, maybe you can get more infos by searching that as I’m not sure I’m correct.
For example, if you pass a color as input, for a fragment, dx means the right fragment’s color minus the fragment’s color while dy means the bottom fragment’s color minus the fragment’s color.
Hope I explain it clearly.
4 Likes
thank you @tanpopo, so is the the order in which it cycles though the fragments right to left, and bottom to top? And fragment here means the pixel on the screen?
Hi! What the derivative node does is applying the partial derivative operation with respect to the x and y components of the input. The partial derivative is a common operation on calculus where you take the derivative only of that component you want, and treat the other components as constants:
As we can understand the derivative as the “rate of change” of a value (so, if a vector function has a high derivative, that means it changes super fast), the partial derivative of a vector in respect to a component, is the rate of change relative of that component. So, a function might have a big dx, which means that for a small change in x, the value of that function changes drastically, but a small dy, which means the values doesn’t change a lot even for big changes in y. The vector formed by all the partial derivatives of a function is called the gradient vector, and it acts like a “slope”, showing the steepest areas of change for that function.
I think a picture is worth a thousand words, so here are some great videos to visualize partial derivatives and gradients
3 Likes