Skip to main content
GameDev.net gamedev.net
🔒 Locked

diffuse + Fresnel term

Started by quasty Dec 9, 2006 at 7:31 AM 19 replies 13.8k views
Original Post
quasty
quasty
Hi, I'm a bit confused about the Fresnel term and how it is used. Can someone describe in its own word what purpose does the Fresnel term fit? I've seened it used in some sort of rim lighting / backscattering effect. Or almost every water is realized with some sort of Fresnel component. I've been seen many different aspects but they don't really correlate. Is there a correct way to add a "fresnel term" to a diffuse material when I have a certian refraction index? thank you
Shai
Shai
diffuse material with a refraction index? Are you sure you don't mean a specular material?

Anyway, the Fresnel term

When you stand really close to a glass window, you do not only see what's behind the window, but you can also see your reflection in the glass. Now if you think about it that does not make sense... glass is supposed to let light go through it, yet you can see your reflection, so that means the glass must have also reflected some light.

That's what the Fresnel term says.

If you shoot several rays of light to a refractive (transparent) object, then some of the rays will be reflected and others will be refracted. The Fresnel term calculates the ratio between reflected and refracted rays (or was it the other way around?) in function of the angle between the incident ray and the normal of the point where the ray hits the transparent object.

If you want realistic water you're gonna need the Fresnel term. Depending on your viewing angle water can either act as a mirror, a transparent object or something in between.
"It's better to regret something you've done than to regret something you haven't done."
cignox1
cignox1
Quote:
Original post by Shai

If you want realistic water you're gonna need the Fresnel term. Depending on your viewing angle water can either act as a mirror, a transparent object or something in between.


That's why when your're at the border of a lake, the water right under yourself looks fully (or nearly :-) transparent but the water far from you only reflects the sky... in a virtual enviroment this makes quite a big difference...
quasty
quasty
Thank you. Actually I'm not trying to render water but human skin. And read something that confused me. With a refraction index of human skin should the fresnel term be somehow used how the light scatters under the skin (or how much on what angle?).

A refraction index of 1.4 is used for the skin. By since skin is more or less diffuse I'm wondering how Fresnel can be used with a diffuse semi transparent material like skin?

thanks :)
Shai
Shai
emm... you want to look into 'subsurface scattering'. Jensen (the guy who discovered photon mapping) has quite a bit to say about it.
"It's better to regret something you've done than to regret something you haven't done."
quasty
quasty
Thanks, although I believe the Jensen stuff might be a bit hardcore, isn't it - especially in realtime? I read about using the fresnel term somehow for skin. But not sure how this could work.
Shai
Shai
well

1) a light ray hits the skin
2) part of it is reflected in a direction dependent on the BRDF of the skin
3) another part actually enters the skin at the intersection point (let's call it point A) of the ray and the skin
4) the skin will then partially absorb this ray
5) the ray will then leave the skin at a point B (which is probably different from point A)

You can use the BSSRDF to calculate the direction of the ray leaving the skin. I'm not sure whether you can actually calculate the location of point B though.


Anyway, a Google search on 'real-time subsurface scattering' will list several papers on GPU algorithms that allow real-time subsurface scattering.

That's all I know.
"It's better to regret something you've done than to regret something you haven't done."
playmesumch00ns
playmesumch00ns
Jensen's dipole approximation bssrdf calculates the total radiosity due to subsurface scattering at the point, x, you are shading (i.e. the total amount of light that's leaving the skin in ALL directions having entered the surface somewhere else).

A certain proportion of the light hitting the surface of the skin is directly reflected in a glossy specular fashion. The easiest way to model this is to use a brdf like cook-torrance with the beckmann distribution function which contains a fresnel term already. Whatever light isn't reflected at the surface is transmitted inside the the skin and will exit somewhere else. You should really scale the light entering the scale by the inverse of the integral of the brdf over the hemisphere at the entry point, but for most purposes you can safely ignore this.
playmesumch00ns
playmesumch00ns
Many other types of (more simple) surfaces need a frensel term. We commonly have to model painted or substrate surfaces (e.g. plastic), which are essentially a diffuse layer underneath a specular layer.

