-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the limit for interpolation of R0 with respect to metallic and the calculation of the cos theata in the Fresnel Shlick term in SSR #75368
Conversation
The rationale for |
4021bf0
to
31a7754
Compare
FYI: The refractive index of Germanium listed there is for infrared. For visible light diamond with 2.4 would be the limit. |
@MightiestGoat Before and after? |
@jcostello wdym? |
@MightiestGoat how it looks before and after the fix |
I tried using proper f0 and f90 like in frostbite paper as well, as it stood out to me on first glance. However as could be expected it makes no difference for dielectrics, and only makes a difference on metals. The problem on #75302 mentions non-metals only. I checked your changes (with 0.37 instead of 1.0) and as expected only changes the behavior for metals. |
@armmah I started working on the non-metal part as soon as jcostello demanded before and after the fix picture. |
d411a34
to
f2a1b61
Compare
Oh nice catch on the reflect vector. All of the experiments I've done I have been using either It ends up solving the problem in a proper physically accurate and consistent way. P.S. on the tall cube the visual was similar, but your ray dir looks much nicer on some other scenarios I have set up in the material tests demo project. |
@armmah Thank you |
Do you think it's possible to have only one commit? |
f2a1b61
to
c8a0e7a
Compare
There are two things going on in this PR. The change of R0 is one thing, it only changes the behaviour for metals and does not help #75302. Essentially it adds in some schlick reflectance for metallic metals. The second change is using Nearly parallel, reflection is fading away as it should Midpoint, reflection is still strong Glancing angle, reflections should be at their strongest, but they are faded out |
Taking a look it seems like removing the reversal of the normal makes it work. I.e. the correct code is :
|
@clayjohn Thank that makes sense but why not use view_dir instead of -view_dir? |
|
Yes, I understood that we are calculating the cos theta of the two vector vectors. view_dir is a little confusing as to know which side the view_dir pointing to. Thank you for clearing it out. |
c8a0e7a
to
082ab24
Compare
0968a81
to
a6bf56e
Compare
a6bf56e
to
2c000cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. In the long term we should probably just write out f0 from the main pass instead of metallic. Then we can take specular color into account (even if its just grayscale)
Thanks! |
Cherry-picked for 4.0.3. |
The default of Ro is assumed to be around 1.5 after applying the formula which is ((u -1)/(u +1))^2 => ((1.5 -1)/(1.5+1))^2=>0.04. The element with the highest refractive index found in nature is considered to be Germanium. It has a range of refractive index from 4.05 to 4.1. After applying the formula to the maximum of the range ((4.1 - 1)/(4.1 +1))^2=>(Approx)0.37. So, the rational limit should be this.
Fix #75302