• About us
  • Contact Us
  • Terms and Conditions
  • Forum
  • Materials
  • Shaders
  • Tools
  • Video
  • Learn
  • Gallery
My Mental Ray

Navigation

  • Main Page
  • Cookbook

MYMR WIKI Tools

  • Creating pages
  • Markup n styles
  • Page protection
  • Help

 

Toolbox

  • Upload file
  • Special pages
  • Printable version
  • Permanent link
Article    Discussion    View source    History   
Personal tools
  • 38.107.191.103
  • Talk for this IP
  • Log in / create account

Gamma

From Wiki

Jump to: navigation , search

You are here: mental ray cookbook / gamma

Gamma correction is an often misunderstood concept of digital imaging systems. In simple terms, gamma describes the non-linear response of a camera or a display device. When a normal camera (analog or digital) receives twice the amount of energy/light, the data it records will not have twice the RGB value. There are several reasons why imaging systems have such a thing as gamma at all. Some of them are due to the technology in recording and displaying images, e.g. photographic film has a non-linear response curve, and so does the electron gun of a CRT monitor: the brightness of a pixel is not linear to the voltage of the video signal. Also the fact that the human visual system is more sensitive to details in the dark than to details in the bright (the response curve of the human visual system is in fact logarithmic, Weber-Fechner law) is calling for a non-linear brightness encoding, especially if you have only a few bits to encode brightness.custom essay Modern TFT monitors do not have a physical gamma but they emulate the gamma characteristics to stay compatible with existing workflows and standards.


Also read up on linear color space for more information on why gamma correction is important when dealing with high dynamic range data or using exposure controls (tonemappers). If you still do not understand why correct handling of gamma is important, read this basic example of what happens without gamma.

Contents

  • 1 Gamma 101
  • 2 More about gamma
  • 3 Where ignoring gamma produces clearly visible defects
  • 4 Gamma in 3ds Max
  • 5 Problems with gamma with a render farm
  • 6 Common Misconceptions about Gamma
  • 7 External links

Gamma 101

  1. Most (all) displays have a non-linear response to pixel values. This is intentional
  2. Most graphics software is written for a linear color model, i.e. they make the simple assumption that 255 is twice as bright as 128. But since the monitor is nonlinear, this is not true. In fact, for most monitors (with a gamma=2.2), you need to send the pixel value (0.5^(1/2.2))*255=186 if you want 50% of the brightness of 255. The commonly used value of 128 will only produce about (128/255)^2.2 = 22% brightness.
  3. Digital cameras have a (roughly) linear response to light intensity, but since they are intended for display on computer monitors, they embed the nonlinearity (gamma) in the image. (True for .jpg, whereas RAW files are just that - RAW, i.e. linear data, that gets non-linear when converted to JPG, for example)
  4. Therefore, if you input .jpg images taken with a camera into a graphics software, you need to compensate for the images gamma.
  5. And if you display the (linear) data generated from a graphics algorithm, you need to compensate for the display gamma.

More about gamma

  • Gamma is not a bug, it is a feature, because the human visual system has a non-linear perception of light intensities. If there are only 8 bit per color to encode the image data, it is important to uses these eight bits in a perceptually uniform coding, which is non-linear to physical values. Even modern displays still have a gamma: our graphics cards normally only use 8 bits per color and to avoid banding, these 8 bits need to be used for perceptually equal steps. Manufacturers could very well produce displays with a linear response curve but if you would drive these with an 8 bit signal, the results would look pretty bad.
  • Most computer monitors today will adhere to the sRGB standard which includes a gamma of 2.2 (that is not entirely correct but close enough for most purposes).
  • Most digital cameras will also store their data in sRGB. This will be different for images from scanners (flatbed and film) as well as synthetic images.
  • Most if not all floating-point HDR data is encoded linear, i.e. with a gamma of 1.0.
  • For an image file, "gamma" describes how the intensity values are encoded. In other words: the bitmap gamma describes what the gamma curve of the display device or rendering algorithm should look like in order to make it look as it was intended. That gamma is built into the pixel values!
  • Some image file formats allow images to be tagged with a gamma parameter but that is unreliable as it is ignored by many programs. So there is no easy and exact way to tell what gamma was used to encode the image data.
  • If your screen has a gamma of 2.2 and the image looks fine in a simple image viewer, that image most likely was created for gamma 2.2 or something similar. This also applies for drawings or painted textures that were edited and judged on an sRGB display.
  • Normal 3D rendering equations assume a linear light model. So, in principle, giving the renderer anything that is not linear, is strictly speaking wrong (although it might still look good).
  • Be aware that the drivers for NVIDIA cards try to hide complexity from the user; when the gamma in the NVidia control panels says "1.0", that is the multiplicative deviation from gamma 2.2. So "NVidia gamma=1.0" is actually the standard sRGB gamma of 2.2


