Thursday, April 29, 2010

Шугаман зарчим

Хүний нүд харанхуй бараан хэсгийн ялгааг гэрэлтэй тод хэсгээс харьцангуй илүү мэдэрдэг гэдгийг бид мэддэг болсон. Тэгэхээр дэлгэц  энэ онцлогийг харгалзан  зурганд гамма хувиргалт хийж гэрэлтэлтийг шугаман бус   зарчмаар  харуулах үүрэгтэй.  Шугаман алгебрын зарчмаар  дэлгэцнээс ялгарах гэрэлтүүлэлтийн хэмжээг 255 хуваахад 128 гэсэн индекстэй гэрэлтүүлэлт яг 50% -ийн  саарал өнгөтэй байх ёстой. Харин шугаман бус аргыг хэрэглэснээр 186 гэсэн индексд харгалзах утга дээрхи 50%-ийг илэрхийлнэ. 
   Монитор ийм хөрвүүлэлт хийдэг учраас  гамма тохиргоог авч байж зурагтай ажиллах нь гарцаагүй. 3D програм дээр ажиллахад зарим нэг бэрхшээл тулгардаг. Рэндэр нь бүх боловсруулалтаа шугаман аргаар гүйцэтгэдэг. Өөрөөр хэлбэл 2+2 гэсэн илэрхийлэл нь 4 гэсэн абсолют ганц хариутай. Рендер нь материалд холбосон текстур зурганд шугаман бус хөрвүүлэлт хийгдээгүй гэж үзээд тооцоогоо хийдэг.
Өөрөөр хэлбэл Photoshop дээр зөв харагдаж байгаа тоосгон хананы текстурыг материалд оноолоо гэж бодъё. Энэ зураг аль хэдийн 2.2 гэсэн гамма хувиргалтыг өөртөө агуулж байгаа. Харин рендэрлэгч нь текстурын гаммаг 1.0 гэж үзээд буруу тооцоолол хийдэг. Хэрэв spotlight-ийг 2 дахин хувилж тавихад гэрэлтүүлэлт хоёр дахин өснө гэж та тооцоолж байж магадгүй. Ингэвэл шугаман бус зарчмаар ажиллаж байгаа үед brightness тав дахин өснө гэдгийг анхаарах хэрэгтэй. Гамма хувиргалт хийгээгүйн үр дүн ингэж илэрнэ. Зураг ч гэрлийг хэт их нялсан мэт харагдана.
Гамма хувиргалт хийлгүйгээр гэрлээ  тохируулж сайн үр дүнг гаргаж авч болох хэдий ч  үүнийг ашигласнаар бодит байдалд нийцэх үр дүнг амархан олох бололцоотой.


Gamma correction is a two part process. Since your textures are created in gamma 2.2 space, they need to be converted to gamma 1.0 The way I have learned to do this is in my renderer of choice (Mental Ray for Maya) I apply a gamma correction of .454545 (2.2 x .454545 = 1). This converts my texture into a gamma space that my renderer can work with correctly. However, the rendered image might look a little off, since it’s a gamma 1.0 image being displayed on a gamma 2.2 display. To correct this I then apply a gamma correction of 2.2 to my rendered image to bring it back into gamma 2.2 space.

To actually do this in Maya, graph the shader network you want to gamma correct. In my case I use file nodes which output their color into my lambert or blinn. Just break that color connection and insert a gamma_correct node (it’s a Maya utility I believe) in between them. Your file node will connect to the ‘value’ setting of the Gamma Correction node. Make sure to set the gamma correction node to .454545 values. Then connect your Gamma Correction node into the color of your blinn or lambert. In order to get your gamma back to 2.2 you can then add a mia_exposure_simple or mia_exposure_photographic to the camera you are rendering. There is a really good article I found on exactly how to use this mia_exposure node right here

Ok, now on to the topic of tone mapping. Gamma correction is a part of the larger topic of tone mapping. I found an absolutely wonderful link regarding tone mapping here : I'm not sure who wrote it, but it's very good.

So images are, by default in Mental Ray, rendered in HDR (High Dynamic Range). In an image without HDR, intensity values are represented on a 0-1 scale (as in what the monitor can represent). In this way, all of your bright and dark values have a fairly small range by which to be presented. Also, there is a limitation with the 0-255 RGB scale in that if you have a scene and increase brightness by 20, all pixels with a brightness value of 235+ will be compressed to 255, flattening the image. HDR images give a range of values that goes far beyond the standard range. Although a monitor cannot display all these added values, HDR images give a much richer range of values with room to make changes without sacrificing quality or 'clipping' your brights and darks. As nVidia is quoted as saying on wiki - HDR's features mean "Bright things can be really bright, Dark things can be really dark, and details can be seen in both."

Although an HDR image is physically more correct, it can't be displayed by the limited capabilites of a computer monitor or television. A pure HDR image would appear overbright or washed out, due to the higher range of brights it can represent. In order for an HDR image to look good on a standard monitor it has to be converted to LDR (Low Dynamic Range). This is where Tone Mapping fits in. Tone mapping converts HDR images to LDR images, taking the physically correct lighting done in an HDR render and attempting to fit them into and LDR range so your monitor can display it.

HDR is best saved in 16 bit (half point) or 32 bit (floating point). The reason for this is (per Jozvex) they have an increased dynamic range which allows them to store more detail to be preserved in highlights and shadows (see link)

The floating point value allows the decimal value to be placed anywhere along the value, increasing the range that can be represented.

Image formats that can retain HDR data are Tiff, HDR and EXR. However, once converted to LDR, any image format can be used that accurately depicts LDR images.

No comments:

Post a Comment