In these cases you calculate the reflectance due to the diffuse layer, and the reflectance due to the specular layer, then you mix from diffuse to specular based on the fresnel reflectance function at that point.
quasty
quasty
Thank you very much, this is very interesting and I've done some reading about it (but still many questions). I've read the Fresnel term by Schlick might be what I'm looking for - but I couldn't get information about it - some older Eurographics papers which isn't available for free. But sample a dynamic way to blend been the parts specular and the diffuse reflected parts - although only very little is reflected specular on human faces - seems like a good idea.

About further SSS I've read in this paper about something I'm more or less already doing:

http://www.idiom.com/~zilla/Work/Notes/fastsubsurface_web.pdf

Render the illumination to a dynamic light map and filter the results based on a scattering factor. I'm using a Gaussian blur for that, but the SSS simulation could be better. In the above paper they come to the same conclusion and a "rapid_falloff" filter is used to simulate the light transport. There are few notes about it, but I've been unable to figure out how this works actually. It is in some way related to a "Green function" and with two components called "spike + board area"

"Spike keeps the result from looking blurred", and "the broad area does the scattering". And the filter kernel is scaled or indexed by something like 1/(c+radius)^power

Does anyone has an idea on how such a filter can be realized or has more information about it? The way it is presented it seems exactly what I'm looking for, but couldn't find any further information about this "rapid_falloff" filter.

thank you very much!
quasty
quasty
Hi,

I wasn't able to find a solution to implement a Schlick-like Fresnel approximation (or another that would be suited) yet - to determine how much light from this view-angle is already reflected in specular terms from the surface, and how much light remains which enters my SSS terms.

When I was looking at my arm, I realized I see a lot more specular reflections when looking from a very plain/flat angle than from directly above (with the light source positioned at the reflection vector). I was looking for something like an algorithmic approximation for that.

Any ideas or resources for that?

thank you very much
playmesumch00ns
playmesumch00ns
That's what the fresnel term gives you. The schlick approximation is widely avaiable on the web. Check out pages 18 and 20 of this pdf: http://www.cs.lth.se/DAT135/lectures/L5.pdf

The way to use the reflection coefficient is as follows:

1. calculate Ldiffuse - your diffuse/sss result
2. calculate Lspec - your specular result
3. linearly blend from Ldiffuse to Lspec to obtain final colour of surface
jollyjeffers
jollyjeffers
I've been writing about specular reflection and the fresnel term for my book recently [smile]

FWIW, I found A Reflectance Model for Computer Graphics by Cook and Torrance to be very useful. It doesn't cover SSS but it does have a very understandable overview of why the fresnel term is important when it comes to modelling light interactions with materials.

hth
Jack
<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ |
quasty
quasty
Thank you both. :)

I've began reading on the Cook and Torrance paper (but still having some troubles with it) and just finished the L5.pdf which was already very useful.

One thing is still not clear to me. Is Fresnel always both: the evaluation of the amount of light reflected of the surface (and furthermore the one entering the material) and the way the ray is refracted? From my current perception these are two separate things, aren't they?

There was the Fresnel formula by Schlick
F = R_0 + (1 - R_0 )*(1 - v*n)^5

What puzzles me: R_0 is not the refraction index, isn't it? Or this seems to be missing then? The more complex formula two slides earlier has it in it:

F = 1/2 * (g-c)^2/(g+c)^2 * ( ... )
g = sqrt(n^2 +c^2 -1)
c = v . h

I guess n is the refraction index and h the half vector as indroduced by Blinn?

I'm asking this because mainly I want to know how much light is reflected in specular terms at the material "skin" at a certain point under a certain angle.

But second I do use multiple texture layers and some parallax vector entering the skin and calculates offset coordinates for a sub-surface-texture. It would be nice if this could be done with a correct refracted ray.