Where ignoring gamma produces clearly visible defects

  • Basically anytime pixel blending is used. For example:
    • Anti-aliasing, especially when doing wireframe renderings or render other image elements of very high contrast (e.g. text)
    • Scaling down images. Again, the higher the contrast/frequency, the more visible the error is
    • Semi-transparent surfaces
  • See the External Links section for more examples on gamma mistakes; go to [1] or [2] for some examples that show that even Photoshop treats gamma incorrectly.

Gamma in 3ds Max

  • Gamma is controlled in the Preferences dialog. There are actually three gamma values:
    • Display describes the gamma of your monitor. Typically, you want this to be 2.2 if you use an sRGB monitor with default settings.
    • Input Gamma sets the default gamma used when reading bitmaps. This value is used to linearize the data of an image. Typically, you want this to be 2.2, too.
      Note: If you open an image file that has an embedded gamma data field (e.g. in .tga or .png format), 3ds Max will by default use that internal parameter instead of the Input Gamma! You can change that behavior in the Gamma part of the File Open dialog.
    • Output Gamma describes the gamma used when saving images. This should be 1.0 if you are saving to linear floating-point image formats, or plan to do compositing work on the images. If you want images to "just display" (i.e. output things like .jpg's straight out of max), use 2.2 here as well.
  • When you open a bitmap and gamma is enabled in the preferences, the file dialog also has an option to either use the global gamma value or to set a specific gamma value for this file. It is important to set this to 1.0 for bump or displacement maps (which should have a gamma=1.0 since they encode linear data)!
  • Note that some legacy algorithms in 3ds Max have been tuned to "look pretty" without gamma correction, and therefore will look funny if you correct for gamma.

3ds Max Gamma preference dialog

Problems with gamma with a render farm

  • One problem that can occur on a render farm is that the render slaves do not respect the gamma flag in the .max file, i.e. they work with gamma=off. This can be fixed by making sure each slave has the preference set to respect the gamma state when loading .max files.
  • When using Distributed Bucket Rendering (DBR), there is (as of 3ds Max 2009) a known problem that causes all textures to globally use the Input Gamma from the preferences (ignoring any gamma overrides set in the File dialog). This comes from the fact that DBR will automatically enable the mr Map Manager and that will not treat the "per bitmap" gamma values correctly. If you use HDR images, for example, in combination with a gamma=2.2 workflow and use DBR (or the mr Map Manager), the HDR will also be affected by gamma=2.2 and therefore produce too dark results. A possible workaround is to set the global input gamma to 1.0 and use mr's "Utility Gamma/Gain" shader to "degamma" textures.

Common Misconceptions about Gamma

I have calibrated my screen - so I don't need to care

WRONG. When you calibrate a screen, you typically calibrate it to the standard sRGB curve, which has a practical gamma of 2.2. When you have calibrated your screen, it means you should always compensate your image with a gamma of 2.2

My camera takes "linear" pictures

It may, and your RAW files contains data in a linear format. However, any RAW-to-JPG software (including the one built into your camera) applies a gamma, most likely the standard sRGB gamma of 2.2

External links

  • http://www.poynton.com/GammaFAQ.html
  • The Rehabilitation of Gamma (PDF) by Charles Poynton
  • Gamma Correction in Computer Graphics by Lawrence Kesteloot, a nice article discussing general computer graphics (e.g. anti-aliasing) and gamma correction
  • Gamma Terminology and Calculations by Timo Autiokari. Also includes advice on typical workflows (with and without gamma correction). This is about print, but applies well to CG.
  • Fundamentals of Liquid Crystal Displays White paper on LCD technology by Fujitsu (PDF)
  • High-speed Conversion of Floating Point Images to 8-bit by Bill Spitzak, Digital Domain. Recommended article with explanations of what sRGB is and the "why" and "how" behind it. Also has nice graphics demonstrating how wrong things end up if you do things wrong and not compensate properly.
  • Adventures with Gamma-Correct Rendering by Naty. A nice article about sRGB and why it is imporant to do the internal rendering math on linear values, with an emphasis on real-time rendering for games but applicable to other types of graphical content.
  • Gamma error in picture scaling discusses how image scaling produces wrong results when ignoring gamma. It has a few impressive demonstrations that show that almost all image processing software scales images incorrectly.

Related Links: custom essay


Associate Editor John Mash Email Marketing of : Email Marketing and his partner site Email Marketing

Executive Sr Editor Scott Galvin From Utah of : Utah Web Design and his partner site Utah SEO

Executive Jr Editor Quinton of : Mikimoto and his partner site Free Online Credit Reports

Senior Jr Editor Quinton of : serving dishes and his associate table

Retrieved from "http://mymentalray.com/wiki/index.php/Gamma"
Copyright © 2008 My Mental Ray Community. All Rights Reserved.
No part of this website may be reproduced unless for personal use without prior written permission from The My Mental Ray Community.