Ingvard Posted June 5, 2014 Share Posted June 5, 2014 (edited) 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! Edited June 5, 2014 by Ingvard Quote Link to comment Share on other sites More sharing options...
Guest tar Posted June 5, 2014 Share Posted June 5, 2014 can you post up your scene - those screenshots almost look the same. Quote Link to comment Share on other sites More sharing options...
Ingvard Posted June 5, 2014 Author Share Posted June 5, 2014 Yes, sure! I've attached. Thanks! refraction.hipnc Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted June 10, 2014 Share Posted June 10, 2014 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: 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: 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 1 Quote Link to comment Share on other sites More sharing options...
Ingvard Posted June 11, 2014 Author Share Posted June 11, 2014 Mario! Thank you so much for the explanation. 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.