# Snell's law of refraction, and Wolff BRDF

1. Dec 15, 2008

### luisbf

Hi
I wasn't sure of where to post, since well, i'm an adult, and math/physics weren't a big part of my curriculum, and yet, years later, i thought that continuing to have severe holes in my understanding of math and physics wasn't beneficial, even if i didn't had any direct applications to aqquiring this new knowledge, so, if i'm sorry if i'll be asking stupid things, but i wasn't sure where to post, and i have no one to talk about such things.

My problem is as follows (this is problably basic, but here goes), i'm trying to write a shader for this BRDF (found that seeing things makes understanding easier), the Wolff BRDF, which is basically a Lambertian diffuse, the cosine of the angle between incident (light) vector, and surface normal, but, multiplied by 2 Fresnel terms, one accounting for the amount of reflected light (from the incident light vector), and another second term, that accounts for the scattered light at the surface, and which uses the viewer vector instead.

This paper uses for the first term, the cosine of the angle between the incident (light) vector, and the surface normal, and the absolute IOR of the interior medium, let's say 1.5.
So far so good, let's say, in RSL (shading language similar to C, for RenderMan renderers, such as the GPLv2 http://www.renderpixie.com/" [Broken]):
float foo = fresnel( cos(theta) , IOR)
What's puzzling me is how they do the 2nd Fresnel term. They mention they mention the following formula
Code (Text):
float foo = fresnel( 1 / ( sin(theta)/IOR), 1/IOR );
i don't understand this, i mean, i spent some time reading Fresnel equations and Snell's Law of reflection and refraction, and please correct me if i'm wrong, but, according to Snell's law, the ratio of the sine of the incident angle, and of the refracted angle, is equal to the ratio of the IOR of the interior and exterior medium, so

$$\eta_{1} * sin(\theta_{1}) = \eta_{2} * sin(\theta_{2})$$

so, to get the sine of theta2:

$$sin(\theta_{2}) = \eta_{1} * sin(\theta_{1}) / \eta_{2} = (\eta_{1} / \eta_{2}) * sin(\theta_{1})$$

but since i have the cosine of theta1, using trigonometric identities then

$$sin(\theta_{2}) = (\eta_{1}/\eta_{2}) * \sqrt{ 1 - cos(\theta_{1})^2}$$

and since i wanted the cosine of the transmitted angle to begin with, then

$$cos(\theta_{2}) = \sqrt{ 1 - ( (\eta_{1}/\eta_{2}) * \sqrt{ 1 - cos(\theta_{1})^2}^2} } = \sqrt{ 1 - (\eta_{1}/\eta_{2})^2 * \sqrt{ 1 - cos(\theta_{1})^2}^2}$$

the square root and the squaring cancel each other leaving

$$cos(\theta_{2}) = \sqrt{ 1 - (\eta_{1}/\eta_{2})^2 * (1 - cos(\theta_{1})^2)}$$

Does this seems correct?
I still don't understand the reasoning for the fresnel( $$1/ (sin(\theta_{1})/IOR), 1/IOR)$$ though
This model can be seen in the following paper:
http://www.bmva.org/bmvc/2004/papers/paper_185.pdf" [Broken]

Sorry if this wasn't the right place to post such questions, perhaps there should be a section for math&physics impaired adults to fix the holes in their knowledge without fear of the ridicule?

Thank you in advance for your time.

P.S.: just reallized that
$$sin^{-1}( (\eta_{1}/\eta_{2}) * sin(\theta_{1})) = asin( (\eta_{1}/\eta_{2}) * sin(\theta_{1}) )$$
The raise to -1 power was confusing me, according to wikipedia

Still, if anyone can correct my reasoning, i would apretiate it a lot (already ordered 2 books on algebra, calculus, and 1 on optics, to avoid making a fool of myself, at least often...).

Last edited by a moderator: May 3, 2017
2. Dec 15, 2008

### Redbelly98

Staff Emeritus
Welcome to PF

Yes.

