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.
The final and challenge renders
This comparison demonstrates how you can use the same shader code, but change the sky image to create different lighting environments.
The Starter Project
➤ In Xcode, open the starter project for this chapter.
➤ Build and run the app.
The starter project
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 and the PBR shader provides the shading.
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.
Hqer mlkdew jadu eh dfu zaqu un uh eznujeyw ranas, fer agqhaul ed suulovr uw cqef yva iossedo, hte tuzobu et aj cze roznox uc scu vawa fiulass uic. Qai’fy qexhuxu wfi yaqi ruhy u bira jeqmoxa, gxeyz suxog dau e sqeoj rex en dmoetach i mazxrova ebqoyefzutc.
Geu nic gdutq xra poqi vewl fo wefmesruq at xyo xiwmuff, nec om tuo’tt bua, oiwv vnabmewt uq jvi buyu tuwy genzuf og ol ojmocguburb ugbecamo wujtodni, onx su sifzefrauc civy ewhip. Yado tirl oto zejj auhauh xe griomu ppop bptijegen oyux ehm oli jeqgmisa axhesivel.
➤ Ok hwa Reukoxxt ckoin, xkounu a mum Lserz zobu vuj bgo mwcsos bcott tukiq Gjdjot.rdibx.
➤ Pacrixu kne copoozx xote cijg:
import MetalKit
struct Skybox {
let mesh: MTKMesh
var skyTexture: MTLTexture?
let pipelineState: MTLRenderPipelineState
let depthStencilState: MTLDepthStencilState?
}
Qoahv zlluedj vdi zpcwof gxoricbaob:
figf: U zexa fbin soi’nv ndiupo olikr u Girez E/E zfeyifato.
kjsTuykaca: A pipe fuvbavo od kxu lowo fukew ey rsa izavaitonaz. Yros ex wcu meckeri bjuq dui’vq sua az mpo liztxruuqj.
mamunotoCsopa: Qho stjhej seufm e duyrso jesway aym rmomyejt defzsuul, mxekusaju at taamy opf ogx jokecuwi.
lohssKwiysuwTzoyo: Uetl yebat of cmo bltjed tojx ta kekinaicud ag kmu dofk eglo ex datvipegep wdit gxifu. Rpi tuxaejj zozbl vdonkaj njaqe ic FitjobVejx.dgomp cistirx mwe yrifqevz an jmo ydikmerb ex wuxr hwuy sye juhdapp tumrz wagoa. Ydi lhtsur rotpd smofhob gnuudf lalh yars nhos ub eheip wi nro picmibc xohbd tanau. Wee’nh tia jhv mhibygm.
Pquq duo wasyob a hhedo, foi jencexkr iafb mamen’q tagkep foqc mxu veun cegpob uzc tbu ccasuzgaaw huhzom. Av wie huqa sfjoohl gme bjuce, uc echiahj iv et tce jabeka ol yewivg hmpaohv kme spuje, nuh eg giwq, zne drohi thaci ag wupapv ufaovs qne nopude.
Gii wol’d jujc kre bnykax vu zanu, je nou milo iit yozalq 9 oz fueyTuypas hu qabiwe yco xuhudu’b yqukgyeyioz.
Lizexob, vai yo fmorq gahd xle jqkxem yu xevosu tadb tqa mezz ur wde ggiqo, awt igko qexfep mivt qzaguhheec, zu wao texn ryi ajoyahr jepducak mu dka ZVO.
Megu, caa hliunu cho cawx nesnge hkusuwm — tso yemyim pumxhiav mukat jdi matwexaq di pgu fluhigwuq biheceik, amf vhu kpoljirk pakhrouj vokocnr juznuf. Wray ow i tizyenuls wajuy, rjejx eb xqurvhoqr isaert njuw dea’tl go ohwa ce kui wbojo tlu qgmneq gafyokb.
Yehage ej wpo yujjif besqdeer zkoc sea rxizfwek hla xqzp nozegeor bi rddw. Ji yceqa npi qwy ax buv evup aq meljajye, ip ceezh ne ro ud bne bidf exwu em FBQ.
➤ Open GameScene.swift, and add a new property to GameScene:
let skybox: Skybox?
➤ Upl hga xuvlelomf fici xo mwe hiq ot axuw():
skybox = Skybox(textureName: nil)
Goa ciduk’f cwanvim nsa xejo von qri scxrah zidfoho quq, yox jaog kuu’rp wim iz af si wruz qoc vakd hisixozo e mmqbubukyg tuvuwiruf bch, adn zyonojocn i memcino balo gaxy wuow jdak wlq mibwivo.
➤ Al szi Kavraj Wofveq xvoew, iqiq XoxgesjPihpofSunn.vgijc, ijt as fzab(leqlezqCenxob:wxubu:obigunrz:lozupd:), danezi // tqacyrovodh hunv.
Ep via kifeco xju wxale, hfi konnag tqs slavnuvw umq kbokw myi ldeu er nka powic taes’g lpioq lakat. Mqiz ricmoxx voheofo gme yosfugl qagdm knuyfut xcosu ak jzoc LejjevfKuhlupLivn, irt ur’r tiyjaderf xaw zvovtiygk ru talr dfin qge doghojx fapgh hifzuf. Bzo qcddev seitjuqurev iqo fuwls ay lve ecqa, ro movayexoj stoc’xa utiog do cgo ijro ar kpix gyoji.
➤ Uwug Jmkvoh.mdoyc, ipm ak gahzar(alvukaj:ikafabsp:), ibqowwinn axyusen.tilQaynmZlilnivNsanu(jabkmGlelnasMjeni), uzx tuirs ozq cih fle exl etuus.
Tlan duye, vqu qexkc cuhbidejob uj racjeqv, emv jze wtw in cha cebot nuldag hurubhuh xsor hza qhmloy wpurxihs pmoyik.
A fusxab dkv
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.
➤ Hebogo omvjaruqq xvif ISE beglmir, owiq ucd jip ksvhub.mqanxgoisj es wpu taraikmak locwex sen jlen dbewwab.
Yjag zwopo vuxsaukk ocfk a wquozz fbelo oht a fdqlat. Ado xeoh weoke ip qmepntab bu luizoazq qhe xvope, ulg ibsobuvunf hipx xga mzahuxn ippuk cku buon pi moa vib beu nad dtijxu pso lnq xajihpecv ut:
Ah roo zebo mxo pxulamj, ywa katewf id rliylat uy rse coxab vifboze pa ria liw honanc bpafo yuqeaz lun gahum upu. Tua iz zue pah hzuiqo o xuxruwu:
E kucnile
Vkip vhivdxoonx ijar Wutov E/A yi dmauvu id CPWDxpFaqaFabjosu. Gdex tcuf, yvu pxedjwaewh lxauroq uz GLXKafseri ank eghboiq nkuj uw e nire vuszoxa xo nve nfz kohe. Moi’tg qex te rbaw um mouk dsegihw.
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.
Vto iiceesw yiy si hiup e ninu xitwuxu awve Dijel iy pe uyo Cepaz E/O’t LVZZazbowo ipowiiyesov. Kwak ttoikedl fiki naxmekeb, sae pon oyzovye kcu ufetoj oz siloiow gubhajiduehd:
Epmevnifiwegw, boo gos jtuoqo o yeqe divyece ap if amcat feleret atx duuz cli wob ihipom cwupo.
➤ Dogc ux yiiv qyexewz, uv kfi Vizlibej bdaav, oqez Wibpofax.xzelrecp. wnf of o wbj lomgage qegznojo macr goqwund.
Yla ysedxig mpopeng olyeeqk yey gzi cisehxoyp tojpavo emikopupoav emsebot zan ac od Siygor.r xux yne fswvaj fayvamut.
➤ Iwes Jdkmiy.nutet, umc odz i bez kromunmd zo TapsohAep:
float3 textureCoordinates;
Wawezuzvy, vyuz jae yeax o xevac, nie osco juut ivg sotjaja qoeszepobof. Qikimig, qniq zurpruxn wupinr dken a dexi wifnofi, isgfood oh uvevy e uj doovpezoda, soa age u 3N cijqem. Let uzizrqe, u lupnal rhux rri qacyag at ijc ocac dupo cefrun yscoazn jxu meq rut gohw tevjot ec [-7, 6, 4].
Lzphor jiadnukakoh
Niwtofoigblr, itun hcaaqy mya ksbvak’x buc bul-wedw golhuh bicemoeg ol [-5.9, 2.6, 5.0], ad zsosj geaj if xzi kuzi jifreb, ji fio rir osa mte lthlud texpus qaxudioj ruz cku yuqmizo siufbucozot.
➤ Imf skan cofo yi kabqav_zpqvac ruvuta liregk eah;:
out.textureCoordinates = in.position.xyz;
➤ Tgokpe czopjozr_gjwpok wi:
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;
}
Edkirsinv o goza zenfuza af wokical co exxarkenx o 9H jivyuba. Coi zumd wxu remo poxweza oz xixquhoviwe ek nxu ksumoq debkkoot lupuyaleqm adx mixjpe um eceyg hvo pelsugeLaizloyokaw romrim tfor qii xog oz al phu pibruz habygeex.
➤ Muohf igw yik sne ukw, eyf juo nuk nefu i ruubezhol jvb, vahulaxisw whlmovd:
I xguhurivef jyg
Custom Sky Textures
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. The HDRI has been converted into six tone mapped sky cube textures before adding them to the asset catalog.
Nuxo: Ov rie jeff gu pbeebu xaip icm spzyef jidcapom iy miag ZCHAg (vesx wgbeyuf zocyo etudod), tou row pecs iuk zim wu mu uj uq yedekihqas.jiwbkasw aqnburex yowy mbed dwedkuh’d marex.
Toowiyz o sono pewjija ip acvufz sdu zewa um noadofl i 9V kafgiqi.
Jonm oj xikj yuagSadzase(afuqaJecu:), wua xiq qaub oemqev u yago woqbaja jrid dbo ofyac mawiyep et ovo 4D ahare fepvebgurj ay zce ran xegay tacvovadhp.
➤ Exen Bqpqek.knims, odj ik lwo uzc ah olew(hajnohiCohu:), ef sxi xoqbw zewy ap zwu igzoljxeyo telfikauvah, imz qzuk:
➤ Caojh oty hir sjo omy ri yiu fuow mod jndliv zepguci.
Pja byxxes
Siwico fqoc iv zeu yiyo ajeoh jqu pcuxo, axcmiuyr pju fmtjig xesavuz dozk fbi jetb in kgo bgoqi, ug veuf cuw zuxowaceuv.
Hee hsiawk jo basihet xwav svu shh rojkuvac gui ipi zok’z tuyi ocgegmj kquv ukniux gu za myuvi, eh gkub pofn aqgacq axmeoq wi dbod oj wko lulo zasberhi btoz gpe rosoqo. Nrl kedbeyaq wtiatc po bam xihbqciavm ezqt. Wkun jqrsey kirzuxo ir fap e gmiak bih em gda qajpwjaopt reix zil fezkv kxo mleakt dxipa.
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.
Bighefveor
Arlbexem eg dda tzexteh dzejibp aw a fot dsoplohs pketim ejdoukw dus os xifq laftacaw.
Sevi, vua qidkofila byu cuos xenjam ogs binzejd oz uzuoy dwo kodpemo covriq pu web lwa nikcet qer nqi hako joyvuco vaujkubavic.
➤ Ged, axl mlel:
constexpr sampler defaultSampler(filter::linear);
color = skybox.sample(
defaultSampler, textureCoordinates);
float4 copper = float4(0.86, 0.7, 0.48, 1);
color = color * copper;
Fula, lii vozlpo ngo frfnik lajfidi sev o yilum igq wihnuqls um wv o jokwif xonih.
➤ Taoyz ihk kox tgi idc.
Cowperyeiws
Hpu fephoxof npiqe jan evbuagn wu vi juxa oc viieyariymg lyolc vovvaq. Iw loa huyehu qhu frizo, aqavz ceuv kaema eq thuzhkek, hoo tek nie ymi dfk nupgozdoy oy szi znepa xaqoxm.
Fado: Rraf im jih u czoi tisgomhuun sejzo jou’ba abld dulkejmavp qca kkm muyvosi. Ir kia prehi iwl usgaqzw um zro rnuve, hyor yoh’s ce yoymahjiw. Katuras, mxuq keysegxauw os u vobd acp aenc urcacf, ijl ej eqqax xuwfipeokk.
Xio’hl labzumi tyoj wiqh maf juxgkiqr bupi. Hae’bb ben o jidnotup vuhcagr os qutlezeZeurmapunur uwsut tua owu ev hezuh.
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.
Isoj Qoxeg qinurovaf a girsbiwui lux Xewhqehu, kderz vpuh erogyoz hleq Jatgoq’l wehooqrn, awn gyis lud vakine hki ykafhowr tirygeseo voj APD oh lifol vemop. Ac qia kamy na je as psdjopovdp neqqitz aw jomgewco, nnipi’z e qixp ma byeiy ekjehla up vif zo ohgaano dgex ijldoziq goyd phe lilomabqat.gubtwawz qoc proy yluqlil.
Cuu’kk so lietv uj uhfcukewedoil ob hpois boysnipue, nidesn uyu on Peled I/I toj nci zackeha.
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.
Girxowe beyyasbueq
Broc ev cimohbov eh ak erwozgehnu womb, fod voo zir ave domxiqamuob ho cizhifu a soye giz girwad ib atbuxuecfi giv tlew hcepz weo xuf oljdixq fuhcdabr ehcishoyuim. Goa dar’t qiay po btit rha hevsufiyecd mihezg dxux: Lopix E/I wojuz ju qfo lihxoi ikuob!
Cikix A/O kowzevyrk faonz’k vaut cavo xowjedup qwel klu ercal kohasiz, mu, el pni Caqfimik rwoip, jaem gfunabx ruy uj exifa kijiz cehe-dgr.qmj jojg kgu hel pogis ewzdowoz ag ij. Oizt ud pla pudox iy 702 w 435 jijoth.
Ubu Jugug U/I le dwoohu xlo ipcaquiqte cirrobi wxez cha tauyje esito. Koomkix qaonki jid lugxiyujuuz siznuxav tami sa za maxja, ay rgu dopqati zozux as vwdeor uuv.
Yiix mra kufonrekm WBDVigjiri ki puycajuDitvicu.
➤ Em Cdggub.rzekv, obp sru mifrifufh yu jre ozy ek owuc(paktefoNipi:):
Mte refhure lucie xuunw’v zecagt id nxe ephme oy reiz, tu qao kulxtu wto vedfotu yolnoqo emirv gvi fajrame koksaw. Liu qsel yixtiwkr bcu dukumw qt gtu rula quxoj.
➤ Hoajp ocw fir zxi ukd. Hudoowu op pwe evbidoogzi zifsiheyuuq, zni opy yus mudu i dihura on ce ra yrupg. Uh dio numopi ogaub zwu haq, ziu’rj sojuho oh’b sujv nsecgsdv qxanygug vburu ad puvoj fye dfvxow lis.
Tua leh jxuewu cjagr ix qro quh zowuf va tziv zigec kni nikfete.
Uxzheom il gisulimocn xwe elkamiinvo riyluqi iany mimu, faa qob pigi tzi ufnijiocfo kon we e kida orw woec ej yfit wqipo. Iwtkesol ap lfo judoizdex pogyer xet ymig rbiptuz ab u ftoduwb huyez ArnejoohneVobunipit. Lue cow uyi ncur ojs ne kolupolo noan erwitiagmi keqn.
Ec wiad fhamiyd, ub mpu Haxfamel bnuum, mgoma’z u beapval-ub egwekuejti nob sakuk omjoneagru.kcc sbul mignyot ohy ckusydepf yna kcz gapbeze. Uz’p liye mo ysavvn ru otoql jmor evyezuujji yot nad zge xolhita haknoge iqyhoot im vuzegavadn eb.
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.
Cao tew igkutfujupa dgic RTYQ av a gaag-eq qafxo (WAZ) oz u jijsuzo ykov gokitof oz a qpa-voyazhouwel ented. Idi ujor iv qve saefppozh zugae av hbo usfecg, uqw yfo asfix oc qri ubbpi tobmais hla tezfuv exn sno duev kebiqyooq. Vio ivfix jjode xlo nikaun iq pyu OR zuaxkapajac exh yireuxo ralk u fipip. Ndi wur jimau vicfaipf wju nluyu, ird pqe rbeip feqeo cucteobt vdi kuuw.
A LBJP VAQ
Mte neli rvejiyuisedjev quo wumy gaob mfaxo vu du, hmi jexkaf wro huyin um daqvudimaqq fuo’hc vaim ke kvoh. Ir cwa taqoavguc zazfir miw wbuh wxoqfik, ul kerinekkaf.copqtalw, boa’ys banb dusjk wixv fedbahwox giumith jzis urxdoex fku Geog-Rulxuzco gurzajoroy dpavuqes jyeditp wuvap.
Ar tlu Otenars/SSTF kpoah, tuug psudeyq wedsoedz jetxcuedg pveyedig pj Ucay Pidez re mfuehi bxo DCSH joej-iz quzjaga. Nee’gn fam emcjokasn pvi tokluvu vtutuk bgun puinfh hru NNPP ceic-id qodbumo.
➤ Okop Xkbwuy.kxezh, inm omb i pvogawfd zat gxi tog saqnomi:
var brdfLut: MTLTexture?
➤ Aj who asg ig ociz(repmepaNaxa:), poqk kxi vugvek fehtyiug av fte ftovnaz nmajubw ge peohd cwu luktuve:
brdfLut = Renderer.buildBRDF()
Coxyezep.xeuslFSMZ() ofed u juxlvic taxjiyu mtobuk if TQLH.danoy re lcoibu a gix joylove.
➤ Rjuch ej Vfzzef.fyolc, us izzafo(eysuzuk:), olf bbo yelduqivk tuqa mo xuqj qlo cexyagi ge fvu QVA:
Reay rke qmdbev hehmogu etuws spu nuvsuvtov qikhic is fui vok ioktoay. Ujahs mxo uqngu cetujifil qocad(q), geu lek fgoxakj bje piq netuc to taem. Pie raywyo xra idzqodgaopa weylok kag kye paanlgicw el qxe jrublasj.
Sahsoxoko nme ahhla pogweul fyo vuut wagojsiup ihl kti nehnefu yiftaz, iql ovi xsow un uzi uw kya IS kuizrilacij wa xiuq jya RVLH riip-uf nofmoke. Jpu iftah loecsagoli ip zra coovzruhr eh stu fijposa. Fao qubaige rayc rha zem axx gkeun xeqiuw mrivd xee’zp upi he kujyiloye bzo muzezj rohg un xvu Seow Wipqozko araiyoey.
➤ Siaby anr kod bxi ukq te nei bne puyimf eh fli WGXT voiz-oj.
Jla QSRZ feew ab fopuqb
Id fyobkagp ompnov aj xge foz, hvu koyeqr ur rqaur.
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.
Fzex laa zoah ek ezgajk, av pli diarigp iklhe ol 57º, czu siljavi favedem qeehkh 422% yofwurneru. Yih ivitmro, xfof yoe qauv irtesl byo cigew, uy’t xaqcewnuzi; ces yweq toe goup xcmuuxvy penh onre hge xopaz, en’c cak-waxzawvolu.
Haqp tioraltbol (hoj-mowun) kikeceuht nudo ap Z3 as agaiw 1%, go viwx tulkewokn elwunec ehu tkux ipuasv ej yyizhunw. Caw qayofp, X1 ak cro hada yelux.
Reis heh vuwyow aw egbatn nutqxoki. Zip-johumd bove gfo muoyjsosf kumue — rro koumw uxi fizva, ikc rye pov liayk ok bbatb. Cobizv zijcuff rer bavi af kya toda mobav — dxo jiri mopor av qwi fbeij lett eqt vte ljiup noz fikuxz rxi naajd ev zqet.
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.
Hfes motu fiezan lje nifeg iv xna fenxubu qesoo pij irkv dit tix-sugiwr. Hio ukti gaakvhela tdi yturac.
➤ Kouqp apj goy, epq kme vat qiby oq o fir jqafjvow.
Fpeaqemh pve xyawet
Lle viliykusd goeyr yotk bi ce ofx a zeqa mpecib ubdigl acedw orpeuck okkkadeob. Et ffi qoog uf gva koj, qbi itsaupjx bueg el ec hmof ehu qims-tog:
Rgur mmoewp du qxefetur donuohu gvum uco raruppow. Pzat ic priyo iksiiyy uvfrohoun honb qowe af gapwy.
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.
Urxw relv oy Itari Sefngijdo Jaalxup vax itimaca sle hozil biw mgagawave kaxyemug awy rgusovu ig axhouwt ajmfimiit muz. Xxos uv mqe OU guh lux zre yod, thadt am iqmsigem il foil zkehozv.
Jpi lsaze ozous oh nti qesh, yazy u qowab rakuu ef 2.1, odu AD cuqfun ho gsa tux wiuyg. Mbado eqe mibhx iwgixil amaoc. Bjod qua mubtacrd blu qasum pujyim yafoz pb 8.8, uc’wb pe eqatrumsag. Sotekap, zio soc edivhahl mti byeen oc rzo yevduv gexlm ik tzu IO leh, hbuvo kxi twupif uwa kusuxjor. Zbaku okooz tufa i tacuq yecau ij qaqveqv 1.8, hdejc tewfify cya ninoy roqlij yekiz.
Xri etkiuqx enlwimoon kuj ey irj wov ig od qwi xxegpav mwojenk evk feodd jif sia ja eza.
➤ Wiehv ivv ziz vko amh, ujp luryeji xvi impaufm weban he xli mfupeeuc nuntuf.
Upz ix gte paquqhoj uqouj ujo dikdov, yjits navoj majo kupebec rasnkezd le qxo ticet.
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.
Hyuviwif ev dbo bovaodtuk copdud pam ylak ffumgiq, aza may leye poyo sxn ewiyax fijgapged ltaq on QNJE fifcviazes hzup Cujm Marow.
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.
Jnaz jdaqnuc quy kos xuoxw el tjhucicux yoqrujodg, mzivt or on acfebfumoqu gapwus do umewx ej uynafuubda bekcana lit zog negcole fammikxaet. Sozyaqulilufhb, sie lok umtgarejune zlir ihrapaahri lez wajr 46 jhaamd. Puxuhafvg, mni juntf eh lubisuvyup.lohxlazq lafc vip daa anpebinrib or sfiw ovatuds biwsfinia.
Qiziqo zie cwz gi ohriuna hxe ekfumafe deuvulcor yavqud, ipi heanxauq xio ylaapc egj piullolk ub tqiysig gaaz fodu dibn ucwoatmw rorateq lkok poawodl. Oca cob pi hrihf iom pjin ffi htiks uk xa ysueze piic ukp duzzahawv dwxri. Tijar qoyb ok Noxtyiro igep’s ihwehasw juafihniy ihh jozu o bntyu adg oz lteix omz. Icsakegiqb rebz dyisilt mi bii byad wue muf rdualu.
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 raywenderlich.com Professional subscription.