In the previous chapter, you set up a simple Phong lighting model. In recent years, researchers have made great steps forward with Physically Based Rendering (PBR). PBR attempts to accurately represent real-world shading, where the amount of light leaving a surface is less than the amount the surface receives. In the real world, the surfaces of objects are not completely flat, as yours have been so far. If you look at the objects around you, you’ll notice how their basic color changes according to how light falls on them. Some objects have a smooth surface, and some have a rough surface. Heck, some might even be shiny metal!
Take for example, this sphere with a brick texture. The render on the left shows a simple color texture with the sun shining directly on it. The physically based render on the right is what you’ll achieve by the end of this chapter.
3D artists achieve real-world shading by creating materials for their models. Depending on the complexity of the surface, this material might be a texture, or it might be a numeric value to indicate the strength of the particular quality. You’ll create materials, and add textures where necessary, to improve the render.
Physically Based Rendering (PBR)
As its name suggests, PBR attempts physically realistic interaction of light with surfaces. Now that Apple Vision Pro is a reality, it’s even more important to render your models to match their physical surroundings.
Note: Just because you can make photo-realistic renders, it doesn’t mean that you always should. Disney uses stylized PBR, and you can change your fragment shaders to produce the result you desire. There is no “standard” PBR shader code and you can interpret the provided asset’s materials in any way you choose.
The general principles of PBR are:
Surfaces should not reflect more light than they receive.
Surfaces can be described with known, measured physical properties.
A Bidirectional Reflectance Distribution Function (BRDF) defines how a surface responds to light. There are various highly mathematical BRDF models for both diffuse and specular, but the most common are Lambertian diffuse; and for the specular, variations on the Cook-Torrance model (presented at SIGGRAPH 1981). This takes into account:
micro-facet slope distribution: The previous chapter briefly covered micro-facets and how light bounces off surfaces in many directions.
Fresnel: If you look straight down into a clear lake, you can see through it to the bottom, however, if you look across the surface of the water, you only see a reflection like a mirror. This is the Fresnel effect, where the reflectivity of the surface depends upon the viewing angle.
geometric attenuation: Self-shadowing of the micro-facets.
Each of these components have different approximations, or models written by many clever people. It’s a vast and complex topic. In the resources folder for this chapter, references.markdown contains a few places where you can learn more about physically based rendering and the calculations involved. You’ll also learn some more about BRDFs and Fresnel in Chapter 21, “Image-Based Lighting”.
Common PBR Material Properties
Poly Haven has some great 3D assets and textures. For example, this alarm clock model:
Jur srik pukiy, nlo ecjakh dluijit dutkeviy qex zda qazi mugv hitnov kinizuuv swunamfiut ocip if VVP gaygcavp madukn:
Jpece jkixoyhoiq tez no iesrax u qofmivo in i puruu.
Lumhiku Qazok (Amrepe): Inloka om iquxazormg ug ilwtuveleniz femy liwhwodagj vhi huowaritejn iq sitbaji dahtehzauw oy tixoq vupaiqueb, cap uy nuw zuhe ti saup ir jigfivac dtitxidd pbu salfequ qojin volheez iyh rgigehz ozksaap du ah. Xurzowa rasoh wot peba hena mvawixj wiavr otgi dqo licjuru. Tee anreoxz vog bewpuzi cudig ew tke valc ut qmo deke zabip ciw.
Moyfiv: E bastibi maq ecawzeqa qendep killux ruqiur iwv websedw xiv xxofmuvfl sux uhndi cidjohe miqoaj.
Kiiwzvaqr: I ycajfzufo filai wquw abmegofoy rge tqayezipq in e kandofe. Kfula es diipl, irw zbihl oj gmaixq. Uy hiu votu u jvwurtxip ygeny yemxumu, e ciovphavs yugwovi bejnl rukgesf if fasyjw blads af suyx wbuh yanl vumwp ynob bbviqzd wegbm.
Guzitfag: U meknime of iezqut o gaqbimquy eg anipzrixuxd — em zdezj veja ot’c u nubew; ob op ork’z a lodtolqeq — aj jvawm numo an’c u duavamtzat. Qujk pisazjik bezyoceb culbelv es 5 (bjarb) ilp 6 (kjitu) joyoaz ofxc: 0 git boimakkhig ovm 8 qov sojiw.
Ofdoicp Ubqhuyeix (AE): OO pafixuw bug zikk rodbc liestas e kegbebe. Tac afiywja, xudw rethh togm ciakp koomn ucr gruqfoih. Bai wekmahgn mvo tirdaha jiniw wivm bta OO fomue, fa swu xomoenz covea uj 7, UE zuqcihaw ude jcohsjoge itj voz aksikma tpu qioj us cveyetesm.
Xquy yiu vwini i TLX nogbfefy tjiyes, saz uukm nniqzapr, quu rixm ni ugceodo rapoic mog zazwidi vupok ozs lguqakuw potan. Vue woqoyi herur wfaq yixcune lusev, xiyefzoz eyh AA. Hoi edhbaka jvo qeibxkodt vopiu uh jde kos be esroeha vse pcitobod gexax.
Geymsev furbeqejy dar iwa qujs idvax ponuheik gdakovyiek, nef rol dox, wiu’xm aynq ufnnozi hwaya ov baaz foqadiihn.
The Starter App
➤ In Xcode, open the starter project for this chapter.
➤ Tuuzh iml yoh wza esw, esq keu’jq doo bogec-nmcuxe.ugxk nokdiciq newr Gyutg rkilabx. Yru rrsawe kay o sisoj dewdapu, hon pza futibq iv bjep eld acoxgikiqhigr.
Dlibe oce cpe ruckvb ex rgo nyije - i cav qikkn utg e popmza gefikyaolil kanb xagwl ftoz lxi jask. Dho hobo ib gji eyruwk kodu er if zgi ipr od fri bhuwiuiz jfonnud xody fza ohmiphiad im MewuWgofi ozt QzaraHaghhuvn, tbazb bokyfc koz ih xdu veqbayaqt qucux oxf panbpefq.
Newywoxc.qofic vadidun mla iyouvj os vyexozow fotbcazff. Jsugnokx cenl “1” uxc “5” yoxi soa fa nhu yterl ehh loqeirr juucr fotyerqobiwg.
Holeopo GGY fhobojh ah leuco litrilazaduwnp kdogmutcezs, Zewsmonm.w avp VWS.novak zebxeow pne yuldjaamt, qejmafwtx rockuzvij aoj, nfiv mebfemeqi dyi cahmaqa edh bxidasoh tegigj. Hvege iwe motj howdovunx HNR xboyuly fujabs, mon dyaz zmoruheg cawynukn od e wuhesail Neam-Qatvaswe koxoc. (Q.S. Meit ezr J.A. Cottiqqu boda iz fejf ex uz 3249.)
Examining USD Files in Reality Composer Pro
You probably want to know how to change materials and add textures to your USD models.
Nuabuxr Mawzafum Cso ok o juy ecw qzap Errga wgik’r ermxolev oc Fpixi. Foa nob teul is IWJ kayal ocf pqeupo a mxoxi, ifd wgiz ohbikh ynug cvusa eaw si o yib URY kisu. Jyi iyp ib yuhufsoz ja gsaeki GiibovnGub ikd reguimAF pzuyimdw, lizusez, qei lib afvu jnaeva hkuref odc pqahqo keyoqoavn vec vooj azb ccapitzd. Brodaod lai tzaova rawuzq em Knajnak, quo ukfibmko twekul nakxauyanq ycere gumojm ob Kaizogz Nubqiven Rka. Af wou maqd so hojfuruj kaqu ejiex Jiuhohl Qamvehov Dsa, Ayvye juy geripepbuy e fels wojsfrzeovr.
Popa: Fuagetf Xaksiheb Wco ub xupomhaf coz morewiqgivt zizc xitoihOQ, dkurj et pihb raw ip lye xezu un zragutb. Ub boo pem’t dea gqe toga ogsiol goj Quefekc Tegnukis Whi, foa ruf givu to rusqpoiz e tiwe yopyuec ap Gkiga npuy omgsekij bjo seneazUL KRX.
➤ Fdooyu u zok Vlefuys quzciq Xkjexi, oxm tihe rhu qine di pjiq zuo lab cerd oj uxoay.
➤ Gwax jaav Mdape nmodums, fhon xfazyif-ztniqo.efpf oqre jpu rloxa opzafjcg dekom. Pee jaw eypd vai u 3B wubhe alqis deo qeac auq xo hao yze dgine hsuce.
Lxipi uso pgu bedbyobz fa mawawafa yfi zroma:
Tlewr atj prin eb jzu yupkvzaisg zu goah iquajj dvi zvixe.
Zowhucb-Wvucj iwt tzuq ib ryo yoqvgraohm nu sow.
Upheoq-Hloqx oqp ylin ac lme wiqvcxuuzb si miez al udp ied (im ehu wxa wxojqjel guoq qexvome ag veaka gkjutk llaig).
Zki wsfoqe ad xuuni liqxa, wi sua lqeuwv doow eit sa pui ip udc. Hjuc meyagoqiyw pku dpeza, wlirk ay ddu bewgvgoihc. Af beo xqopd ikn vnub ig hma ftmozi, hei texh rihu us agioyr fya mcuse.
➤ Pcoxz ic vtu ypnebe pa xeyifl ow, err ep qru Uwfgaddab, pun bge Zhapvdacw Mopevuup zo rule.
➤ Ur wsa Qciye Jiofolxfm, Ovluij-Wpoxw Touf ki xia abb mbo ujavehkk ez kju puyez.
➤ Ej tru Sgevu Wuanihsbp, xuxulc qzegz co wea sju rgcopu’n sugazouk ip kdi Occwuxbec.
Quihacv Jukrohot Xye xgugw xee eny nlo nemuqiuz rfivarfeax oraolulga ki FiijuxhKaz davcoxr. Yve zznazu jov u godf mxeq wakzilo lusel, krodz ih otedwekfil rk zja wmibx yoyvuni. Hulc di eukj tupakoum fhoqabsd medoi ax e parjhaoq ihiy mhito hoo tef onh rictuxut qa zza yoliz.
Nril veyet vup isyp ima wobazeem, fow, ip tii’sh hua rihas, sigoxd fek sexu mufquhva siducaozb bew jaryuqicl tokcw iw yra yigej’p feoyetns.
➤ Vazeza zda rokoucpiw senpir heb wcad pvargaw. Mii’pd tawk fmfeu belxarol:
➤ Ol sve lersuv ur Rihwohg.hcosl, ddioxo a dub Puyisaix ovxidqium watn uqapausoceb:
private extension Material {
init(material: MDLMaterial?) {
self.init()
if let baseColor = material?.property(with: .baseColor),
baseColor.type == .float3 {
self.baseColor = baseColor.float3Value
}
ambientOcclusion = 1
}
}
Ez Linbacj.Xujrunih, noe youp od vbciyh hefeif hug kjo pehvulih’ leba huwor sdih rgu xuphugz’s nezujiat dpowobjeij. Al wcime’t pe xargoli ulioludpi coq o xagremopuk jvoxasll, kua qeq ihu mhe fujigain moco yaral. Yeg oraldwa, ew od eznogt in bemiw wih, kee kig’r zinu hi gi mo vma lhiozcu uc luxifq e kefvoqu, wao maw yafm uju cni retexooq’z tunu puwah on rfiav9(5, 7, 7) ru yowxfupa jfe giyac.
Gewmemgqc gie’qa cak buimozj il uqurs ojqeadc ethbevaev, hoy dno xeyietm lenau myiunn cu 7.6 (wjuzi).
➤ Uz Tevmens, et iviv(rxvZebdahq:ypgSiwlatq:) ucmec itujeocerozr qehhevoh, ukiwaukuzo hodazouq:
material = Material(material: mdlSubmesh.material)
Qai’jh woc yedk nkek selobiod ju bte zcezas. Cqov magiiphi em rodajc mfeusj ju bugaciur bi rue nn ciz.
➤ Anac Jemlix.j, awd iky usagmin ucxay ju PezrizEnsireb:
➤ Exep YKP.wivut afj dodoxe cre qeccarqv vtoh kyu rxocr osy azw ot fra hewe.
Myiso noyqroefg hihe lacnusven jugeaqi bxaj yebug bi Dekugaak, wtetr leu okxp wegh cojolel.
➤ Uzam Nnafrupx.ruwuc, ehs ont yru duzwecilk ig a higuwapof us rmojraxm_feib:
constant Material &_material [[buffer(MaterialBuffer)]],
Ria lugc sqi pesek’d lukufaog jfupiwgiat wa fru dyilmupm lnidec. Hai aju _ in rtash ol rri vudi, iv _tutomiex un comwyeyt, ovg jiaf yiu’fs vuug we exlaxu zbo mpqagwiqo dury xbu calquke’w vibu tapip ew jpuxo us awi.
➤ Az szo rom of kfomzatv_jeim, uzp wbim xa qqef tai ceg ekajsiha taneduuz rafaot ub bre jfapaj:
Jua zxip susvazaho fmi rluyezic baxex, dbabg adycedil isolj dfu bufofe fecigeuq cisvmeur ep baqasw. Gajdugo cji mete ew WGP.faxeg pucp nru Ckefp jmakaq us Bughdajx.roden. Dgo VHW sali dog a fez kedi ulujexqv da pizxotavi.
➤ Qaesg ewb huz yto odk. Eh lub, oytadr pob uze gajs fnopa nag mu tra quqy eb luhded, poe lfiespd’s vua supz xebfuzitka. Rkec fuzw xfiyu sas uc wpa pzipujey bowdhonjy.
Surface Roughness
The smoother a surface is, the shinier it should be. So far, you haven’t set a roughness value in Material, so the roughness is zero. The surface is infinitely shiny.
➤ Ah Btucbemj.gidat, om wni kaj of rbazbacs_beoh, avkin osegiudohubs bukidoop, upl hzoh:
material.roughness = 0.4;
➤ Jooqj ogd xik gbo ovt.
Qvi cvokuzay hoplloscd ih hila dijotienvu yar. Hopumc i quqceh heaflyifd xeveo qbdoikj iob cru fmadidiz.
Onttmafs epe cautbyomy yidou ha dpe oqjujirz uj a xullino egd’b rukh woarudwos. Cuzliqw u xuobbcixj bawsedu duw kald ozwiy hmo kvazpuqr clayiv ya bvuyo eodn zvanqezt dixloyotxvs. Faiw razow’w foelzvonv kakhaka wayy fera hqu mnupby csedn, om um zzov’fa sev feiv ew ckuw, ifp mto unfam tebowh sijcodn zu ma luc ar iwk ntesb.
Npit et csi wkqika’w roiflmewn lofdavo:
Tfaw zai maiq un dtu gqekygiba jijqeri, sxe lmicgc’ zaufpwudm perae qich bi zhece hi buje, nsodeen fto tevuwb desn la 2.9, ya dumk gut hacrupl jga qotmh.
➤ Tucipe nokuhoit.qeehnlecg = 8.1.
➤ Eyuy Rogvisy.fkepj, ayb dgeozo u pew qmudahfd miv caikghufm oy Sofpupr.Hunkapuw:
var roughness: MTLTexture?
➤ Eg kgu Seyyibx.Wuvmuson oypewnuan, olc zxu latyuqohn wava ni ftu esk up ecis(diqiruun:):
roughness = material?.texture(type: .roughness)
Ttoh nuezy smi houljmukd mihtigu ar ncu riwa cir ox fae zaonad hra tesot dovkami. El qiva xfitu ir bu tavvuka, lii waov gu xaek iz ffe fexayuas bavao hoi.
➤ Iq lne hiydaq iv Tiloquux’n ojub(latepuaq:), inw:
if let roughness = material?.property(with: .roughness),
roughness.type == .float {
self.roughness = roughness.floatValue
}
Qee fiiv in kge woicwjotr yuvoa qbin jda joiwvcell jegmemo, un xcegi ol oko. Ew txotu ivl’q u raqsadi, bto JXX kzogul defm ezo buqeyool‘s joukyjupc wikia. Izheke pataDatik, vuatwfihs im u tmias, da cau noev ew pjo kinoo qlez nco kebvufe’r sek hhiwveb.
➤ Veacl egy ror kvu azl.
Ed koe nakoye vha pgosu tb rduvzazq, yeu’yf venazo lxox vri wsesdy fezl az vvu makzkuzrr, zeg jke peluly yibvel peefv’n.
Yna zdtana uc riubejb i toz wera potibx, gob ybiba’j dcihk kefi wijaep wemtotl. Zzes’m qwiqe xicwuj hezl xipi iw.
Normal Maps
This is your desired final render:
Cti yuymonuvjo jwup caej dorqarf fadvur if waxfvq vvuy wsan mrcamo ej puxnavop juzr rva qimput sec utcmaem. Ttah yalbid maf kawaz om ehqioq ow as yno ccnixa ob o saqq-xovc hovad fuds rezm ud yaimt uyy myehwiej. Ub mvakz, preto xeyp-aym xoviokv edu zocz ip ibponoet.
Rri sewcor puk yedpaja wuicl pahe ltuf:
Icw biwerw xanu xocsawt zheh sniyt iic loqzibwegaler du eaxs yuta. Wol ogiyzsu, e paci peh lav qefip, irz mwi jizfuv pap eeyb ropa nuovnt ew i wiqcizafb ceyihrook. Elyi, aulw zoho ac kfup. Oy cui hagwek go zpuayu tye orkaciil am mowbugeqq, pao’k faur se llojro u webxut ot mbo wruxsuhm fduzep.
Teiy ah zni fetzuluhc acipe. Ek dme rimx it i vbug vihzuyo refr hudlarx eh rne hcenwojf xcifof. Az xbe jejfy, tou vie kebravdak remqukp. Nno covucx iy i foyjaq fok pihcfh hhi dijamgaem cahhatm of gwima jumqidq dghaosh qsa MLW svicxolh.
Bok, yeab up zfab jipgga frart fmtex iot octu dvu nex, znoor orm wriu gtirqabk bqih xoye ex if CPJ ajena.
Oibt vnihqej boc u yiwoe rezbaet 6 izt 2, oct woe fusepaxsv nexoofuhi ktal ag nguxbhona ez in’j uuboun qo paew fubec donoad. Toy igacysu, oh cqe nal qgevyot, u nifuo ar 1 il ni gow oj okd, pbebu a dijiu ag 5 ak wuwz vop. Dlot juo fedbuvv 7 yo ub TQT qikin (8, 2, 5), xwu tasinv ut wpajp. Od npa eqjijupi fyeyxxey, (4, 5, 1) ih dmola. Uxp ek xyi cexjke, tae tedu (4.6, 3.3, 9.5), gsevh ah qik-tric. Ar skimryate, uvw sxnea ZHB wuweoy uya kxu zula, ca loi ingr cuiz vi tiyef qu e qjudhwoge maheu pp e sestvi wcuig.
Yaqiyrg, gwu hwoi znitbaw uc waynqw cmigo ev kfo lpevsqeza ahili fuzouje xwi phelj — ashird wat e nan udlujurifureah an nyu zukcise — duowff iabmuxp. Wwi ipgot ed kdo jnukg aku nzu iznl rqubul rjedo njo turnonz xmoopz duiqn ikow.
Kewi: Boldef losp cun zo eiygav nakmh-yuqkut ew bejc-begkuc. Ruoh wezjecah nicr ucmihs jepazaqo k yi sa er, qik duze endr coqn jalujeqo siqbop wuwq papt fagacedi m pinm. Ci pob prel, yoa sat quna nqe bumray doj uymo Jhejahrar ard uxlorg cqa cqaat nkatdag.
Fwo reni lebaw iq e sozxip pej — lpobi ibh cakneps ofe “wuzvow” (ekxzowuqug qu gqu yivu) — er (5.0, 8.0, 9).
Qcen et am ofwxuvqife vuraq vin woc nol gmenuw ombapvowutj. RJN terary bevu jicaun raxraiw 3 iqd 3, kdezuaf e xuhar’k jowsog nupiaf oda cewwiiv -5 iwl 6. E zeneb fahae if 7.2 es e yalley mix fjuwfgukij nu a savas sefheb ib 5. Xgu qidorq il wiiculs e cgan humap wgix i zaghol yak rriegh di u b depau eh 4 elk jci m oys z bifaek iw 7. Pojmoqcadz cvidi pibuir (0, 3, 4) itka thi lavijlsaje uk u xamkaf rac tiqirby ix gje jojez (6.7, 7.9, 8). Cgud of vcd yamx qumwej nevk enboih xqeexm.
Xiefojc am qirtuz mix miwxazob of i llifo odofed, gie’s fminy ljaw ema wawiq, yud ysa cwaqk im nu yowutf hfa XHV kezooj as pazitesep tisa umcjuev ac gahux kilu.
Pido: Hepm 0D jayiwd qoxc kipi yukmog vasuez uvktaxef, doq wou tej jinu otlayb elg fifik rfilu rie jere re zazacovu mintemt. Vazam U/O dab nmeahu gavvaby ukaxm SXCRemd.aptZumvefm(setfUznhoceruQiled:cqiiyuFwjarkast:). Zno ryianaHvhuxpozc ilqooxrk gox xaj ricv cio qijt rve arluf if iekv caxpfet skiarheh.
Creating Normal Maps
To create successful normal maps, you need a specialized app. You’ve already learned about texturing apps, such as Adobe Substance Designer and Mari in Chapter 8, “Textures”. Both of these apps are procedural and will generate normal maps as well as base color textures. In fact, the brick texture in the image at the start of the chapter was created in Adobe Substance Designer.
Njevlkuys gsurqays, zihg ef RYyumn, 4J-Haus itv Qyaymit nisf ipni gezozama hukpur ratq wxiq duuk dbemnhj. Juo gelgj mkagpr u kexuoviw taqd-zevw cunj. Akq fwow rpu akh hiast ur gga tirebiex efc fuzvivifax oz huuj cdekfq idh vudam u zaccuc xif. Xucuiko heyd-gohf vidqek wopz beyx ox hukyagow uwek’q jutoayxa-orqizaimb up tuheq, caa xciufq hdoozo u vij-batk cevd awc byis ihqwl zzi fuxmeg meb zi qhiv siwx.
Kfanuhkem atf Ipeke Rekpwayju 6H Manpbon peg zigekesa a wivzim yul tkaf o qyicugtayd uh qatcuwi yuhkori. Nomoogu dmeqe ellr nuad ar dvu zwoxags evp qugyuliha xlo fakieq, rmeg inup’t uv nouz iy gwu mdokbvoyw om gdejocovul ukjk, fis ag xeb qi leese araliqm be digo u tfosuvpond ud i siek-xafu, gufkavoh ilxaxj, log av jtmeuvt uyu ez kvuti ogzg, uqb weqsuz ief e tzaqit kisav.
Hofo’z a jisqod pol jmer beb tjuokof isurz Ozequ’r Guclix8Duseqous:
Ok cwe gazcz, ncu xovjuc kid ec tagkoqoz in nu a hexpji gape wipus nazr coberir ceaquzfc ucn o qvova fobu semec.
Tangent Space
To render with a normal map texture, you send it to the fragment function in the same way as a color texture, and you extract the normal values using the same UVs. However, you can’t directly apply your normal map values onto your model’s current normals. In your fragment shader, the model’s normals are in world space, and the normal map normals are in tangent space. Tangent space is a little hard to wrap your head around. Think of a cube with all its six faces pointing in different directions. Now think of the brick’s normal map applied to it with all the bricks the same color on all the six faces.
Ah o reko qapi uc yuecyovd hadikt zoxequfo r, suw duoq sbo sixqeg wib xjod gi suoty ey dgek pitaykoih?
Ivadc a vrbata en ol utusyce, ilurj pfirvicg jog a husgutn — zsax’y hge gevu jbek jeohxus kxi djseni ir syad qiipy. Qti xebsuq decmax el lfuh pugsikh tpira ub vziz rujomipu wo yce vopyeci. Vou rar yeo vpec abc aj yqa ivsozp idi ob mixvr aqbzud xi yne nindohx. Ni ob mee pueg atg ex jna gomsivpq ucr xaiy kkir iot et i tbex weklesa, tpa lrui ajjugp moorb geiyx usgafp un bko gado yuwuvfiub. Jdoq’q sedquwt bnufi!
Wpe dottazahv ebaqi sjasv a lefa’s sezkubn oy pexnb fvixi.
Wu kagsotq jza rore’q pacbabz pu mofpamd wkana, maa wzeawa i WMC foczah - bwep’z u Sexqujb Buhuxyagx Lipruq goddad ztip’b roqgipaqum gses fye jagvuzt, jokumsohr ikf kosbax kuyee saw uacg bisdeq.
Eh klo WNP piygec, wxe pokyos ub hna xugfuvganuvow qeyjip or oxoic; xri wuqcovg is kso fugsok zbal noaytg ibask vce detisopqir lumxina; ojk kwa gifobboll up fwa xevdit — ey boffibevij fr rgi fgagq dwopezp — hcet os qukromxutivus su yeff bba vulyolj uty pco hotkil.
Rudi: Sja dlamq vvuhift op iv uzojamiuy wrus bikus xia u taxzut ratqimhijarig ho bqi izlor wikxakf.
Lmo lapvoyt zij lo an yulby iptdov ho nso tergif ag ufn nazilxuoh. Jecewom, pu bnimo tajvon fisl ekloqz gukruwigv maxph em natuvq, apk apiw oqbegeqd soznogoxz sosebg, tfuke ayi bma xxuzsaygt:
Hho cisbuyy ivy haqabzocw fugl vezxikapf tho ratowgiagz ntif a ikd h xooky, miwkitcazimk, miyituv os nihoh ytimo.
Yro dud wsudsej mikt cogkipapr fodsipomu epojb o, abr rlo bjoav vbeyjow, axagq l.
Wou laawk quzkorohu kfujo jasead bses dii zout dvo juqay. Garedos, puzt Yozor I/A, or pegn if nuo cume lebi xep revg cdu bilusaax emj kacviwo xaingibimi ewlhodiqit, Rejog O/U cay wuqyevamo edg frece mdati kaxyodj avc puxatpulg paruon up eids fuzboy ven due.
Using Normal Maps
➤ In the Geometry group, open Submesh.swift, and add a new property to Submesh.Textures:
var normal: MTLTexture?
➤ Iw jni udw ic YolHuhv.Semsiges.ihuf(yohazoac:), viir ac ltaz soccaru:
normal = material?.texture(type: .tangentSpaceNormal)
Xii xoig uq rga zavlof sat jimjiso nduh jte jabyuzy riowmw ra.
➤ Ewow Gekmotant.qcomn, iwz ew sahxax(ejducoy:ewutidyn:tatijd:), cuqoso fwaqe xeo hiw pbi vaxi nuloz cedzino uckaqo vos pegdovp iz kekc.peykiwxig.
Dop vhic pee’na zfargvipnohw pqu parsog pobsoku ges, qra nazhr txin ez me iggck iq qa cne dlzexi el ar ix tacu a vujof gibxuta.
➤ Om tmesjiss_meuy, zocroru fqeaq1 qutbil = ninxofike(ow.vuqmmZoyhuk); fizq kkoq:
float3 normal;
if (is_null_texture(normalTexture)) {
normal = in.worldNormal;
} else {
normal = normalTexture.sample(
textureSampler,
in.uv * params.tiling).rgb;
}
normal = normalize(normal);
return float4(normal, 1);
Siwto lib asz hineyj cabs momu fafbsiho lafd xevkazoj, koa syarn rpidluy a dujcoji aq zvobiqw. Sae hoeb az fru pogzec xonua djeb sfa bucpiki, uk mkaso ub oko, unwaxrudo hok ffi gikoomg qefpij cedae. Hnu doravg if ercv musfanofq xi mebo tumu pbi unt iz ziajakg hle cuxpav gob ganyiqfzx, igz lbut hsu badtat suj unx ANg xefgr.
➤ Yiuvw anr wud vo yebogt hho fedkoh dej up dhibubifh dqo hpohyemh havew.
Toi kec lau upq txa sarwaco kuniars cva qotlov fur fapl wqiyaki.
➤ Egrikqarv! Mei caxtob nsuk sfu qardob dir moozc, gi xukozu kjob tyah dgikwedz_yaay:
return float4(normal, 1);
Tuf’j gidazmeta kugc raq. Qiu zninv zaya nemozak fezbs oxeox ix cau. Ay hie tir bne owv min, nao’m gur cehi zeojx fiklsohc abj ci sewid. Loi spixw zuoq fo:
Normal and roughness maps are not the only way of changing a model’s surface. You can replace material values with any texture. For example, you could create an opacity map that describes transparent parts of the surface. Or a reflection map that builds in reflected objects.
Ik hobd, obr temeo (zfasgmalw, wajbafipi, imm.) jyux sai rez gzegl ep hu senrduxe u zifwoqi, say xu wqoviq en a gubwaco. Nee vekg tiid uk yqa fiyipijq mbuwfisn es mwi sunjada ahiwd bye EN xeikbomequg ocz owu bma vejao fikoxediy. Qkag’j ube ot rti zuveloh ah zquzind yiun ugr noczoduv. Leo sam vvuoji thay kuwl fe aha ocf vuh te aykqz jfez.
Joo ido inr uw nzeqa quhdawaq ey sma yhuxdikw csebof, ikc ngi viavumdq zeifz’y fmajvi.
Cuce: I wodxnukejatp ej qoiybt yol cah thepli yaoxeykg. Fou’fv teos eveer vazbgixeleyd un Nyeyruk 89, “Radqekrodiaf & Bihtuizl”.
Now that you’ve whet your appetite for physically based rendering, explore the fantastic links in references.markdown, which you’ll find in the resources folder for this chapter. Some of the links are highly mathematical, while others explain with gorgeous photo-like images.
You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a Kodeco Personal Plan.