Jump to content

newbie quastion about Derivative u/v


Mzigaib

Recommended Posts

I know it's a very newbie question but can someone explain to me what is derivative U/V or du/dv?

It's a "math thing".

Roughly, it means: the amount by which something changes, relative to a change in some other thing (it relates two things that are connected in some way). The area of math where those terms show up is called "Calculus", but you will also come across a lot of terms from another area called "Linear Algebra".

My absolute all-time favourite online course (35 lectures) on Linear Algebra [MIT 18.06], from the best math prof in the world (Gilbert Strang) is

(yes, I like this series a lot :)).

Professor Strang also has some gentle, introductory ("big picture") overviews of the main concepts in Calculus in

.

MIT also makes a more "standard" Calculus series available on-line. The main portal for the open courseware (the math section) is here. There are some introductory courses on

and
. And the MIT channel in youtube is here

Happy learning!

  • Like 1
Link to comment
Share on other sites

I am very bad at math, If theres a example for at least in what this is used in CG or Houdini would be nice.

Derivatives are mostly used in the shading contexts (SHOPs), but also show up in COPs and, under different names, in CHOPs (the "Slope" and "Area" CHOPs), although in the shading contexts they typically represent differentials instead of the actual (partial) derivatives (in contrast to PRMan, for example).

A classic example for surface shaders would be in computing the tangent directions for an anisotropic specular model . As an example, you can take a look at the vop_computeTangents() function in $HH/vex/include/voplib.h. This function is called by the "Specular" VOP, for example, to calculate a tangent space when you set the "Specular Type" to "Anisotropic".

They're also sometimes used without you being aware of the fact, such as when you use a Texture VOP (it uses these things internally to anti alias the texture color). But there are many other possible uses for dPds, dPdt, Du(), and Dv().

HTH.

Link to comment
Share on other sites

Thank you very much for the explanation, It starts to make sense to me.

Just a little doubt, I'll try to be clear as possible because it's difficult even to formulate a question of it but these derivatives functions they are applicable on just the render process or I can use it on anything else?

For what I understand this functions are used most for calculating pixel render filters, am I right?

Link to comment
Share on other sites

Just a little doubt, I'll try to be clear as possible because it's difficult even to formulate a question of it but these derivatives functions they are applicable on just the render process or I can use it on anything else?

You may see the same concepts being used (indirectly) in some non-shading contexts as regular operators, like in those CHOPs I mentioned (Slope and Area) or the PolyFrame SOP when set to compute tangents from UVs, for example, but the only place where you will see these functions (Du, Dv, area(), etc) and the associated globals (dPds, dPdt) available directly, is in VEX (or VOP networks, which is really just a visual form of VEX). And even then, not in *all* of the VEX/VOP contexts (simply because for some contexts these ideas are not well defined).

A couple of simple c-shell commands can show you all the contexts for which some native form of derivative information is available:

mario-79% foreach c ( `vcc -X contexts` )                     
foreach? echo Context \"$c\":                                      
foreach? vcc -X $c | grep -E 'dPds|Du'                             
foreach? end

Context "surface":                                                 
  (Read Only)   vector dPds                                        
 vector4 Du( vector4; ... )                                        
 vector Du( vector; ... )                                          
 float Du( float; ... )
Context "displace":
  (Read Only)   vector dPds
 vector4 Du( vector4; ... )
 vector Du( vector; ... )
 float Du( float; ... )
Context "light":
  (Read Only)   vector dPds
 vector4 Du( vector4; ... )
 vector Du( vector; ... )
 float Du( float; ... )
Context "shadow":
  (Read Only)   vector dPds
 vector4 Du( vector4; ... )
 vector Du( vector; ... )
 float Du( float; ... )
Context "fog":
  (Read Only)   vector dPds
 vector4 Du( vector4; ... )
 vector Du( vector; ... )
 float Du( float; ... )
Context "photon":
  (Read Only)   vector dPds
 vector4 Du( vector4; ... )
 vector Du( vector; ... )
 float Du( float; ... )
Context "chop":
Context "pop":
Context "sop":
Context "cop2":
 vector4 Du( vector4; ... )
 vector Du( vector; ... )
 float Du( float; ... )
Context "image3d":
Context "cvex":

mario-79%

If you're using VOPs (instead of coding VEX directly) and are in one of the shading contexts (surface,displace,light,shadow,fog,photon), you will have access to the ShadingDerivative VOP, which is the same as the Du and Dv VEX functions. (BTW, the "cop2" context should have it available, but it seems to be missing -- in VOPs, not in VEX).

For what I understand this functions are used most for calculating pixel render filters, am I right?

That's one application -- for computing the local size of a filter (based on the amount of change in the uv coordinates relative to the underlying change in surface position). That's what I meant when I mentioned "anti aliasing a texture". But, you likely don't want to (or need to) code texture filters by hand inside the shader.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...