Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

renderpipe

3D Math in houdini

Hello everybody,

I studied the 3D math for computer graphics lessons and I also studied the Matrix Math on the odwiki.

I understand how to compute dot product, cross product and how to normalize vectors. Also matrix multiplication, identity, etc. You get the picture.

My question is, when will I use this mathematics in Houdini? Other than shader writing is there any other use of this math?

Maybe the material is still new to me that me not understand how to use it. Is it possible that maybe you guys give me ideas on when I use this math? Keep in mind I am still noob to 3d so maybe that why I do not understand when I will use this mathematics.

On math website it says normalized vectors are in range -1 to 1 however in adv renderman book it says normalized vectors are in range 0 - 1. Which is correct?

TIA

Share this post


Link to post
Share on other sites

You would use math to control particles. I haven't touched houdini's particle system yet but in maya you can get alot of control by writing expressions which are really just math expressions.

Share this post


Link to post
Share on other sites
My question is, when will I use this mathematics in Houdini? Other than shader writing is there any other use of this math?

You will probably come into a situation where you have some use for this type of math in everyday use of Houdini... but these cases willl be *rare*. That is not to say that familiarizing yourself with some of those concepts is a waste of time though. It helps a *great deal* to "know what's going on" when you use, say, a Slope CHOP.

That being said, the one place where you will *categorically* need to know/use that kind of math, is when writing shaders (shaders that are more involved than "plastic", that is). This is why the matrix, vector, spaces, etc. sections in the wiki are under "WritingShaders".

Maybe the material is still new to me that me not understand how to use it. Is it possible that maybe you guys give me ideas on when I use this math? Keep in mind I am still noob to 3d so maybe that why I do not understand when I will use this mathematics.

One simple example that you'll meet early on when you start learning to write shaders, is the so-called "Lambertian Diffuse" calculation (what you and I call simply "diffuse"). This is given by L.N -- that is, the dot product of the (unit-length) lighting direction, and the normal to the surface (i.e. the cosine of the angle between them).

You could call the diffuse() function to have it do exactly that for you, but you will quickly find cases where you'll need to calculate this by hand for other purposes and in other contexts.

In other words, even though one could make an argument that you could just combine existing functions without worrying about the underlying math, I can guarantee you that this would only last a very short while; you'd quickly come up against a case where you'd need to "know what's going on".

Again; this is really only true in the context of writing shaders, not for "using Houdini" in general.

On math website it says normalized vectors are in range -1 to 1 however in adv renderman book it says normalized vectors are in range 0 - 1. Which is correct?

I don't know what that math site was talking about, but when talking about normalizing vectors, one usually refers to normalizing their length. And a lenght, by definition, is positive.

So, typically, a normalized vector is a vector whose length = 1.

Having said that; there's no requirement that the length you're normalizing to should necessarily be 1; it can just as easily be some other number. But by far the most common meaning (ie. in 99.999% of all cases), is that the vector is a unit-length vector (length=1).

Hope that helps,

Cheers!

1 person likes this

Share this post


Link to post
Share on other sites

Thank you Mario and halion for your reply.

I don't know what that math site was talking about, but when talking about normalizing vectors, one usually refers to normalizing their length. And a lenght, by definition, is positive.

So, typically, a normalized vector is a vector whose length = 1.

Having said that; there's no requirement that the length you're normalizing to should necessarily be 1; it can just as easily be some other number. But by far the most common meaning (ie. in 99.999% of all cases), is that the vector is a unit-length vector (length=1).

Ahh ok I get it now. I was much confused before. The mistake I made was that I forgot about length. I was confusing length with direction. I'll restudy the material to make sure I got it right now. Thanks

I'll continue with learning houdini basics and then I'll keep my notes handy for chops and shader writing. The renderman book is very tough for me and since I'm a weakling in math I had trouble with all this matrix and vector lingo.

Thank you very much!

Share this post


Link to post
Share on other sites
On math website it says normalized vectors are in range -1 to 1 however in adv renderman book it says normalized vectors are in range 0 - 1. Which is correct?

If you go with the definition that a normalized vector is of length 1, then the resulting individual components of the component would range from -1 to +1.

I'm sure the adv. renderman book is correct too but they're probably referring to something more specific.

Share this post


Link to post
Share on other sites

I think in the Renderman book they are generalising for the sake of simplicity for artists. Mathematicly it's correct to say a normalized vector ranges from -1 to 1, but from an artists point of view, an artist takes it for granted that the normal is facing in the correct direction (positive from the surface, however the surface may be oriented) and it's magnitude is 0-1.

Share this post


Link to post
Share on other sites

OK. You guys are talking about the individual elements, and that's fine, I agree with all the things you're saying.

But I was thinking in terms of a vector as simply an algebraic quantity -- i.e it's not a function, and so there's no concept of a mapping from some domain to any range.

It is either normalized, in which case its Euclidean length (which is just a property of the vector) is 1, or it isn't normalized, in which case its length is other than 1 but still positive (by the definition of length operation).