According to that paper, the reason is that a light ray can be transmitted into the object some distance before being reflected. This will modify the Lambertian cosine distribution of reflected intensity, which holds when rays are reflected at the surface. The Fresnel term accounts for the modification of the cosine distribution.

For more details, have you looked at Ref. 9 of that paper:
L.B. Wolff "Diffuse Reflectance Model for Smooth Dielectric Surfaces", J. Optical Society of America A, vol. 11, no. 11, 1994, pp. 2956-2968.

Well, you seem to understand quite a bit! But to answer your question, yes, there are non-homework areas at PF for questions like this:

For physics questions, choose one of the Physics subforums
https://www.physicsforums.com/forumdisplay.php?f=9 [Broken]

There is also a Programming subforum, if you run into questions about programming code
https://www.physicsforums.com/forumdisplay.php?f=165

Last edited by a moderator: May 3, 2017
3. Dec 15, 2008

### luisbf

Hi

Thank you very much for your time, that second term was puzzling me - i'm a painter and didn't had much math&physics at school, unfortunately - i blame myself for drawing a lot in the math classes i confess, but if only my teachers had bothered telling me there were practical applications for all that, and had shown me some pictures, of fractals for instance... So, the few i know so far, has been of reading "math for idiots" books in the last 8-10 monthes, and being stubborn as a mule, so my math is full of holes, for the time being.
Back to the topic though, i was re-reading the wikipedia entry, some things aren't very clear, but, what was confusing me in that 2nd Fresnel term, was the $$\theta_{2}=sin^{-1}((\eta_{1}/\eta_{2})*sin(\theta_{1}))$$
until i realized it was the same thing - since i wanted the cosine of theta2, and using trigonometric identities i was going to end up reaching the same equation:
$$cos(\theta_{2})=cos(asin( (\eta_{1}/\eta_{2})*sin(\theta_{1})))$$
which is
$$cos(\theta_{2})=\sqrt{1-((\eta_{1}/\eta_{2})*sin(\theta_{1}))^2}$$
which lead me to the equations in the first post.
I thought that $$sin^{-1}(\theta_{1})$$ was raising $$\theta_{1}$$ to the -1 power, when it's the inverse function, the arcsine (which means back to the "math for idiots" book, and reading about mutliplicative versus compositional inverses)

About that paper, unfortunately i don't have a subscription to Optical Society of America, i think that paper is for subscribers only, and the only 2 papers i found that mentioned the Wolff model were the "Fresnel Correction of the Beckmann Model", by Hossein Ragheb, and Edwin R. Hancock, and "Improved Diffuse Reflection Models for Computer Vision", by Lawrence B. Wolff, Shree K. Nayar, and Michael Oren, so i had to rely on these 2, but thanks for the suggestion, i'm going to try and see if there's a public copy at http://citeseerx.ist.psu.edu/".
About the code, it's just a way to keep myself busy, seeing math in action sort of helps understanding it, and i found RenderMan Shading Language to be quite accessible. I'll clean the code, and post it in the programming section, just in case anyone is interested.

Once again, many thanks for taking your time to reply.

Best regards

Luis Fernandes

Last edited by a moderator: Apr 24, 2017
4. Dec 15, 2008

### Redbelly98

Staff Emeritus
You're welcome, and good luck!

Mark

p.s. to see that referenced paper, I recommend going to the library of a local university's physics department, and see if they have it. I'd estimate that a subscription would cost roughly \$150 per year, since you'd need to be a member of OSA in order to subscribe. But I'll also warn you, the math is likely to be very detailed, and also using references to more papers that you may be compelled to look up, and those papers would reference others, etc. etc.

5. Dec 16, 2008

### luisbf

Hi Mark

Thanks for the suggestion, going to try and check that book/article, i was curious for some time now about Wolff's model, in detail, and the papers i found only refered to it in an somewhat superficial way.
I'll post the renderman shader code as soon as i have it cleaned up, together with some images, and gnuplot graphs, comparing it with the Lambertian diffuse model, in case someone wants to "play" with such things.
Thanks once again.

Best regards

Luis Fernandes