Upload
others
View
0
Download
0
Embed Size (px)
Citation preview
Whatdoes“linear”meaninalinearworkflow
Let’sstartwiththebasicswhentalkingaboutalinearworkflow.Weneedtodefinewhatthewordlinearactuallymeans.Thereislinear“light”andlinear“data”.Linearlightisthewaythatwewanttorepresentimagestooureyes.Lineardataishowwewanttostoretheimagedata.Westorethingswithlineardatainmindbecauseweneedtoaccountforgammaindisplaydevices.Mostcomputerdisplaydeviceshaveaninherentgammaofapproximately1/2.2=0.4545.Thisiswhat’scalledsRGBgamma.Videomonitorshaveagammaofrec709.Theyarecloseinvaluesbutnotexactlythesame.Havingsaidthat,agammaof0.4545isnotexactlysRGBorrec709butwe’regoingtocallthatcloseenoughforourpurposes.Becauseourmonitorsdarkenimages,weneedtocounteractthat.Hereisabitofagraphofwhatmonitorsdotoimagedata,thelinearimagedata,andthesRGBcurvethatweusetocorrectforthemonitor.
Themaththatcreatesthecurvesisapproximatelyasfollows:
MonitorEffect=pow(pixelvalue,2.2)sRGB–pow(pixelvalue,(1/2.2))
Robert Nederhorst � 3/12/09 10:47 PMDeleted: 2.2
Asyoucansee,yourmonitordoesaprettysignificantgammacorrectiontotheimagedatabeingdisplayedonit.Becausewecancorrectforthat,it’snotaproblem,aslongaswetakeafewthingsintoaccount.Let’stalkmoreaboutwhathappenstovaluesbecauseofthiscorrection.AsCGIartists,wehavebecomeaccustomedtoavalueof.5tobeexactly50%ofbrightness.However,that’snottechnicallycorrect,asyoucanseebythepreviouschart.
Lookingatthechartalittlemoreclosely,wecanseethatthehorizontalvalueof0.5isjustbelow0.25ontheverticalaxis.Technicallyit’s0.18.Doesthisseemfamiliar?Usingphotographicterms,that’s18percentgrey.Eighteenpercentgreyintermsoflineardatameans50%ofvisualbrightness.Whyisthisthecase?Well,oureyesareverysensitivetolowlightlevelsandweperceive0.18as0.5.Whenyougotobuya“greycard”ataphotographyshop,itwillbe18%greybutyoureyeswillseeitas50%.So,nowthatweknowthatoureyesturn0.18into0.5,andourmonitormakesthingsdarker,wecorrectforthatinsomethingcalledaLUT(lookuptable)thatmapsthevaluesweseeonthemonitortosomethingoureyesareusedto.ThatLUTgetsappliedinseveralplaces.Beforewegetintothethefullnittygrittyofwherealltheplacesshouldbe,let’slookatimagesthatcanhelptellthestoryalittlebetter.
Thefirstsetofimagesisaverysimpleillustrationoflightattenuation.ThefirstimageiswithoutanysRGBapplied.Thesetuphereisa100wattlightinaroomthatis12’x15’x9’,withGIturnedonandaninfinitenumberofGIbounces.Twoproblemsareevidenthere.A100‐wattbulbcaneasilylightthisroom,butthisfirstimagedoesnotshowthatishappening:
Robert Nederhorst � 3/12/09 11:11 PM
Robert Nederhorst � 3/12/09 11:11 PM
Deleted: Usingthehorizontalaxisonthechart,wecanseethatavalueof0.5isvisuallyequaltoaround0.75.That’saprettysignificantdifference.
Deleted: around
Inadditiontothelightnotfillingtheroom,thisnonlinearrepresentationofthelightfalloffiswildlyinaccurate.It’sjustugly.However,inthissecondimage,wecanseethatthelightiscertainlylightinguptheroomquitenicely,andthelightattenuationissignificantlymorepleasing:
Thoseexamplesareverybasicbutgiveaquickideaofwhatistocomeintermsoflightingaccuracy.
Nextisarenderthatisnotcorrectedforthedarknessthatmonitorsapplytoimages.AspecialthankstothetalentedarchitectsatMarch(http://www.marchmade.com),whoprovideddesignedandmodeledthisenvironment.Thisimagewasrenderedwithasun/skysystem,andusesGItogetdiffusebounces.Thesunisaround20degreesoffthehorizonsothereisaprettygoodamountoflightbutcertainlynothighnoonstylelighting.
Thisimageseemsverydark.It’stoodarkhonestlybecauseifwethinklogicallyweknowthatataround4‐5pmyouwouldseemorebouncelightaroundtherestofthisstructure.Weknowthatbecausewe’reusedtoseeingthingsat4‐5pmallthetime.However,thecomputerandmonitorhavenoidea.Theyarebutdumbdisplaypresentationdevices.Let’sputansRGBgammacorrectioncurveontheimagetoshowwhathappenswhenwecorrectforwhatoureyessee.
Thisisofcoursemuchmorerepresentativeofwhatyouthinkyouseeataround4‐5pm.EventhoughthesRGBseemstoremovesignificantamountsofcontrast,thisimagecertainlyhasplentyofthat.However,it’simportanttonotethatthisimagewasgeneratedwithsRGB(linear)workflowinmind.Thatmeansthetextures,shadercolors,andvalueswereadjustedbasedonthatsRGBcurve.
LinearWorkflowina3DApplicationSo,whatdoesastandardworkflowlooklikeinthe3Dprocess?Let’sfirsttakealookatPhotoshop’scolorsettings.Sincenearlyeverytexturepaintedisfrom
Photoshop,weneedtomakesureoursettingsaresetofforalinearworkflow.Photoshopbakesinagammatoits8bitoutput,sowhenwesaveanimage,it’sbeengammaencoded.Thisisnotidealbutweneedtofindawayaroundit.Alternatively,wecanuseopenEXRimagesfortexturesasthereisnogammaencodingonthoseimagesoranyotherfloatingpointformat.
MakesuretousesRGBfortheRGBpartoftheworkingspacesarea.Nowthatthepaintingtoolissetup,weneedtotakealookatthe3Dapp.However,let’slookattheidealpaththatimagedatatravelsthroughthe3Dapplicationbeforeanythingelse.
Weneedtoassumethatthedatagoingintotherenderislinear.Thismeansweneedtoremoveanygammaencodingthatimageshave,iftheyare8bitdata.However,32or16bitfloatingpointimagesareassumedtoalreadybelinear,it’simportantthatwedonotcorrectthem.Intheend,ourrenderergenerateslinearfloatingpointdatathatweneedtopreviewinanimageviewing.Sinceit’sdatalinear,weneedtoaddthesRGBLUT,whichwillmakeitvisuallylinear.
Let’stakealookatafewexamplesofwhathappenstothetexturedatawhenlinearworkflowisproperlyappliedandwhenit’snot.HerewehaveasimplegradientcreatedinNuke,asafloatingpointopenEXR.Thetopimageislinear,andthebottomimageisanon‐linearimage.Inthisinstance,thenon‐linearmeansansRGBlut/gammaisbakedintotheimage.Wewillcallthisagamma‐encodedimage.
Noticethedifferencewithrespecttothemidtonesandtheblacksoftheimages.Sincethetopimageislinear(nosRGBlutbakedin)thisshouldgiveuscorrectresultsintherenderer.
Now,let’sseewhathappenswhenthelinearandthenon‐linearimagegetsusedasareflectionmap.Thisrenderwassetupwithawhitebackgroundsoanyreflectionwouldbepure1.0.Thegroundplaneisblackandthereflectiontexturechanneloftheplanewassetwiththeaboveimages.Theimageshavebeentaggedwithluminancevaluestoshowwhere50%brightnessis.
Hereisthelinearresult:
Hereisthenon‐linear(gammaencoded)result:
Robert Nederhorst � 3/21/09 9:17 AM
Robert Nederhorst � 3/21/09 9:17 AM
Robert Nederhorst � 3/21/09 9:24 AM
Deleted: (akait’sencodedwith
Deleted: sRGBencoded
Deleted:
Usingtheframebuffer’sabilitytosample,wegetavalueofaround.7onthe50%markwhenweexaminethenon‐linearimage.However,whenwesamplethelinearresult,thevalueis.5.Thisisdata‐linearcorrect.
Now,let’stakethatonestepfurthertodisplacementmaps.Thetopimageisgeneratedfromalinearfile.Thebottomimageisusingagammaencodedfile.
Hereitshouldbeevenmoreclearthatmakingsurethatweputlineardataintotherenderer.Wecanseewhatresultsfromnottakingtheextracaretoensureaccuracy
Robert Nederhorst � 3/21/09 9:24 AM
Robert Nederhorst � 3/21/09 9:25 AM
Robert Nederhorst � 3/21/09 10:22 AM
Robert Nederhorst � 3/21/09 10:23 AM
Robert Nederhorst � 3/21/09 10:24 AM
Robert Nederhorst � 3/21/09 10:24 AM
Deleted:
Deleted: .
Deleted: Wecanevenseethatthe3Dappisremovingpixeldata,andinthiscasevaluesbelow.01!
Deleted: notgammaencoded
Deleted: gammaencodedtobelinear
Deleted:
inthesesteps.Thisisthestartofit,sincetexturesmakeour3Dworldgoround.Thereismoregroundtocoverthatwillhelpshedtheproverbiallightonthesubject.
Whyisworkinginlinearspaceimportant?Wehavealreadyseensomeearlyexampleofwhyusingalinear,orgammacorrectedworkflowisimportant.Wecanseethatrendersthatareproperlytransformedandwhenourlinearlightisaccountedfor,thatourrenderslookmoreaccurate.Achievingthislightinglevelwithoutusingagammacorrectedworkflowispossible.However,weneedtopushwaymorelightenergyintotherenderssothattheGIcanbouncetheraysaroundmore.Whenthathappenswehavelongerrendertimes.Generallyspeaking,rendertimesare3‐4xlongerwhenmakingadjustmentstolightingscenariosinordertoaccountforwhatwe“want”toseewhennotworkinginalinear,orgammacorrectedmanner.Goingevenfurtherdowntheoutputpipeline,compositingandcolorcorrectingisaffectedbyusingalinearworkflow.Thisisbecauseifwedon’tworklinearly,wecolorcorrectourdatainanon‐linearmanner.Thiswillresultinwildlyinaccuratevaluesforsomethinglikebrightness(orgain/multiplyincompositingterms).Hereisaflowchartofwhattheprocessshouldlooklike.
Manypiecesofsoftwaremakeafewassumptionsbasedonthefileformatandthebitdepthoftheimage.AcompositingapplikeNukeassumesthatifyouhavesavedyourdataasaformatlikeopenEXR,thatyouareworkingwithlineardataandthatanygammaisonlybeingcorrectedbythedisplay,whichNukedoesinitsframebuffer.Italsoassumesthatifweworkwith8bitdata(jpg,png,tga,etc)thatwehave(ortheapplicationhas,rather)bakedinthesRGBgammaandneedstotakeoutthegammatomaketheimagelinearagain.
Hereistheresultoftakingourcorrectimageandturningupthebrightness(gain)by3x.
Wecanseethatthebrightsarereallybrightandthemidtonesaremuchbrighteralso.Thatimagehadnogammaappliedtoitwhenitwassavedoutonlytheviewingsystemappliedthegamma.Now,let’ssaythattheimagedidhavegammabakedintoit.Thesame3xbrightnesswouldlooksomethinglikethis:
Visually,wecantellthatthisimageisnotright.Everythingismuchtoobrightandthevalueswehadbeforearenot3xbrighter.Theyaremuchbrighterbecausewe’renowdoinganon‐linearcolorcorrection.Wealwayswanttodolinearcolorcorrectionbecauseit’smuchmoreaccuratetowhathappenstovaluesintherealworld(linearlight,remember?)versuswhathappenstodataintheCGIworld(nonlinear).So,nowthepointcomeswhereweneedtosaveoutourimagery.Hereisthecompletedflowchartofhowa3Drendergetshandledbycompositingsoftwarethatisawareandmanagesgammaandlinearworkflow:
Hereit’sevidentthatwritingoutto,andreadingfromanonfloatingpointformatisthebigdifferentiatortotheworkflow.However,whilethesekindsoffilesaregamma(sRGB)encoded,thesoftwaremakesaccountsforthemontheinputandtheoutput.Evenontheweb,thebrowsersassumethatimageshavebakedinsRGBcurvestothem.It’sfunnytothinkofwebbrowsersbeingcompliantwithcolorstandards,buttheyare.
Howtoworklinearlyin3DSMaxusingbuilt‐inrenderersHerewehavethestandard3DSMaxpreferencespanelattheirdefaultsettings:
Weneedtomakeafewchangestoittoworklinearly.Remember,weneedtohaveaviewingLUTandalsocorrectinputdataforthesRGBgamma.Hereisthemodifiedpreferencespanel:
Firstthing’sfirst,weneedtoenablethegammacorrectionandmakesureourgammaissetto2.2.ThisnumberiscloseenoughtosRGBthatwe’rejustgoingtogowithit.NextofcoursewewanttoseethatthegammachangeshaveeffectintheMaterialEditor(fortheshaderballswatches)aswellasthecolorselectors.Thiswaywecanvisuallyseehowourchoicesaffecttheresultingcolors,becauseasweknow,avalueof0.18isactually0.5.Weneedtobeabletoseethatorelsesettingupvalueswillbeverydifficult.Finally,weneedtosettheinputgammaofbitmapsto2.2.Why?Well,rememberweareassumingthat8bitdatahasabakedingammaof2.2.Bysettingtheinputgammato2.2andtheoutputgammato1.0,welinearizetheimagesothatdiffusecolorsgettransformedproperlysotheylookhowweexpectthemtofromoursessioninPhotoshop.
Howtoworklinearlyin3DSMaxusingVRayWe’regoingtoswitchovertoVRaybecauseitoffersreallygreatsupportforlinearworkflows.HereisthebasicVRaycolormappingrollout:
You’llnoticesomegammasetting,andafewcheckboxes.Hereistheresultingpanelafterit’sallsetup.
What’simportanttonoteisofcoursethegammasettingof2.2butalsothecheckboxfor“adaptationonly”.ThisisbecauseofcoursewewanttolettherendererworklinearlybutitbecameapparentthatifwewerenotsamplingatsRGBgammathatalotofnoisewouldgounnoticedbytherenderer.Why?Well,it’stimetobreakoutthecalculatorsagain.Let’ssayweputanoisethresholdof0.005.Thatisaprettyacceptablenoisefloortolookfor.However,theproblemisthatbecausewhilevisuallywe’relookingfor0.005therendererseeslineardata.Thisisonceagainduetothe0.5reallybeing0.18duetothelineargamma.Whenwerun0.005throughthepow(0.005,2.2)wegetavalueof:8.664310539439e‐06.Thisvalueisalotlowerthan.005,sothesamplerwon’tcatchit.Weneedtofigureoutwhatnumber0.005isinthelineargammaworld.Byusingthepowerfunctionpow(0.005,(1/2.2))tolookuppixelvaluesfordecidingonwhentosample,weknowwe’relookingfor0.009.Ofcoursethisisallforeducation’ssake.SinceVRaytakesitallintoaccountwiththesimple“adaptationonly”checkbox,wecansimplyignorethemathifwewantto.
ConclusionsLinearworkflowandunderstandinggammaisaverytrickyproposition.Itactuallyhelpstosometimesgoonfaiththatthenumbersworkaslongaswefollowtheformula.Theshorthandoftheformulaisasfollows:
• Transformalldatagoingintotherenderersothatwehanditlineardata• RenderlinearlyandgammacorrecttheviewingsystemwithaLUT• Outputtofloatingpointfiles(openEXR)forcompositing• Compositingsoftwareshouldaccountforlinearworkflowwithaviewing
LUTthatmatchestheoneintherenderer
Robert Nederhorst � 3/22/09 7:50 AM
Robert Nederhorst � 3/22/09 7:56 AM
Robert Nederhorst � 3/22/09 7:56 AM
Deleted: checkboxlabeled“Linearworkflow”.
Deleted: Seemseasyright?Yep!
Deleted:
• Outputfromcompositingif8bitshouldhavesRGBgammabakedin.Iftherenderisfloatingpoint(openEXR)thenit’simportantnottobakethegammain.
Oncealinearworkflowisstarted,artistsnoticethattheimagerylooksmorephotographicandit’seasiertogettheresultsdesired.Ultimately,that’sthegoalisn’tit?