I'm still missing something here. Any insights on how to use these terms correctly? Thank you very much!
quasty
quasty
I've found the solution to calculate R0 ( ((1-n)/(1+n))^2 ) but I'm wondering what is correct, cause the way to calculate Schlicks Fresnel approximation is describes in an nvidia tech report as
F = R0 + (1-R0)( 1 - N.L)^5
but in the above paper (L5.pdf) it is quoted as
F = R0 + (1-R0)( 1 - N.V)^5

Does anyone know for sure which is correct? thanks
playmesumch00ns
playmesumch00ns
It depends what you're trying to do... if you're using the beckmann distribution function for the cook-torrance brdf then the fresnel term is already encoded in there for the N.L part. So just blend your specular layer over the diffuse layer using the N.V equation.

Don't worry about refracted rays etc. The fresnel equations just describe the reflectance and transmission of a dielectric. It's snell's formula that gives you the direction of the refracted ray. But for doing skin, it's not something you need to worry about.
quasty
quasty
Thank you. :)

But I'm wondering - the quotient R0 is pretty small for most values, current R0 = 0.036 approximately while using n = 1.47. And when using the Fresnel term:
F = R0 + (1-R0)( 1 - N.V)^5
is can almost be reduced to
F = (1-N.V)^5
cause R0 is so small. And this will basically highlight the silhouettes on the mesh. But when using this factor to blend between specular and diffuse no specular parts will be visible on any part in direct view (where N.V = 1) - from what I tested the fresnel value on these points is always ~0. Is this correct? It would mean no specular values could be displayed on a orthogonal surface. And additionally a high fresnel value (at the silhouettes) doesn't necessary mean there is something specular to blend into, does it? Since the term seems to be independent from the light source. One would blend into black, if there isn't something specular (or not enough) instead to a possibly colored diffuse value.

I was wondering about the results and if I've grasped it correctly? Does R0 need to be that small? And how about these specular blend issues when using basically (1-N.V)^5

thank you very much! :)
playmesumch00ns
playmesumch00ns
Your assumptions are correct. This is why it's important to use properly-valued HDR data when rendering. If you "just fudge it", it won't work.

What I normally do is to expose a "frensel strength" parameter that lerps from 1.0 to the calculated fresnel reflectance. This gives you the option of blending it off if it doesn't look right.
quasty
quasty
Thank you.

I've done some more testing since I don't have properly-valued HDR data and so I'm trying to "fudge this"; but also looking for a way to make this somehow stable in terms how the specular component can be described best as a solid specular reflection model on a human face.

Currently the specular Blinn/Phong component is parametrized by two maps (specular and shininess maps) over the human face. Resulting in more or less soft specular reflections as it is desired, but without accounting the specular reflections at gazing angles. So this Fresnel term by Schlick describes the spatially varying "potential" of a specular reflection, doesn't it?

I tried in shifting the - by the parameters of these two maps - calculated specular intensity (Is) around based on the Fresnel term (Fr) - which never really worked. I just tried using something like this
float Fr = fresnel(...);float specfactor = max( Fr, SpecularMap.r );//instead of//float specfactor = SpecularMap.r;Is = specular( N, L, V, specfactor, specexponent );
and calulating the specular intensity based on that. A high potential in the Fresnel term (Fr) will increase the specular level and rule out the specular level factor from the specular-map - because apart from some areas (nose, lips, forehead) the specular factor is generally quite low.

It not quite right yet, but I get specular reflection at gazing angles as well at orthogonal surfaces (if it needs be), and only at gazing angles if there is a light source present in the appropriate way it is reflected. But I was wondering if its "right" or maybe to be more prudent to do it differently? Is there maybe something physically more plausible, more correct which describes this type of reflection model (on a human face)?

thank you very much
playmesumch00ns
playmesumch00ns
I'd do it like this
Is = specular( N, L, V, exponent ) *        lerp( 1.0, fresnel(...), fresnelEffect ) *       specStrength;

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.