Everything has Fresnel


You can sorta think of this post as part 2 of my “Everything is shiny rant”. While standard specular lighting is pretty common in games, one effect that we rarely see in games is proper fresnel.

Hopefully, you know what specular is by now. The most common model for specular in video games is Blinn-Phong, which is:


H = normalize(V+L);
specVal = pow(saturate(dot(H,N)),power);

In this case, V is the view vector, L is the light vector, N is the normal vector, and power is the specular exponent. H is the derived half vector, and it is the vector half-way between the View and Light vectors.

How does it work? Here’s a diagram.


You can see the View, Light, and Normal vector. Now, with this function, where will the specular value peak? Intuitively, you would want the specular function to max out when the view vector is at a reflection vector to the light. And that is what happens. This function peaks when the half vector is aligned exactly with the normal, which happens to be when the reflection of the View vector points right at the light. And life makes sense.

Here is another case:

Once again, the View vector reflects exactly into the Light vector. In this case, would the specular highlight be the brighter, dimmer, or exactly the same as the first case? Well, it would be the same, since you are viewing the maximum value of the specular highlight in both cases. Is this how the real world works? The short answer is no.

Here is a picture of a brick, from two different camera angles. In the top image, the light and camera are both looking straight down, which resembles the first case. In the second line, the light is hitting the surface at a grazing angle, as in the second case. I’ve split the specular and diffuse components with polarization so the diffuse is on the left and the specular is on the right. Let’s check out a brick.


So, wtf? For a material as simple as a freak’n brick, the Blinn-Phong model for specular is completely wrong. And it turns out this happens because of a little thing called fresnel.

Let’s take another look at our two cases of specular. According to Blinn-Phong, they should have the same intensity, but in reality, the one at the grazing angle is much brighter.

To account for this affect, you can use Fresnel. A pretty good realtime approximation for Fresnel is the Schlick Fresnel. From the GPU Gems 3 chapter on skin:

float base = 1 – dot(V,H);
float exponential = pow( base, 5.0);
float fresnel = exponential + F0 * (1.0 – exponential);
specVal *= fresnel;

For some reason, most people tend to want fresnel only on the really shiny surfaces, like water, glass, and metals. But really, fresnel has a strong effect on almost every material. In fact, I would argue that fresnel is more important visually on the less-shiny materials. Here is a piece of PVC pipe.


Certainly, PVC has a fresnel. But in my opinion, I would say that the fresnel has a more visually important effect on the brick than the PVC. Going from almost nothing to very specular is much more important than going from high to higher specular. Isn’t that a more visually important effect? For me, it’s a mistake to think about fresnel only as an effect for water/glass/metal, because it makes a tremendous visual difference on the less shiny surfaces. Here are a few more examples.

Poor cardboard. So misunderstood. It always gets referred to as a “pure diffuse material”, even though it actually deserves to hang out with its shiny friends. The specular is important at straight angles because it adds a subtle desaturation, but cardboard has a very bright specular reflection at grazing angles.


Ever wonder why it feels bright when you drive to work in the morning? Most people think that happens because the sun is in their eyes. Actually, the major source of brightness is that road pavement has a strong fresnel as well. Next time you are driving and the sun is in your eyes, look at your side-view mirror and check out how much darker the pavement in the side-view mirror is relative to the pavement in front of you.


Here is some cloth. It’s a towel from Ikea. Rough, cotton cloth is about the least specular common material that you will see around the house. This comparison isn’t that great because the second image is brighter overall, so it’s harder to see the relative change of the specular to the diffuse. If you want a better example, I’m leaving that as an exercise for the reader.


And just for kicks, let’s check out an X-Rite color checker. When using a color checker, they always recommend that you hold it perpendicular to the camera. Hopefully you don’t need me to tell you why that is.


Viva la Fresnel!

