chapter

H16MantraUserGuide
ABSORPTIONANDNESTED
DIELECTRICS
ABSORPTION
Whenlighttravelsthroughatransparentmediumsuchasglass,thematerialabsorbsacertainamount
oflight.Thiseffectbecomesmoreobviouswhenthetransparentmediahasbeentintedorcoloredin
someway,likestained-glassorfruit-juice.
WhenrenderingwithMantra,thiseffectcanbesimulatedinvarietyofways–usingavolumeto
attenuatelightasittravelsthroughanobject,forinstance.However,forsimplicity,asetofparameters
whichallowanartisttoquicklyachievethedesiredlookwithouttheneedforcomplexsetupshavebeen
provided.TheseparameterscanbefoundonthePrincipledShader(AswellastheClassicShader).
TransmissionColor
Thecolorwhichwillbeusedtotintarayasitpassesthroughatransparentobject.Itisimportantto
rememberthattheamountoftintingisdependantonboththedistancetherayhastravelledthrough
theobjectandtheAtDistanceparameter.
AtDistance
Thisparameterdetermineshowthetransmissioncoloraffectsarayasittravelsthroughatransparent
object.WhenthedistancetravelledthroughanobjectmatchestheAtDistanceparameter,onehundred
percentoftheTransmissionColorwillbeblendedwiththeresult.Incaseswheretheraydoesnottravel
farenoughinsidetheobjecttoreachtheAtDistancelimit,asmallerpercentageoftheTransmission
Colorisused.Conversely,iftheAtDistancelimitisreachedbeforetherayhastravelledalltheway
throughtheobject,adarkerandmoresaturatedversionoftheTransmissionColorisused.
H16MantraUserGuide
Forsimplicity,imaginethateachraywhichencountersatransparentsurfaceis“tagged”withdatalike
thehitlocation,TransmissionColor,andAtDistancevalue.Whenthisrayhitstheothersideofthe
transparentobject,itcannowusethisdatatocalculatehowfarithastravelledandthereforehowto
applytheTransmissionColor.Eventually,thisraymayhitanopaqueobjectwhereitevaluatesthe
surfaceshaderandcombinestheresultwiththepreviouslycalculatedabsorptioncolor.
Usingthismethod,itispossibletoaccumulateabsorptioncolorsacrossmultiple,non-overlapping,
transparentobjects.(Forasolutiontooverlappingtransparentobjects,seethesectiononNested
Dielectrics)Essentially,theprocessoftaggingarayandcalculatingitscolorcanberepeatedforevery
transparentobjectencountered.Ratherthanreplacingtheabsorptioncolor,thevaluesaremultiplied
togetherbeforebeingcombinedwiththecolorreturneduponhittinganopaqueobject.
H16MantraUserGuide
Itshouldbenotedthataraydoesnothavetoexitatransparentobjectforabsorptiontotakeplace.
Considerthecaseofanopaqueobjectembeddedinatransparentone.Uponenteringthetransparent
surface,therayisstilltaggedwiththerelevantdatatocalculatetheabsorptioncolor.Theonly
differenceisthatthedistancetravellediscalculatedatthepointtheraycollideswiththeopaqueobject
ratherthanuponexitingthetransparentone.
Additionally,thetransparentobjectdoesnothavetobeaclosedsurface-singlesidedsurfacescantake
advantageofabsorptionaswell.Forplaceswherearaydoesnotcollidewithanotherobjectinthe
scene,theabsorptioninformationisdiscardedandthecolorblackisreturned.(Essentiallytreatingthe
one-sidedsurfaceasaninfinitelyDeeptransparentobjectwhichabsorbsalllight)
NOTE:AlimitationofOne-Sidedtransparentsurfacesisthattheabsorptioncolorwillnotbeappliedto
LightObjectsseenthroughtransparentsurfaces.Ifthiseffectisrequired,consideraddingdepthtoyour
transparentobject,orcreatingemissivegeometryasastand-inforyourlight.
ABSORPTIONWORKFLOWCONSIDERATIONS
AtDistanceandScale
WhenapplyingashaderwithAbsorption,itisalwaysimportanttorememberthanthatamountof
absorptionwhichoccursisbasedonthedistancetravelledthroughtheobject.Boththetraveldistance
H16MantraUserGuide
andtheAtDistanceparameteraremeasuredinWorldSpace.Thismeansthatthescaleofyourobject
canhavealargeinfluenceonthefinalrenderedresults.Considerthefollowingobjectswiththesame
shadersettings:
Theexampleaboveillustrateshowimportantitistodoyourlookdevelopmentonanobjectatthescale
itwillberenderedwhenusingAbsorption.Ifyouweretodoyourshadersetupatonescale,butthen
theobjectwasplacedinthefinalsceneatadrasticallydifferentscale,youwillnotgetthesamelook.
AbsorptionandCameraPosition
Asexplainedabove,absorptionworksbytaggingraysthathaveintersectedwithtransparentobjects
withusefulpiecesofdata.Onlywhenarayintersectsasurfacewhichisfacingthecamerawillthis
informationbeConsidered(Thisallowsmantratotrackwhenarayentersanobjectversuswhenit
leavesanobject).However,thisalsomeansthatplacingacamerainsideatransparentobjectwillnot
generatecorrectresults.
H16MantraUserGuide
NoticehowtheTransmissionColorhasbeenlostwhenthecameraisplacedinsidetheobject.Theray
leavesthecameraandintersectswiththeinsideofthesphereasitleavesthetransparentobject-it
neverreceivesinformationaboutwhenitenteredthesphere,soisunabletocalculatethedistance
travelled.
AbsorptionandVolumetricEffects
Absorptionisaverysimplebuteffectivewayofrepresentingtheattenuationoflightthrougha
transparentmedium.However,becauseitisnotatrulyvolumetriceffect,itisnotappropriatefor
representingalltypesoflightingeffects.Insomeobjects,theattenuationoflightiscausedby
particulatemattersuspendedinthemedium,theseparticlescanbothabsorbandscatterlight.Consider
alargefluideffectlikeanocean:
Youcanseethatwhiletheoceansurfacehasarealisticfeelingofdepthusingabsorption,onlythetrue
volumetricrenderingdisplaysthecharacteristiclightscatteringofarealocean.Unfortunately,volumes
arecostlytorender,sosomeconsiderationmustbegiventothequalityofarenderversusthespeed.In
manycases,likeaswimmingpoolorshallowriver,absorptionmaybesufficienttoachievethedesired
resultwithoutalossinquality.
NESTEDDIELECTRICS
Renderingmultipletransparentobjectswhichareembeddedinsideeachotherisacomplextask,both
fromthepointofviewoftherendererbutalsofromthepointoftheoftheartistbuildingthescene.
Considerthefollowingexample:
H16MantraUserGuide
Thesimplestapproachwouldbetomodeleachoftheobjectsseparatelyandsimplyhavethemoverlap.
However,ifyouconsiderhowaraywilltravelthrougheachofthetransparentobjects,itquickly
becomesclearthatyouwillgenerateacascadingseriesofincorrectrefractions.
Tomakemattersworse,notonlywillraysrefractincorrectly,buttherewillbesurfacesinplaceswhere
noneshouldexist(Fluidintersectingtheicecubes,glassIntersectingthefluid).Eachoneoftheseerrors
compoundsthenextcreatingapoorrender.Inthediagramabove,everyreddotisanincorrectly
evaluatedsurface.Thismethodisgoodintermsofworkflow,butpoorintermsoftheresult.
H16MantraUserGuide
Analternativemethodwouldbetomodeleachobjectwithoutoverlaps.Thismeansfittingthefluidto
theglassandcarvingholesinthefluidtomakeroomfortheicecubes.
Unfortunately,thisisnotenoughtocorrectlyrenderthisscene.Inthediagramabove,theBlueDots
indicatewherearaywillneedtotravelthroughcoincidentsurfaces.Torenderthisscenecorrectly,
thosesurfaceswouldneedtohaveaspecialsetofIORvaluestocorrectlytransitionfromonematerial
toanother(Glass,water,andiceallhavedifferentIOvalues).Whilethissetupwouldresultinabetter
finalrender,theworkrequiredisbothtediousanderrorprone.Additionally,precisionerrorsmayarise
fromcompletelycoincidentsurfaces.Tocorrectforthis,youmayrequireasmallgapbetweeneach
material,butthiswillnotgivephysicallycorrectresults.
Thebestsolutionwouldtobesimplyoverlaptheobjects,butsomehowlettherendererknowwhich
objectsshouldhaveprecedenceoverothers.Insomesense,itwouldbelikeaskingMantratoremove
theoverlapsatrendertime.
ThisistheconceptbehindNestedDielectrics.Byprovidinganumberwhichrepresentsthepriorityofa
material,Mantracantrackwhichobjectarayhasenteredandsimplyignoresurfaceswhichhavea
lowerpriority.Toachievethis,thePrincipledShader(aswellastheClassicShader)hasaparameter
calledSurfacePriority.
Simplybysettingthissurfacepriority,Mantrawouldknowbothwhereandhowarayshouldtransition
fromonetransparentmaterialtotheother,correctlycalculatingtheIORvaluesasitgoes.Intheabove
example,theglasswouldhavethehighestpriority,followedbytheice,andfinallythewater.
H16MantraUserGuide
SurfacePriority
Anumericalvaluewhichestablishesanorderofprecedencefortransparentmaterialsinascene.Avalue
of0indicatesthatthesurfacepriorityshouldbeignored.Increasingvaluesindicatelowerpriority.
Considerthissimple2dexample.
Noticethatwhenallcircleshaveequalpriority,theysimplyoverlap,creatingmultipleintersecting
surfaces.However,asthepriorityvalueisincreasedforthegreenandbluecircle,theinteriorsurfaces
areremoved.
In3d,onrefractivesurfaceswithabsorption,theeffectofsettingcorrectsurfaceprioritycanbe
dramatic.
Intheaboverender,boththeredsphereandtheblueboxhavethesamesurfacepriority.Youcan
immediatelyseetheproblemsinboththerefractionandabsorption.Theseproblemsarisebecauseitis
uncleartoMantrawhichsurfaceis“inside”anothersurfaceandthereforeitcannotcorrectlycalculate
theresult.
H16MantraUserGuide
Inthiscase,theredspherehasahigherprioritythanthebluebox(Remember,lowernumbersmean
higherpriority.RedSphere=1,BlueBox=2).Theabsorptionandrefractiononthepartsofthesphere
insidetheboxisnowcorrectanditappearsasifthereisnooverlapbetweenthetwoobjects.Mantra
simplyignoreswhicheverpartsoftheBlueBoxhaveoverlappedtheRedSphere.Thissetupwouldwork
wellforsomethinglikeIceCubesfloatinginWater.
Intheaboveexample,theSurfacePriorityvalueshavebeenswitched(BlueBox=1,RedSphere=2).This
hastheeffectofremovinganypartsoftheredspherewhichoverlappedthebluebox.Thiswouldbean
idealsetupforhavingwaterdropletsrestingonthesurfaceofaglass.
DISPERSION
Inoptics,dispersioncanrefertotheseparationoflightintoitscomponentwavelengthsasittravels
througharefractivematerial.Aclassicexampleofthiseffectisthespectrumproducedbylighttravelling
throughadispersiveprism.
H16MantraUserGuide
WhenrenderingwithMantra,itispossibletosimulatethiseffectusingtheDispersionparameter
includedonthePrincipledShader(AswellastheClassicShader).
Dispersion
Whenthisparameterissettoanon-zerovalue,refractedraysaretaggedwithasinglewavelengthin
thevisiblespectrum.EachofthesewavelengthsmodifytheunderlyingIORcausingtheraystoseparate
astheytravelthroughtherefractivematerial.Thelargerthisvalue,thelargertheseparation.
Becauseeachrayistaggedwithasinglewavelength,itisimportanttohaveenoughsamplesto
representtheentirespectrum.Eachrayisrandomlyassignedawavelength;however,someattemptis
madetoensurethatthevisiblespectrumisuniformlysampledperPixelSample.
Inthefollowingdiagram,youcanseehowasinglePixelsample,with3secondaryrays,willnotbeable
toadequatelycoverthevisiblespectrum.Thiswillalmostcertainlyresultinnoiseinthefinalrenderas
H16MantraUserGuide
eachpixelsamplereturnsarandomdistributionofwavelengths.
However,asthenumberofsecondaryraysareincreased,weseethatmoreofthevisiblespectrumis
representedinasinglePixelSample.Thiswillresultinmoreconsistencypixeltopixelandthereforless
noiseintherender.
H16MantraUserGuide
ThefollowingsequenceofrendersdemonstratehownoisefromDispersionchangeswiththenumberof
secondaryrays.Ontheleft,withonly1PixelSampleand1SecondaryRay,eachpixelessentiallyreceives
arandomcolorfromthevisiblespectrum.Asthenumberofsecondaryraysisincreasedto5,25and
100,thenoisecausedbydispersioniscompletelyresolved.
H16MantraUserGuide
DISPERSIONWORKFLOWCONSIDERATIONS
RemovingNoise
Mostoften,noiseinarenderhastheappearanceofsmallchangesinbrightnessfromonepixeltoits
neighbours.Inthecaseofdispersion,thisgrainylookcanbeamplifiedbytheintroductionofcolornoise
alongsidethechangesinluminance.
Intheaboveexample,botharesimilarlyunder-sampledbuttheimageontherightappearstoexhibit
muchmorenoise.Thisisbecausesmallchangesinbrightnessarefarlessobviousthandramaticchange
incolorcausedbyinsufficientlysamplingthecolorspectrum.
Ifyoulookcloselyatthewhiteareasofthesphere,you’llseeverysimilarnoisepatterns.However,the
imageontherightappearsdramaticallynoisierduetothechromaticnatureofthenoise.Itcanoftenbe
necessarytoincreasetheamountofsamplingonobjectswithdispersioncomparedtosimilarobjects
H16MantraUserGuide
withoutdispersion.Inthefollowingexample,youcanseethatsignificantlymoresamplingwasrequired
toachievesimilaramountsofnoisebetweenbothobjects.
Inthiscroppedversion,youcanseethatthewhiteareasofthespheresnowhaveverysimilarnoise
levelsandpatterns.Thisisbecauseenoughofthevisiblespectrumhasbeensampledtoconvergeback
tothecolorwhite.But,itrequiredalmosttwicethenumberofsamplestoachievethisresult.
Becauseofthisdifferenceinsampling,itmaybeusefultooverrideRefractionQualityparametersonany
transparentobjectwithdispersionenabled.Thiswayyoucanbesurethatyouaresendingextra
refractionsamplesonlytotheobjectswhichrequirethem.