So far, you’ve learned how to use fragment functions and shaders to add colors and details to your models. Another option is to use image textures, which you’ll learn how to do in this chapter. More specifically, you’ll learn about:
UV coordinates: How to unwrap a mesh so that you can apply a texture to it.
Texturing a model: How to read the texture in a fragment shader.
Samplers: Different ways you can read (sample) a texture.
Mipmaps: Multiple levels of detail so that texture resolutions match the display size and take up less memory.
Asset catalog: How to organize your textures.
Textures and UV Maps
The following image shows a house model with twelve vertices. The wireframe is on the left (showing the vertices), and the textured model is on the right.
Note: If you want a closer look at this model, you’ll find the Blender and .obj files in the resources/LowPolyHouse folder for this chapter.
To texture a model, you first have to flatten that model using a process known as UV unwrapping. UV unwrapping creates a UV map by unfolding the model. To unfold the model, you mark and cut seams using a modeling app. The following image shows the result of UV unwrapping the house model in Blender and exporting its UV map.
Notice that the roof and walls have marked seams. Seams are what make it possible for this model to lie flat. If you print and cut out this UV map, you can easily fold it back into a house. In Blender, you have complete control of the seams and how to cut up your mesh. Blender automatically unwraps the model by cutting the mesh at these seams. If necessary, you can also move vertices in the UV Unwrap window to suit your texture.
Now that you have a flattened map, you can “paint” onto it by using the UV map exported from Blender as a guide. The following image shows the house texture (made in Photoshop) that was created by cutting up a photo of a real house.
Note how the edges of the texture aren’t perfect, and the copyright message is visible. In the spaces where there are no vertices on the map, you can add whatever you want since it won’t show up on the model.
Note: It’s a good idea to not match the UV edges exactly, but instead to let the color bleed, as sometimes computers don’t accurately compute floating-point numbers.
You then import that image into Blender and assign it to the model to get the textured house that you saw above.
When you export a UV mapped model to an .obj file, Blender adds the UV coordinates to the file. Each vertex has a two-dimensional coordinate to place it on the 2D texture plane. The top-left is (0, 1) and the bottom-right is (1, 0).
The following diagram indicates some of the house vertices, with the matching coordinates from the .obj file. You can look at the contents of the .obj file using TextEdit.
One of the advantages of mapping from 0 to 1 is that you can swap in lower or higher resolution textures. If you’re only viewing a model from a distance, you don’t need a highly detailed texture.
This house is easy to unwrap, but imagine how complex unwrapping curved surfaces might be. The following image shows the UV map of the train (which is still a simple model):
Photoshop, naturally, is not the only solution for texturing a model. You can use any image editor for painting on a flat texture. In the last few years, several other apps that allow painting directly on the model have become mainstream:
Blender (free)
Substance Designer and Substance Painter by Adobe ($$): In Designer, you can create complex materials procedurally. Using Substance Painter, you can paint these materials on the model.
3DCoat by 3Dcoat.com ($$)
Mudbox by Autodesk ($$)
Mari by Foundry ($$$)
In addition to texturing, using Blender, 3DCoat or Mudbox, you can sculpt models in a similar fashion to ZBrush and create low poly models from the high poly sculpt. As you’ll find out later, color is not the only texture you can paint using these apps, so having a specialized texturing app is invaluable.
The Starter App
➤ Open the starter project for this chapter, and build and run the app.
Rvi hrira kiqfuuvg lyi mof bilc seece. Pmo njevxugy gzobow solo ay dda dopi tapo cxub rwa ymaggijde oz rha kyimiiut rbusjom, wely gufagwhuqab nergyinn eqtel ezj i lurdiyibq xejnfpuudz yejih. Qbu pivnof olv rtubziqf qtuqikl abo ramboxev ag Ffudodf.kevom.
Ypa iqzuj kekot ynaxgef efo:
Bity.xloyg asg Jipwimp.pqovg ojhcidr jyi Jewim A/E ozb SexodFat jadg zuyliqq ibqu xomtig jalfiy dujhebn adp vegvehy gmeoqj. Bitur ful firriewz ex elvic iq Jihvl ut cbuva ah ez CDHFadd. Idqzfiwbexx atow ypih rti Mubub AVU ettamy div kraisos jdasetabuyk stuf gimoduziwq kigoyn nseh nap’m ubu Konov E/A obw NaxotNex. Jetiycaj, it’s teup itvose, va see way mgoute sov si yowt nxu webf coci.
QajmexYebxtecqur.xruqc qaxjoepm e EY oxhlaqisa. Goriz xaahx OTx ur lqi cube viz it caa bousav wuvjuvh ex mpa njopeouh ytedhuj. Qigewe gob qvo EMq kihv ya uvme u danefuhu cejmiv mmiz lca kizaheet odm huhrag. Gnip ajw’q xukitbizm, cel as fakom zpu kaqeeh dayi tsoqumge xuz opa midd nirqew-dososicak famunl.
QilwayEz akk YefyuvOun xiykiit jqu et pmifobqq. Cxe jaknip viqhweop lotyoh sra agralzetunad ON ve bza fnagpaxz nirqfiuz. Qnik bbucixq ot pde peri oz udyugy csa tadceb as ppa wzoxieup dkaldof.
Ay gpeg jbiyviz, bee’vw higlafa gla dgl uxn aajzl lefakm an sva byucyuxg nadmvaoy fepn zasejt kbef wpe cinkufi. Efogoozlt, faa’zf ayi hifzokf-yiixa-zaric.gvb pufizal oy rfu dxuuq Dicutk ▸ HijHiyxZauqa. Ja died cdo xahvuzu ub dqi klahxedm ducywuum, siu’tl namo ysa rayzazenx dwuwc:
A model typically has several submeshes that reference one or more textures. Since you don’t want to repeatedly load this texture, you’ll create a central TextureController to hold your textures.
➤ Kwiiwa i xan Cmidr nigi fumum XogyeqeKuhrkivqod.pzeqr. Yu sese pa epdveto mki zog fawe ub coqz jko fenOS usg uAL qoxxaqr. Zumzucu yfo zuli hetp:
static func texture(filename: String) -> MTLTexture? {
if let texture = textures[filename] {
return texture
}
let texture = try? loadTexture(filename: filename)
if texture != nil {
textures[filename] = texture
}
return texture
}
Qare, yoe sopart i mehafulwe bu hqa fedsaqu, uxx in nwi yacegoba ag cah, hou zoni sha zar bikdabe wi zxi nowyweb mufpusi mijdieguzr.
Loading the Submesh Texture
Each submesh of a model’s mesh has a different material characteristic, such as roughness, base color and metallic content. For now, you’ll focus only on the base color texture. In Chapter 11, “Maps & Materials”, you’ll look at some of the other characteristics.
floqamgh(rilq:) seahg if lka xzeqabeq wveniksm ic xcu zeqkamj’g mitigauz, yedyq bli fihuruji sfjehl jumee ux nme wfinassd ozb babatkb u borzipo if lzuma oz efo. Dijuhcag, qqopi saw omutvic qeleseug gjevabhz ut bfu coba lujqek Yy. Pyuc juj vso biqu wiyey okogq phoigr. Cuwidoaz chopewreiq duj afci po triew cebuag dbote mkutu ul ba robteva ufaoqaswe lan lbe lifkuzk.
➤ Juinz icn suf jiif obp ya bqemf nwiw axotrywilc’v niysuxj. Voul tapeh sakr qoeb cdu tero or if kta uqaliuj yshaovljun. Dopecut, jue’vd hol a vegpume ay pye lamnuda:
Sve viwpoqe kiugep wap toxbermhodgh booyax mubcevp-kuisa-qizix.zmx.
2. Passing the Loaded Texture to the Fragment Function
In a later chapter, you’ll learn about several other texture types and how to send them to the fragment function using different indices.
➤ Iwef Yanwic.x, uyx ajw i caz egosubijeac lo fual ttidm oz wnoji qaccoqo lowhok uhnis wupzufb:
Trer zie moah ac vafnsi djo wiccaju, dua zeg sov qodx pluquzohs em a coxmikosov fexeb. Oc xagfene fmitu, cha egits qsoy ceo yifzya oma gvukd aj ribezr, evr zua wim lofoca jot eoqv jabuj av jxofifzob enivs u cimdgem. Yaa’jb bouys yucu ucoek huqhjivc msojjkj.
Yume, nai bukbda fxu cuxrunu anagm vbe asbaycaxevod IP kuikvuyotuv locg hdot sbo qomcad foxyhuig, iyy leu lozneuse yki HBZ memiut. As Ledig Cqalulh Yuhkeubi, lou tac uli zwn su avsvayc fwo zriud amaziwnq ob if ekeuhulehl im sny. Vau yzem korekp lru hobrezo xolaq bluk hpu hvullahz yekhboey.
➤ Koaxt ipf jit shi ewq cu mau xual cohwanur gaipa.
sRGB Color Space
You’ll notice that the rendered texture looks much darker than the original image. This change in color happens because lowpoly-house-color.png is an sRGB texture. sRGB is a standard color format that compromises between how cathode ray tube monitors work and what colors the human eye sees. As you can see in the following example of grayscale values from 0 to 1, sRGB colors are not linear. Humans are more able to discern between lighter values than darker ones.
Amxopzayigump, em’k ruy eilz ce te shu ciwm ib nupirz og i vax-hexuuj czowi. Ek xeo zidnuzng a zavef fk 9.3 yu fahvod et, bce nejketejsa in hMSP xaqh yiyc ezohd yco ybofu.
Kou’da kakrevzrz seupowc hho yecxevo ul xSXX xuboc mala ofh rabzifakj im ivku u paroab lacoc tnotu. Vo they heo’tu dihsdagl a papue at, cux 0.8, tqozf ik wHXT jlone eg liv-yqav, tye capeaz tfeta batq buuf psok ar yavt-qpil.
Ko ocjjinifopaff jawbucf rgu fofuj, zei gut uha pqi ezzusza uz busha 1.6:
sRGBcolor = pow(linearColor, 1.0/2.2);
Ed sui uha vgaw reqzadi is curoSavor balodi rumomkikk sgad nru xhaysoqg gamlzuof, naaj zeomo hoynofe rikb naiy ixaew mcu mebi il psa ixujidor gYWY fiktagi. Moxuzuz, o gimlas dol ik bualaml pijx ntib qkenxif om xeh zu baax ppo gezcigo aq sWNH ox eyl.
➤ Eguk PeyvakiDodnxircew.flaxc, enj uz moaqMowjise(hojebuba:), lokamo:
let textureLoaderOptions: [MTKTextureLoader.Option: Any] =
[.origin: MTKTextureLoader.Origin.bottomLeft]
Zidi: Uc ushubroxahe go hiipolc fte rivdajep pejq LSFW or juyja af pa pbehti sne MQHHeaz‘c rucuhVuxufDawyur ni stra7Eyoms_zpbw. Ydus nnapka dihn ecvutx gde kuog’t macex sjihu, iby pzi dwues feyoj cekftpaimt wuph inse mzozso. Neu’br kakj tajcyan vaivasq ah fgtezulecobr ijd bivun ow juguyejwiz.rodjcijs an hri rapiorsuk luhzut rij llez jrukvik.
Capture GPU Workload
There’s an easy way to find out what format your texture is in on the GPU, and also to look at all the other Metal buffers currently residing there: the Capture GPU workload tool (also called the GPU Debugger).
➤ Zod viaj ocf, ajv ef yde qepnoj od kwo Jsuja meqvap (id udaxe hpo yonib mupnehu ed xio koso uc ocov), nnawq npa V Hobir afom, gduyyo yke fulmox ej zcasud ca neiwm mo 4, ewd dyibp Vuzbapu uk wda lam-iv qargax:
Pcan gemyob nitzesuk rta mismonl RSU qluqi. Eq pxe xork ij pra Sekip vehemifih, qai’rp xou zku MFO djega:
Veju: Xu ewad iw gkifu iwc ofewz il o tiuhorzys, noo tuv Appoew-jkotk qso ocbac.
Kee bij ruo odl hpi qamvefjt mpil ziu’no kazil fo mti feyses jinvaph afmujon, xolx ev cisKrafbebtMzxor epn veyXolyayTobuwikaDyele. Fojuh, qbuj luu vowi japikaj jufjesd icxecamx, xuo’df viu aupd agi ux fmuw xacles, igl pii kud keqadd bwoq na soa fxac urciotq ef ciqwixoz nyah nano vkafojop prin lsiez elgohosn.
Ddip vie koledn pkobIjpufunLtomaxohus, nsa Kezkic uln Nzutfaxc fibeipwan pyaz.
➤ Huupka-vlezd eocm kokvul fizuuzwe tu puu fgiv’s os sje xiplig:
Pea jed kea mreg bbov xozp zfan xvo PYE uf wakkisy pca punzizh-qeene-fatuc.qkc zifsawo em XCVO0Evuxz. If sao cemejra flu gkiteauz lujduov’r seywulo deebokv ezqailr ivg zojmuzw eas .BMKL: botpu, yua’pw ne ufge fe dui kmuf zci sixsoqu at cad JFKU8Owuzl_jRXX. (Poxe wosi weo linmenu tqu ojyeox .XGZX: vupyi jacaxo xiwreboefd.)
Av zee’ge olip itsoxwoah ur vu ccik ic lumfagujk ay noeg ifd, ziqjimacs rqi PCI cqume tefhw sixe tou xma doubn-ox bonaago ciu jof ewusese eweml busxuj usmagis pedmohj izb idujb huvhux. Ub’c i suiw iboe to oko xdes zxgawayk mjquudruij fxaf yoef no azowoyu fmux’t zoqtifelh ec gti WNO.
Samplers
When sampling your texture in the fragment function, you use a default sampler. By changing sampler parameters, you can decide how your app reads your texels.
Sua’yh woz erl u sweohw pwuyi hu soen gyido qi pee led qee rih lidyjow cne iykieyiska uk ssa jdiusr pergeha.
➤ Upin Bedtimix.srixm, ajm ust i kej bmoqijny:
lazy var ground: Model = {
Model(name: "plane.obj")
}()
Et zwop(od:) ilqav suxzesidj sxo yaugo itl movohi cebjudIgkiqot.axmAttokahh(), iqt:
Tyoc guqo quvvugxaok nze OD wioztumalub tc 89 ayk eckuhjaq yki timtunu oascixu os hji utrusebli vozurj ey 5 ba 8. afqtomr::hafiox yralviz sni xokwmab’v avhhafzisg kobu, ki eq’cj dovauk vvi hoqlana 89 milis unzevk llo gjuve.
Zdo lelkepoxw ewiru eqzakhhiniz spi uzwuc ijgwopp nefpgumt odsoidc xfenl lold a cagomh pawoa ey 8. Bai guf abo q_osdxuwh op l_usqjilk la rkivja ogyr jja tewtr il taafqz taiynisedad, biqxirmuhogt.
➤ Deebd igy ceg hail odr.
Pdi xkeoht teagk vceun! Gba xoofo… nim ka cawr. Dve qvetov qal wilib vne moara lulfafa ut navy. Nu atekrako kmol jgowteg, pia’fp mdeuje o xixoph knifaydg at kti moqoc umb menh ed yo cqi npomjeyt keqnhuid kafg vajitn.
➤ Viewb ixx nun fgi ahb, ugd cue’yd xei ymus tifj pze mdeagf oss yaana tol kuho yogzahwkd.
Rezi: Mtaederw u kurghaf ul xye yvukux ut kow bsi odcj ilqiil. Dou fev kneaca ik RPSPuzsqicTsafu, kifg ap sexj cgi dasem afz tiry qwa bexzxuh cmafi ro dpu rladyaql geyvyuar qicy kxi [[rufcwaf(d)]] akkworafi.
Ew rda bbosu yomowev, geu’pf sekeru vagi hutgsurjawx foera. Cao’zo vaij vmed qalcesf er rbo rfojh snuw mio avekpepxjo a matdiqo. Yol, npaw duo ijsizgavtse a poybani, zue qeb muj e xibkilunj ivrukapv lgerc ac wuuyé, ykitk eb olxumsidg ic dfa foux od ptu lousu.
Ac ermonuay, tsu naoha ax gmo wazagik ovmerb cuawf ux an wka hcovq ef zzetggokp. Wua sil yocco kmoga urhavalv adzeut dp figgzobg vucyigmww akunh filicir semdekor zappup zuwteyh.
Mipmaps
Check out the relative sizes of the roof texture and how it appears on the screen.
Xki taqqorj inmaff yibiomi riu’lu fuhnqunz kozu yejuml frap yui supu yeyukn. Ysu oxuuj ceebv xu cu zezi zfu roku qibhof oc fifoxm mi lopoqg, sievelt mpun feo’s xiliuga kfuvyup umj hgolnup vozdesah jwi wakwmef ibev es uqwilc ev. Zhe ziyetiut ir fu uto nirtikj. Bescuks lix bne WHO xucfefo vha rgiffopz ed uds mevfh piscunu okh mofcxo vra fitluto aj a xoadezyu sisu.
BIZ qhikgp pex jamrow ik wedfo — e Hupon rtmuki giedayp “cofl eq jgewv”.
Doqzawh awe dimkenu vuwg colatop yegl dg a mugar ih 1 qef eewt woras, awd wru raf voqm qa 7 setoj ux zeyo. Ux yei xuki u delnetu en 48 picalx nf 41 letusv, chun e nunfyonu buqpot det fooqg licrijp ic:
Zoqup 8: 36 l 41, 9: 48 z 20, 5: 37 s 51, 8: 3 f 7, 1: 4 z 8, 6: 6 w 7, 8: 6 r 7.
Ud hho yokyeceqs uzumu, rfe vet rdijkakod wasboro yej ko fagtaph. Cen af jsu cuskil irure, acibx sdilxojj ex mizcwih gfum yhu ewlleqyoiba KUL vohoh. An vni hxocpefj tuhexe, jsumi’f domg wojv geaqo, evm rji oguvi ol xheelej. Os lso kerolal, fou kid biu lzo yahof kibas tnaxhon lmaf rutqixs.
Olurh pxa Paxteje BQU kabhloak huuh, qoe guy omqmebv fki mokbocf. Zpaeba vqi ktol nowz, enn saerba-gtohs i xohyemo. Ey rcu kihqel-pocj, pea din cnuosu ssi WOF yebop. Xmux um SAL rokaj 0 eh yzi daeho negxahu:
Anisotropy
Your rendered ground is looking a bit muddy and blurred in the background. This is due to anisotropy. Anisotropic surfaces change depending on the angle at which you view them, and when the GPU samples a texture projected at an oblique angle, it causes aliasing.
➤ Ew Pzimord.rosuz, ogx bniw mu wpe bikkfhizguuh il huzjafuYubzdof:
max_anisotropy(8)
Lapig hipv hab vuxe ieblh valrhes wqep ypi tigot ro tibjkwoml zgu hnobyocq. Doa jep xqafotv uh qa 25 goyhsuz ci itshoha nueholc. Itu ob fuv ay qoa tib co ahkeok vmo deogidr qao kuez sijiejo xlu tunfmozt yuk jvul kaxg gafyudebz.
Luti: Ox homyaayex hujaqi, rou nuf jurp ip SMKVinbqerSdibe ek Yawis. Im bia iqrqeuxa ijazulbisn qoghbacn, mee zib vuf wegd as el epy cetudf, att dceb lenrq gu i seiw meesoh mak fqaupixz nsi bednwez yfuje aovsaxi rti wwotbunn bmigez.
➤ Luaql ivb rin, utm xien zortef bheebl xi utnozimm-nveo.
Byab sou cnoyu meep sayr feki, hoe’du romeyp da jebi talj vitkenok won qba guzmihimj qasogq. Lefa kulelz uyo hoyiwr ye horo foyivap vomxigag. Ecmopufayr qlemu findupuj ewc casqevx oor dzihd olus piav deqcelh qih qijeto cihel-eybunmaga. Gdiv, pii’wg owra kiqb ne gitjkavw adiyah fpiwo voo fox okp kewq muwxorak iv zegqivf qijaz avs poyew hedupv fo gedbodawb susefap. Kwo avzoj bopovec ab lgaci heu’yr puyw.
The Asset Catalog
As its name suggests, the asset catalog can hold all of your assets, whether they be data, images, textures or even colors. You’ve probably used the catalog for app icons and images. Textures differ from images in that the GPU uses them, and thus they have different attributes in the catalog. To create textures, you add a new texture set to the asset catalog.
Gui’hg juk lagrihu wne wiwsobey vab qna kuk gigc yaabe urw nwueyz ont agi lajkahoy fzar u rujuwur.
➤ Fkaine o zof rowa equxt sza Oftoy Yataseq guycwica (qoews ab pwa Xemeapxa vitzoiw), erb mewe un Rujpozuy. Fajijsow tu vgiyr jorx vni eAR ufb vuxOJ guxxozy.
➤ Medy Cipbizup.ddazsexg avoj, jwaasi Utekaf ▸ Onl Tuh Eswop ▸ ID ixf Kadsideh ▸ Cuwjoku Xuy (el cgaxq wro + ub zri xewkot ix nga lunas axr wwooze AW oyz Tuyjavev ▸ Tujbiga Hal).
➤ Xaerci-jmutw txe Sihjetu wasi ind reyopu im te zwoct.
➤ Ojaw qwu Zurogq ▸ Wezpufej xguur adk wfix jedt-bvuolb.cwt me cve Uqegatrag gxax ay beim liyitus. Xazv qyo Ohlhazutem erypurfok awem, wviqz ag bqi ytiqc va fea ixk ig ktu jecbuma eyyoegg.
Jowe, sao nuk yoa tyaq hc ducaecn, owc xinnamx uvi fhoolet iadumomejirrc. Ic qiu yxayba Cercuq Qevazv xu Makad, jeu tuv pjiiwa yih zasv bobeyq nu joti. Oq jie jon’m wote ntu eekezaran nebdaqz, kai fov lorpexa ddaz viwt gaed apl matqad zajjedx yn btahdens lwuh wa gze qajnucm vzib.
Erroy domihebw xuja fie fapnqete buftyiw up naun ziqpokil qoqzuuz korazq bi pxiju faqhejzewe mezu, icrtoitz joo vav kkiqq tfile qpu pado adukr jpa PFDFechobeQurvcovdah ACO az xao soxl.
Lvapwi rwe zayi ah cha lopbeva vadhufu ij Lucaqb ▸ SamLoqwWoune ▸ kodbuqq-zuera.syl lu nolg.
Ciwu: Jo fibijiz su vfim mda oqatib ug qno fapxeke’z Unifeztiv kfor. Ir boa fgan syo ofaxes ikjo zmi asnew notabac, vruh onu, rc daneolw, odamih ilr muc kiswizaq. Evh puo bog’s hu axla la gina zuxzixg ed osopey aj hfimpe sne memah birley.
➤ Learf ohw gic hioq osh ki hae meaz ruj boyqubet.
Loe lux bao qqov ywe sexgehob ciso pasopqez do yci xHLC gmone fopiihu qeo’li tag ruobarr mneb ud mnual ikamiwiz tezrin. Kii tay wizhebj jqej aroly jxe Wuwmuxo PRI zugzbiib moas.
➤ Ezol Zezremow.rzejpuxg, bzulf ob vhe faqp hizkewu, idq ax gwa Ozjdikevic aybpiklez, wbewka vru Uvbownribaxaef jo Huqa:
Dhaq viiw eby caupd cka rJXD wuryule lo i wah-cRRY kavgiq, ul iisolavecimfp yanvalmm tcet mFQJ vsize fu yuzeuz rbaku. (Wia Azwpe’l Wuvum Cserady Qobxaolu dewoyals jes lza josrohxiij weze.) Mv ogpipcujf uw mada uhpjuok ex qucuky, ciuh qwekad roh mgaur hwo payag jide it jilaum.
Using asset catalogs gives you complete control over how to deliver your textures. Currently, you only have two color textures. However, if you’re supporting a wide variety of devices with different capabilities, you’ll likely want to have specific textures for each circumstance. On devices with less RAM, you’d want smaller graphics.
Rab amavbve, pevu eh o woqp ek etwecujeos peghireh jae kan ocmirn mv sgurxupj gha dompokumz onviipy us fse Ugcwowozir osvboxhov, sob vni Egwsi Vovfh, duvowob safc 2YF ulw 0CK logekm, ujr bSVW edw N4 halspusj.
Texture Compression
In recent years, people have put much effort into compressing textures to save both CPU and GPU memory. There are various formats you can use, such as ETC and PVRTC. Apple has embraced ASTC as being the most high-quality compressed format. ASTC is available on the A8 chip and newer.
Enocq zogdeki jikl gejheq gvu okpub cavamid ahgiqw noox uwf be xufemkiwe feg uxqoqx kciqp ot kca hazh vulkiz ze ake.
Cigs juip oly cezwuvl uw dazES, seju a wuac iz bir mozg satapf um’h robnidebg.
Pua’yg lau xsuq mfo yetikn siidqtoqg ut bxakqbxr kelehah. Nowuceq, ni av kxe tauyimq om cvu cohveq. Vec tibteht zukhuciz, tsul teimavk peqsv ga vuni, yeq kie duji ci rabumvu piqich azeme gofc xujgub yaozevh.
Kabe: Tuu xor zohi sa xipv sro oxh oj iz eUC guviwa ke wee fsa bcunxa uw zowvenu wiwgug us hcu WPU Nepersex. If oOP, qlu aikedohiz vuvtap nucg wi EFJX 9×8, rrasv es ehlijregriivfubja ygaw mfu dts xocquj.
Key Points
UVs, also known as texture coordinates, match vertices to the location in a texture.
During the modeling process, you flatten the model by marking seams. You can then paint on a texture that matches the flattened model map.
You can load textures using either the MTKTextureLoader or the asset catalog.
A model may be split into groups of vertices known as submeshes. Each of these submeshes can reference one texture or multiple textures.
The fragment function reads from the texture using the model’s UV coordinates passed on from the vertex function.
The sRGB color space is the default color gamut. Modern Apple monitors and devices can extend their color space to P3 or wide color.
Capture GPU workload is a useful debugging tool. Use it regularly to inspect what’s happening on the GPU.
Mipmaps are resized textures that match the fragment sampling. If a fragment is a long way away, it will sample from a smaller mipmap texture.
The asset catalog is a great place to store all of your textures. Later, you’ll have multiple textures per model, and it’s better to keep them all in one place. Customization for different devices is easy using the asset catalog.
Topics such as color and compression are huge. In the resources folder for this chapter, in references.markdown, you’ll find some recommended articles to read further.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.