Fix old scenes to work with the new gamma system
HowTo

From POV-Wiki
Jump to: navigation, search

Note: The title of this page and part of its contents are somewhat outdated, as POV-Ray 3.7.0 proper will now support virtually full backward compatibility for legacy scenes, and in this sense there will be almost nothing to fix. The information in this page rather applies to migrating a scene to use the physically realistic assumed_gamma 1.0

Before "assumed_gamma 1.0" or the most recent 3.7 betas, the colour math was simply wrong. So in order to get exactly the same result, you'd have to mimic that wrong colour math - which 3.7 refuses to, except for legacy scenes using "#version 3.6" (or anything smaller than 3.7) and "assumed_gamma 2.2".

If you do want to port the scene to the right math, here's what I expect to be the most important steps:

  1. In the ini-file, set the "Display_Gamma" to whatever fits your system; set "File_Gamma" to the same. (Ideally, your system should have a Display_Gamma of 2.2.)
  2. In the scene file, use "#version 3.7", and remove any "assumed_gamma" statement.
  3. Gamma-adjust all colour literals, by raising the R,G,B components to the power of 2.2 (or wait for the next beta, and use "srgb" instead of "rgb"). Check your scene for colour values that are computed from some other values - you may (or may not) want to gamma-adjust these as well.
  4. Check your scene for input image files, and whether they are handled properly regarding gamma. For images that are used as anything non-color (e.g. height field data, bump map, texture map or what-have-you), explicitly specify "gamma 1.0" after the filename. For any images that do wind up being used as a colour, try the default first (i.e. no "gamma" statement); if the colours appear too washed-out or too strong, try explicitly specifying "gamma srgb".
  5. Toy around with overall brightness and/or brightness of individual light sources, until you feel comfortable with the illumination. You may also want to tweak some of the colours in your scene (both pigment and light sources). If you're using self-made input image files, you may also want to tweak their gamma setting, but try to avoid this with 3rd party input images (you should usually find a way to make them work by tweaking the scene rather than the image).

Color literals

As of version 3.7.0.beta.41, POV-Ray natively supports gamma-adjustment of color literals, provided they conform to the sRGB standard:

pigment {color srgb <110,160,008>/255 }
pigment {color srgbft <1,1,1,0,1> }
pigment {color srgbt <1,1,1,1> }

If you are still using version 3.6, or need more flexibility of the gamma parameter:

#macro gamma_color_adjust(in_color, out_gamma)
	rgbft <
		pow(in_color.red, out_gamma),
		pow(in_color.green, out_gamma),
		pow(in_color.blue, out_gamma),
		in_color.filter,
		in_color.transmit
	>
#end

pigment {color gamma_color_adjust(rgb <110,160,008>/255, 2.2)}
pigment {color gamma_color_adjust(rgbft <1,1,1,0,1>, 2.2)}
pigment {color gamma_color_adjust(rgbt <1,1,1,1>, 2.2)}
pigment {color gamma_color_adjust(red 1 green 1 blue 1 transmit 1, 2.2)}

light_source
{
	-z * 40960
	color gamma_color_adjust(rgb <240,240,240>/255, 2.2)
}

Transparency

Colors with partial transparency (filter and/or transmit) suffer additional degradation that is not resolved by the above fix. For instance, Chris Colefax's lens flare macro. It is not clear yet how to resolve this issue. (See here.)

See also

Personal tools
Namespaces
Variants
Actions
Content
Other Pages
Toolbox