Gamma and textures...

Gamma and textures...

Post by Marco Iannaccon » Wed, 13 Aug 2003 08:49:43



I have a doubt about gamma correction in RM.
If I wanna render images to be reproduced on a device with a certain gamma,
I set the needed gamma correction in RenderMan (i.e. 2.2 for TV NTSC or PAL,
1.7 for film printing, etc...), and I get the right images.

But...  must the images if apply on the various objects in the scene,
independently from output gamma correction, have linear gamma (=1)?
All light calculation must be done independently from gamma correction, and
this must be applied only AT THE END, right?

If, for example, I have a PC with a correctly sRGB set monitor, with 2.2
gamma, and I paint the textures by hand, and I they apear "good" on my
monitor, they actually have the gamma of my monitor, it's like... they've
been gamma corrected with the value 2.2, so, If I wanna use them in my 3D
scene I must convert them to linear gamma (simply applying the opposite
conversion, 1/2.2), right?

--
Marco Iannaccone

ICQ UIN: 18748121

 
 
 

Gamma and textures...

Post by Dan Ma » Wed, 13 Aug 2003 20:13:51


Quote:> If, for example, I have a PC with a correctly sRGB set monitor, with 2.2
> gamma, and I paint the textures by hand, and I they apear "good" on my
> monitor, they actually have the gamma of my monitor, it's like... they've
> been gamma corrected with the value 2.2, so, If I wanna use them in my 3D
> scene I must convert them to linear gamma (simply applying the opposite
> conversion, 1/2.2), right?

Yes, that is exactly correct. Unless you know otherwise, it is safe to
assume that ALL 8-bit-per-component images have an implied gamma
encoding. So if your shader works with linear light values, then you
will need to decode the 8-bit pixels. You do this by raising them to
the power of the gamma curve (e.g. pow(x, 2.2)). You could get fancy
and invert the whole sRGB function with that little linear segment,
but I just use pow...

If your final output format is 8 bits per component, then eventually
the renderer or the compositor will have to re-encode these linear
values (RenderMan can do this with the Exposure statement).

Keep in mind many older renderers incorrectly operate on gamma-encoded
values as if they are linear. They never bother to linearize incoming
pixels or gamma-encode outgoing pixels. With some tweaking, you can
actually get decent results with incorrect math, at least until you
try to do fancy HDRI or image-based lighting (incorrect math was
prevalent in low-end 3D until HDRI became popular and everyone finally
had to learn about gamma encoding...*

You'll have trouble matching the output of a "gamma incorrect"
renderer using the proper linear arithmetic... Although the RenderMan
standard IS flexible enough to accomodate such "incorrect" shader
math, and I bet some people do use it that way.

Dan

* an astute poster once wrote "the video industry had gamma all
figured out decades ago; it took the computer graphics industry to
come in and*things up..."

 
 
 

Gamma and textures...

Post by Marco Iannaccon » Thu, 14 Aug 2003 08:08:34


Thanx a lot! :-)

--
Marco Iannaccone

ICQ UIN: 18748121

 
 
 

1. Monitor Gamma and Picture Gamma

There has been much discussion about Gamma on this list lately, a
topic of some confusion because there is Monitor Gamma and Picture
Gamma, and the two are not the same.

Theoretically, a perfect monitor could be built, where pure red shows
as pure red, pure green as pure green, etc.; however, because the
components that are used to build electronic equipment are highly
inaccurate, a perfect monitor is only theoretical.

The actual values of resistors, capacitors, and coils that go into a
piece of electronics vary greatly from their stated values. For
example, a higher-grade 3,000 ohm resistor can vary in value from
2,850 to 3,150 ohms. Standard resistors have a 10% tolerance. The
value of a capacitor can vary from +50% to -20% of its rated value.
Then there are factors such as stray capacitance, wire resistiance,
and inductance caused by the current to contend with.

So, while the design engineer says this circuit will do this, the
resultant application of that design might not, and they add variable
components to allow "tweaking". Instead of having a 3,000 ohm resistor
in some part of the circuit, they might use a 2,500 ohm one along with
an adjustable 250 to 750 ohm one.

The whole point of this is that your monitor is not going to be
perfect, even when it is new, and as it ages, the values of its
components (especially capacitors) will change.

Adjusting your monitor gamma is a way of tweaking it so pure red show
as pure red, etc. It also is used to establish a uniform grayscale.
This can be done completely independently of your graphics program,
and needs to be repeated periodically to compensate to component
aging.

On the other hand, if you use a program like Paint Shop Pro to adjust
the gamma value of a picture, you actually change the palette values
of that picture. One way to see this is to compare the palettes of a
picture at different gamma value adjustments (double-click on the
foreground or background color box or actually open the Jasc-format
palettes in a text editor).

Calibrating the gamma of your monitor just changes the way you view
pictures, not someone else's view. It's becoming the norm for PC
monitors to include gamma adjustment (I believe that it has been built
into Macs for some time, and UNIX). A good package will allow you to
set the values for red, green, and blue independently, along with
grayscale. If your monitor does not include this capability, then I
would search out one of the web sites that have been set up to handle
this, and not foing it from within a paint program.

I have found that I get a good match between my scanner, my printer,
and my monitor since I did the calibration.

Adjusting the gamma value of a picture can be useful for "tweaking"
its appearance, but remember that you are actually changing the colors
when you do so.

co

------------------------------------------------
NOTE: any e-mail sent to the originating address
is automatically deleted without being read.
------------------------------------------------

2. G400 Old age?

3. Gamma Gamma Hey Hey

4. Anyone got Animatek's World Builder

5. Gamma mia, here we go again, Gamma...

6. PS memory realease to TWAIN

7. Gamma correction: O = pow(I,gamma) or O = pow(I,1/gamma)?

8. Textures, Textures, Textures!

9. Textures, Textures, Textures