35 Responses to “Everything has Fresnel”

  1. Fresnel is awesome. I got quite carried away with it once and bothered to re-arrange the formulae so I could build in properly in the shading network of one of the 3D apps I use. Requires gamma correcting, but awesome. Also totally redundant as I had a fresnel shaded already done by someone else. Hmm. Does the real time one require shifting into gamma 2.2 (or whichever gamma curve you’re in)?


  2. Yep, fresnel is cool. For the gamma correction, you should be converting into linear space when you read your textures and convert from linear to gamma at the very end. But inside the shader, while doing the fresnel calculation, you shouldn’t have to do any gamma conversions.


  3. Yes indeed. A lot of people would plug in the fresnel shader and proclaim the results rubbish, but it’s only as they didn’t realize a linear (…naturally…) calculation. Only wondered about the CPU gems shader and linear as I’ve got no idea how many game pipelines use a gamma corrected workflow. I know of examples that do (well, one) but only as they’ve mentioned it, so it’s hard to tell how widespread it is. On with the awesome blog.


  4. Really good blog! Usefull to show real world sample of how light work. Can you share your opinion about Fresnel not applied on highligh but applied to Environment mapping.
    I read that an approximation of ambient specular lighting (so lighting without the light source used for the highlight) is : Fresnel with specular color and dot(N,V) * prefilteredenvmap based on roughness. And this should be done for all objects even matte. But on matte/concrete object with low roughness and low specular color, the fresnel effect seems to produce unrealistic rim lighting.


  5. Hi,

    Great post ! Using V dot H instead of N dot V is indeed the way to go. I have a small question though: Why are you multiplying (ie darkening specular) instead of performing addition to make the specular lighting go to white ?


  6. Multiplying is fine as you tend to define your overall spec/reflectivity to mean the “highest value it will reach”. The fresnel calc goes to 1 at 90 degrees (to the eye), so multiplying always gives your specified/desired value there on the rim. The rest of the equation gives you the diminishing value as it faces towards you, so multiplying reduces it accordingly.

    I’m now going to post this, after proof reading it, and find more errors in it.


  7. Mr.p: You’d be shocked at how many games do their lighting in gamma space. If you see a game, and it has that weird “for some reason this looks like a high-res PS2 game” look, it’s usually because their lighting is in gamma-space, and not linear. The best way to tell is to look at their diffuse falloff, and if it looks way too soft, it’s probably in gamma-space. Also, if you see the hue shifting as light falls off, it’s probably in gamma-space as well. You can see that a lot in characters.

    Sebastien: I’m very opposed to the dot(N,V) thing. It’s ok to add a little in a few cases if you can’t afford anything better. But as a replacement, I think it’s terrible. If I’m driving and I’m looking at the road, by that model, I would get the same fresnel brightness at high noon as well as when the light is almost even with the pavement, which is very wrong. When the dot(N,V) thing is over-used, it always looks like that cheap plastic-ish look.


  8. “This comparison isn’t that great because the second image is brighter overall”
    just because the carpet under the towel has Fresnel too! =)


  9. Hi Roman. Yeah, with all the crazy things our visual systems do, I sometimes feel like I spend more time explaining disclaimers than writing the actual post!


  10. OMG! EVERYTHING IS A REFLECTION!


  11. In the land of realtime rendering would you bother to do some basic energy conservation in your shaders?

    For example, if you’re using this fresnel approximation for refl/spec, would you then invert it and multiply the diffuse/ambient shader values by it? That way you don’t get the shader returning more light than its receiving once where got reflection contributing to it. That’s a basic example, but I do it all the time in offline rendering (and infact nowadays numerous shaders do it for you), but I just wondered how much it happens in games…


  12. Energy conservation is something we probably should do more in games. But in reality, shaders in games are so duct-taped together that we have to do hacks to compensate for other hacks. So in U2 we didn’t do much with energy conservation, but I think a few other games do for their specular highlights.


  13. Regarding your fresnel function “base = 1 – dot(V,H)” — is that a typo, shouldn’t it be dot(N,L)?


  14. Cool, does this work with the latest version of Minecraft? Where can I get it?


  15. <a href="http://www.marymccranks.com/category-106/]ニューバランス スニーカー 激安 夏ボーナスセール http://www.marymccranks.com/category-106/


  16. <a href="http://www.twitability.com/]オロビアンコ バッグ メンズ ビジネス 割引ショップ http://www.twitability.com/


  17. <a href="http://www.quadcityfun.com/]ボッテガヴェネタ 財布 メンズ 新作 http://www.quadcityfun.com/では【格安saleスタート】


  18. <a href="http://www.pamaenterprises.com/]ミュウミュウ 財布 人気大割引 http://www.pamaenterprises.com/


  19. <a href="http://www.sabisoftware.com/]オロビアンコ バッグランキング常連TOPS http://www.sabisoftware.com/


  20. [...] Everything has Fresnel [...]


  21. Right until now, no one could think about Burberry sneakers with socks or shadow detail. Could, nonetheless, although the daily transform in marketplace pattern and to check new outfits selection, is currently usually a separate working day to compare the place the fusion of the ft with texture, or might be opaque tights will be the latest craze among the persons vogue girls. For those who have been likely the end result in the Burberry significance of the answers have impacted the output, get hold of us on line. Most of us have to do, what circumstances you’ve in your unfailing mode so you’re able to completely give you the option to rework their practices of individuality within the Burberry Outlet method makes sense [url=http://topbagsreplica.tripod.com/]replica hermes handbags for sale[/url] . Superior layout trainers, human Burberry outlet outlets short article or posts, in a way only see the many content material and timing of peak seems to are actually dressed incredibly appealing to assault even though. So, you can take a look at with tights or perhaps anyone might have pantyhose which can be not see information. Specialized Burberry on the internet store. We offer HIQ Burberry Purses and Burberry scarf for reasonable. Get price cut Burberry luggage at most affordable price ranges and best client opinions right here you are able to pick all types of most economical genuine Burberry products and solutions, coat, and luggage etc. Relevant Content articles Leading trend Burberry goods on sale of large choice Your favourate Burberry collection will be the perfect presents A wide number of high-quality Burberry solutions are very hot on the web High Vogue and Top quality Burberry add-ons on the net for sale With the leg along with his dark Burberry an additional terrific collaboration, it can take a glance on the length of espionage [url=http://hermesbagsreplica.tripod.com/]replica hermes handbags birkin[/url] . Its accurately the situation with Burberry scarf [url=http://replicahermescheap.tripod.com/]replica hermes handbags for sale[/url] . If your Burberry scarf on the internet, to ensure that it includes a proportion with the square and after that the actual people today is often known as compounds created Burberry head. Burberry head band is quite well-liked, including all ladies of any age these relationships can can be found in a range of measurements and shapes. Jewels in the night while in the Gulfstream from the Atlantic Burberry are almost certainly the best option [url=http://hermesbagsreplica.tripod.com/]replica hermes handbags birkin[/url] . The Earth has lots of amazing figures of connections Burberry Online Retailer. For those who have the strength of your sun shades Burberry and find the connection amongst items stunning within with all sunglasses Burberry sunglasses Burberry gives excellent joy. Even though the utilization of prosperity towards the requirements of your group of people, we really feel excellent and good satisfaction Burberry finest, whilst lots of many others are featured. .

    Related Articles:


  22. [...] based rendering is awesome. I’ve been preaching fresnel for years. I would love to get rid of kS and other hacky terms. If you find a good physically based model, [...]


  23. That is really interesting, You’re an excessively skilled blogger.
    I have joined your feed and stay up for looking for more of your excellent post.
    Additionally, I’ve shared your web site in my social networks

    paire de louboutin homme


  24. therefore it think about as big as the bead to figure out how many beans certainly, there could possibly be in a hank. the bigger the beans the inferior a lot of in a hank. when choosing beans in the video store believe without doubt buy the from weight follicle or. various well-known offenders throughout jewelry thefts typically members of your family, fine friends of all members of your family and after that professionals dispensing service to your residence. ways to keep your valuable’s as a result of applying for stolen could well be to fastener these kind of people way up when not utilized. trying to hide your pieces all throughout your own home in numerous merchants is not a good solution, when you consider that usually ones memory did not closely with to as much as we’d like,
    nike blazers diamante hair pins http://www.tkrempreendimentos.com.br/airmax.asp?p=1806
    nike blazers diamante hair pins


  25. however it would depend upon how big is the bead to see how many beans generally there are could well be in a hank. the larger the beans the lower end cellular phone concerning hank. when choosing beans in a store you’ll quite likely buy the a mass strand or. the few universal causes here in fashion thefts get close relatives, other people associated close relatives also workers getting service to your dwelling. spending plan. ensure that your valuable’s by way of moving taken is always attach these items right up when not being utilised. hiding your gadgets for the period of real estate in a variety of areas is not a great choice, just because in certain cases a recall does not have to interact personally at least we’d like,
    nike jordans iii x dcc http://www.tkrempreendimentos.com.br/airmax.asp?p=4612
    nike jordans iii x dcc


  26. I simply want to mention I’m very new to blogging and absolutely liked your web page. More than likely I’m going to bookmark your blog post . You really have outstanding well written articles. Thanks a bunch for sharing with us your web site.


  27. I would like to thnkx for the efforts you have put in writing this web site. I am hoping the same high-grade blog post from you in the upcoming as well. In fact your creative writing abilities has inspired me to get my own web site now. Actually the blogging is spreading its wings fast. Your write up is a good example of it.


  28. I simply desired to appreciate you yet again. I’m not certain what I would have taken care of in the absence of the entire smart ideas discussed by you over that area of interest. Certainly was a troublesome difficulty for me personally, nevertheless observing the very specialized approach you dealt with it forced me to cry with gladness. I am happier for the help and believe you really know what a powerful job you’re undertaking educating other individuals through the use of your web site. I’m certain you have never got to know all of us.


  29. Wonderful site. Plenty of helpful info here. I am sending it to a few buddies ans additionally sharing in delicious. And of course, thank you for your effort!


  30. At this moment I am going away to do my breakfast,
    once having my breakfast coming yet again to read other news.

    my blog post – androx


  31. I must tell you that it’s hard to find your articles
    in google, i found this one on 13 spot, you should build some quality
    backlinks in order to rank your site, i know how to help you, just
    search in google – k2 seo tips


  32. [...] Everything is Shiny  Everything has Fresnel [...]


  33. Good day! I could have sworn I’ve been to this site before but after going
    through some of the articles I realized it’s new to me.
    Regardless, I’m certainly delighted I came across it and I’ll be book-marking it and checking back
    regularly!

    Visit my page; greencoffeefatburntrial.com


  34. We saw these folks acquire Burberry purses and purses outlet, to help you be involved in a lot of crucial events [url=http://youtu.be/3GT7J-0Db0A]Replica Hermes Birkin Handbags[/url] . A witness might queen, tips on how to acquire your Burberry handbag expressed, since it signifies every one of the luxury and upscale. These are typically the accounts associated that has a remarkable good quality.Hence the concern gets to be not just speculation why some females have their purses specifically very good Burberry Shoes information. Burberry Outlet fatalities could assistance him, the pleasure of absolute outlet of your respective effort and time BurberryBurberry designer fashion and under no circumstances replaced sixtieth equal home quarantine, but those people. Luxury polished emphasised femininity The characteristics with the adhering to type. Putting on a remarkably quick consideration is usually to get all the options from the girls determine [url=http://www.dailymotion.com/video/x20qhde_cheap-replica-louis-vuitton-epi-leather-handbags-red-ladies-cow-leather_redband]Cheap Replica Louis Vuitton Handbags[/url] . No coat duration considerably less significant about the system slightly below the knee.The distinctive silhouette on the walking Burberry Shirts design underscores the one of a kind character of woman fascinating. Trench Coat Winter Jacket this era needs to be just below the knee particularly. To feed many of the adult men purses Burberry Belt Picture similar asymmetric results which has a delicate lace.Buy discounted Burberry luggage at most affordable price ranges and very best shopper critiques in this article it is possible to decide on all types of lowest priced authentic Burberry items, coat, and bags and the like. Linked Articles The top and Numerous Burberry Items are your superb selection Unique Complete Burberry Outlet Guys Shirts And Adult males Shoes Burberry Outlet Gentlemen Shirts And Guys Sneakers Are Special Gains Unparalleled Purchase Burberry Outlet Burberry development with the winter period of 2010 could be the individual spot from the 80s [url=http://youtu.be/X6BhfecWRlo]Replica Chanel Flap Bags[/url] . N to lessen expenditures, threedimensional shapes, large muscular tissues, big significant door. Attributes special experiences are most likely quite possibly the most well-known. The length can be arbitrary. Confined size jacket and technique are certainly helpful extended in 2010. Item varieties could also be various. Will you The easy real truth is Burberry purses and purses are frequently among the celebrities somewhat, you could find quickly around the monitor or even a newspaper that a lot of males celeb awards Burberry trays artist picked for the reason that brings these persons Burberry purses don’t just the mobility on the hip and classy Burberry Outlet presentation, but also comfort and ease and evenly.Dealing with Burberry scarves are lovely period of 2011, faux fur and knitwear. 1980 coexist with speedily each year, forty Burberry items is usually appropriate characteristic, and favorites. As decorations emphasize the femininity and elegance with all the trend is of varieties of females related [url=http://www.dailymotion.com/video/x20qm58_cheap-replica-louis-vuitton-monogram-multicolore-white-cross-body-bag-ladies_lifestyle]replica louis vuitton monogram multicolore[/url] [url=http://youtu.be/N-i37ZIt41A]Replica Hermes Handbags[/url] . .

    Related Articles:


  35. Thank you for any other excellent post. Where else may just anyone get that kind of information in such a perfect
    manner of writing? I’ve a presentation next week,
    and I am at the look for such info.


Leave a Reply