基本的光照计算公式_第1页
基本的光照计算公式_第2页
基本的光照计算公式_第3页
基本的光照计算公式_第4页
基本的光照计算公式_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、基本的光照计算公式TheBasicLightingModelOpenGLandDirect3Dprovidealmostidenticalfixed-functionlightingmodels.Inourexample,wewilluseasimplifiedversionthatwewillrefertoastheBasicmodel.TheBasicmodel,liketheOpenGLandDirect3Dmodels,modifiesandextendstheclassicPhongmodel.IntheBasicmodel,anobjectssurfacecoloristhesum

2、ofemissive,ambient,diffuse,andspecularlightingcontributions.Eachcontributiondependsonthecombinationofthesurfacesmaterialproperties(suchasshininessandmaterialcolor)andthelightsourcesproperties(suchaslightcolorandposition).Werepresenteachcontributionasafloat3vectorthatcontainsthered,green,andbluecolor

3、components.Thishigh-levelequationdescribestheBasicmodelmathematically:surfaceColor=emissive+ambient+diffuse+specularTheEmissiveTermTheemissivetermrepresentslightemittedorgivenoffbyasurface.Thiscontributionisindependentofalllightsources.TheemissivetermisanRGBvaluethatindicatesthecoloroftheemittedligh

4、t.Ifyouweretoviewanemissivematerialinacompletelydarkroom,itwouldappeartobethiscolor.Theemissivetermcansimulateglowing.Figure5-2illustratestheemissivetermconceptually,andFigure5-3showsarenderingofapurelyemissiveobject.Therenderingisunderstandablyboring,becausetheemissivecoloristhesameallovertheobject

5、.Unlikeintherealworld,anobjectsemissiveglowdoesnotactuallyilluminateothernearbyobjectsinthescene.Anemissiveobjectisnotitselfalightsourceitdoesnotilluminateotherobjectsorcastshadows.Anotherwaytothinkoftheemissivetermisthatitisacoloraddedaftercomputingalltheotherlightingterms.Moreadvaneedglobalillumin

6、ationmodelswouldsimulatehowtheemittedlightaffectstherestofthescene,butthesemodelsarebeyondthescopeofthisbook.ObjectSurfaceFigure5-2TheEmissiveTermFigure5-3RenderingtheEmissiveTermHereisthemathematicalformulationweusefortheemissiveterm:emissive=Kwhere:kisthemateria1semissivecolor.eTheAmbientTermTheam

7、bienttermaccountsforlightthathasbouncedaroundsomuchinthescenethatitseemstocomefromeverywhere.Ambientlightdoesnotappeartocomefromanyparticulardirection;rather,itappearstocomefromalldirections.Becauseofthis,theambientlightingtermdoesnotdependonthelightsourceposition.Figure5-4illustratesthisconcept,and

8、Figure5-5showsarenderingofanobjectthatreceivesonlyambientlight.Theambienttermdependsonamaterialsambientreflectanee,aswellasthecoloroftheambientlightthatisincidentonthematerial.Liketheemissiveterm,theambienttermonitsownisjustaconstantcolor.Unliketheemissivecolor,however,theambienttermisaffectedbytheg

9、lobalambientlighting.IncomingAmbientLightReflectedAmbientLightObjectSurfaceObjectSurfaceFigure5-4TheAmbientTermFigure5-5RenderingtheAmbientTermHereisthemathematicalformulationweusefortheambientterm:ambient=KgxglobalAmbientwhere:kisthematerialsambientreflectaneeandaglobalAmbientisthecoloroftheincomin

10、gambientlight.TheDiffuseTermThediffusetermaccountsfordirectedlightreflectedoffasurfaceequallyinalldirections.Ingeneral,diffusesurfacesareroughonamicroscopicscale,withsmallnooksandcranniesthatreflectlightinmanydirections.Whenincomingraysoflighthitthesenooksandcrannies,thelightbouncesoffinalldirection

11、s,asshowninFigure5-6.DiffuseObjectIVTagniedFigure5-6DiffuseLightScatteringTheamountoflightreflectedisproportionaltotheangleofincideneeofthelightstrikingthesurface.Surfaceswithadullfinish,suchasadustychalkboard,aresaidtobediffuse.Thediffusecontributionatanyparticularpointonasurfaceisthesame,regardles

12、sofwheretheviewpointis.Figure5-7illustratesthediffuseterm,andFigure5-8showsarenderingofadiffuseobject.IncomingLightReflectedDiffuseLihtObjectSurfaceFigure5-8RenderingtheDiffuseTermObjectSurfaceHereisthemathematicalformulationweuseforthediffuseterm(illustratedinFigure5-9):diffuse=KdxlightColorxmax(NL

13、,0)where:Kdisthematerialsdiffusecolor,lightColoristhecoloroftheincomingdiffuselight,Nisthenormalizedsurfacenormal,Listhenormalizedvectortowardthelightsource,andPisthepointbeingshaded.Figure5-9CalculatingDiffuseLightingThevectordotproduct(orinnerproduct)ofthenormalizedvectorSVandLisameasureoftheangle

14、betweenthetwovectors.Thesmallertheanglebetweenthevectors,thegreaterthedot-productvaluewillbe,andthemoreincidentlightthesurfacewillreceive.Surfacesthatfaceawayfromthelightwillproducenegativedot-productvalues,sothemax(NL,0)intheequationensuresthatthesesurfacesshownodiffuselighting.TheSpecularTermThesp

15、eculartermrepresentslightscatteredfromasurfacepredominantlyaroundthemirrordirection.Thespeculartermismostprominentonverysmoothandshinysurfaces,suchaspolishedmetals.Figure5-10illustratestheconceptofspecularreflection,andFigure5-11showsarenderingofacompletelyspecularobject.ReflectedSpecuEarLightObject

16、SurfaceObjectSurfaceFigure5-10TheSpecularTermFigure5-11RenderingtheSpecularTermUnliketheemissive,ambient,anddiffuselightingterms,thespecularcontributiondependsonthelocationoftheviewer.Iftheviewerisnotatalocationthatreceivesthereflectedrays,theviewerwillnotseeaspecularhighlightonthesurface.Thespecula

17、rtermisaffectednotonlybythespecularcolorpropertiesofthelightsourceandmaterial,butalsobyhowshinythesurfaceis.Shiniermaterialshavesmaller,tighterhighlights,whereaslessshinymaterialshavehighlightsthataremorespreadout.Figure5-12showssomeexamplesofshininess,withtheshininessexponentincreasingfromlefttorig

18、ht.Shinins=5Shlninas,s=20SliiniriM=50Shinira-100Figure5-12ExamplesofDifferentShininessExponentsHereisthemathematicalformulationweuseforthespecularterm(illustratedinFigure5-13):specular=K$xlightColorxfacingx(max(NH,0)shininesswhere:Ksisthematerialsspecularcolor,lightColoristhecoloroftheincomingspecularlight,Nisthenormalizedsurfacenormal,Visthenormalizedvectortowardtheview

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论