Post news Report article RSS Feed Gamma-correct lighting

I have been trying to avoid working on graphics recently in order to work on gameplay, but there was one feature I just had to implement. It has no performance cost, and makes a big difference in how the game looks! This feature is gamma-correct lighting. You can see the new lighting on the right side of this picture.

Posted by jeffr on Feb 3rd, 2010

I have been trying to avoid working on graphics recently in order to work on gameplay, but there was one feature I just had to implement. It has no performance cost, and makes a big difference in how the game looks! This feature is gamma-correct lighting. You can see the new lighting on the right side of this picture.

You can see that the picture on the left has a harsher "CGI" look to it. To understand why this is, you first have to understand the 'gamma' curve. The gamma curve is used by digital displays to more efficiently encode color information for human perception. Here is a comparison between physically linear brightness (how many photons are emitted), and perceptually linear brightness (numerical differences correspond to perceived differences at any point).

Adapted from the Wikipedia gamma correction article[1]

The lighting equations used for computer graphics are all based on physics, and thus assume that brightness 1.0 emits twice as many photons as brightness 0.5. However, on a computer screen, this assumption is not correct. Until very recently, there was nothing to be done about this, so we just lived with lighting that is physically incorrect. However, modern graphics cards have tools to support gamma-correct lighting, which you can see below on the right.

This is especially important for specular highlights (shiny areas). With incorrect lighting, specular highlights usually appear blown-out and hyper-saturated. To compensate, 3D artists often make specular maps that are the opposite color of the base surface, so that they cancel out and look white. However, with gamma-correct lighting, this is unnecessary; the diffuse color doesn't bleed into the specular color in the same way. You can see this by comparing the scars in the picture below. The lighting on the right is gamma-correct.

Please ignore the glazed look in his eyes -- I will eventually add a special shader to render their surface shininess and retinal reflections.

To add gamma-correction to your game you just need to do two things -- convert textures to physically-linear space when you load them, and convert the framebuffer back to perceptually-linear space when you display it. In OpenGL you can just convert the textures with the texture_sRGB extension, and convert the framebuffer with the framebuffer_sRGB extension. These operations are free -- they use dedicated hardware, and have no performance cost.

Bonus comparison shot!

If you are interested in learning more about gamma-correct lighting, you can read NVIDIA's "The Importance of Being Linear", Naty Hoffman's "Adventures with Gamma-Correct Rendering", or Bungie's "HDR the Bungie way".

If you have the latest alpha build of Overgrowth, you can turn on gamma-correct lighting by opening the "config.txt" file in the "Data" folder, and setting "gamma_correct" and "post_effects" to true.

Track us
on ModDB (visit our page)

Please join us here too:
Facebook icon ModDB icon Steam icon Twitter icon YouTube icon

Post comment Comments
MiniHendrix Feb 4 2010, 12:41am says:

Yet another reason why you deserve Best Upcoming Indie Game.

This game will be a treat to play.

+7 votes     reply to comment
AlCool Feb 4 2010, 2:10am replied:

You've seen gameplay?

-3 votes     reply to comment
Arxae Feb 4 2010, 2:19am replied:

the gameplay will be like lugaru, only better ^^
play lugaru, it will give a great idea of how the game will play ^^

+9 votes     reply to comment
Jackson97 Feb 4 2010, 1:24pm replied:

This game is gonna be so EPIC!
Awesome graphics!
Awesome gameplay! (cause it's a sequel to Lugaru)
And hopefully awesome story!

I'm so gonna buy this!

+5 votes     reply to comment
REZBLUE Feb 4 2010, 11:58pm replied:

Im not bashing Overgrowth or anything, I fully support their efforts but my God are you guys whipped. There has been no gameplay shown just pictures of terrain with a human/animal hybrid model sometimes standing on a hill and you guys are pitching tents in your pants.

+1 vote     reply to comment
akblabla Feb 5 2010, 9:09am replied:

They say that the gameplay is going to be greatly inspired by lugaru's gameplay (OG is the sequel to lugaru as told before)

+3 votes     reply to comment
Darthlex Feb 7 2010, 6:09pm replied:

Also I may add that some of us actually have played around on their engine quite a lot, already. It's awesome, and it is no less than a pleasure to follow the work these people do.

I will blanly admit that the reason I bought overgrowth is actually because of the amazing PR these guys do, and not the game itself. - The satiric, beautiful, thoroughly detailed work, that these guys do .. It makes the experience that much more enjoyable, and it earns them IGOTY with ease.

+2 votes     reply to comment
iamtwin Feb 4 2010, 12:42am says:

Excellent man keep up the good work. :^)

+3 votes     reply to comment
Kharcov Feb 4 2010, 12:50am says:

Very interesting. Indeed keep up the great work.

+3 votes     reply to comment
Tastyrice Feb 4 2010, 12:54am says:

That's one HUGE step in the right direction of achieving realistic lighting. As I have said on an earlier post I am curious whether the implementation of real-time radiosity or at the very least indirect lighting is possible.

Very good work nonetheless. Already had this game pre-ordered a while back. Can not wait to see the finished product. Keep up the good work!

+5 votes     reply to comment
c3r14l-suck3r Feb 4 2010, 2:58am says:

Is that linear brightness just for the normal maps, or is it a post-process?

+2 votes     reply to comment
pippy360 Feb 4 2010, 6:35am says:

i love that your releasing you dev tools but i dont like the idea of the game,not that its a bad idea just that im realy into s.w.a.t and cod type games.

anyway the point of my comment is that im still realy close to preordering and i will if you make that amazing engine very modable.

ps. if you promise to release the source code after a while ill preorder a few hundred times, how cool would it be having a open source game engine that looks like this

+1 vote     reply to comment
mothmann Feb 4 2010, 6:48am replied:

not into s.w.a.t and cod type games?? umm what game do you think this is?? i'm pretty sure this is a 3rd person hand to hand combat game. Not a first person shooter.

-4 votes     reply to comment
Tatsur0 Feb 4 2010, 7:26am replied:

mothmann, he clearly stated that he WAS into s.w.a.t and cod type games and expresses that Overgrowth's gameplay (assuming it plays like Lugaru) doesn't interest him however the engine does.

+5 votes     reply to comment
Dragonlord Feb 4 2010, 1:38pm says:

Gameplay? What gameplay?

0 votes     reply to comment
jeffr Author
jeffr Feb 4 2010, 3:19pm replied:

Not sure what you mean, but it is coming along pretty well. :) John's beard is on its last legs.

+1 vote   reply to comment
MOST Feb 4 2010, 2:27pm says:

I've played the first part of This game looks very good to me, I wonder what the second part that looks good

+1 vote     reply to comment
Medevila Feb 4 2010, 6:16pm says:

That's some sexy gamma correction!

+2 votes     reply to comment
nubblecakes Feb 5 2010, 3:43am says:

Every game should make use of this when possible. Very good tech.

+1 vote     reply to comment
cW#Ravenblood Feb 7 2010, 9:51am says:

pure love

+1 vote     reply to comment
Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Post news
Report Abuse
Report article
Related Games
Overgrowth Single & Multiplayer Adventure
Related Engines
Phoenix Engine
Phoenix Engine Commercial TBD
Related Groups
Wolfire Games
Wolfire Games Developer & Publisher with 4 members