Jump to content

vex shading


exarhos2003

Recommended Posts

The dot product of (1,0,0) and (1,1,0) is (1*1 + 0*1 + 0*0) = 1. The dot product is a simple operator. The math I posted not too long ago in the vex forum even.

The dot product of the *normalized* vectors between said vectors is 0.707... That's because if you normalize them, you get (1,0,0) and (0.707...,0.707...,0) which will result in 0.707....

Looking at your picture, it looks like your lighting model is probably modifying the 0.707... value. Try connecting the output of the floattovec1 vop into Cf directly.

Link to comment
Share on other sites

i dont know whats going on, the reason i normailzed it is because later i need to extract the angle it produces.

ill post the file later,

does anyone know if the value the dot produces is in rad or degrees? the acos VOP has rad for input..

Edward already answerd all your questions, but maybe a little more explanation will help....

1) Yes; you *do* need to normalize the two vectors that you feed to the dot product VOP -- or rather, you need to normalize if and only if what you're interested in getting as a result is the cosine of the angle between the two -- which is the case here B)

This is because the dot product between two vectors A and B is actually defined as:

dot( A, B ) = length(A) * length(B ) * cos(theta) {where theta is the angle between A and B }

So if A and B are normalized, then their lengths are 1, and the above turns into:

dot( A, B ) = 1 * 1 * cos(theta) = cos(theta)

2) The cosine of an angle is neither in degrees nor radians -- it is simply a ratio, and describes a geometric relationship. Just think of it as a "quantity", a "scalar", anything but *not* an angle.

3) To get the actual angle from the cosine-of-the-angle, you need run it through the inverse operation, which, for cosine, is called arc cosine (and often written as cos^-1). In Vex, you'd use the function acos(). And in VOPs, you'd use the Trigonometric Functions VOP, and select Arc Cosine as the function.

All trigonometric functions in VEX that either take, or return, or otherwise manipulate angles in any way, express said angles in RADIANS. This is true in most (all?) trig libraries -- Houdini's expression language is an exception, where the user is likely expecting everything to work in degrees and so would be more intuitive to express things that way; but this is definitely not the rule.

And just to preempt some possible headaches, note that the inverse of the cosine function is *not* 1 / cos() , but a completely different function -> acos() !! :huh:

4) As Edward mentioned, If you want to see (as in "visualize") the result of all this, then you'd feed it directly to Cf, and not to the "Diffuse Color" of the lighting vop. The reason is that the lighting vop will then weigh your input by the diffuse reflectance (BRDF) function (something like dot(L,N) if set to Lambert diffuse), which is likely not what you want at all.

However! (:) ) ... given that the cosine of an angle (or the angle itself if using acos(angle) ) can be either positive or negative, you might want to take the absolute value before passing it to Cf.

Cheers! :ph34r:

Link to comment
Share on other sites

2) The cosine of an angle is neither in degrees nor radians -- it is simply a ratio, and describes a geometric relationship. Just think of it as a "quantity", a "scalar", anything but *not* an angle.

To be even more complete yet cryptic: SOHCAHTOA

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