Download - Maya Bokeh Lens Shader
BokehLensShaderbyAshAiadAutodeskMediaandEntertainmentDivision
BokehisaJapanesewordfor“blurredorfuzzy”(暈け)
Thisisareallifephenomenonthatoccursinphotographywherethelightsourcesinanoutoffocusareaofanimage.DifferentlensBokehproducesdifferentaestheticqualitiesinoutoffocusbackgrounds,whichareoftenusedtoreducedistractionsandemphasizetheprimarysubject.Forsomereallifeexamples,pleasevisittheBokehpageontheWikipedia.
WecansimulatethesameeffectinMayausingtheBokehLensShaderinmentalray.ThisistherenderwithoutusingBokehasourstartingpoint.
Before
After
OncementalrayBokehLensShaderisbeingappliedtoMaya’sCamera,itwillproducethefollowingeffect,andmuchmore!
TableofcontentTableofcontent........................................................................................................................................... 1
HowtosimulateBokehLenseffectinMaya ............................................................................................... 2
AssignLensshadertoCamera ................................................................................................................. 2
UnderstandingBokehLensshader .......................................................................................................... 3
AdvancedBokehEffect ............................................................................................................................ 8
HowtosimulateBokehLenseffectinMaya
AssignLensshadertoCameraWestartbyselectingthecameraofchoice,andundertheattributeeditorofthatcamera,clickon“LensShader” toassignamentalrayLensShader.
Under“CreateRenderNode”dialog,openthe“Lenses”verticaltabandlocatethemia_lens_bokehShader.
BydefaulttheBokeheffectwilllooksomethinglikethis
Note:TheShaderparametersrelyonthescenesize,thereforeresultswillvaryfromonefiletotheother.
UnderstandingBokehLensshader
On:Thisisatoggleon/offswitchtodisabletheShaderifneeded.Defaultison.Youcanapplyanrenderlayeroverridetodisabletheshaderforspecificrenderlayers,forinstance.
Plane:Isthedistancetothefocalplanefromthecamera,i.e.thepointofinterest.Thispointwillbeinfocusandtherestwillbeoutoffocus.
TogettheproperPlanevalue,wewillusethemeasuringtooltogiveusthatdistancefromthecameratothepointofinterest.
YoucanalsousethecameraNear/FarClippingplaneasamethodtodeterminethedistancerequired.
Withaplanevalueat18.8
Withaplanevalueat8.7
Radius:Thisistheradiusofconfusion.Thisisanactualmeasurementinsceneunits.Avalueof0willresultwithNoBokeh.Thehigherthevalue,thefurtherawaytheBlurwillaccrue.
Fromlefttoright,Radiusat1.0,0.5and0.0
Samples:Themoresampleswehavethebetterthequalityofthe“blur”,howeverthatcomeswiththeexpenseofrendertime.
Fromlefttoright:Sampleat0,24and48
Bias:Lowervaluespushthesampleprobabilitytowardsthecenter,creatinga"softer"lookingDOFeffectwithamore"misty"look.Highervaluespushthesampleprobabilitytowardstheedge,creatinga"harder"lookingDOFwherebrightspotsactuallyresolveassmallcircles.
BladeCount:Thisdefineshowmany"edges"the"circle"ofconfusionhas.Azerovaluemakesitaperfectcircle.Noticetheshapeofthehighlightintheblurredareaoftherenderedimage.
Withbiasat0,noticehowtheblurredhighlightsareperfectcircle.
Withbiasat4,noticethe4cornersintheblurredhighlights.
BladeAngle:Onecanalsosettheanglewiththeblade_angleparameter,whichisexpressedfrom0.0to1.0where0.0iszerodegreesand1.0is360degrees.Theeffectwillbemorenoticeablewhenyouhavehardcornerhighlight(forexample,avalue4orgreater).
WithBladeAngleat0(0degree)
WithBladeAngleat0.25(90degrees).
AdvancedBokehEffect“UseBokeh”and“Bokehmap”
ThisoptionallowsusinganimageasBokehmap.Whenthisoptionisused,theparameters“bias”,“bladecount”and“bladeangle”havenoeffect.ThemapdefinestheshapeoftheDOFfilterkernel,soafilledwhitecircleonablackbackgroundisequivalenttothestandardblur.Generally,oneneedmoresamplestoaccurately"resolve"acustomBokehmap.
Note:Thesizeofthisimagemapdoesnotcontributetothequalityoftherender.
ThefollowingrenderedimagesdemonstratedifferentcustomBokehmaps.