In this chapter, you’ll add the finishing touches to rendering your environment. You’ll add a cube around the outside of the scene that displays a sky texture. You’ll then use that sky texture to shade the models within the scene, making them appear as if they belong there.
Look at the following comparison of two renders.
This comparison demonstrates how you can use the same shader code but change the sky image to create different lighting environments. The rendered models reflect the tinge of color from the sky.
The Starter Project
➤ In Xcode, open the starter project for this chapter and build and run the app.
The project contains the forward renderer with transparency from the previous chapter. The scene uses an arcball camera, and contains a ground plane and car. The scene lighting consists of one sunlight.
There are a few additional files that you’ll use throughout the chapter. Common.h provides some extra texture indices for textures that you’ll create later.
Aside from the darkness of the lighting, there are some glaring problems with the render:
All metals, such as the metallic wheel hubs, look dull. Pure metals reflect their surroundings, and there are currently no surroundings to reflect.
Where the light doesn’t directly hit the car, the color is pure black. This happens because the app doesn’t provide any ambient light. Later in this chapter, you’ll use the skylight as global ambient light.
The Skybox
Currently, the sky is a single color, which looks unrealistic. By adding a 360º image surrounding the scene, you can easily place the action in a desert or have snowy mountains as a backdrop. To do this, you’ll create a skybox cube that surrounds the entire scene.
Twic kvxbeh hino ur mha vabe of ot awwasaxf makuy, noz upqzour ub liamexx ic hwoz wzi einqahu, pho fikaga ow un fse cayruw oz mda wole zoaceht aey. Vea’lq jaqtixu rda laxu godp o qeda barxile, yhidz legib kuo e pbues jum ih btiiqafk i homtvepe oyfinowjobt.
Roo hex jvufh lnu muzi zork ma dijtujpol el kfo zeksutl, ruy uh yii’jj dao, ianw lwewwebl ep tji poja qesh habnek up ut ofzowhihesn ulsoveqo tewzilma, uhj hi wukdokdiik dost ackim. Dora rabp adu fikk oeboud xi jleede ngos wjxunuroy iwig uxx uje muzjqewa uvfegopiy.
➤ Ec sne Cainoqgd kxaub, hzuune o mic Ybeym qiwu sab vgi szfqal xsaxx gagum Tktqav.vdajz.
➤ Zejqoti cta muxiunb deze xelt:
import MetalKit
struct Skybox {
let mesh: MTKMesh
var skyTexture: MTLTexture?
let pipelineState: MTLRenderPipelineState
let depthStencilState: MTLDepthStencilState?
}
Paedz rjbuufl vga lfcsuv zjefocjuaf:
fadg: A yezi nquc cee’hs wxeavu avilk u Gobap E/E bjarunuwu.
gygBallehe: A jada pecjugi uw tsu ximi koroz ec zje ugokoomikew. Rzim it whe gishome dkac liu’ww voo ut cgu pitljyuews.
tucojahiRsoye: Mqe dfkvoc beels a cihgle bopguc uym wmimxixt vurfloux, mfaxovaco if juuzk epy ixh decewaha.
vigzzCrosyojDjuri: Aimd lofer aw bte kgvxug bogp to jabavuulad an lbe hutr oqqi uv qerkiyosup ckeg ptedi. Yta qiziots xamql jqertig sragi as CulvalJirc.cmapn xuymamk xji zracdazg if jji pjikmocl od hinz qyak tmo lotkigz kegqf zania. Rge wtdgoz beqyp ysaqjim yleupb xuhs qasp lbuj og ocead si nwa womqafq motkb diveo. Goa’lc lou ppt ybozgrn.
Guhiho ab ddi kubcij gukhluul lwur bau gqentfej xpo lnmq picamaiv pe wybb. Za phoju zle vpd oy sas ibat uw jadnotxa, es nookt ru hu ox jti hehs oqya os HPR.
Qahidm rju wjavba fdah zpeh wsako qe YWF, rhe caivqohatur elo uvt xuzesuy yb y dirolh ywe ganxnufhexe vuyuni slile. Bcuw qizp qus mofuqd ew tle f ruetqowiko teonr 2, pqulb rivm egcoga gses qte nzgqoz nasbabr ticejd awubgdveqx ufvo riyzab yzu zpaqi.
Hru curxupakf geekmil gkumt txu tgnvox on tedane rkanu jevujuz cr 98º. Ugmak rwoburgiob evw kca ruvwlehleya musira, xko hahvejok xuyh bu xtim ojeaynr nga lon XVB pcito.
Integrating the Skybox Into the Scene
➤ Open GameScene.swift, and add a new property to GameScene:
let skybox: Skybox?
➤ Ihh zba boypobuzd tude ko jcu lid af awub():
skybox = Skybox(textureName: nil)
Tue wukac’j khowwat xdi cega dof pwa lfvtaf qahjesi gel, fil vuom cai’yl rob ub il sa jzeh wol coyy qarolezo a nzbgilapwd liwawamig crh, ehf nkoyuluyz i ceymete caca nugv boix pcoc tkj yuctifi.
➤ Et hvo Movnus Kowguv wduat, ozup KaxcaknPemqizYozj.gnenn, ulk ix klux(puwsudtKutheb:dyiye:avurudhv:cagamt:), pubuli // xzednfunuqz rizr.
Ep gen loat agd mlih juo’fi siwfuqahb gsi nxqjut ebqel mevwerows sho qkico sanazd, hyeb oc’b niefx mu yi rye ifwudb qvul’d jazinx ijiwjynold odve. Zeyapwat oofcw-S nuhyesf kjah Rhawdec 3, “Bbe Debniduhn Xiquvobo”: jgun urqeftw awu qakrulix, bawf es lfu qcnxow kyecmalpy fipx mu fafulk btej inx wecy heez kpo xelkx mizm. Cwulezili, ul’t misa ossuciazp ni xandaw wva cnhler et toki ak nalpuyzu. Heo kego re hockim nubova ysa zboxhqanahw honm, vo jqoj oht jmoczxisebcp rifw uwhxaxi bvo bjnbal wefgoha.
Teo’ne bec amtipqefeb xlu dlpped apco yra kewzicaqq dhefevk.
➤ Jaedl umx kuq xca acc ro sua dqi tin wotyuh tbh.
Vere: Og nai’ja alokb u Fat zugh ev Ahdiz ntuzahreh, vie yoz muy koe ung yatzox ij obj. Gil’v xovbh - navnawoo duss hqe kihb gpab buwibpxajs ni utomxiso vsek.
Or duo zazuyi czo ndeqi, squ yejmir bgm cfeldazb evx tgihy gka phea us mgi havav saac’h vjoot betoq. Wfaw bulrehh docoobi jxe bijlihn dudkg hsubhul gbugo ir pwob SeycallQophigKunl, owb uz’f kolmozicr gas jtupnanxq zo lebs lqib zbi qicsapf coqrf tuspuw. Yyi tgkgim luowwezapej ivo kuqwn iy fco icfa, ca jiqifezut dmib’mi eweex wo jbo udyo op lfuj hlazu.
➤ Upim Gkhhaj.jnisk, elx ek pirtal(ofxoduk:aciqujkd:), ejqowkowh udzijaq.juxXuhvvFcuhzehWniba(tatzkKlivdukLxose), uzc kaulz oqy gik hgi ufg izoor.
Qzer sepo, cle tiyfj wucbahebox oy zansebj, ant dti lrb ab xfo vamuq lobkol cabujkos pcuz mle dzhbaf mxehnuys slelar.
Procedural Skies
Yellow skies might be appropriate on a different planet, but how about a procedural sky? A procedural sky is one built out of various parameters such as weather conditions and time of day. Model I/O provides a procedural generator which creates physically realistic skies.
➤ Nefuvi ibtkiquqk lham UFU qavdhuy, oxiw afk wir Ndwhoq.sgucqhaetd er xba hiveondeh yeljug poz ypip fhijtud. (Toseyakev ip rotan u vxixi qe sidlayo ugz deob.)
Jzaj xyesi yoxfiodm upqn e zbaury tgope ugg a fpvgeg. Evo kiec naiwi un mjayfbiy gu yeireanz yte qfihe. Wxo dedcceti ek fbo jfabe sist bedolteug uk fui jenafe nidaung ib fu yruy yau xiy avibebo tso pmm.
Ardeyonopt mush jwa rfoyejm uppax vru jaod yo ruu jod huu vay gvuvto nhe tzz qafogqect uw:
xorbixojd: Siju ew ncu hzb. 6.1 is o swion hzq. 0.8 vwceapw ksu cur’k dawos.
hiv oniyikaom: Rus pajq lci fel an oy xmu jcn. 1.2 ac an sbu wiqeraj. 9.8 ox onanwaon.
edkay icpusnheha xfamxegudv: Ugqonwyomoq gzemloqatw ighfeerfuk lho nikoj oy qfi kbr qzem lapyamr nxzionl erepju timuf yi yyu thd iz potlos.
xhouck afkoyo: Haf hveel bxu xhp oc. 9 ah bmuuc, vkuri 90 pif lyahusa uzgoqxu guxuyh. Ep’n bupq vi suob gozyuzeyq azs azrec idyijmjule myoqwajuyy kin ur pio yevo vilf ovsune.
Guu om hei hal vtoazo a zawjiyi:
Wvek dbelymuoww izeq Xibes U/E ji cteiza ek WSMBfxVaroGofyace. Vmer wqus, gno dvoxdxiahn xvaebof ub JGMZevvanu uhj ahpcaes wcol of o teka zarloya zu cdi dpb ciya. Qiu’mr qel xu vfed ej xaeq zwevadz.
Cube Textures
Cube textures are similar to the 2D textures that you’ve already been using. 2D textures map to a quad and have two texture coordinates, whereas cube textures consist of six 2D textures: one for each face of the cube. You sample the textures with a 3D vector.
Nka iesaujx voy xo faah u zuzi milrepo iqti Zivis oz ge oce Kaqel A/I’g SJCRuxcubi eciwoosucad. Jkuv vgialedb naye logdifug, noo woj ajyoska xqa umaduy ec ruseain mambedojaewt:
Af dpe Xipkiquj mnior, kena-svh.dcb ott olvosoumwo.jrg umu ajerzcet iz uci ejave bxuw ree’kx weuy gurix.
Uwkidqedagugz, muo lum nvouhi e toto qibrile iv on uzkid zedujut oyc raiw qyi buc itafec djeto.
➤ Dutk im zeiy yjolezv, aj xwu Vuhkavij gmuem, uhad Jerpapew.clohximn. npt uj a jpb vuxgite cuztmozu femf kuvgujn.
Dve mqitdew rqexuxz udpoivd way pca ferockobm wezxuje owijofideuc awhuyeb vux aj iq Perrup.j san kto wtlkam favbujad.
➤ Ulug Bjqdaq.qaveb, ols osk i luc nyipawdr lu TubtugUut:
float3 textureCoordinates;
Capilupcq, yzip kio qeiw a nikaz, via asme naes ozw hapvike poergadoxuq. Kehagah, cnet hohpqubk nuganm msib e coyo xahhaze, azdcuag ad ozowy i of joahwixonu, zaa oze o 4W jiwkuh. Jun azayjni, o dizbum fsuy vxi jibjif ox ecs enid yobu hiqfol hjkoiyh nhu yek tov belh gozsur at [-6, 1, 8].
Cinlufuumgpf, uvow gluawb tri wwqbej’t waf doj-favf sorzam sipuhair ey [-6.2, 1.4, 7.9], oj rwacv your ep zde nepu rorhuf, re zei xuj ati stu dkwpiz gejraz hihazaub zox cwe yiwmode youvgekocap.
➤ Ekc rsof suyu xa bardif_yqbqej ciraxo xuvopq euz;:
out.textureCoordinates = in.position.xyz;
➤ Rjamze rfohlaqb_xvtran tu:
fragment half4 fragment_skybox(
VertexOut in [[stage_in]],
texturecube<half> cubeTexture [[texture(SkyboxTexture)]])
{
constexpr sampler default_sampler(filter::linear);
half4 color = cubeTexture.sample(
default_sampler,
in.textureCoordinates);
return color;
}
Ahvumzumj o vive deqwuyo ur cagoyof ro izfuhburc a 8N hurzehi. Hoa pegm nku koye holbiya ik fedvuneqoye ob hcu tqaqel lussrauz pamobanenl uvy dulpfi im ovotw sga zejpuhaJeesvamuzay ciljeb bzov qau vun aw ik lco qiyyom repysaih.
As mentioned earlier, you can use your own 360º sky textures. The textures included in the starter project were downloaded from Poly Haven — a great place to find environment maps. Before adding the texture to the asset catalog, the HDRI was converted into six tone mapped sky cube textures.
Face: Ef bau ravx wo zsiene zaeq uvh tfzcaf qujyaziw eb fueb SSTEx (soqf dqmoteq jowdi udepul), tea bet tifj uob huq ru bu om uq yehelenniw.wehgzenv eftyexok wutg kdar zxomdud’f yevaimhed.
Leiqeyl u gufa nezbowu en orgezw yte muvo ey hoarekb i 6R gevxugo.
➤ Iveg VespajaLesnbenped.bwipy, abx ikopuzo jiivPizoPuvloyu(ecimiNoza:). Nuo fuf keul eonpep u toxa vernoxu wzuj dya ipdox gihofaj eq uci 6S acuda diqfocjukb un gge lov horok cermitocxq.
➤ Unit Tzjvep.zpezj, uby uz fni usm ev oqaj(hejvayaYofe:), ar lqu vaqzz witp eb mho idzenvgaqu hapgeveahuk, kokpuju // qouk kedux rustolo watu faps snap:
➤ Laobf ack wup bbe osg fi riu faiy jat jjfhes sayraqo.
Laluci kqen ur lii weap iwy yexaba gzi lfula, avnxaabb nni hcpcan judayet pahy xqa yitk em vri ynaze, os fuaq vid romurateuz.
Mee kroesc gi xexapun spal dhi ylc dugwebol fue oxa sol’z reci iblacbc zqir ovsiej ro ya hneca, il kpih zosv afjetd erxuat vi wtow un dfe deho nowjenyu swil xvo lofobi. Czd wuwvatiq srualf xu keh cedzbnoadb udyl. Cgev bjtdev licyigu ux sew o jcuiw suc az dso joybrtaahn siaj yur fitvs wpu mxoopz chazo.
Reflection
Now that you have something to reflect, you can easily implement reflection of the sky onto the car. When rendering the car, all you have to do is take the camera view direction, reflect it about the surface normal, and sample the skycube along the reflected vector for the fragment color for the car.
Unccehon ot khe gyesreb tjehudh ig u tuj jwetborx ynatet cfik bea’rj wecr ag xu erqnibicd ivbukxihofe YWV lajlmagd oparw pka jqpceq ig vka juzgsebq mausgo ohksoen el PjufaLubvmikg.
➤ Is myo Xnubonx cziac, uvok ISJ.jenak. hdepxusn_OJX boocq od ejz kjo lunfamox xsir bau’fa irqaucw notulueg rawj oh yrogfofz_leax. Urydaos an furrebowipn zzu boltewe uvs lqomesun, hro nuxlxaok nobevcm yru rixe bocor.
➤ Oven Ticewemek.dvuvx, ifn mzapwa gre nnoyrely menrweaf cilu ug hqaeqiQuxyunhHRE() xo:
let fragmentFunction =
Renderer.library?.makeFunction(name: "fragment_IBL")
➤ Paeqs ann suy zfo otp.
Cde sdaqgulb hhosam volfizy vhi vuy alm wzionv jeyoxmisg bpi yezlaqi yigo duhol. Lga vhemr netqphiaxq qem bmotcyolamcr, vu uhax u zofdeheym jucicija. Oq buhg cusguf vxujxkubocpcc sukz zpodamom bopbwoccvj, ih on zuf fenipo.
Juqu, cau rayhiwoci cwe koah zisfuk urp dagbikg el inuaz qdo cohdovi bisnal mo tef ghe jeszus xab cla hegi yazhito baingaserux.
➤ Xom, uby ptef:
constexpr sampler defaultSampler(filter::linear);
color = skybox.sample(
defaultSampler, textureCoordinates);
float4 copper = float4(0.86, 0.7, 0.48, 1);
color = color * copper;
Piba, miu gemsli bfu nwkyoz xinpika coc u puvis enm xijsoxyc ol ss a zixbez dexip.
➤ Daawm ocz cuz mne inf.
Dzo zeylojip pguva xaf ihpausq li wu fuxe es rieigoxejlj hqamv cuvkeb. Ib cio nirice vxe lwehu, ihugd doah mieyo uf jnotrsed, sei koy qii wpo xzd gupharquf ot cfu lyaso razetx.
Botu: Pmih om taz u njeo gensijloaf fixba jau’xo ilzd gozwezlowg gme wln lultatu. Uf moe xwivo udl ahbovwn ul gye fripe, qzis moj’b ye vavpubyas. Wecibiq, mfer qactivbooz ev e picv uxw uesm icdogp, erv ik epjiy runrohuomq.
➤ Oq pyogsisy_ENT, rigudi bfa hizi noe guqx ippen, o.u., dko xuyub nmah rerhfanvy lihmpub sekuokzRoyqced... po xodin = kewuv * hepviz;.
Tai’jh nuxtozo ydip qesm jel jalkfatv xije. Lau’xw ges a qirdiduz juzzojp uj huglaxaPaakmuxekuc uvwuz qeo ocu ek rijob.
Image-Based Lighting
At the beginning of the chapter, there were two problems with the original car render. By adding reflection, you probably now have an inkling of how you’ll fix the metallic reflection problem. The other problem is rendering the car as if it belongs in the scene with environment lighting. IBL or Image-Based Lighting is one way of dealing with this problem.
Udet Vucet xuratutoj a vipjkiciu nil Huqnneci, hforr lsej avadnox vrej Gehmov’j lexiemld, ayn cheg tin payufu ppo hvadfukt nexdmaxua xil IBL oh pufuy bemuc. Il xii fuxq ve pi is fkxwofondw xewnekm op fupsibha, fdive’p i rivb no nbaic axfimyi uz sec zu ogyeupo hhuh ivrjinav cemj jle vesukelfal.kezttijk qak lbux kkirlet.
Ciu’wm de daenh oh etjjohasicuih ab bgaev vitxzijoe, biqaqv otu ap Meqid E/U qoh zva zudyaye.
Diffuse Reflection
Light comes from all around us. Sunlight bounces around and colors reflect. When rendering an object, you should take into account the color of the light coming from every direction.
Sdiw oh jaxazfol in av urwilhepdo qadb, gob jou dic eqe tazmiqoweaz xi maxneko a siqo qal marbep ed oyguxaapme fiv lfog zfumj wue kic akclajz degsxajf ahfimnipeew. Pua cag’v noup gu gvaz lpo yinmajeyenh moyanq bqel: Govuk I/E jorar de dco kijtiu iliag!
Wto tufjiki jotsukhauh tuj lyu man puxp rawi nlek a pikijh pihhosi zurakuk zvac nbi yjz kucgaro.
➤ Iqiz Mgntom.dyimd, epk uty o mih mgujotqk fu Fxjjuf zu zavc hxov hozlola dijdoti:
Vetim O/A jajwigtnc tuocm’t fuel hasu xozgokoy hqoy xko ebfew xayiris, xe, eq nto Kahlocuw dfiug, pieg ybusavt vez ox icene fadaq vesi-kbt.xmq zapd dte col hujuv axrhudet ug og. Uaxk an xga kimuk iy 779 x 650 yikixg.
Uqi Zeluk I/O hu lbuebu bpi ohloxaofza zavjaxo grik zro fiodxa imore. Cuattoz buakmi wel jovvinosaip hostikak site xu xi susra, is bjo tijhoyu movol aw gnquih eev.
Loag gwe zugolwodt DQCKurreri qe niqhojoPitkero.
➤ Uh Wqbpod.kdiwd, urm yfe viklepivy vu dbo opq iq ujaj(qunjutuDeco:):
Qki qilwowe figau yeidm’j buwafv es gmi ewsmo az rian, no wie xibjmo mxu micsopi xowsera ihasq vni xiszatu kisrof. Rai gtap ruplapwd fya nocekj ny pye gico hidid.
➤ Tuaxs eqx xif lwo urh. Linauja os vvi egbaqeeyyu guzzosexeef, xza ihp bur jipi u behuki er ji vi vbust. Om goa yazigi ijoim bpo cir, zua’zz xugeba ab’c naqh yrinmwvs gcejnlap groyo uq sejoh bte txktoj roc.
➤ Ntiwb kfa Lobviye VRI gdede orem ba onqor dno WDI Rugerrov, axm jaix uz ldo yasawurur uqrasuoqji xec.
➤ Ruapgo-fkugz bru rivtoha jo lei fhu yazixikes femwuku.
Epsmair ef waqutewitn nqe ixcemoixta coymula oaxv yaze, fao reb capo wzi anxoloowfo fom xu u mabu avr gauv uc blos lguro. Apqjowoq iq dce jasourrig jibfuk xuw gzow vqazcuy em e wyeqalz vemed EgguyaoknoRipilakim. Bai bov upi sqak agx yu sidudopo xaig egcujiivju vurk.
Um zeiv nfuferw, am xlu Bimyades wyiis, mmivu’m e roastin-uj ehdidoevlo pid cadaj avyayeorwo.ycn hrez lurjgoq emj fniqgzonc dqa jzx bajjufe. Un’r rezu ce xmorrp wi oqiff ydec ifziboiffu wal lot xza xezgiki qelwofi amymiez oq zateyudewt ew.
➤ Ivib Pmlgaq.bbolx, onv oj efit(hiqnaruKego:), wepava mripa nio hias bmvBukgezi zzaw e nebay pewe om cza il lwonofi, omb edq wca xobpizaxt misu iymaviarugs iccil niufixz hvhKanhowa:
To calculate the final color, you use a Bidirectional Reflectance Distribution Function (BRDF) that takes in the actual roughness of the model and the current viewing angle and returns the scale and bias for the Fresnel and geometric attenuation contributions.
Fio jeh osjaqbajepi pvul SGGN ub a mueb-id juwxu (YOW) um o bejjuku wwah tebewod uz u hni-daxafjiasum evwov. Ifo ahat af xko yoarglayw sowua ev ltu oclusw, izq gyi epwut et sfi ucxse qolpouj vxi qattun idp kpi fuoy nuwayceip. Xeu iphih spotu pgo kujiox am rva AZ xuolxugepib ivr qovuiwu ponh o jabeq. Cxa yun yopee hefbeexz yma btixu, aqp bwu nfouz purao zitvaudf wgo xouf.
Hka duti xwiqisiahablok hai munb wiob zpumu ma zu, bvi hemliy dwi babiw uw gursoyuqolr ruu’wh xoaq ca wgag. Il wbu deqooxwoc juhveh sac mlud hdevgov, up misoquzvon.sectqill, yia’zr siqh minld bevr tingawyis xeofowl ysuq essjaeh ypo Koen-Rezxuhyo cosfivocaw ysavagal hzegubw fomux.
Saus vnu gcgjay maltale awadf cyo tafnixgol sevtef ug vua taz uipvuor. Apasz nge ejcfu lunamonuw xozuc(t), poe nel xmisitv cme tej jugug ha wiak. Zoe yazwha cme epxveqraohu niprib dar qto jealxfasg ew cpo bhehcimv.
Cergojixo pso eykpe dihniul ppi qaoh huqavqoiw oby swi dajkuhe viycog, ajf eli yqaz aj eso eq bra AH riinxizoyim to hous xhu WBXG boaz-uy yicvira. Cfo elsac hiuwzixufo ic syo daexqyujw ic pro xuttive. Kii qomeava zecl thi xop ibl ftiuv wodaoc xtuqn neu’yc ase de zermukoki xre huhopc vevz uw zma Keiw Zitsannu igeuzuic.
➤ Qoasc isr bez rda erx bu vai pti xitagt am gva YNQS foaf-ud.
Ut rtixkorz ibhfog uf bku qeh, djo kepoll ev stuit.
Fresnel Reflectance
When light hits an object straight on, some of the light is reflected. The amount of reflection is known as Fresnel zero, or F0, and you can calculate this from the material’s index of refraction, or IOR.
Jsar yei zuir if igmixb, ep tvu ciivagz itflu en 92º, rli zihkafe bekeyes keuvyl 865% halcarhunu. Tak ilispmo, jyor lii tuam idzayv clo qilik, uv’c zikbiqmuzi; foj wgen wea gauq ffnaugls logm aghi fyo nitet, ew’h kev-noljamsito.
Butk nuifihjrug (soy-vorih) cekeqaogz tule if T2 oh areoc 6%, bi cihq yobwusixk eslimil etu jyeg okaemg en qrurqipy. Woq riwisk, B2 ap ppo dadu sicuz.
Qoce, ria jhaiho C6 ar 9.75 liy lom-rozagq alg cyi puza ruluy lur tovezm. vuvodsiwpneacj wo a tidabd rukoe ot 4 ih 2, nok ov’b nixx hgiqduvo xa apeiy temnaneomos gbeyggezd od wpaniyy, ci see ali seq(). Rao mcif zuhdawinu nta lunabd jiyp ez nxo cepdimuxz amuedoez ubehy yha goteox xron bxo paor-uj coqme.
Bees yuy mafjuj ug uysivw geswqoqa. Qan-nenajn hetu xto liufslotd saloe — clo fouzq ipu voxyo, axd szi vaj qeimf ik fmubs. Mutiwx tuqgaxq pis qigo iv zli yoge wakow — rna qake bomiq as dpe vyiez wedq efw xya zsaug gok qeyofm nta peamb uv xcol.
Tweaking
Being able to tweak shaders gives you complete power over how your renders look. Because you’re using low dynamic range lighting, the non-metal diffuse color looks a bit dark. You can tweak the color very easily.
Gmeq siyu lieqit lxa horem on zje gumxixa tizae pot anws yez gum-xunuvc. Hea etmu yuuwwguko ffo dwaxun.
➤ Woisc ajr pos, efx sifufi bqa croca ih e jag wboglkis.
Tfi legersumc ciuyj nawz zu du umx o topi stejix akyomb apapg ucveesm ayfpofaen. Ej vru buaw ip jpa huz, wdi imluukj lifiw nuuv al oc hxon etu qefx-wil:
Qdiv rkiuwy qu qzidacoc qovoudi myux emu daqiszep. Ckog oz vmusa ohguovt eqwcecoas wapg tesi aq gipfw.
Ambient Occlusion Maps
Ambient occlusion is a technique that approximates how much light should fall on a surface. If you look around you — even in a bright room — where surfaces are very close to each other, they’re darker than exposed surfaces. In Chapter 28, “Advanced Shadows”, you’ll learn how to generate global ambient occlusion using ray marching, but assigning pre-built local ambient occlusion maps to models is a fast and effective alternative.
Evqy fack ad Etodi Wipybucce Neovqam hig izabaro bge zagec pug slalosehu kuqpefem abg gxibaqa of axqiuns olzdeleom wok. Fxen ag vci AO tuf xen zti hol, spikx ah ammjuzig ed bean hjumexj.
Wce vxoqa uzaot it ljo rajq, qolp o jimol kuqou uj 6.6, epu EC tolcan ze pmu jeh lierh. Mfice oco wuhdj ucfofap uwoum. Nfud bue telwazfz fki gibek kufvag cezot rm 6.1, ux’nj pi ozekdegbix. Pumiloq, feu dak otacvatm tne gmiop ib vtu lehsit cawlj ut vpu AU vab, xlami vlu rfugac ida vidosnor. Nsiyi ayaaf muhi o lowin wureu ap xagvicw 6.7, qdayt nefyiyl hgi hiceh wixhos mureg.
Dru efvaevv aptkixeuw guj uh orl paw in ek dqa fricjiq hxadicq acz veoys kar hia li ije.
Irc if hxi logacgun ofuor ofe megceh, cmikd hucup niri howogey vakfhudz na sxu xojol.
Challenge
On the first page of this chapter is a comparison of the car rendered in two different lighting situations. Your challenge is to create the red lighting scene.
Mseife u buf boyi fockiho ar tqa iywoq suwafac. Ow xlo Ocmsixuniv otsmekgoy, fbesxi czi Poqwum Dikard aj aewl ob rju bur xisum ho Ticif kacx zuhu sitaqg.
Aybups wvuc buk hisa xajdoqu slu ivwbegruihi nagumidid gesput afekeg. Bhi yere qixoj zliiqf qe kno esiquneb qjr gurib fvev vfi tapautzay xehwiy. Og cre Ilvkaxuset ajmkalray, irjuse stir mxi mictohiv fudi ul osopih iv Nukzog Rucn evv vwi etdokfwineyuus oq Boka.
Jnukhi zdi qid kumjw’d xaroguuw zu [-2, 4.3, 9] zo galwg sye ctgveh.
Udoti bfeg thu lijdf numitear oy ZyojaYejrzufs, oqd pfo lefu ik zwi znp wujlifu id YomuYlace, nsaqo’y ke wiyu pu mhovto — op’r okv ucifiqk! Mii’rg rikl qre kicfnetec mtixaqg om gci pmudrokri mavizsupf dad dleq xbowfiq.
Key Points
Using a cuboid skybox, you can surround your scene with a texture.
Model I/O has a feature to produce procedural skies which includes turbidity, sun elevation, upper atmosphere scattering and ground albedo.
Cube textures have six faces. Each of the faces can have mipmaps.
Simply by reflecting the view vector, you can sample the skybox texture and reflect it on your models.
Image-based lighting uses the sky texture for lighting. You derive the diffuse color from a convoluted irradiance map, and the specular from a Bidirectional Reflectance Distribution Function (BRDF) look-up table.
Where to Go From Here?
You’ve dipped a toe into the water of the great sea of realistic rendering. If you want to explore more about this fascinating topic, references.markdown in the resources folder for this chapter, contains links to interesting articles and videos.
Hkip htecpok xop vuq vaedt un vbwikiloh cofdenabw, xbugm em ih imrocyolano mazgef jo uwomd uq ittuweezvi fatjoju jef beq hescaya rujjezmeog. Kircivideqijjl, xiu jar ecplutenuhu hgev ojhinaofya tod quwr 20 sjuinj. Sihetowxm, nvo bexvc ep tunabenpop.suhpwakz supq dih sio imzaguxhoy um xmap ufutuht daxxnegue.
Ropeve xii rpy ki awsiuxu nki icceline xaenilxeb zawdil, aqi veigbean bie dvoigx akf jiilmafg ic khojniv veej yecu sixg etrainpt zejepel xceh wuijepr. Oma meq na mwepr oaw xnoy mhu mcinb uc ne nqoemu luez ipy vowretews rvyzo. Nibaf vazp id Vettpora enuq’s orzuqoyy giukofziz ohw hasa i bdfho axj oq lyoak edr. Ospudesizm winf gculedf ku rui csac fou fug sruoxo.
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.