shikung444 Posted February 20, 2006 Share Posted February 20, 2006 I am making a rock shader in vops and I'd like to apply moss to the underside of the rocks. How can I bring in the normal direction (facing negative Y for instance) to use as a bias for the moss shader? Thanks for any feedback. Quote Link to comment Share on other sites More sharing options...
stu Posted February 20, 2006 Share Posted February 20, 2006 Here's one quick and dirty way: moss.zip Quote Link to comment Share on other sites More sharing options...
shikung444 Posted February 20, 2006 Author Share Posted February 20, 2006 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. Quote Link to comment Share on other sites More sharing options...
shikung444 Posted February 20, 2006 Author Share Posted February 20, 2006 I just figured out a solution, add a space change vop right after the global parameter P to convert from world to object space. Quote Link to comment Share on other sites More sharing options...
SvenP Posted February 20, 2006 Share Posted February 20, 2006 Heres one based on normal direction Moss.hip Sven Quote Link to comment Share on other sites More sharing options...
shikung444 Posted February 20, 2006 Author Share Posted February 20, 2006 Awesome! Thanks Sven! I'm going to learn quite a bit from this tonight. Quote Link to comment Share on other sites More sharing options...
shikung444 Posted February 20, 2006 Author Share Posted February 20, 2006 just out of curiousity, I'm not sure what the "dot product" node in sven's example does. All the rest of them I am familiar with. So if anyone has any insight on this, that will be helpful for the future. Quote Link to comment Share on other sites More sharing options...
shikung444 Posted February 20, 2006 Author Share Posted February 20, 2006 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. Quote Link to comment Share on other sites More sharing options...
SvenP Posted February 20, 2006 Share Posted February 20, 2006 http://mathworld.wolfram.com/DotProduct.html Quote Link to comment Share on other sites More sharing options...
shikung444 Posted February 20, 2006 Author Share Posted February 20, 2006 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. Quote Link to comment Share on other sites More sharing options...
peliosis Posted February 20, 2006 Share Posted February 20, 2006 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 Quote Link to comment Share on other sites More sharing options...
sibarrick Posted February 20, 2006 Share Posted February 20, 2006 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. Quote Link to comment Share on other sites More sharing options...
crunch Posted February 20, 2006 Share Posted February 20, 2006 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 , 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. Quote Link to comment Share on other sites More sharing options...
Jason Posted February 21, 2006 Share Posted February 21, 2006 P.S. only one out of 25 kids actually got it -- I was quite depressed. 24894[/snapback] ..was it you? Quote Link to comment Share on other sites More sharing options...
TheUsualAlex Posted February 21, 2006 Share Posted February 21, 2006 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. Quote Link to comment Share on other sites More sharing options...
shikung444 Posted February 21, 2006 Author Share Posted February 21, 2006 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 Quote Link to comment Share on other sites More sharing options...
old school Posted February 21, 2006 Share Posted February 21, 2006 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. Quote Link to comment Share on other sites More sharing options...
edward Posted February 24, 2006 Share Posted February 24, 2006 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.