h16 mantra user guide packed primitives - sidefx · h16 mantra user guide copies of packed...
TRANSCRIPT
H16MantraUserGuide
PackedPrimitives
WhatArePackedPrimitives?PackedPrimitivesareawaytoexpressaproceduretogenerategeometryatrendertime.PackedPrimitiveshaveinformationaboutotherpiecesofgeometryembeddedinsideofthem.Thisinformationcouldbeanactualpieceofgeometrystoredinmemory,areferencetoasmallerpartofanotherpieceofgeometry,orevenapathtogeometrystoredondisk.TheinformationcanthenbeusedthroughoutHoudinitomoreefficientlyrepresentgeometryintheviewport,inthebulletsolver,andinMantra.
TheTypesofPackedPrimitivesPackedPrimitivescan“embed”differenttypesofdataaboutgeometryforuseindifferentscenarios.EachofthesePackedPrimitiveTypeshaveadvantagesandlimitationsandaregenerallytailoredtobeusedinspecificcircumstances.
InMemoryPackedPrimitives
An“InMemory”packedprimitiveisgeneratedby“Packing”thegeometrydirectlyinaSOPnetwork.ThiscreatesaPackedGeometryPrimitivewithanembeddedreferencetothecurrentversionofyourgeometrystoredinRAM.Inpractice,the“embedded”geometryessentiallybecomesasingleun-editable“primitive”withasingletransform.
AdvantagesBecausethe“embeddedgeometry”simplyreferstoapieceofgeometryinmemory,copyingapackedprimitivecreatesacopyofthereferenceratherthanacopyofthegeometryitself.Thismeansthatthereferencedgeometryissharedamongallcopiesofthepackedprimitive.ThisstandsincontrasttocopyingstandardHoudinigeometry,whichcreatesduplicatesofallpoints,primitives,etc.,intheoriginalpieceofgeometry.
H16MantraUserGuide
Copiesofpackedprimitivesuselessmemory,aresimplertotransform,andcanbedrawnmoreefficientlyintheviewportorrenderedbyMantra.Additionally,becausethegeometrycanexistinatraditionalSOPnetworkbeforebeingpacked,youcaneasilygenerateproceduralgeometrywhichadaptstoyourscene,usestampingtogeneratevariationsofyourpackedgeometry,ormakeinteractiveeditstoyourgeometrywhileviewingtheresultslive.Essentially,workingwith“InMemory”PackedPrimitivesisamoreinteractiveanduser-friendlyversionoftraditionalinstancingworkflows.Individualcopiesofan“InMemory”PackedPrimitivecanalsobe“Unpacked”inaSOPnetwork,loadingthereferencedgeometryintomemory.ThisallowsyoutogenerateproceduralworkflowswhichareahybridoftraditionalHoudinigeometryandPackedGeometryPrimitives.
AHelpfulReminder“Packing”geometryhasanassociatedmemorycost.SinceyouarestoringtheoriginalpieceofgeometryinRAMaswellasthememoryoverheadforthe“InMemory”PackedPrimitiveitself,asinglepackedprimitiveisnotnecessarilyanymoreefficientthantheoriginalpieceofgeometry.Thebenefitof“InMemory”PackedPrimitivescomesfromtheefficientrepresentationoflargenumberofcopieswherethereferencedgeometrycanbeshared.
H16MantraUserGuide
Thisisimportanttorememberwhencopy-stampingpackedgeometry.Ifeveryinstanceofyourpackedgeometryisunique,thenyouwillnotreceiveanyofthememoryorperformancebenefits.Infact,inthisscenarioyouwillusemorememorythanusingstandardHoudinigeometry,sinceeachpackedprimitivehasitsowndataontopoftheembeddedgeometry.TIP:It’spossibletosomewhatoffsetthecostofpackingstampedgeometrywhentherearelimitednumbersofstampedvariationsusingthe'cachestamping'parameter-seethehelpfortheCopySOPformoreinfo.
PackedDiskPrimitivesA“PackedDisk”Primitivehasanembedded“path”toafileondiskratherthanareferencetoapieceofgeometrystoredinRAM.Generallyspeaking,“PackedDisk”primitivesarestandardHoudiniGeometrywhichhavebeenwrittentodiskasa.bgeo,or.bgeo.scfilethenloadedintoHoudinithroughaFileSOPasa“PackedDiskPrimitive”.A“PackedDisk”primitivebehavesinaverysimilarfashionto“InMemory”PackedPrimitives,the“embedded”geometryisrepresentedasasingleun-editableprimitivewithasingletransform
AdvantagesMuchlikethe“InMemory”packedprimitives,a“PackedDisk”primitiveisanexcellentchoiceforefficientlyrepresentingcopiesofgeometryintheviewportandinMantra.Copyinga“PackedDisk”primitivecreatesacopyofthepathtothegeometryondiskratherthanaduplicateofthegeometryitself.Anotheradvantagesharedbetween“InMemory”and“PackedDisk”primitivescomesfromhowthegeometrycanberepresentedintheviewport.Theviewportdoesnotcopythegeometry,butsimplydrawsitmultipletimeswithdifferenttransforms.Thismeansthattheviewportcanalsorefertoasmallersubsetofthereferencedgeometryanddisplaythatinstead.
H16MantraUserGuide
Since“PackedDisk”primitives,bytheirnature,areloadedfrompre-generatedgeometrystoredondisktheyarelessdynamicthan“InMemory”packedprimitiveswhoseembeddedgeometrycanbegeneratedprocedurally.Theonlywaytomakeeditsto“PackedDisk”primitivesisto“unpack”them,howeverthiscausesthegeometrytobeloadedintomemoryasstandardHoudinigeometry,negatingthebenefits.Inthissense,“PackedDisk”primitivesarelessflexiblethan“InMemory”packedprimitivesandbestusedforstaticgeometry.However,thereareseveraladvantages“PackedDisk”primitiveshaveover“InMemory”packedprimitiveswhenusedatrendertime.WhengeneratinganIFD(AfilewhichcontainsacompletedescriptionofasceneandhowtorenderIt.),a“PackedDisk”primitivecanberepresentedsimplyaspathtothefileondisk.Incontrast,an“InMemory”primitivemusthavetheentirepieceofGeometrycopiedintotheIFDinordertobereferencedbyMantra.BothofthesemethodsaresuperiortostandardHoudinigeometrywhichmustincludeallofthegeometryaswellasalloftheduplicatesofthegeometryintheIFDfile.
H16MantraUserGuide
H16MantraUserGuide
Additionally,Mantraneverhastoloadintomemorya“PackedDisk”primitivewhichisn’tcurrentlybeingusedtorenderthescene.Instead,“PackedDisk”geometryisstreamedintothescenewhennecessaryandthenunloadedwhennolongerinuse.Thismeansthatsinglecopiesof“PackedDisk”primitivescanstillbeusefulatrendertime,savingmemoryintheIFDfile,aswellasreducingtheamountofgeometryMantraneedstoloadatanygiventime.Thelightweightrepresentationof“PackedDisk”primitivesmakesthemidealcandidatesforsceneassembly,especiallyforstaticbackgroundobjects.Thatsaid,theverysmallmemoryfootprintintheIFDfilealsomakesthemveryusefulforobjectswithlargeon-diskfootprints.(LikeFluid,Smoke,orRBDsimulations).
PackedFragmentsA“PackedFragment”primitiveisgeneratedby“Packing”somepieceofgeometryalongwitha"nameattribute”.Eachpieceofthegeometrywithaunique“nameattribute”willbecomea“PackedFragment”primitivewithanembeddedreferencetothe“complete”pieceofgeometrywhichissharedacrossall“Fragments”.Inpractice,each“Fragment”essentiallybecomesasingleun-editable“primitive”withasingletransform.
H16MantraUserGuide
Advantages“PackedFragment”primitivesareidealforrepresentingmanypiecesofagreater“complete”pieceofgeometry.Each“Fragment”referstosomesubsetoftheembeddedgeometrywhichissharedacrossall“Fragments”.When“Unpacked”,onlythesmallersubsetofgeometrywillbeloadedintomemory.Additionally,becauseeach“PackedFragment”representsasinglereferenceandatransform,theyareusefulforcaseswhereeach“Fragment”willreceivesomeuniquetransformationsuchasaRigidBodySimulation.ThisstandsincontrasttostandardHoudinigeometrywhichdoesnotshareitsgeometry,soeachindividualpiecemustbeconsidereditsownobject.
H16MantraUserGuide
“PackedFragment”primitivesuselessmemory,aresimplertotransform,andaremoreefficientlydisplayedintheviewport.
H16MantraUserGuide
AHelpfulReminderEach“PackedFragment”containsareferencetothelargerpieceofembeddedgeometrystoredinmemory.Whenyouhavemany“Fragments”,thisisaveryefficientwayofrepresentingthegeometrybecauseeach“Fragment”onlyreferstoasmallsubsetofthesharedGeometry.However,ifyouweretodeletemanyofyourfragments,leavingonlyasmallnumber,each“PackedFragment”isstillreferringtotheoriginal“complete”pieceofgeometrywhichisstoredinmemory.Thiscanpotentiallymeanalargeamountofmemoryoverheadwhichisnolongernecessary.Consider“Unpacking”yourfragmentswhenyouhavemuchfewer“Fragments”thanintheoriginalpieceofGeometry.
RenderingPackedPrimitivesPackedPrimitivesareextremelyusefulforrenderinginMantra.Ingeneral,theproperuseofpackedprimitiveswillallowyoutoincreasethespeedofyourrendersaswellasreducetheoverallamountofmemoryneeded.Additionally,IFDgenerationwillbefasteranduselesson-diskmemory.However,itisimportanttounderstandhowMantradealswithPackedPrimitivesandthedatastoredinsideoftheminordertotakefulladvantageofthematrendertime.
MaterialAssignmentWithstandardHoudinigeometry,Materialassignmentcanoccurattwolevels–theobjectlevel(OntheobjectNode),ortheprimitivesinsideoftheobject(UsingaMaterialSOP).Materialsassignedat“lowerlevels”overridematerialsinthehigherlevels.Whensendingascenetoberendered,itisfirstanalyzedtoseewhichmaterialswillactuallybeneededinthefinalrender.Houdinicheckstheobjectsforanymaterialassignments,alongwithanygeometryattributeswhichapplymaterials,thenmakessuretoincludetheappropriateShadersintheIFDfile.
H16MantraUserGuide
WhenusingPackedGeometry,thisprocessismademorecomplexbyaddingathirdlevelofmaterialassignment–materialsassignedbyattributesinsidethePackedPrimitive.Likethepreviousexample,materialsassignedat“lowerlevels”overrideMaterialsinthehigherlevels.However,inthiscase,whenthesceneissenttoberendered,thematerialassignments“inside”thepackedprimitivesarehiddenfromHoudini.(RememberthePackedGeometrymaysimplyrefertoanobjectondisk).ThismeansthatHoudiniwillbeunabletoaddtheappropriateShaderstotheIFDfileforuseatrendertime.Duringrendering,Mantrawillunpacktheobject,findthematerialassignment,butitwillnothavethenecessaryShaderstoapplytotheobject.
ThesolutiontothisproblemistotellHoudinitoincludetheShadersintheIFDregardlessofwhetherornottheyhavebeenassignedtoanyobjectsorprimitives.OntheMantranode,thereisanoptioncalled“SaveAllSHOPS”whichwillembedallShadersinyoursceneintheIFD.(Thiswillincreasetheon-disksizeofyourIFDbyasmallamount).Thisway,whenMantraunpacksthegeometryatrendertimeandfindsthematerialassignment,thenecessaryShaderswillbeavailable.
H16MantraUserGuide
Ingeneral,whenworkingwithPackedGeometry,itisimportanttorememberthat“packed”dataisonlyaccessibleonceithasbeenunpacked.Formoreinformationaboutassigningshadersandoverridingshadingparameters“inside”PackedGeometry,pleaseseethedocumentationonMaterialStyleSheets.
DisplacementandSubdivisionSurfacesIngeneral,whenusingPackedGeometry,displacementshadingandsubdivisionsurfacesarehandledinthesamewayaswithanyotherpieceofgeometry.However,ifyouareprimarilyusingyourPackedGeometryasinstancedgeometry,thensomecaremustbetakentogetthemostoutofyourworkflow.Beforerenderingadisplacedorasubdividedsurface,thegeometryis“diced”intosmallerprimitivessuchthattherewillbeoneprimitiveforeverypixel(withshadingqualitysetto1).Thismeansthatobjectsclosertothecamerawillbedicedmorethanobjectsinthedistance(whichhavelesspixelcoverage).However,forinstancing,thiscancauseaproblem.Asdiscussedpreviously,thebenefitofinstancingcomesfromthefactthatgeometryissharedacrossallinstances.Inthecaseofdisplacementsorsubdivisionsurfaces,theobjectsmustbeevaluatedanddicedindividuallywhichmeansthegeometryisnolongerbeingshared.Toavoidthisproblem,thereisarenderingpropertywhichcanbeaddedtotheobjectcontainingyourinstances–“vm_sharedisplace”.EnablingthisparameterwilltellMantratousethehighestlevelofdicingneededforthesceneononeobjectandthensharethedicedgeometryacrossallinstances.Keepinmindthatthismeansthatobjectsfarawayfromthecamerawillhavethesamelevelofdicingasobjectsveryclosetothecamera.Thereissomepotentialforthistocauseproblemsinyourrenders,however,thebenefitsofinstancingthegeometrymostlikelyoutweighanydownside.
H16MantraUserGuide
Intheworstcasescenario,where“incorrect”dicinglevelscauseproblemsinyourrendering,youcould“split”yourinstancesintotwoobjects,foregroundandbackground,sothatdistantobjectsareevaluatedseparatelyfromnearbyones.Alternatively,youcouldalsounpackanyobjectsclosetothecamera,essentiallyremovingthemfromtheinstancinghierarchy.