I'm a gameplay programmer
focused on developing
engaging and unique experiences!

My Resume Learn more

Color Accuracy & sRGB

Part of being a graphics programmer means understanding how the human eye and mind perceive light. This comes into play with sRGB as we recreate visuals on a computer display.

sRGB Color Space

sRGB is a color space that matches the way that humans perceive light. But why would we need something like that? Due to how our brains evolved, humans don't actually perceive light linearly. A good example to think about is being in a room with two of the same light sources. If you turn on one light, you'll notice the room is much brighter than when there were no lights on. However, if you turn on the second light, it'd be really hard to say if the room was actually twice as bright, even though it technically is. Our eyes are much better at detecting more light in a dimmer environment than more light in an already bright environment. Thus, we need a color space that matches how our eyes perceive light!

Graphics Pipeline Colors

So what does sRGB mean for graphics programmers? The RGB values we use to indicate colors in code can map to different spaces depending on how we interpret them. This means we need to acknowledge what color space our RGB values are in before we use them.

Since most art programs already work in sRGB to account for having humans author colors, we know the assets coming into the graphics pipeline will have colors in the sRGB space. However, this is a problem as a lot of the time we are manipulating an asset's colors in our simulation. sRGB colors aren't linear so manipulating them mathematically with addition and subtracting creates incorrect values. This means we need to convert any incoming sRGB colors to linear for us to manipulate in engine. However, they will eventually be converted back to sRGB for the final rendered images of our simulation!


Probably one of the most notable aspects of a graphics system that sRGB affects is lighting. Let's take a look at a sphere rendered with a directional light from the left that hasn't taken sRGB into account.

That still looks alright! What does it look like with sRGB correction?

Notice the really quick transition from light to dark. This matches our original example of how we perceive light. At the point where the sphere isn't interacting with the directional light, it becomes dark really quickly. Also notice how the texture itself looks the same.

No Comments Yet.

Leave a comment