IOW, a vector either belongs in the set of all normalized vectors, or it doesn't -- normalization doesn't result in a "range of possible vectors".

Would you agree? Or am I missing some subtlety here?

Share this post


Link to post
Share on other sites

Mario, that makes perfect sense, and I don't think anyone here is arguing a point with you; just adding observations. I suppose "range" is not the proper word to be using here.

As I remember that chapter on mathematics from Advanced Renderman, there's only a brief paragraph or two of explanation on normalized vectors and I seem to remember the explanation was entirely in relationship to a surface or tangent plane, which is why I said I thought they were generalizing for simplicity sake. I think it's easier to understand a normal vector in it's relationship to a surface within some sort of coordinate space, rather than an abstract algebraic quantity with no domain or range.

Share this post


Link to post
Share on other sites

Getting back to when I use vectors and matricies: I use it to get around deficiencies in Houdini and to deal with Transforms for wierd and wacky stuff as well as for shader programming.

One example in Houdini is extracting the transform of an inspect viewport. Very tough but doable. Another is custom manipulation of particle Transforms and the up-vectors separately.

Vectors are all over the place and are simple to deal with compared to transforms for the artist. Matricies are not that easy for artists as it requires a broader understanding that is hard to come by. :unsure:

The user should not have to resort to matrix math unless through an operator that does that for them but the support should be there for 99% of the work. Since no operators except VOPs support matricies directly, we have done a pretty good job so far.

In the textport, there are some expressions that can extract and crack transform matricies. vop SOP networks are great for hacking away at matricies.

As for the Advanced Renderman Guide saying normalized is 0 - 1 is not correct and I believe nowhere does it say that. Normalizing of input vectors is required ( unit length = 1 ) to get proper output out of a frontface() function which does return 0-1 values as it's whole purpose is to cull values below 0 (= backface of surface) based on the dot product of the eye direction L and surface normal N. I believe this is where the confusion lies. Mario's first description goes in to much more detail.

Share this post


Link to post
Share on other sites

Hello,

Thank you for replies. I apologize now because I make mistake when I say renderman book says range 0 - 1. Old School is right when he say this is not in there. I guess I was too confused that I thought I saw it in there. I have been reading many websites for clarification when I got confused in the books.

Now that I understand I made a mistake in my quothe. I'm a little bit more confused now. Maybe I give example. Let's say I have a vector that is:

(1.2, -4.2, 3.5)T

The dot product is: 31.33

The unit-vector is:

(1.2, -4.2, 3.5)T / sqrt(31.33)

= (0.2143, -0.7503, 0.6252)T

I hope I am correct in the above.

So in the final result, is each element also called a component? And each component can be a range of 0 - 1? Is this where my confusion lies?

I just want to make sure I'm understanding the terminology correctly.

I now see that this information will come in handy very much in shader writing and advanced transforms. Buy hey, I better learn it now than never :)

Thank you very much for your patience and assistance.

Perrry

Share this post


Link to post
Share on other sites

Hi Perry,

Sorry we all went off on a tangent there (we were actually all agreeing with each other, but hey! math is fun)... and thanks Jeff for bringing us back! :)

Let's say I have a vector that is:

(1.2, -4.2, 3.5)T

No need to transpose it; you can just leave it as a row vector. In the world of CG, vectors are usually given as row vectors -- and I believe all matrices in VEX are row-major (gotta double-check this, though).

The dot product is: 31.33

The unit-vector is:

(1.2, -4.2, 3.5)T / sqrt(31.33)

= (0.2143, -0.7503, 0.6252)T

I hope I am correct in the above.

You are correct. YAY! :D

And taking the dot product with itself is equivalent to computing the square of its length (but I think you already see this).

So in the final result, is each element also called a component? And each component can be a range of 0 - 1? Is this where my confusion lies?

Correct. No confusion that I can see :)

After the above procedure, the vector's length is 1, and so we say it is normalized.

And if one were to examine the possible range of the components (or elements) of a normalized vector, one would notice that their values could never be outside the range [-1,+1] (by construction).

Strictly speaking, you'd say that the domain of the elements of a normalized vector is [-1,1]

Well done! :)

Share this post


Link to post
Share on other sites

Thank you Mario!

I love it! I'm am finally understanding this! For me math is fun once I understand what is going on, otherwise I prefer to pull my teeth out with monkey wrench.

I was about to ask how do you actually get the value of 1 for the length of the normalized vector. However, before I asked this question, I computed length of the unit-vector just to be sure, which gave me:

The unit-vector is:
Vu= (0.2143, -0.7503, 0.6252)

Length of unit-vector:
|Vu|= sqrt(.999749)

So I guess this is as close to 1 as I'm going to get.

Also thanks for information about not having to transpose row vectors:)

Your posts are very detailed and helpful. I really appreciate the time you guys give to me. This stuff is starting to get very cool for me.

Perry

Share this post


Link to post
Share on other sites

hmmmm.....

All this makes me think it's time to get working on the "vectors" section of the Wiki....

That way "WritingShaders" could sport four unfinished sections!! :lol:

Time is our enemy :ph34r:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now