Jump to content

fresnel vs refract


Ingvard

Recommended Posts

Hello guys!

 

Sorry for double posting. Maybe somebody here will tell me what is the difference between vector of refraction which is produced by fresnel vex function and refract vex function?

 

Thanks!

post-4815-0-22555100-1401967587_thumb.jp

Edited by Ingvard
Link to comment
Share on other sites

The only difference between the two is the way in which they deal with total internal reflection (TIR).

If you look at their output for the cases where the transmission is valid (kt>0), you'll see that they're identical:

post-148-0-76460500-1402415388_thumb.jpg

When writing this kind of function, there's always the question of what to do with the transmission vector (T) when there is no valid transmission (which happens under TIR since you end up with a div-by-zero or root-of-a-negative and T is undefined). You could return a zero vector (possibly dangerous), or assume the user will always inspect kt and deal with the issue (not very reliable), or pick something arbitrary that's "incorrect" but not zero. Both fuctions choose the last approach, but they make different choices (a matter of legacy behaviour I think). Under TIR, fresnel() returns T=I (direct transmission), and refract() returns T=R (mirror reflection) -- and that's why you see a difference (notice that the difference is only happening in the black portions of the image above; i.e: under TIR).

 

Knowing this, you can modify refract() to match fresnel() (or vise-versa) by inspecting kt:

post-148-0-29999900-1402416335_thumb.jpg

 

Though of course, the moral of the story is not so much "here's how you make them match", but rather "here's where you have no business refracting at all" :)

I've added a few parms to your shader so you can explore all of the combinations I mentioned above.

HTH.

 

mgm_refraction.hipnc

  • Like 1
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...