vec3f findRefracted(vec3f L, vec3f N, float n1, float n2)
{
//
//
vec3f R (0.f, 0.f, 0.f);
float LdN = L.dot(N);
float cos2 = 1 - (1 - pow(LdN,2))*pow((n1/n2),2);
cos2 = sqrt(cos2);
R = - (n1/n2) * (L - LdN * N) + cos2 * -N;
// what I had before....R = - N * LdN + (N * (-LdN) - L) * (n1/n2);
return R;
}
In VizShader :
vec3f unitvec = refractVec.dot(viewDir) ;
In the center, the refracted ray is going straight through ( same direction as the view dir) and the dot product between two parallel rays is 0 - so we get black. The differences are symmetric going out from the center.
Dec 13 2011
Breaking it Down - Visualizing the Components:
Tasks- Visualize the following:
- View direction
- Reflection direction
- Normals
- Refraction directions
- hit 1
- hit 2
- Time between hits (distance)
Notes on Expectations :
- View viz outer rim will match Reflection viz outer rim
- (Grazing angle of reflection will match View almost identically)
- Reflection will look like Normal directions compressed and shifted toward viewer
- Refraction will be similar to View direction colors
- When indices of refraction are equal, refraction directions and view directions will match.
- Distance between hits will be greatest in center and diminish toward outer rim.
Ready, set, GO!
View Direction (Pointing away from Sphere)
Reflection Direction (View Pointing Away)
Normals
Refraction Directions:
Enter/Exit
Hmmmm.... Shouldn't it be a symmetrical gradient outward?
Good References:
http://www.flipcode.com/archives/reflection_transmission.pdf
http://hyperphysics.phy-astr.gsu.edu/hbase/phyopt/freseq.html
No comments:
Post a Comment