Jump to content

How To Shade In Vops Based On Normal Direction?


Recommended Posts

Thanks Stu!

That's a great step in the right direction for me. However, I can see the "quickness and dirtiness" of the fix, as if I have multiple objects with varying y positions, the lower ones are completely covered with moss, and the higher ones have no moss.

What I'd now like to know is how to base the bias on each object (maybe using bounding box), not on the global y position.

I appreciate everyone's help on this forum, as I'm at the stage where I relatively understand how to think in the "houdini" way, but I have to do research to figure out how to use each node to meet the result. So thanks again and I hope to contribute more as I learn more.

Link to comment
Share on other sites

Now I have another question, how could I shade something based on the angle of the faces? For example, If I have a polygonal mesh with smooth areas where the angles of connected faces are low value, and curved areas where the angle of connected faces is higher.

Is there a way to have different shaders for those areas procedurally (and of course blend between the shaders)

Thanks in advance.

Link to comment
Share on other sites

Hello,

Yes, I looked dot product up on the internet, however it all seems like a very abstract explanation of the concept, and I don't understand what it does for the normalized vectors in order to get the result we end up with. I know now what nodes to use to get the needed result though.

Link to comment
Share on other sites

Now I have another question, how could I shade something based on the angle of the faces?  For example, If I have a polygonal mesh with smooth areas where the angles of connected faces are low value, and curved areas where the angle of connected faces is higher.

Is there a way to have different shaders for those areas procedurally (and of course blend between the shaders)

Thanks in advance.

24882[/snapback]

I attach an example, the only drawback of this method is that measure SOP does not differentiate if the polys bend in the direction of the normal or the opposite, so you have the same color when it is a hill or a groove :)

I'm sure somebody has a nice solution for this also.

measure2cd_example.hipnc

Link to comment
Share on other sites

Occlusion sop

This will create an attribute in the grooves and valleys, you can then use that to drive your shader.

The dot product as a concept is very simple it is a measure of the angle between two vectors. -1 means they are completey in opposite directions, 1 means they are facing the same way and 0 means they are at 90 degrees to each other. When you are looking at a sphere the points on the edges will have a value of 0 and the point right in the middle will be 1. Therefore the dot product can be used as a measure of curvature. Very useful for shading things. :)

Link to comment
Share on other sites

Hello,

Yes, I looked dot product up on the internet, however it all seems like a very abstract explanation of the concept, and I don't understand what it does for the normalized vectors in order to get the result we end up with.  I know now what nodes to use to get the needed result though.

24888[/snapback]

I had to explain the dot product to my son's grade 4 class... Not an easy task since they didn't get vector math at all... and as you say the dot product is a bit abstract.

However, here goes. If you have two normalized (unit length) vectors, the dot product is a representation of the angle between the two vectors. If they are colinear (pointed the same direction), the dot product will be 1, if they are opposed, the dot product would be -1, if they are orthagonal (perpendicular), the dot product would be 0. This actually maps to the cosine() of the angle between the two vectors. If you look at a cosine curve, you'll see that when the angle is 0, cos(0) = 1, cos(180) = -1 and cos(90) = 0.

If, on the other hand, you have one vector which isn't normalized (say A), and one vector which is normalized (call it B), you can tell how far A goes in the direction of B by taking the dot product. This falls out of simple trigonometry, but was very difficult to explain to a bunch of 9 year olds.

P.S. only one out of 25 kids actually got it -- I was quite depressed.

Link to comment
Share on other sites

One of an excellent book that I've ran into about 6 months ago happen to be a book called ABOUT VECTORS. Though I think having some basic concept of vector math would help, but the book explains quite well things in regard to vectors. IMHO, it explained the whole fundamental concepts of vectors quite well. I defintiely recommend this book.

Link to comment
Share on other sites

Thanks everyone for your explanations... What would be Really helpful is explaining it in terms of concrete shading examples, like

(this is how the normal information is currently, by using the dot product to connect the normalized vector it gives us "this" shading result, otherwise it will look messed up in "that" way because the vectors need to be compared in such and such way for the rendering engine)

Just something that I can mentally reference with to put some substance to the abstract concept

Link to comment
Share on other sites

Here's a stab at some useage explanations of the dot product. It's nice to know the math but unapplied it is, well not very functional.

First I think of the dot product as folding two vectors ontop of each other and seeing how much the one vector "shadows" the other. As you rotate one vector on top of the other, the shadow line recends and forms the half curve of a cosine curve. The cosine curve is god in shading as it is used to compute simple lighting responses on surfaces. So the dot product can be used to fake some illumination, used to calcualte light falloffs and responses to surfaces and much much more.

You have to get the dot product if you want to write meaningful shaders.

Direction:

The dot product is a great way to see if two vectors are pointing in the same direction. For this to work, you should normalize both vectors such that their length equals 1. The dot product of the two vectors will either be a positive value and they point in the same direction or a negative value and point in opposite directions.

This is used to determine if a face is facing toward say a light or camera or away. The dot product is the big part of the frontface() function.

Magnitude:

The dot product can be used on non-normalized raw vectors to see the difference between two vectors.

Square a vector

To square a vector and return a float of the final length, just run the dot product on the same vector: dot(N,N) will return a float that is the square of the length of the incoming Normal.

I am sure there are many other uses that I have incorporated. It is just such a handy tool to have.

Link to comment
Share on other sites

I had to explain the dot product to my son's grade 4 class...  Not an easy task since they didn't get vector math at all...  and as you say the dot product is a bit abstract.

24894[/snapback]

Are 4th graders even introduced to the concept of angle yet? Explaining the dot product to kids doesn't very useful to me as they need to know a lot more concepts to properly appreciate it. I like the approach that rational trigonometry takes. Just take two lines (not vectors because they're more complicated) and give it a measure of how "spread" apart they are: 0 for when they're least spread apart (ie. parallel), 1 when they're most spread apart (ie. perpendicular). So if we're talking about unit-length vectors and their dot product, it's just a measure of how spread apart the vectors are plus some information about whether they're facing in the same direction.

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...