You are on page 1of 16

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com HDRIandMentalRay+RenderPasses DigitalMediaClub(www.dmcscad.com)April2,2008 Inmylastlecture,IsharedwithyouthepracticalapplicationofphotographyandhowtoobtainHDRIs usingphotographictechniques.ThistimeIwillbetalkingabouttheimplementationofHDRIinaMaya sceneandsometricksthatIhavelearned.Aswitheverythingelse,therearenumerouswaysofdoing things,andwhatIplanonshowingyouisonewaythatworkedforme.ThePasseswewillcreateusing onlyanHDRItolightoursceneare: Diffuse Specular Shadow Reflection Ok,soyouhaveanobjectthatyouwanttouseHDRIwith.Letstalkabouthowtogoaboutdoingso.

so. Firstthingsfirst,letsopenoursceneandgetourobjectintoview.(YesthatsWootyouseeonmy screen).

Figure1

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com Ithinkthefirstandmostimportantthingtodoistomakesurethatthedefaultlightingisturnedoffin therendersettings.YoudontwantthismuckingupyourHDRlitscene.Alsomakesurethatyoure usingMentalRay.(Figure1.1)

Figure1.1 Okmovingon.Whatsnext?OhIknow!SomeHDRIsweetness!Thatsright!LetsfindtheIBLsettings, opentherendersettings(Figure1.2.1).YouseetheMentalRayTab?Innotchangeyourrendererto Mentalray(Figure1.2.2).Clickthatandthenmovedowntotheenvironmentlineattheverybottom andexpandthelinebyclickingonthearrow.SeethebuttonnexttoImageBasedLightingcalled Create;clickthat(Figure1.2.2).Guesswhatwegetnow?Wegetashinynewenvironmentsphere andawholetonofnewoptionsintheAttributeeditorfortheIBLNode.Letstalkaboutthenextmost importantpart,whichisgettingyourimageontothesphere.JustclickonthefolderIconnexttothe imagenameandloadupyourLightMap.OnceyourLightMapisloadedupitmayormaynotlook weird.Ifitdoeslookfunnyitsmostlikelybecausetheimageyouloadedupwasthatofachromeball. BydefaulttheMentalRayIBLnodeisnotsettohandlethisproperly.ItissettohandleaLat/Longfile whichhasa2:1aspectratioandisbasicallyasphereunwrappedflat.Tofixthissimplychangethe Mappingatthetoptoangular.(Figure1.2)

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com

Figure1.2.1

Figure1.2.2

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com

Figure1.2.3 Oknowwehaveourlightmappluggedletstalkabouttherenderstatssection.Sinceweareonlygoing tousetheIBLnodetoEmitlightandnothingelse,weneedtoturnoffsomestuffinhere.Firstweneed to:turnoffPrimaryVisibilitysothatwedontseeourlightmap,turnoffVisibleasEnvironmentsothat itsnotvisibleinPrimaryReflections,turnoffVisibleinSecondaryReflectionsandRefractions.Lets leavevisibleinFinalGathereventhoughwewontbeusingitinthistutorial.Mightbefunforyouto experimentwith!(Figure1.3)

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com

Figure1.3 Ifyouhavepressedrenderatalluptothispointandgotonlyblackdontworry,thatsok.Since presentlywearentusingfinalgather,wearentusingreflectionsfromourlightmap.Sincewedisabled defaultlightingwehaveeliminatedanyilluminationoradditiveprocessinthescene.So,letsaddsome back!GototheIBLnodeattributeswhichshouldstillbeopeninyourattributeeditorandexpandthe LightEmissionPart.NowIpersonallyamnotclearonwhatallthesettingsinherebecausequitefrankly thereisntalotofdocumentationonthesubjectandwhatdocumentationthereis,islacking.Icanguide youthroughtheimportantstuffthough.(Figure1.4)

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com

