Jump to content

Question about "I" variable


kursad

Recommended Posts

Hi

I have started working on a shader. I can normally get what I want by creating a vector by substracting position "P" from position "eye". I also wanted to use the "I" variable described as "direction from eye to surface". But when I use it as part of a dot product I am not getting anything close to what I think I should be expecting. As you can see from the picture the upper example is wrong, and the bottom one is right.

post-5686-127473120929_thumb.jpg

I thought that the "I" variable was same as Renderman`s "I" variable

thanks

Edited by kursad
Link to comment
Share on other sites

Just to complete the thread, I is indeed the vector from the camera to the current shade point. The wrong direction to compute the dot product with the surface normal. You need to negate the I vector so that it is a new vector going from the shade point to the Eye.

Finally you need to normalize both the negated I and the surface normal or your dot product won't return a sensible value (unless that is what you want). The I vector holds the distance from the Camera to the current shade point as it's magnitude.

Link to comment
Share on other sites

Just to complete the thread, I is indeed the vector from the camera to the current shade point. The wrong direction to compute the dot product with the surface normal. You need to negate the I vector so that it is a new vector going from the shade point to the Eye.

Finally you need to normalize both the negated I and the surface normal or your dot product won't return a sensible value (unless that is what you want). The I vector holds the distance from the Camera to the current shade point as it's magnitude.

old school, thanks for the tip, I did not know about the length aspect of that vector

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