The importance of being linear

manu3d

Active Member
Contributor
Architecture
I'm going through the online version of the GPU Gems books held on the nvidia website and this chapter concludes with a nice, compact set of recommendations on the generally mind-twisting problem of gamma correction:
  • Assume that most game players are using uncalibrated, uncorrected monitors that can roughly be characterized by an exponential response with gamma = 2.2. (For an even higher-quality end-user experience: Have your game setup display a gamma calibration chart and let the user choose a good gamma value.)
  • When performing lookups from nonlinear textures (those that look "right" on uncorrected monitors) that represent light or color values, raise the results to the power gamma to yield a linear value that can be used by your shader. Do not make this adjustment for values already in a linear color space, such as certain high-dynamic-range light maps or images containing normals, bump heights, or other noncolor data. Use sRGB texture formats, if possible, for increased performance and correct texture filtering on GeForce 8 GPUs (and later).
  • Apply a gamma correction (that is, raise to power 1/gamma) to the final pixel values as the very last step before displaying them. Use sRGB frame-buffer extensions for efficient automatic gamma correction with proper blending.
I haven't gone deep into shaders to know how much of this is applicable to Terasology, and of course the renderer isn't trying to be photorealistic, but I suspect some problems we are having with some blocks that are too bright might be related to non-linear textures.

I thought I'd share it here as it is as much of an issue during asset generation (i.e. creating textures outside of Terasology) as it is in dealing with them within shaders.
 

manu3d

Active Member
Contributor
Architecture
It would be nice if it's that simple. Go ahead and give it a try. ;)
 

OvermindDL1

New Member
Contributor
Sadly, the way manu3d described it is correct, gamma is quite a fun topic that I have had to deal with many times in the past. ;)
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
On the other hand we do need to fix the lighting, but there are lower hanging fruity fixes than fully worrying about gamma :D
 
Top