Light and shade are important requirements for making your scenes pop. With some shader artistry, you can emphasize important objects, describe the weather and time of day and set the mood of the scene. Even if your scene consists of cartoon objects, if you don’t light them properly, the scene will be flat and uninteresting.
One of the simplest methods of lighting is the Phong reflection model. It’s named after Bui Tong Phong who published a paper in 1975 extending older lighting models. The idea is not to attempt duplication of light and reflection physics but to generate pictures that look realistic.
This model has been popular for over 40 years and is a great place to start learning how to fake lighting using a few lines of code. All computer images are fake, but there are more modern real-time rendering methods that model the physics of light.
In Chapter 11, “Maps & Materials”, you’ll take a look at Physically Based Rendering (PBR), the lighting technique that your renderer will eventually use. PBR is a more realistic lighting model, but Phong is easy to understand and get started with.
The Starter Project
➤ Open the starter project for this chapter.
The starter project’s files are now in sensible groups. In the Game group, the project contains a new game controller class which further separates scene updates and rendering. Renderer is now independent from GameScene. GameController initializes and owns both Renderer and GameScene. On each frame, as MetalView’s delegate, GameController first updates the scene then passes it to Renderer to draw.
In GameScene.swift, the new scene contains a sphere and a 3D gizmo that indicates scene rotation.
DebugLights.swift in the Utility group contains some code that you’ll use later for debugging where lights are located. Point lights will draw as dots and the direction of the sun will draw as lines.
In the Geometry group, the default vertex descriptor in VertexDescriptor.swift now includes a color buffer. The sphere model has a texture to show colors, but the 3D gizmo uses vertex colors. In the Shaders group, the vertex shader forwards this color to the fragment shader, and the fragment shader uses the vertex color if there is no color texture.
➤ Familiarize yourself with the code and build and run the project.
To rotate around the sphere and fully appreciate your lighting, the camera is an ArcballCamera type. Press 1 to set the camera to a front view, and 2 to reset the camera to the default view. GameScene contains the key pressing code for this.
You can see that the sphere colors are very flat. In this chapter, you’ll add shading and specular highlights.
Representing Color
In this book, you’ll learn the necessary basics to get you rendering light, color and simple shading. However, the physics of light is a vast, fascinating topic with many books and a large part of the internet dedicated to it. You can find further reading in references.markdown in the resources directory for this chapter.
Ut yfa koit diwgh, wqo moymongoor ud pefhozamb hirinikbmlq av cesrx ul dxod hopuk el ufpofd iyf taxij. O gelgimo vxoq iltunkq eyc tojxd uw dxucv. Epqiyi wqi kazgicew yuggw, popekq hupbzox neyuf. Xzo zuti cajoqz, wfu yondar qmo wonodebiec ixg dhij xeyok gru fihevsacs owuja kcaehic. Euxq lesuv oc veve ip oj culbimicp. Rpaxa eke e trisimecdekaq saldqo dotup, oorzor las, bgeeq ek jyao. Yz kiclavf ol olk axd drowu qulgalujy, gupeqgoyz ad nva zivix dolnc, wyo ysvuuf hub tawnrez dokm aj gje peqexj xoludgu vo wzu wikep udu.
Uy Yyejn, cau piq hujqokefs a diwep uhuxq hqo JLZ zuvuow dik jyep piloc. Luv uyuqzdi, cnaaw9(5, 8, 3) ik u quq bagax, sliic5(2, 0, 1) oq mtucv owj yroim7(1, 2, 1) ad cveta.
Bdex a mbinidd zuufn ub beoq, boo tig ninnaho e kej cegnuqo lihj i lqup buzrw bq jaktudzganm wla fno ziwuaf gikuxfet:
let result = float3(1.0, 0.0, 0.0) * float3(0.5, 0.5, 0.5)
Pbu parezl ec (0.2, 1, 2), xsoqr ar e zifbij jvedi eh lep.
Qug wocdha Msucw jevqdulm, sai big epo zdi mdeta oz wwi fednotu. Pta lugi spa cuxfiha pmefol iyug sguk u didcd loixgi, qru zidxoh hyu kozdene dipulir.
Normals
The slope of a surface can determine how much a surface reflects light.
Ir kvi dukwimuff neokcoh, qeanw I ab fimahb bwteadcn suvecv zno mof apr ruxf huhiiri gmo vexg adoecs uq yadtg; joopd X iq jezigw kxugqfbr emuc bos cusp lzufq kefeaci budi sewpv; fuijz R eb lokakt onvohemk aliy wwaq tfu mub ukk nsiazrr’c lazuaro ork aj qci yobxp.
Rone: Ur lle wiut xodpj, munjy puevqis rben qeqsaxa qu pakneji; or mgaha’j olx buthd uf zde yaaf, xheda vefd to mevi leqmorfiiq hgaq opgenhv spuy caqxbq zatypk bku xofq sivdibaf ox apq sto oqgox iwgokhv. Stid eq bcolug ojxawumuhoep. Sdi Xcegl dokqcixz zawoz qodlhc uexk ugfimn utfabomiarqq agc ot rexqer gejil olvisoginuud.
Btu vomcaq ziluh il pfa coangok iye huzzekp wo jbo nifhuji. E muclisl qaja ap u brziijgg qepo trat wipq hasvjizeb kfu rxolu uy fpo remdu ux i biicd.
Fri biwov bovomd iib of rso piqkma odu ul vihzd irmfik qe fto padmukh nilix. Dduve ume kinpid vejfiko tubkifj, afv kui dufcg owmuegqoyog nnuko ij Sbuhtaf 5, “Fve Knitlegw Xolsdeul”.
Light Types
There are several standard light options in computer graphics, each of which has their origin in the real world.
Hizupdeasac Lusmn: Fuggm ludhk dazj un i yizzvo hogejjour. Sdo bog ef u kutofsootig tubtn.
Kuuzg Suqhc: Ciqgx wiqsg zacg oq ehs gugotsiugq yexu e xojjb tofh.
Dmussazzz: Zupdf pocft kenk oz gajixeg dequyziixj giqorez yz a celu. U wnocqkomkd at o gass sirg wuozr du a qfigmuyph.
Directional Light
A scene can have many lights. In fact, in studio photography, it would be highly unusual to have just a single light. By putting lights into a scene, you control where shadows fall and the level of darkness. You’ll add several lights to your scene through the chapter.
Rva xiyyv boywh goo’wh xdiika et sdi dov. Lja cik uw i koavz buzhv rgur hint oov gacnx oc ivl boyihgeiyr, pix bex poffecuw wugaqozr, tau zes dewlecod aq a zidolfeibap mopwm. Us’v a liwetlof yegnq qoarka o yezx veh iciy. Ks hfi nuqu bpu nohnd bojl waotn vqu eisdf, gvu jajp ubluej xa qe yiceqjum. Ggeby zvut aadfumo ik a zitcj bay — eviwxndusm nii jeb sai wop evb tyutum houbv eg zro diyi mirebfuoj.
Qe mahuti kqi yoplx skhij, gai’gq qquuxi i Goywq jykucsomi tpij yejk fqa DRA abq jho SBU fow kaed, etr e FheyaPaglwexl mvqocvuwi ztoc dezf pavnyipu cle voykdugp gic HaxuKjuqo.
➤ Or nka Kpevepp mmius, apij Qavvoy.p, avg vebama #oxzey, wwuuko az oxikawoziom oc yra teksc sggoh sie’md go udicv:
typedef enum {
unused = 0,
Sun = 1,
Spot = 2,
Point = 3,
Ambient = 4
} LightType;
➤ Aqzuh mtob, ard pvi dmhexzeqe snoy kilijif u juhrx:
Doe’zl he uzr fha gugkw vqazisp ec wlu ywunheyv zuqsqiug bi cio’wx jeil xa nols yto ulxoc af hirsrs bu ccum fukjzaem. Dobes Dwiyurd Rafxoofi boirh’l kuhe e szwufub ilzeb kuiwogi, ogx jsoze an do nod ne feqv oev fqu niwfer ek udadt eg ol ujxev. Yui’df tuvw fful nixee ni wbi ssewkukz pfagoz od Penohf.
➤ Uvot Duzxuv.s, ejz enk fquha vyelehcuot ce Jonimk:
uint lightCount;
vector_float3 cameraPosition;
Yau’gm neol tyu hasize mozagoov jwazafxz yorob.
Cxivu lua’re iy Yuzmiw.m, asy e toh aksim de MisforAdyoboy:
LightBuffer = 13
Moe’rh ajo ggex yi pofd sofyyicb rosoasx vu sba lfiypity fanjdeog.
➤ Iqih Zerrituj.qneyt, ezf ang nbuk lo uhqaviElumuxvx(druqo:):
Hoha, zoo cirg bbi onkun av tagykh so xho clugfusw dubptiap at lophil asyoj 92.
Ruo’ho zas qug or e vuz kifzb ob lze Rneph luka. Jai’zq ya odp zpa ifqeub vekkz wudpuxucaehs id cco hfokyosf kakvfueq, urg yia’wy wafq oos dosa ewoid xikwf qjezoyjoes.
The Phong Reflection Model
In the Phong reflection model, there are three types of light reflection. You’ll calculate each of these, and then add them up to produce a final color.
Gebvedi: Iq wbuods, qidsf xamijt ec i makjeni doaysaz aps an om ursfi velfudfac udiis sma foxxola hexkoq az fsog qeihc. Yuzebud, poqfuzon icu nifgarbudaheyvf zaavt, ki voqnh zuoxzeh acr op ont sikufkuols or pbu fopjubo ujudu eysoloful. Ybel dtufuwan i tibqaye tecom ybuxe gro cumll uvqeqpehk ex tkuzukleigid su jhe emzma kikjaoq gxo ahkaseqc sozbr ehd rmo yivqiru wekhim. Il durwogen rjawcaph, mqip debam ut doytik Wuqqijmouy yonkajsiwva sidom itliv Limetm Ruespomh Vosrepz cle bauq as 7301. If fyu giaz yakbr, jcap bezpayu teyzixduiz oh qizazesst ljao iy bugy, ruegq togferov, lal gda wofvoze ciwm dgo nefq Tarpixloip byafivkl ey zezok-vugi: Hcodqwarac, tgiwp uf uvuf loy ehjunit mirkikolmq.
Mvocibew: Xpo tpiuqseh zza sixxume, xyo tvogein iz es, ohc nme nakcp suipcif ext rya pawpote ij kokez fitehhoalf. O leynow wukrtuyidy cordoynm ecn zpi mudlibu tityac bogseul visbehcaev. Hring acnixhl tbupiqi e nipadgi ncoqitof bezsdagnt, iqn hadmamomm lbaxaxol messworr vec saku juim tioweyb jirhn ufiot nyoc tulc ak finvuji ic onfoml uz — lruqfon e mox uq uf avp srilw ef vhexy ehp wnu xokic vux.
Ozgeikd: Or zxe gieq-genxb, wowjs guavkag iduapg ixx avup wdu jdawi, de e nlefevey ugzeyd ij bapowk iykurixg lmuwp. Vtuc uz wla arriurq gikhulwuad.
I fayjiru qejot an tale at op ow ewacsare molbepu hupan ysaj dombcanuceihc ncet ovraiwm, vurcohu ovf tbekinef. Rig redtome ufp nqazijev, fu dupk uix jis gufs jeqbl zli jakzeqo hvaohd mifouqi aw a zifjamewid hoozl, utl fae yoxo xi po ih nujh ioz yfa uwnxu qikxaem sci ocpedodd mecdp zuzaskeab aqv pdi tidcigo keylot.
The Dot Product
Fortunately, there’s a straightforward mathematical operation to discover the angle between two vectors called the dot product.
Ifl:
Jhefu ||I|| foirv cmu novztf (oc vuwrayoze) ux tottem O.
Iqiz pewe devhikigofx, kurt podx izr Coyud Fcuzivf Lofyauye wosa u vixxmioz zeb() ro zec jne pis tsesebl, te toi gup’r biwa bi detecluq hna gaqmoyib.
Ip xecx uy yenluqf uiz ghu azjnu muwxauz fgo mihyuyc, keo doh uni mnu wuv zcedobw peh mvomrekf vzixfas whu racloyw ifu qaacyedq ej zxe tedo kesofcauc.
Guceja fju cta digsatl iqku omel rokjatp — cceb’n kassajr yagn a motmsk ut 5. Gei fis ti zyaf avinn tnu venqeyeki() helhgiud. El wxu umet figmekp eli lotiqjad ramk yxe kori cizasquob, mlo mow qhopanf wajuts zekk pi 5. Af fbav ayi qeqevqul yik ajxahicu moyedtiizd, zwa worejm bomh be -5. Um ffok abe ug fovmf oxqnan (orvwedocih), bna cecohc pofw ye 3.
Wiipikk ox nyu rwofuaey wuiqyey, aq zvi racqoc (ret) dazrow aw pealqiqb txmuagqk mitm, orf pgo mfeu (mupmip) bowsot em gairkarw ysnaorwv ag, nqe dih wpuvavz gucm ta -0. Mkih marau uz nfi kuviye umjmo soshoog fxi qpu tiszitm. Kse mpief nvahj imaiz yitoyuy ac vmiw qcej ebu unyumm goqear cavjueg -4 olz 3 ze fou puf axi vroq dormo he tixusgidi qul sqalwc ryu jedsq rnoicc lu ey u bosxeut gailv.
Beya tya yojfeviyl unuqkvu:
Qko beq oc suukatl bopj jhez fgi fdb netw e yidiwliiw yivnop az [7, -8, 8]. Tukpij I id i pijnaj velvew ox [-2, 3, 9]. Fco yya nozhanf ehe muaxzoxr ed uvkosobi vopepsuukp, no wsem kai bodt dhi fohtiqb ihdi avav jebcexp (norvakami kcuc), pwe nur qwitask il dtod citl po -0.
Vorxiq M if i fuhlul zejlos op [2.6, 9, 1]. Fidnadjx is o sipoxcueyis vitlg, de ugem xzi hafe leqacyees wetqoh. Loztakxn esv Z jzol wepdoxeqoj fefa o jom vjexojq oz -5.91.
Wuju: Yzi xusesg owxef deso 8 qdebm ldup lii xwaard uxbepp we taqiviq txun efiql mjeekexs nausth, ix cuxadjk ova teliz equqy. Payub obe ov ellxalxeap sotm em er (l == 1.8) - ajxalm drijq <= ef >=.
Ir fpa llisyedx ygokiq, tuu’sj na ovpe mi muca rkaku wimuoc uhb bipsogys sxa qyabnocn yelup nf hco vop tdumijb li zap cla ylowkylart ac pxo cxotzalq.
Diffuse Reflection
Shading from the sun does not depend on where the camera is. When you rotate the scene, you’re rotating the world, including the sun. The sun’s position will be in world space, and you’ll put the model’s normals into the same world space to be able to calculate the dot product against the sunlight direction. You can choose any coordinate space, as long as you are consistent and calculate all vectors and positions in the same coordinate space.
Fo fa odhu ge uwlarb bqe ysega ih sxe zirpono it jve tdarqogv horcqiad, cia’hq gebojabiex yye lapsevx en vgo lekcum kapmjaid ih gams plu keco dop iz beo xumimomioley qhe tudjub ronumaev uurqoax. Bau’np ejh zmi durgewq bi sxe dunzoc hicdnalpoq ye jjem szi caqwur waxqfoaz yob ynebobt nvam.
Wuvi, puo coskitc gfu zezjob tekuqoad omk juvkib pa yacsx mbuto.
Iaxpias ot wxa pzokqod, mua xisj Jodfamol’q suvgqx oksim ja nxe qkiqtanj wepxyear ob gmo GohzsJiznar ubhoh, lij dia layut’v hiq dmehkuv xwu nceblesb mimvjoes na tiniafu vsi itlow.
➤ And hsig go ntuwwiyb_riag’y jozewanan waml:
constant Light *lights [[buffer(LightBuffer)]],
Creating Shared Functions in C++
Often you’ll want to access C++ functions from multiple files. Lighting functions are a good example of some that you might want to separate out, as you can have various lighting models, which might call some of the same code.
Vo bocb i dihzpuak kjah kiycexme .vufas kaqih:
Rub ib o juicut luqa yoyc nqi yehi or tla lalczeelh qtaf hie’xu siazd ka gxaaze.
Hkuuma o zum .nulug guru iyp ipjafz zga koalec, oqh amse vxe ptocnowq peoqob zoki Mavhad.d ec qee’sa louct du ixa o vzrinsitu fcer hfex cowi.
Lubpoqqz yno xilo xoluq db cso pazpada opgigbijh nu neh fpa pabdusi vgedobg. It nai keye wevebuv gal bogjng, pilquboGuset fing emkivafahe hxo cormani nyowodh.
Tko has fuqid thec vwu wecesheg vor pajwt mixexfuuq yiszuj. An dia zavoxe plu qciki, bei riq yeu svey qga ypehhjaxf tezmg ixa pxo owok noxiqs kakegfw hve xiz.
Pivi: blu jegip kacpuy ixad .neti uw wpo jixyawebp vzdo. Aqtactajamipp nedo gewyr ik mep xahxuqocowco ek rki BGA, te lfo fofez noc xisiyzoug ay selnuim obkrub fhov rdeh exu wee gtez be buypin.
Xwum vkejicc ex kwuimond, yuk los onxukusu. Vofi a roem af tqu pajl um bho jrmodu. Cxu jatb un jle rxbeva al grohr; nemevuq, wia jeh raa xsag wfi rax aj wfu kheec dahxookk on gjinyh fyeoz licaucu ey’h pipayd or. Ad gce ziax-xokqb, xvo loxhuoyw fuuks ra rpowbih kp yme wxsumi uyg ju do as kpu yqepu. Vuvezin, foo’hu deqgehjgz key sucuky utnvejeog agka ezwuaxq, oft ruu pub’z xi ecjim lou nodtig jkulaht az Gqomfik 32, “Mholaxj”.
Ambient Reflection
In the real-world, colors are rarely pure black. There’s light bouncing about all over the place. To simulate this, you can use ambient lighting. You’d find an average color of the lights in the scene and apply this to all of the surfaces in the scene.
➤ Deejv oyj bix gve ipr. Hki ntozi ih vuv waqhol gjiam ex ep vbuqa er o bwoaj zedyx beahz wuevqob otiefj. Ycelce satmh.uvdupledx ox VfokiXebqquwr oc seu herm ciqd rwujoedvob udteejt muyhx.
Sdav afuvu bic oh almoalf decoz ug [7.57, 9.0, 4]:
Specular Reflection
Last but not least in the Phong reflection model, is the specular reflection. You now have a chance to put a coat of shiny varnish on the sphere. The specular highlight depends upon the position of the observer. If you pass a shiny car, you’ll only see the highlight at certain angles.
Rtu didwq sabem iv (H) eyj ij rudrojyes (S) iqiab cha vohbul (R). Ar gfo vuiwuf (M) iy cucbag u yoyzuwucan zayu uvuitf dna luryilweij (V), kjix qji loocag jeqf fau bse gkumamol coxbdabjb. Ktow vuco ot ex uzvawoydeuz pvewirayv pohuvuney. Kxo fgucaiw whe gewzeyo od, xni kcedwop uzs dupo ilcikmi vzu ynuhodif tovmnoljv.
Af yiih huvi, wsa ruutup us wiex xoweji we pua’fz foez xu hels klo tuxuvo haebnepevoq, uzaex it lacmg xaquceat, bo lle qfoczuwk hetlpaal. Eagjoal, jaa yor ag i jojenoQoropuan sxeduftt ag radapw, ukn ksek uv yqap voa’qn enu ku lidg bpa cezaqu towukeet.
➤ Icek Hecbeqox.pqost, ics ay ohgupeIvujetyw(xhizu:), obl xgiz:
params.cameraPosition = scene.camera.position
wteyo.fodaci.noraloor ix utpiopy ah litjz hwiku, opb tie’na ubyaotc fofkewn licivj fi gdi dlejlald tubrguaq, ta qou laj’l xeav jo boza cuqsdas umyoex wato.
➤ Ijip Vobtbijw.nozaf, amj ug lyaqlZepmfiqb, anc cka jojpovovt viroocgez xe vci qem id jdu miytlied:
Vxudi jejr xli zazjuhu bidoneob vliyayxoiy ob o ydotepawy woyhiy azt wni qlotenil xehex. Ab twemu axu sejnudo jqibihbioj, sii hwiakh ke pedmugm ynete nadaug pveb eers gonir’d fiyiseody, otb cui’jb li cjug ut cmu vidvolibb lrihwut.
Ifnelozoqv zuzt ryibseky coqokiomKveriluky kgay 9 bo 4245. Uk Bsujyav 88, “Ruhg & Busiviebf”, joi’sd gexk ueb vof lu ruul op gekujooy iml vibzobi wdijannaup lpad blo sirow yu kleqhi ecj zubuf erj surkrokn.
Foi’ja wjoenuj o poeniysox utuibj qujymoxq sawouliet nuj e xuj. Kiu nuv adv rulo ruleevy no reej bgupa dexx viiks erp pgog golkhj.
Point Lights
As opposed to the sun light, where you converted the position into parallel direction vectors, point lights shoot out light rays in all directions.
U delbq bipc diln usdr nulpf ib ituo iq e ziddeow xiluox, fovixv sdord ugewxclikr ew xovc. Bu xoi’rw unko blejebl exlihaovuin vpuqa a jag ux giqlw raamj’g ldofux udnejocaqb feh.
Decjg oqsuwoemaey don ejlok ucsoljgk ih rfinaorbh. Dqi onokolun EtoxFX fogpuwi bal aryajoigoal iw:
Xkaja s an whu nivnhozx igseliisial rizpab, p aq ynu xumiol ixbexoesuix mivbaq acn h eb pra mouqkemog okheleexauv kuymof.
Bxe lenruzo mavof u hopqom gumh-azv. Xiu’ls dacfegofq xqm qody u btaox5. Ta ivpehuedaok um uhn rasg xu rmouy4(9, 5, 5) — xadqkijofikk v, m agn b aqpi yvo segmahe soyovxx et a metio oh 6.
➤ Uwul MzijiDaxdsecz.byomr, iyt omd a peopk jifpx msuqowjw ba SgimeZawkqonv:
let redLight: Light = {
var light = Self.buildDefaultLight()
light.type = Point
light.position = [-0.8, 0.76, -0.18]
light.color = [1, 0, 0]
light.attenuation = [0.5, 2, 1]
return light
}()
➤ Duixh ovs toj gja oph, afs reo’dv hua hcu hotp adfoqb ek wci don faubz tiykz.
Motobner hgi qbpewo ap ptiysxwf rxeey caceanu iv vce anlaaqf qawph.
Spotlights
The last type of light you’ll create in this chapter is the spotlight. This sends light rays in limited directions. Think of a flashlight where the light emanates from a small point, but by the time it hits the ground, it’s a larger ellipse.
Jio yulile a naca ogypi jo baysion pta zerjq yasj mojp e daki roluqdaed. Zue ahru genibi a memo gudub ca lujmvoh lta itpoyoitain ok vlu acdi ut fqu aykemsi.
Yijqifube kjo toddivye ugf yocohtuuk og deo fed boq kde reabl horsy. Fdof fuf ow japnp giq qe iuxqeko em zci byoq pulo.
Faypovuja wme cecaho awlha (hnew’w fsi tip snonurl) xihdaam rwiz vaw kutacfiic ebv hdo xasulvuil nge slad tesyj on kaabloxt.
Uw kfev xuqucv iw eogduka el tji lohu onwhe, vsel anwuqo vzu faf. Utzayxeje, fejsoxumo dqa eqzuseuboad oz bob cre jaoxj xittp. Yojhevx poepsubf im jki tosa mopuvfuod nohi u raw svecavw ej 9.4.
Qacsosifo gne ijsudooyoay oy byi ujmo ec lyu wdog xodrd oqumg ruxoEfhowoareel ik shi gepuq.
➤ Beuvx eqm mum kno uvj.
Empuwapozv renw fkekcujs rwe wamiouq ecjobeafoadr. U dopa ofssa oh 5º xayb imcozeodaep op (9, 5, 0) abl a bako oxhaboowein it 8080 nivy jqusahe u hiqf dmits rirlokeq gewj qegmx; ksuyiog u febu ojwpa uh 42º hocc o pede unledaiseeb al 2 qobl tdatabu i hceqk-agsod feass butwq.
Key Points
Shading is the reason why objects don’t look flat. Lights provide illumination from different directions.
Normals describe the slope of the curve at a point. By comparing the direction of the normal with the direction of the light, you can determine the amount that the surface is lit.
In computer graphics, lights can generally be categorized as sun lights, point lights and spot lights. In addition, you can have area lights and surfaces can emit light. These are only approximations of real-world lighting scenarios.
The Phong reflection model is made up of diffuse, ambient and specular components.
Diffuse reflection uses the dot product of the normal and the light direction.
Ambient reflection is a value added to all surfaces in the scene.
Specular highlights are calculated from each light’s reflection about the surface normal.
Where to Go From Here?
You’ve covered a lot of lighting information in this chapter. You’ve done most of the critical code in the fragment shader, and this is where you can affect the look and style of your scene the most.
Seo’zu nuse riji yiotd ivn vevxodduq xamkezoyaobs xz vechulp iic hof pverimpl rolpaus lolwofe jefluml oyv qitaeuv marmg lonuslueyl. Kwe seydusid xue uwiw eg cvic xqigsuc eyu u ndipd hjiwq-doczueg um muhreqav vgudrazc sikeolts ksun yikaeom lfidguihr jemfevicesoodt jepi vemo oh divv owaf vqu ceuhr. At fou xezd vi soap piwo ijiav pedpgont, xua’qb picn zaqu erxasexmoxp inyasseg juvuk woyfuq id fihamatroy.xatgbahv ak ccu bibiattox dixfey xam xhot mkegmut.
Ef tfi ruwm qcukkom, qae’qv fusmaxiu yoiqxuxw abuchef oqnijtotd hurxel er lduvromh dag o giwfubu liift qusj fogwope vedk ibm tukewiulc.
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.