Upload
dominic-alderson
View
255
Download
0
Embed Size (px)
Citation preview
7/31/2019 HDRI and Mental Ray
1/16
BrendanFitzgerald
www.crazy8studio.com
HDRIandMentalRay+RenderPasses
DigitalMediaClub(www.dmcscad.com)April2,2008
Inmy
last
lecture,
Ishared
with
you
the
practical
application
of
photography
and
how
to
obtain
HDRIs
usingphotographictechniques. ThistimeIwillbetalkingabouttheimplementationofHDRIinaMaya
sceneandsometricksthatIhavelearned. Aswitheverythingelse,therearenumerouswaysofdoing
things,andwhatIplanonshowingyouisonewaythatworkedforme. ThePasseswewillcreateusing
onlyanHDRItolightoursceneare:
Diffuse
Specular
Shadow
Reflection
Ok,so
you
have
an
object
that
you
want
to
use
HDRI
with.
Lets
talk
about
how
to
go
about
doing
so.
Firstthingsfirst,letsopenoursceneandgetourobjectintoview.(YesthatsWootyouseeonmy
screen).
Figure1
http://www.dmcscad.com/http://www.dmcscad.com/7/31/2019 HDRI and Mental Ray
2/16
BrendanFitzgerald
www.crazy8studio.com
Ithinkthefirstandmostimportantthingtodoistomakesurethatthedefaultlightingisturnedoffin
therendersettings.YoudontwantthismuckingupyourHDRlitscene. Alsomakesurethatyoure
usingMentalRay.(Figure1.1)
Figure1.1Okmovingon.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.If
it
does
look
funny
its
most
likely
because
the
image
you
loaded
up
was
that
of
achrome
ball.
BydefaulttheMentalRayIBLnodeisnotsettohandlethisproperly.ItissettohandleaLat/Longfile
whichhasa2:1aspectratioandisbasicallyasphereunwrappedflat.Tofixthissimplychangethe
Mappingatthetoptoangular.(Figure1.2)
7/31/2019 HDRI and Mental Ray
3/16
BrendanFitzgerald
www.crazy8studio.com
Figure1.2.1
Figure1.2.2
7/31/2019 HDRI and Mental Ray
4/16
BrendanFitzgerald
www.crazy8studio.com
Figure1.2.3Oknowwehaveourlightmappluggedletstalkabouttherenderstatssection. Sinceweareonlygoing
tousetheIBLnodetoEmitlightandnothingelse,weneedtoturnoffsomestuffinhere.Firstweneed
to: turnoffPrimaryVisibilitysothatwedontseeourlightmap,turnoffVisibleasEnvironmentsothat
itsnotvisibleinPrimaryReflections,turnoffVisibleinSecondaryReflectionsandRefractions. Lets
leavevisibleinFinalGathereventhoughwewontbeusingitinthistutorial. Mightbefunforyouto
experimentwith!
(Figure
1.3)
7/31/2019 HDRI and Mental Ray
5/16
BrendanFitzgerald
www.crazy8studio.com
Figure1.3
Ifyouhavepressedrenderatalluptothispointandgotonlyblackdontworry,thatsok. Since
presentlywearentusingfinalgather,wearentusingreflectionsfromourlightmap. Sincewedisabled
defaultlightingwehaveeliminatedanyilluminationoradditiveprocessinthescene. So,letsaddsome
back! GototheIBLnodeattributeswhichshouldstillbeopeninyourattributeeditorandexpandthe
LightEmissionPart. NowIpersonallyamnotclearonwhatallthesettingsinherebecausequitefrankly
thereisnt
alot
of
documentation
on
the
subject
and
what
documentation
there
is,
is
lacking.
Ican
guide
youthroughtheimportantstuffthough.(Figure1.4)
7/31/2019 HDRI and Mental Ray
6/16
BrendanFitzgerald
www.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.
Therefore
the
shader
has
abuilt
in
importance
mechanism
that
attempts
to
selecttheprimary(key)lights.MayaHelpDocs. BasicallywhatIhavefoundisthatincreasingthese
numbersincreasesyourrendertimebutalsoincreasesthequalityofyourshadowsandlight. Varyfocus
willoffsetthedirectionofallyourdirectionallightsrandomlyandimprovequality.Lastbutnotleast,
disablebacklightingwhichshouldonlybeuncheckedifyouhavesomethinginyourscenethatis
transparentlikeglassthatgreatlyoptimizesthesamplinginyourscene.
Whew,Ithinkthatcoversmostoftheimportantstuff! Ithinkeverythingelseisprettyselfexplanatory,
butthebestwaytolearnistojuststartclickingsomestuffandgetyourhandsdirty! Seewhatcomesof
it!(Figure1.4)
7/31/2019 HDRI and Mental Ray
7/16
BrendanFitzgerald
www.crazy8studio.com
Ok,letsgetthelastthingsetupsothatwecangetintotherenderpassespart.Ifyouhavenoticedby
nowwehaveeverythinginourbeautypassexceptforreflections. Addingreflectionsrequiresyouto
createapolygonsphere. Aftercreatingthepolygonsphereyouwillscaleittoaboutthesamesizeas
theIBLNode,andapplyasurfaceshadertothesphere.Afterapplyingthesurfaceshadertothesphere
youneedtogototheoutcolorofthesurfaceshaderandclickthecreaterendernodebuttonthatlooks
likeacheckerboxnexttotheattribute.(Figure1.5)
Figure1.5Atthispointitsimportantthatyourreflectionmapisalat/long.Ifitisnt,youcaneasilyfixthiswith
HDRshopbyjustlookinguppanoramictransformations.ThisisbecausetheIBListheonlyplacethatI
havefoundthatsupportsAngularmappinginMentalRay. Anyway,onceyougetthecreaterender
nodedialogboxmakesureyouchooseasprojectionandthenclickfile.Afterthatintheattribute
editorforyourshader,changetheProjectiontypetoSpherical.Nextselectyourlat/longandnowwhen
yourenderyouwillhavereflections.Youmightnoticethatyouseeyourreflectionmapinthe
background;this
is
an
easy
fix.
Select
the
polygon
sphere
and
pull
up
the
attribute
editor
and
go
to
renderstats.Turnoff:Primaryvisibility,CastShadows,ReceivesShadows,DoubleSidedandclick
opposite.NowyouhaveaspherethatonlycontributestoReflectionandRefraction,nothingelse.
7/31/2019 HDRI and Mental Ray
8/16
BrendanFitzgerald
www.crazy8studio.com
Figure1.6Dang.
Thats
alot
just
to
get
the
HDRI
lighting
setup,
so
now
we
should
break
it
down.
My
approach
to
thisproblemwas,Ithink,relativelysimple. IfyouthinkofusingEmitlightintheIBLnodeasthesame
thingasmakingatonofspotlightstheneverythingwillmakesense.(Figure1.6)
DiffusePass
Forthediffusepass,allwehavetodoiseliminateeverythingexceptforthediffuserays.Todothiswe
havetocreateanewrenderlayer.Makesurethatyoucreateanemptylayer(dontusetheaddselected
geometrytorenderlayerthisbuttoncanbebuggy). Afterwhichyoucanselecteverythingthathas
diffuseinitandrightclickandaddtothatlayer.Makesurethatyoudontaddthereflectionsphere,not
thatitreallymatters,butitwillhelpinkeepingyoursceneclean. Next,rightclickonyourrenderlayer
andgo
to
the
attributes
of
that
layer.
Turn
the
Override
on
for:
Cast
Shadows,
Receives
Shadows,
Visible
inRefractionsandReflections.NextgototheattributesfortheIBLnodeandunderEmitLightUncheck:
EmitSpecularandRaytraced.Youshouldhavesomethinglikebelow.(Figure1.7)
7/31/2019 HDRI and Mental Ray
9/16
BrendanFitzgerald
www.crazy8studio.com
Figure1.7Afterthatyoushouldgetarenderthatlookssomethinglikethiswithonlydiffuseinformationinthe
image. Asyoucanseewehaveseparatedoutthediffuseinformation.(Figure1.8)
Figure1.8
7/31/2019 HDRI and Mental Ray
10/16
BrendanFitzgerald
www.crazy8studio.com
Specular
Thisisprettymuchthesamestuffasbefore,socreatearenderlayerandcallitSpecular. Onceagain
addeverythingtothislayerthathasSpecularinformation.Alsowewanttosetupthislayerthesameas
thediffusepass.Afterthatssetup,gobackintotheattributeeditoroftheIBLnodeanduncheckEmit
DiffuseandCheckEmitSpecular.(Figure1.9)
Figure1.9NowPressrenderandyoushouldgetsomethinglikebelow.(Figure2)
Figure2Shadow
Nowtothefunpart,separatingouttheshadows.Onceagaincreateanewrenderlayerandadd
everythingtothescenethatreceivesshadows.OntheAttributesforthislayermakesurethatyouleave
7/31/2019 HDRI and Mental Ray
11/16
BrendanFitzgerald
www.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
7/31/2019 HDRI and Mental Ray
12/16
BrendanFitzgerald
www.crazy8studio.com
Afterallofthathitrenderonandyoushouldgetanimagethatlookssomethinglikethisinyouralpha
channel.(Figure2.2)
Figure2.2Almost
done
just
alittle
more.
This
next
one
should
be
interesting!
Reflections
SoinitiallyImustsaythatthereisaproblemwithmymethodofdoingwhatwearegoingtodonext.
Youmaynoticethattheonlykindsofreflectionsyouwillreceiveareglobalreflectionsoronesfromthe
HDRI,butnotfromthegeometryitsself.Idevelopedmyownprocessforthis,butitishighly
impractical. IamgoingtotrytoavoidbringingthisupandinsteadwillshowyouanotherprocessthatI
foundonlinefromsomeonemuchsmarterthanmyself. SinceReflectivityisanadditiveprocesswe
dontneedlightsfortheShadertointeractwithHDREnvironmentmap.Soletssetitupourreflections.
Createanewrenderlayer. FormyteapotsceneIonlywantreflectionsontheteapotsthemselvessince
theground
plain
isnt
reflective.
So,
Ihave
only
added
the
teapots
to
my
render
layer.
Next
remember
thereflectionspherewecreatedearlier?Timetoputittouse!Selectthereflectionsphereandaddthat
tothereflectionlayer.GototheattributesofthereflectionlayerandturntheOverrideOnforCast
ShadowandReceiveShadow. Lastbutnotleast,gototheIBLNodesettingsandturnoffEmitlight.
(Figure2.3)
7/31/2019 HDRI and Mental Ray
13/16
BrendanFitzgerald
www.crazy8studio.com
Figure2.3Nowpressrenderandyoushouldgetsomethinglikethis.(Figure2.4)
Figure2.4Seetheproblem(Figure2.4)?Ido!Howtofixthis?Wellthereare2waystogoaboutthisthefirstwayI
willtrytoexplainasclearlyasIcanandthesecondwayIwillleaveituptoyoutogotoanotherwebsite
forthetutorial.
Thefirstwayistocreateanewrenderlayer.Inthislayeryouneedtoaddeverythingjustasifitwasa
beautypass.Onceyouhavedonethatyouneedtoselecttheobjectthatisgoingtoreceivereflections
forthispass,andaassignablinnmaterialtoit(thiswillbeourreflectionshader).Nowopenthe
7/31/2019 HDRI and Mental Ray
14/16
BrendanFitzgerald
www.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
7/31/2019 HDRI and Mental Ray
15/16
BrendanFitzgerald
www.crazy8studio.com
Thesecondwaywasdonebysomeonemoreadeptthanme. Byusingsomeofthenewproduction
shaders,thatareunsupportedcurrentlybutcanbeunlocked,wecanremedythesituation.Iamnot
goingtogetintoexplaininghowtodothisinmytutorialbutifyougoto
http://www.djx.com.au/blog/category/tutorialsandgetalltheinformationyouneedfromthisamazing
dude!
Figure2.7
http://www.djx.com.au/blog/category/tutorialshttp://www.djx.com.au/blog/category/tutorials7/31/2019 HDRI and Mental Ray
16/16
BrendanFitzgerald
www.crazy8studio.com
Wellthataboutdoesit! Belowisafinalcompositewithalltherenderpassesthatwecreatedhereplus
aOcclusionPass.Ifyouhaveanyquestionspleasefeelfreetocontactmeaswitheverythingthereis
alwaysmoretocover.Hopefullythishelpedandyoulearnedsomethingnew!Rememberbecreative
whentryingtocomeupwithdifferentrenderpassesandkeepthinkingoutsideofthebox.Thereis
alwaysananswer.(Figure2.8)
Figure2.8
Specialthanksto:
AlTorres
KirtWitte
CecilyKamps(Girlfriend/Editor)
BridgetGaynor
(Digital
Lighting
and
Rendering
is
agreat
class!)
AndRemembertheDigitalMediaClubmeetseveryweekonWednesdayinMontgomeryRoom223
from89pm!
www.DMCscad.com