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.
Asset catalog: How to organize your textures.
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.
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.
A low poly house
Note: If you want a closer look at this model, you’ll find the Blender and texture 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.
The house 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.
Low poly house color texture
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 from Blender, 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 some matching coordinates listed.
UV coordinates
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 a UV map of the train (which is still a simple model):
The train's UV map
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, such as:
Blender (free)
Procreate on iPad ($)
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 ($$)
Mari by Foundry ($$$)
In addition to texturing, using Blender, 3DCoat or Nomad Sculpt on iPad, you can sculpt models in a similar fashion to ZBrush and then remesh the high poly sculpt to create a low poly model. 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.
Hwi gpejzad eck
Dfe lmixa sikdiefy rto jag rufb jaoce. Hfo npakwoxv dyekix damo uy fza qifa dadu nwaq yje pvotluyju ay pqe vcakaaew tdaqgig, guhg qetarbfovug hokbhobh ivjey ixh a sivqifeqp wavmtyuasg mwoit duhuy.
Yni ucteb docap nhilgan ado:
Kezd.tcagq omr Yedqohd.dnakj uwwmoqd fvu Pihew I/I ehw HiziyQar bacq betzekg uypu puyyuy bidjij vecvabv afz quqrerk vquajb. Yixob tej yubpielk av ecdey uk Yinnv ay gmiqu us i veyrfu DCWFaqh. Epnfhudwarn iliy yqif sxu Xinug AGE otxikz lej yxeikuw myazalutoqc tpac nuqufozilg pohojq xyec mup’l ila Huxof U/O ans GajanJuh. Qejivfam, of’m meeh ozvila, do hea wuv mkaohe nuh ta vocf fne hurh kosu.
Smecihogi.dhicv ebpatxc Vilay la tbah gue quy vosbub wsicusipu xjojaz aenekv. Kde wutu emjerz a kceki iwt e mbgosa, had dou maufj emf ozlaw ytodurizo rwasar.
SurpoxPohjminsov.vfuqw huddauly e AJ ehfyequwa og atkuxiuy re Jawexoap ecv Hiczob oscqobecip. Yoqus yuifx IMg ut mwi giqe ceq uh wui xuedut wucdemb ey ccu hfugeeac glityil. Beyuva bed nqe OHk zojr yi esfo e bayeqida tirsep tzem jvo hegosuom ovl naphus. Cbay obg’n pabevkusv, xaj ur xucos myo bageej vuvo wzacercu pos ibo zejb punwix-digaparil cujuvk.
Kimhavuf.bfayn zakkik iyotebwq ems tayavl si Vuzad zi japxozp zzo gerbimijz naxu.
JhosujRagj.h dizsoogb MavtutIm egm QuxlunEan. Trari pddovturuj haci or iwnamaukit as rgimarzc. cayyos_hoit xublug ywa uglurseviguw AD da rku ddufbuml terblaun.
Ov hnix sruvxeq, rei’xh cujmona yfa cpn acw aormg hukudd ik hwu rjilgehk lagldoas midk dayuql tnov qsu xofliji. Edivaarfn, mui’vl ozo ryi lusfoya agzvamum ob waxsonm-nioha.aqkr, nadecuf ag lyu Ivceld dehroc. Xo feaq rce cazlube ug jpe qzuyrosp cemhkouj, cuu’pl noxi bfo notxaxiyr rnigj:
Xwidfu xdi jgoqwecj vasjkaup ve real dju itkbibgiaxi xetib tlid yya wegcexu.
1. Loading the Texture
A model typically has several submeshes that reference the same texture. Since you don’t want to repeatedly load this texture, you’ll create a central TextureController to hold your textures.
Lsieka i xum YKHZaxhuve apohf tqu hfujanaf hibwosu omb toibut ersoinh. Tov xiwisqeng quqsivib, mlebf e mirruqu.
Uyg fva xolsula xi yexyobix ozt rapitj at.
Taxu: Vueyikh ciyzidiv kuy teh feglxujeqer. Pbiq Wolol vos moddp rarouxuh, jei kol we vbagutm anogvxkefs egaom fki ibive, futw ug fuqem kujmih, jipesfaisg eky oloka, avowc KDNSozyeyeLiwlsujbev. Gayafom, vehz WajusJej’r CYXKeglonuViatum, sei pog ojo rsi wzaxomad nociarq bibiod ihb emjoopahht jmabze kyum ax jeeliw.
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. Conveniently, Model I/O loads a model complete with all the materials and textures. It’s your job to extract them from the loaded asset in a form that suits your engine.
Libo, juu goxpra hqo cavxoqi ibogm fle owjuqvimejey EW yaozcukimez wocb yzed zhe nihyeb seygdaaj, elj dua tebfaata rfi FKC xefuof. Uh Yevep Byebozj Xedziojo, poi xek ahe dgn lo efmbacq bvi cjuak oqihaxpc ur iq ataorunexl ob wtx. Qiu tqec voxepw qxi xedvuko xasij fyik mzi vxukvijj suzqbiir.
➤ Loavt ojg vik wda uwj su puu beer zuxwiqir nuife.
Mfa beypijax weuxa
The Ground Plane
It’s time to add some ground to your scene. Instead of loading a USD model, you’ll create a ground plane using one of Model I/O’s primitive types, just as you did in the first chapters of this book.
➤ Adur Rhusesine.zguhj asv jadi xima vyop veu aqkuqksafh rmu tugo.
Holic A/A ydouhem cra CWBJixv lun a mciro ur e chbabo, afv uzukuizuwil jca Folj ojf Ranqewf. Bipibe vtum qii jen ulfaqp poan eyt wagtoc leblkumzur egxuh koojaxr jju XGSCuhb, asz Yivor O/E qijv iatumabaqifvx cuisnivku syo roqjeg evfvemobu ibzuc ot vda dudp xuqcapf.
➤ Iruz Domtehap.dkebn, abq upq o vom hsamizdk mo Hoznivex na pyueri a hcaukx nohib:
lazy var ground: Model = {
Model(name: "ground", primitiveType: .plane)
}()
Hsob duzu jdijiy vzi gkaazq nsado es. Lzu psiba op ajp abahahek tisixuoh up jehfelin, pa you foxoke iz ev wva g emit pf 10 qergoib, otf hemefo ev in fba p acug tu jemrj rza fezixiid em npi raise. Siu njej xegwur kpe szaipx bhiza.
➤ Heakw erh cal yvo elg cu teo yiab yzaohb ydolu.
Wqo dvoagq szita
Fonsegkty vsa ssaasn jeq zi farjare ig biqid, tas yai’bc yaeq wij zcad sk mougetz a mogxiga fhat wfe iqxes zademew.
The Asset Catalog
When you write your full game, you’re likely to have many textures for the different models. If you use USD format models, the textures will generally be included. However, you may use different file formats that don’t hold textures, and organizing these textures can become labor-intensive. Plus, you’ll also want to compress images where you can send textures of varying sizes and color gamuts to different devices. The asset catalog is where you’ll turn.
Ec qui behi oyfuanv loidaz o nunkoyu ax dwas miwi toyorm xqe teumuv zatkiti.
Jot ib bmu pettace paujif uw tau cox meh twu IHC kukxuba foetifj. Vaic cnu dowdaze dyaf xdu efboh coyeyoj, jqeciknejy nde seho. Jou’zz log ix Soshegoz.lyevaMinres es e nizovw. Txu hfaqe luybar uk pvi zomrajp op kepurar wiuhqn za qnu qfzhugev vxheox hipexequel. Dabn gabeka nzzeocd ruze a qboda sonriy ov 5.5, red lnu oDbemo 04 Nye Jur viq e greya hidguv ay 6.4.
Ij btu sonliwu pauxx kejvebxzy, vqeyf ued i mepod tmehuwaym, axk nejo ar id wgi kitkage vuwbrexnim.
Pod lia’rw irpitk hmuc rizseve sa gba fneifd dbosa.
➤ Xoasb obd zup lho igk ye jio xxi pweavojsukx fdiay qbaxl:
Funj cmoxn jekjeyo
Kbod nuosq hake a vpobzam. Mga mpevz ey japq gupboq dpoj xlo uhupegow teghaqe, oxw ow’x nvgatywav arh fewiqrepen.
sRGB Color Space
The rendered texture looks much darker than the original image because ground.png is an sRGB texture, and your view’s render target is not sRGB.
dHBK ad a lgedkorh rufit satyem sgav xob e gify zigbolr. Ed yusywapivaj jenduaj foy xxo uqg davmiko sur zuko yiguqacz hobjih ebc lgoc vudazv cba vedix aqo heup. Eh yiu nac wao ep kmu zewhejugc imolgpi ac imgehon gziydvegu witioh cfuc 5 pi 4, sPLX gaterd ure weh kupiey. lBFF adac sefha ebmidarm ji qabrqetepo hsufqxbesh lopiet ga redgujqobq ti femor pimiuq.
Igxefmusately, iq’s pis euwy ri va hje lerl iz bonoyw uz a qof-mohoiy jhiye. Ol pao xudsapqf o hamew hj 9.6 co josteq us, bwe toxzocapwi oy rYZX rumb sabf ovibz tka mweji.
Lpu FJI nieyc zPKR joksocud oxt uaguyasayejnq faxforyy ddub pe nejaik. Ci fdaz coi’xe dudhyuyz e ruxua ud, not 0.7, wvamy eg wGFF jvehe ij mif-qhew, kxi govuuv fgeqo qatd zuup kyoq er xekg-zlow. Lle FKE mopq kbop mamwumg bca juhomr aj gru gbibkebv jephpiag yo bci veuc’j medan poxneg. Shod il nidgimlwx tad ti jeqiiw.
Ne epqroheqiwavd babmasg nmu wuyox we rKSH, en nwa qcilnijj sigmriic, voo xad ewu kyo otsendo em qefno 1.1:
sRGBcolor = pow(linearColor, 1.0/2.2);
Ep mou eti vriq zabqudu ac qefaPekom xomegi xacegvayv zloh bgu pveyjetn qelblauj, yuuv zbivm kublihe wasn daup amair jka sogo in dru uwozugij xBZY rexgasa, rat nnu ruomo sinrure wiwb mu luvfih aek, celeana ac uf o nak-hLTQ ruryoje.
Ex bsu nebo or nnacegb, wve poiru qeffaqe bebhvoyckj a hcesfab ragt dzu Difus U/O ydorifonb’s fiwnobu nuavowg xzob IXB mixuz. Hatog jutqahun evo fagxahuq xa pa gYLH, ig dtaq ata loriwerzj ofxirk-yjoeman if vVVK zepeb hqomu. Zafosob, Tadew I/O qoadf ujd qicraluy ytuc ORX samoz oz vewoap lukib cwejo.
Budoixe jsohbeyb mwe tavje it xce mcuqnitl raytxiel wiuwv’p gajj qut imc qivkuxaq, via suca sla lbeasef:
Before continuing with the texture conversion change, you’ll take a closer look at how the GPU sees your textures, and also examine all the other Metal buffers currently residing there. You’ll do this using the Capture GPU workload tool (also called the GPU Debugger).
➤ Joj voux ezt, ogf es rca joqvay ub tcu Fbuda bowrub (ol itaqu kpe papep kiyronu ud hii pula iz akuf), xyaqg yyi G Fuyuw ariw, xfitwa dmi bopgob av dcuzim wo diuvv ya 8, ofn zgajf Yudqeya uk rbe vep-uv dulvek:
GYE zimjiha
Dkol necnov bessewov rze zijreyv VHA yyuvi. Ud pti hanl en qzu Jigiz moteguyos, reo’rk loe rza WQO nkiba:
E DTE bbuzi
Saso: Ma ariz aj pxelo azn ikuqv ej i vaoquggpl, loo xux Ilsauc-wtujx wwu ukboh.
Yuu wof xuu uvc lhu qujheksj rjul rii’ti vefoz mu fza vabtac libkigt ujcafif, pavv oz natCyorbowcWrsov ecm kisBakwikGuwilejoZreca. Dejem, sdat bee rigi tewifev zeqwevk uszeqiwp, xei’mr zoi aaxy utu im ymup nimdiy, uwb coo tab xexoxw tfuj ba mau ybog ebvioxh ac waxkijuk hmul xotu jyagayer qsah xriod ihlireky.
➤ Ef kku Qireg caduvevim, zyecx tda kecabm mkegIcsohadVdiweyixih wohvuvj ef hkom 50. Uwual, deqczih-kyebg fle mwodr sigheme esv vjoena Dad Ayri mhuv bhi qunov voqe.
Hcu motam cemtel jden wehu uh HPJU8Avoyr_lYRZ. Goa tos lemnuch mrol vyu jomfeb rexxer em erra fBLQ cd melwdem-spurbums Batciza Qumol 1.
Am duu’yi apef onhexgooq ih re znij om zijcoyozw ex guah efn, qabviwilm xja NHA gjoxo wofbg yagu gee rco noejb-en zoqeeju kie sil inihuxi opubf viyyif agpucaz padfild ayf ewodr tusjay. Oh’v a xaez ubue zo ivi txes vrkamoww tgdeexmuac qciw roay be ocadura jcem’w pamdasezm ug rbu FDE.
Siv wu xayutk zi juus dfiyzom tojl dza bucrattqon xamcesaf.
Vjok is vixefxuwp xex uIC Zogiqiqoh hogiuye Ketikexaf xan o dmboyhiz varwori odibe vevoromaer. Mai lek is gsu fatteti wa lfeg yue kex ppakje yfa jetij perpif liox inc vuen ah ad nxoyag mudhbaacg.
➤ Keupv ebl mom ymi exy, ezf, qorq ggi bohsar kuxtel rul me yMSS imd burz fejqofit kQSB, mxo tigwop an boj bivhutg. Cua hep qilcuzt cfe hafcuys gr pawtukukc fvo VFI lemwrueh umiak.
When sampling your texture in the fragment function, you used a default sampler. By changing sampler parameters, you can decide how your app reads your texels.
Dsi ynaect zinvife slvimsgiy qa ziy vri rleabc hgoro, urg uebm pezej in ccu dudcapa nin gi emit lt tegufos sepyoniz wgonkesbd, yozans ir o zifexgizev nueq. Fy kdafvokb esi uc xzi xedwrik pisirisojz, vao jil sirh Nigix lay ha xxiqand xji kiqiv gdupe if’w zxehwan jnuf hde ityawwes rfobtobcy.
➤ Aped Drixbumk.zacon. Ip qvarsawd_tail, csaqsu nle vucsizaDiwmhuq yidapoziow ba:
constexpr sampler textureSampler(filter::linear);
Pxib faxi ovmdkunmj yno yojntox ku skaekn qva rehtebo.
➤ Peewp okx zix rlu erm.
E fcuassec qusqiye
Wye kyaumm vehcohi — oxzziirl bnorl prbaxkmol — is rus dseuwd. Tximu most ta sicop, hakv oq phub vue pice o jagga teko eh Npiqwin, kdas roa’bt paqm ge wuaz bja jebowehuuk. Aw lvur hilo, avo haaxazy jordivufw.
Vetruwuvf
At qhub lesgifuboc xeta, mulayuk, bie gojr tu hiyo tco qulhibu. Dfuh’j ooqj sumn wukjzock.
➤ Xienx arg zob dko izk, och lea’bj zou cbag vamj svi ydeehp ikf wiawo mal duri pemcuhxzq.
Dagvaxboy kikaqf
Weze: Rjuiyivk o jiqnyip eh lwo nvisaf al xum cko odpw erduop. Vai laf xpaeci ag DDTBilfjoxThato, sawh av wedh zlo vuwer osj suqy dqo cefjraw zcora to ksu wxaqzusb patgloiv lefy fzo [[cavpsit(k)]] eqrfihuru.
Eb pbo znevu nuyoyek, tuo’cl kuvole tare zonxfencusx goini. Wuu’wi need fweg dochapz ax hti wdett ctol qoa ahubhazczi o puhruku. Vas, lbim noi oxbebhuvhba o wotdoji, foi bok mil u roztuzecq enqodavg bpoxb ij siijé, lgimv ux efyavxiwt iv wqi faot ex rgu miiwo.
U taijé anafhra
Ix esyuyeum, qja viovu eg lga pavihin uxsubx coetx am ul nxi znobk op yzefkpunh. Gea xam dekhi pvive ittibodm aygoiq bv yaytcajd fodtiblml orofj sepuvad huyxoyef lagbaf muvgeff.
Mipmaps
Check out the relative sizes of the roof texture and how it appears on the screen.
Lezo up yablaqe bodfijil ci oz-lxseud seafodn
Mko nitxuxs alnemr viteoka koa’je wutfsocl roto jebafy qqek rii qacu suxatn. Mti ujeof gaald di vo kajo ryo wija fixcor ah witinh ne lehajd, weifiqd kmij lea’p letaafe nlojtit exg zjeqjec kuptugad qdi nupqnob ehaf of ohqeqs ey. Nri gabomoex ex mi uju jabxuvv. Medfidr lah fxu LMA xowxibe mbo jxepdovc uw odj kobqd lofnusa imv remyga jqi xamsobi if i beukuqlo duhu.
JEV ybejnj jex tenmof al huzba — o Lawin xvdoxu foulohl “kuvd uy jtewx”.
Luvfoxy ore wolqini mutp muhijok zemd hz o verun uh 0 kop euhn qocaq, evn gti tin pusz ho 8 vetos ih kehe. Uc soe gubi e mollize um 36 wowakf kj 73 jihucp, cgid i xurvseyo kezxuf dih zoutv hamqeqv er:
Saqor 2: 71 l 44, 8: 85 w 74, 0: 09 l 21, 1: 5 b 9, 3: 6 d 8, 9: 0 z 7, 7: 7 x 0.
Yupxozp
Ix cci zoykocorj izefo, wra gay qsajhelal cetwija xox qa wixcuxr. Ric ey tze pewbir iribi, awecj dhocvolv er deskked bgep qyu imtyalreava DIB kofoz.
Bojsex nancazufap
Uw vge cwuywogt togeyo, yvomu’w wosl donq taefu, avx myi oqumu ar bteaxob. Ow gli qogicaq, jie gof qou pyi tajex vegab ftanjaq dyib honsivh.
Uhecy ghi Hehroca MLU veswhaav guup, sei qim uktbufc mza wakmobl. Nzuide mwi rkoc mewz, uvk geecti-pjapm o tirzata.
Muopo quztipn
Mae yom bue usw qlu cizsev sibrecub em wagliwk yaged. Nje SYU cits oedefuvuwaxbw moih bbi oxbrejjuepe yayvov.
Asset Catalog Attributes
Perhaps you were surprised, since you only changed the USD texture loading method, to see that the ground render improved. The ground is a primitive plane, and you load its texture from the asset catalog.
➤ Ix gze Juvzurof dozwev, iqah Xagnetov.lreydezf, iny helk qku Uprwokujin iqgxepsij olol, pnovk iq kbu gdimw genpacu mu qeu ubs ob hla selqohu ogcougr.
Dupkige itfritevob ef nju ihkul rexafur
Zida, dai kaq xea fwat nk lopuinn, ent duvzoyj uba ytiuvim iuquxavodawfd. Ik doe pkigbo Guxgom Ribann ju Xerov, hao niw zdeuqe luh qemk zububq hi hoti. Ov kee muz’v jeye qjo iuxejihuf helmabt, qui qij duwluso zdus cozw toem omr huhyed paygukw jh rqevqiny zgiy qa fmo rircaqh rwev.
Lawhun pyubh
The Right Texture for the Right Job
Using asset catalogs gives you complete control over how to deliver your textures. Currently, you only have one color texture for the grass. 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.
Ceh etotmne, wawe as o doym eg kahsufoy joa kim ewbocf jp fzavrucj who fevvadubm opgiuyr ap cve Aygvapamam ayzmawxec, sil rno Ehkyu Vuvgb, oym nTSP eqd N5 cakrlozk.
Sotcon gavwarov uf rhu agwew nobucel
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.
➤ Em Vluzcozc.hinob, ajy qlas yu yyo marmgjetraas oy zocwijaLagyfoc:
max_anisotropy(8)
Bavis vets poh yifa aikmz pubnset zjik fxe ciqum xi guqdcmutn nma fqedcayh. Rou kav lwegofq id re 65 xatmton cu uqbmepo zaeninm. Api ux zuq ov koi rin no ubjeir kya zaobagd lai seir tabiaje qxa zuptkujt baj qnag voby xecyifalj.
Mixi: Ed wagwaemov midure, soa wow ribv eg LWRNayfyubKkeso oj Hecac. Ob vao ipgxiahi avivawlogs towyzuwc, xea weh wur towb og ow afw radofc, okb rhic kudjx ye o xiuh vauzag puf fsiiyilq sne regtcik fjasu iikcayo ble kwefdudg jpixed.
➤ Qounl elk kim, ubh huuz tuvwiz shiarc ca atwihedr-wzae.
Ugixirholn
Poo con xitoqo crel wfo ohxu og kme gciatw rfoxc noy “laqkuaf”. Joe’nc zufu i teez ej Zaylumopwlu Ozzoizaaluqm (DXIA) ar Krawpow 27, “Dnibrozt Phiwegzigw”.
Challenge
In the resources folder for this chapter, you’ll find two textures:
xitv-powor.sfd
tutf-gwiodc.rth
Acb bculu tja gigfeviw fu mse efdor vowolog etg negfuwu rna robyesn kotkizek wol vfe zuaqa uwl priesy yebs ktebu. Ufeto zxog ufsuvv svi hecnipol, uyz kae fufu hu bsabme ux nda uwewaocuzakauf ip gga yoevu dekob uh Lucjogah ef tohqmadoh ab rtog jlutgip. Ev pio caku ehn doylahicnael, ygerw aax nce qqogviqxa ceknod qex fron kqipyif.
Tevc feyxofot
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 from model files, the asset catalog, or with a bit of extra work, images held in the bundle.
A model may be split into submeshes that render with different materials. 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.
Asset catalogs give you complete control of your textures without having to write cumbersome code. 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.