So I'm working on creating refracting glass spheres for a ray tracer I am building and am attempting to implement Schlick's approximation for Fresnel refraction as per the suggestion of another user on this site in order to make my glass look more realistic. However after implementing it, my glass still looks quite lackluster. There is barely any difference in appearance except for there is some mirror reflection as well but it looks sort of as if I combined a mirror sphere with a refracting sphere artificially. I wish stack overflow had an easy way to upload pictures so I could show you what I mean.
I have posted my code below to show you the part where I implement Schlick's approximation. After I calculate the approximation I make two recursive calls to raytrace the scene: one for a reflected ray and one for a refracted ray.
if (hit->mat->IsRefractive())
{
temp.Refract(hit, total2);
total2++;
float Ro = powf(((1.8-1.0)/(1.8+1.0)),2.0f); //Refractive index is 1.8
STVector3 V = myray.GetD()/myray.GetD().Length(); //Normalized view vector
STVector3 L = AllLights[0]->GetDirection(hit->point); // Light vector
L = L/L.Length(); //Normalize light vector
STVector3 H = (V+L);
H = H/H.Length();
float costheta = STVector3::Dot(H, V);
float F = Ro + (1.0f - Ro)*powf((1.0f-costheta), 5);
STColor3f Krf = STColor3f(F, F, F);
STColor3f Kr2 = STColor3f(1.0-F, 1.0-F, 1.0-F);
Ray temp2(myray.GetE(), myray.GetEnd());
temp2.Reflect(hit);
result += Krf*RayTrace(temp2, total, total2);
result += Kr2*RayTrace(temp, total, total2);
}
This is the problem: float costheta = STVector3::Dot(H, V); To find the amount of light that re-emerges from glass using Schlick's approximation you need to use the angle of refraction not angle of incidence. When light enters glass use the angle of incidence.