Figure1.4 First,clickthecheckboxthatsaysemitlightandjustlikethatwehaveturnedonthecomplexprocessof emittinglightfromanimage.Itsalldownhillfromherenowait,uphillImean.Findingthosemagic numberscanbefrustrating.ThefirstthingyouaregoingtodoissetyourQualityU/Vtothesizeofyour LightMap.ThisjustsetsupAcontrolTextureforlightemission.EveryPixelinthattexturevirtually representsadirectionallight.MayaHelpDocs.Thesenumberscangreatlyincreaseorreduceyour rendertimessotreatthemwithcare.NextwehavetheSamples,andIthinkthebestexplanationcomes fromthehelpdocsagain;Samplingalldirectionallightsrepresentedbythecontroltextureisoften prohibitivelyexpensive.Thereforetheshaderhasabuiltinimportancemechanismthatattemptsto selecttheprimary(key)lights.MayaHelpDocs.BasicallywhatIhavefoundisthatincreasingthese numbersincreasesyourrendertimebutalsoincreasesthequalityofyourshadowsandlight.Varyfocus willoffsetthedirectionofallyourdirectionallightsrandomlyandimprovequality.Lastbutnotleast, disablebacklightingwhichshouldonlybeuncheckedifyouhavesomethinginyourscenethatis transparentlikeglassthatgreatlyoptimizesthesamplinginyourscene. Whew,Ithinkthatcoversmostoftheimportantstuff!Ithinkeverythingelseisprettyselfexplanatory, butthebestwaytolearnistojuststartclickingsomestuffandgetyourhandsdirty!Seewhatcomesof it!(Figure1.4)

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com Ok,letsgetthelastthingsetupsothatwecangetintotherenderpassespart.Ifyouhavenoticedby nowwehaveeverythinginourbeautypassexceptforreflections.Addingreflectionsrequiresyouto createapolygonsphere.Aftercreatingthepolygonsphereyouwillscaleittoaboutthesamesizeas theIBLNode,andapplyasurfaceshadertothesphere.Afterapplyingthesurfaceshadertothesphere youneedtogototheoutcolorofthesurfaceshaderandclickthecreaterendernodebuttonthatlooks likeacheckerboxnexttotheattribute.(Figure1.5)

Figure1.5 Atthispointitsimportantthatyourreflectionmapisalat/long.Ifitisnt,youcaneasilyfixthiswith HDRshopbyjustlookinguppanoramictransformations.ThisisbecausetheIBListheonlyplacethatI havefoundthatsupportsAngularmappinginMentalRay.Anyway,onceyougetthecreaterender nodedialogboxmakesureyouchooseasprojectionandthenclickfile.Afterthatintheattribute editorforyourshader,changetheProjectiontypetoSpherical.Nextselectyourlat/longandnowwhen yourenderyouwillhavereflections.Youmightnoticethatyouseeyourreflectionmapinthe background;thisisaneasyfix.Selectthepolygonsphereandpulluptheattributeeditorandgoto renderstats.Turnoff:Primaryvisibility,CastShadows,ReceivesShadows,DoubleSidedandclick opposite.NowyouhaveaspherethatonlycontributestoReflectionandRefraction,nothingelse.

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com

Figure1.6 Dang.ThatsalotjusttogettheHDRIlightingsetup,sonowweshouldbreakitdown.Myapproachto thisproblemwas,Ithink,relativelysimple.IfyouthinkofusingEmitlightintheIBLnodeasthesame thingasmakingatonofspotlightstheneverythingwillmakesense.(Figure1.6) DiffusePass Forthediffusepass,allwehavetodoiseliminateeverythingexceptforthediffuserays.Todothiswe havetocreateanewrenderlayer.Makesurethatyoucreateanemptylayer(dontusetheaddselected geometrytorenderlayerthisbuttoncanbebuggy).Afterwhichyoucanselecteverythingthathas diffuseinitandrightclickandaddtothatlayer.Makesurethatyoudontaddthereflectionsphere,not thatitreallymatters,butitwillhelpinkeepingyoursceneclean.Next,rightclickonyourrenderlayer andgototheattributesofthatlayer.TurntheOverrideonfor:CastShadows,ReceivesShadows,Visible inRefractionsandReflections.NextgototheattributesfortheIBLnodeandunderEmitLightUncheck: EmitSpecularandRaytraced.Youshouldhavesomethinglikebelow.(Figure1.7)

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com

Figure1.7 Afterthatyoushouldgetarenderthatlookssomethinglikethiswithonlydiffuseinformationinthe image.Asyoucanseewehaveseparatedoutthediffuseinformation.(Figure1.8)

Figure1.8

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com Specular Thisisprettymuchthesamestuffasbefore,socreatearenderlayerandcallitSpecular.Onceagain addeverythingtothislayerthathasSpecularinformation.Alsowewanttosetupthislayerthesameas thediffusepass.Afterthatssetup,gobackintotheattributeeditoroftheIBLnodeanduncheckEmit DiffuseandCheckEmitSpecular.(Figure1.9)

Figure1.9 NowPressrenderandyoushouldgetsomethinglikebelow.(Figure2)

Figure2 Shadow Nowtothefunpart,separatingouttheshadows.Onceagaincreateanewrenderlayerandadd everythingtothescenethatreceivesshadows.OntheAttributesforthislayermakesurethatyouleave

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com castandreceiveshadowaloneon,turnoffreflections(thisalsomightnotmatter,butbettersafethen sorry).OnceyouvedonethatgobacktotheEmitLightoptionsintheIBLnodeandturnmakesurethat Emitdiffuse.NextgototheHypershadeandcreateaUseBackgroundShader.Intheusebackground shadersetSpecularcolortoblack,Reflectivityto0,andReflectionlimitto0.Leaveshadowmaskwhite. Lastly,whileyouhavetheshadowlayerselected,rightclickontheUseBackgroundShaderyoujust createdandselectAsignMaterialOverride.Noweveryobjectinthislayerwillhavethisshaderapplied inthislayer.(Figure2.1)

Figure2.1

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com Afterallofthathitrenderonandyoushouldgetanimagethatlookssomethinglikethisinyouralpha channel.(Figure2.2)

Figure2.2 Almostdonejustalittlemore.Thisnextoneshouldbeinteresting! Reflections SoinitiallyImustsaythatthereisaproblemwithmymethodofdoingwhatwearegoingtodonext. Youmaynoticethattheonlykindsofreflectionsyouwillreceiveareglobalreflectionsoronesfromthe HDRI,butnotfromthegeometryitsself.Idevelopedmyownprocessforthis,butitishighly impractical.IamgoingtotrytoavoidbringingthisupandinsteadwillshowyouanotherprocessthatI foundonlinefromsomeonemuchsmarterthanmyself.SinceReflectivityisanadditiveprocesswe dontneedlightsfortheShadertointeractwithHDREnvironmentmap.Soletssetitupourreflections. Createanewrenderlayer.FormyteapotsceneIonlywantreflectionsontheteapotsthemselvessince thegroundplainisntreflective.So,Ihaveonlyaddedtheteapotstomyrenderlayer.Nextremember thereflectionspherewecreatedearlier?Timetoputittouse!Selectthereflectionsphereandaddthat tothereflectionlayer.GototheattributesofthereflectionlayerandturntheOverrideOnforCast ShadowandReceiveShadow.Lastbutnotleast,gototheIBLNodesettingsandturnoffEmitlight. (Figure2.3)

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com

Figure2.3 Nowpressrenderandyoushouldgetsomethinglikethis.(Figure2.4)

Figure2.4 Seetheproblem(Figure2.4)?Ido!Howtofixthis?Wellthereare2waystogoaboutthisthefirstwayI willtrytoexplainasclearlyasIcanandthesecondwayIwillleaveituptoyoutogotoanotherwebsite forthetutorial. Thefirstwayistocreateanewrenderlayer.Inthislayeryouneedtoaddeverythingjustasifitwasa beautypass.Onceyouhavedonethatyouneedtoselecttheobjectthatisgoingtoreceivereflections forthispass,andaassignablinnmaterialtoit(thiswillbeourreflectionshader).Nowopenthe

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com shadersattributesset:Colortowhite,Diffusetoblack,Ecentricityto0,Reflectionto1andSpecularity towhite(courtesyofBridgetGaynor).Selecteverythingelseinthesceneandturnofftheprimary visibility.Thisshouldgiveyouanicereflectionbutwithoutselfreflection(Figure2.5).Ididmanageto conquertheproblemofnoselfreflectiononapreviousprojectbutinacrudeway.Ifyouwhereto duplicatethegeometrythatyouhavethereflectionshaderon,placetheoriginalshaderbackonitonit andjustturntheprimaryvisibilityoffontheduplicationyouwillgetyourselfreflections.(Figure2.6)

Figure2.5

Figure2.6

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com Thesecondwaywasdonebysomeonemoreadeptthanme.Byusingsomeofthenewproduction shaders,thatareunsupportedcurrentlybutcanbeunlocked,wecanremedythesituation.Iamnot goingtogetintoexplaininghowtodothisinmytutorialbutifyougoto http://www.djx.com.au/blog/category/tutorialsandgetalltheinformationyouneedfromthisamazing dude!

Figure2.7

BrendanFitzgerald www.crazy8studio.com Brendan@crazy8studio.com Wellthataboutdoesit!Belowisafinalcompositewithalltherenderpassesthatwecreatedhereplus aOcclusionPass.Ifyouhaveanyquestionspleasefeelfreetocontactmeaswitheverythingthereis alwaysmoretocover.Hopefullythishelpedandyoulearnedsomethingnew!Rememberbecreative whentryingtocomeupwithdifferentrenderpassesandkeepthinkingoutsideofthebox.Thereis alwaysananswer.(Figure2.8)

Figure2.8 Specialthanksto: AlTorres KirtWitte CecilyKamps(Girlfriend/Editor) BridgetGaynor(DigitalLightingandRenderingisagreatclass!) AndRemembertheDigitalMediaClubmeetseveryweekonWednesdayinMontgomeryRoom223 from89pm! www.DMCscad.com

You might also like