计算机图形学computer-graphics课件13

PPT
  • 阅读 86 次
  • 下载 0 次
  • 页数 63 页
  • 大小 3.519 MB
  • 2022-12-01 上传
  • 收藏
  • 违规举报
  • © 版权认领
下载文档30.00 元 加入VIP免费下载
此文档由【小橙橙】提供上传,收益归文档提供者,本网站只提供存储服务。若此文档侵犯了您的版权,欢迎进行违规举报版权认领
计算机图形学computer-graphics课件13
可在后台配置第一页与第二页中间广告代码
计算机图形学computer-graphics课件13
可在后台配置第二页与第三页中间广告代码
计算机图形学computer-graphics课件13
可在后台配置第三页与第四页中间广告代码
计算机图形学computer-graphics课件13
计算机图形学computer-graphics课件13
还剩10页未读,继续阅读
【这是免费文档,您可以免费阅读】
/ 63
  • 收藏
  • 违规举报
  • © 版权认领
下载文档30.00 元 加入VIP免费下载
文本内容

【文档说明】计算机图形学computer-graphics课件13.ppt,共(63)页,3.519 MB,由小橙橙上传

转载请保留链接:https://www.ichengzhen.cn/view-77498.html

以下为本文档部分文字说明:

1ShadingIShandongUniversitySoftwareCollegeInstructor:ZhouYuanfengE-mail:yuanfeng.zhou@gmail.com2Objectives•Le

arntoshadeobjectssotheirimagesappearthree-dimensional•Introducethetypesoflight-materialinteractions•Buildasimplereflectionmodel---thePhongmode

l---thatcanbeusedwithrealtimegraphicshardwareSimpleLightingmodelWithSpecularlightingGouraudshadingWire

framePolygonWhyweneedshading3WithshadowWithTexture4Whyweneedshading•SupposewebuildasceneusingmanypolygonsandcoloritwithglColor.Wegetsome

thinglike•Whichisthebest?5Shading•Whydoestheimageofarealspherelooklike•Light-materialinteractionscauseeachpointtohaveadifferentcolororshad

e•Needtoconsider-Lightsources-Materialproperties-Locationofviewer-SurfaceorientationWhy?6Scattering•LightstrikesA-Som

escattered-Someabsorbed•SomeofscatteredlightstrikesB-Somescattered-Someabsorbed•SomeofthisscatteredlightstrikesAandsoon7Rendering

Equation•Theinfinitescatteringandabsorptionoflightcanbedescribedbytherenderingequation-Cannotbesolvedingene

ralways-Raytracingisaspecialcaseforperfectlyreflectingsurfaces•Renderingequationisglobalandincludes-Shadows-Multiplescatteringfromobjecttoobject8

GlobalEffectstranslucentsurfaceshadowmultiplereflection9LocalvsGlobalRendering•Correctshadingrequiresaglobalcalculationinvolvingallobjectsandlightsou

rces-Incompatiblewithpipelinemodelwhichshadeseachpolygonindependently(localrendering)•However,incomputergraphics,especiallyrealt

imegraphics,wearehappyifthings“lookright”-Existmanytechniquesforapproximatingglobaleffects10Light-Mate

rialInteraction•Lightthatstrikesanobjectispartiallyabsorbedandpartiallyscattered(reflected)•Theamountreflecteddeterminesthecolorandbrightnessoftheobj

ect-Asurfaceappearsredunderwhitelightbecausetheredcomponentofthelightisreflectedandtherestisabsorbed•Thereflectedlightisscattered

inamannerthatdependsonthesmoothnessandorientationofthesurface11LightSourcesGenerallightsourcesaredifficulttoworkwithbecausewemustin

tegratelightcomingfromallpointsonthesourceLightcolor:I=[Ir,Ig,Ib],RGBmode,CMYmodeBGRYMC11112SimpleLightSources•P

ointsource-Modelwithpositionandcolor-Distantsource=infinitedistanceaway(parallel)-I(p0)=[Ir(p0),Ig(p0),Ib(p0)]SimpleLightSour

ces•Easytouse(incomputer)•Realisticispoor:•Imagecontrastishigh,somepartsarebrightandothersaredark;•Inrealworld,thelightswillbelar

ge.•Wecanaddambientlighttosolvethisproblem.13umbrapenumbraSimpleLightSources•Spotlight-Restrictlightfromidealpointsource14Whyusecosfunc

tion?SimpleLightSources•Infinitelight:Sunlight-Justknowthelightdirection;-Theintensityisconstant.•Ambientlight-Sameamountoflighte

verywhereinscene-Canmodelcontributionofmanysourcesandreflectingsurfaces15Ia=[Iar,Iag,Iab]thesamevalue

ateachpointonsurfaces16SurfaceTypes•Thesmootherasurface,themorereflectedlightisconcentratedinthedirectionaperfectmirro

rwouldreflectedthelight•AveryroughsurfacescatterslightinalldirectionssmoothsurfaceroughsurfaceSuchasmirrorsSuchasawalltra

nslucentsurfaceSuchaswater17PhongModel•Asimplemodelthatcanbecomputedrapidly•Hasthreecomponents-Diffuse-Specular-Ambient•Usesfourvec

tors-Tolightsource-Toviewer-Normal-Perfectreflector18AmbientLight•Ambientlightistheresultofmultipleinteraction

sbetween(large)lightsourcesandtheobjectsintheenvironment•Amountandcolordependonboththecolorofthelight(s)andthematerialpropertiesof

theobject•AddkaIatodiffuseandspeculartermsreflectioncoefintensityofambientlightaIpaIak=19DiffuseReflection•Anidealdiffusesurfaceis,atthemicroscop

iclevel,averyroughsurface.•Chalkisagoodapproximationtoanidealdiffusesurface.•Becauseofthemicroscopicvaria

tionsinthesurface,anincomingrayoflightisequallylikelytobereflectedinanydirectionoverthehemisphere.20LambertianSurface(朗伯面)•Perfectlydiffuserefle

ctor•Lightscatteredequallyinalldirections•Amountoflightreflectedisproportionaltotheverticalcomponentofincomingl

ight-reflectedlight~cosqi-cosqi=l·nifvectorsnormalized-Therearealsothreecoefficients,kr,kb,kgthatshowhowmuchofeachcolorcomponentisreflected,rela

tedwiththematerials21Lambert'sCosineLaw•Lambert'slawdetermineshowmuchoftheincidentlightenergyisreflected.•Rememberthattheamountofen

ergythatisreflectedinanyonedirectionisconstantinthismodel.Inotherwords,thereflectedintensityisindependentoftheviewingdirection.IpdIpdcosqqCABdIpdId

kcosq=:,,ddrdgdbkkkk:pdIincidentlightintensity22Illuminationeffects•Shadedusingadiffuse-reflectionmodel,fromlefttorightkd=0.4,0.55,0.77,

0.85,1.0.•Shadedusingaambientanddiffuse-reflectionmodel,Ia=Ilight=1.0,kd=0.4.Fromlefttorightka=0.0,0.15,0.30,0.45,0.6023SpecularSurfaces•Mostsurf

acesareneitheridealdiffusersnorperfectlyspecular(idealreflectors)•Smoothsurfacesshowspecularhighlightsduetoincominglightbeingreflectedindirect

ionsconcentratedclosetothedirectionofaperfectreflectionspecularhighlight24IdealReflector•Normalisdeterminedbylocalorientation•Angleofincidence=ang

leofrelection•Thethreevectorsmustbecoplanarr=2(l·n)n-lrlHowtocomputer2cosincosinlnliv25ModelingSpecularRelections•Phongproposedusin

gatermthatdroppedoffastheanglebetweentheviewerandtheidealreflectionincreasedfIr~ksIcosafshininesscoefa

bsorptioncoefincomingintensityreflectedintensitycos()frv26TheShininessCoefficient•Valuesofabetween100and200correspon

dtometals•Valuesbetween5and10givesurfacethatlooklikeplasticcosaff90-9027SpheresshadedusingphongilluminationmodelRefractlight•Snelllaw•

ηt,ηiaretherefractfactors2811(coscos)tiqqt=-lnRefractfactor2930DistanceTerms•Thelightfromapointsou

rcethatreachesasurfaceisinverselyproportionaltothesquareofthedistancebetweenthem•Wecanaddafactoroftheform1/(c1+c2dL+c3dL2)to

thediffuseandspecularterms•Theconstantandlineartermssoftentheeffectofthepointsource31Lightsourceattenuation(衰减)•I=Iaka+fattIlightkd(N.L)-fat

t=1/dL2-fatt=(1/min((c1+c2dL+c3dL2),1));Distance11.3751.752.1252.5C001.25.25.501032LightSources•InthePhongModel,weaddtheresultsfromeachlightsour

ce•Eachlightsourcehasseparatediffuse,specular,andambienttermstoallowformaximumflexibilityeventhoughthisformdoesnot

haveaphysicaljustification•Separatered,greenandbluecomponents•Hence,9coefficientsforeachpointsource-Idr,Idg,Idb,Isr,Isg,Is

b,Iar,Iag,Iab33MaterialProperties•Materialpropertiesmatchlightsourceproperties-Nineabsorbtioncoefficients•kdr,kdg,kdb,ksr

,ksg,ksb,kar,kag,kab-Shininesscoefficienta34AddinguptheComponentsForeachlightsourceandeachcolorcomponent,thePhongmodelcanb

ewritten(withoutthedistanceterms)asI=kdIdl·n+ksIs(v·r)a+kaIaForeachcolorcomponentweaddcontributionsfromallsourcesPhonglightmodel3536ModifiedPhongM

odel•ThespecularterminthePhongmodelisproblematicbecauseitrequiresthecalculationofanewreflectionvecto

randviewvectorforeachvertex•Blinnsuggestedanapproximationusingthehalfwayvector(分向量)thatismoreefficient37CalculatingthereflectionvectorR

=Ncosq+S=Ncosq+Ncosq-L=2N(N.L)-LCalculatingN.HinsteadofR.V,inwhichH=(L+V)/|L+V|2*b=a38Usingthehalfwayangle•Replace(v·r)aby(n·h)b•bisc

hosentomatchshineness•Notethathalfwayangleishalfofanglebetweenrandvifvectorsarecoplanar•ResultingmodelisknownasthemodifiedPhongorBli

nnlightingmodel-SpecifiedinOpenGLstandard39ExampleOnlydifferencesintheseteapotsaretheparametersinthemodifiedPhongmodel40Comp

utationofVectors•landvarespecifiedbytheapplication•Cancomputerrfromlandn•Problemisdeterminingn•Forsimplesurfaces,it

canbedeterminedbuthowwedeterminendiffersdependingonunderlyingrepresentationofsurface•OpenGLleavesdeterminationofnormaltoapplication-ExceptionforGL

UquadricsandBeziersurfaces(Chapter11)41PlaneNormals•Equationofplane:ax+by+cz+d=0•FromChapter4weknowth

atplaneisdeterminedbythreepointsp0,p2,p3ornormalnandp0•Normalcanbeobtainedbyn=(p2-p0)×(p1-p0)p1p0p242NormaltoSphere•Implicitfunctionf(x

,y.z)=0•Normalgivenbygradient•Spheref(p)=x2+y2+z2-1=0•n=[∂f/∂x,∂f/∂y,∂f/∂z]T=p43ParametricForm•Forsphere•Tangentplanedeterminedbyv

ectors•Normalgivenbycrossproductx=x(u,v)=cosusinvy=y(u,v)=cosucosvz=z(u,v)=sinu∂p/∂u=[∂x/∂u,∂y/∂u,∂z/∂u]T∂p/∂v=[∂x/∂v,∂y/∂v,

∂z/∂v]Tn=∂p/∂u×∂p/∂v44GeneralCase•Wecancomputeparametricnormalsforothersimplecases-Quadrics-Parametericpolynomialsurfaces•Beziersurfacepatc

hes(Chapter11)45PolygonalShading•Shadingcalculationsaredoneforeachvertex-Vertexcolorsbecomevertexshades•Bydefault,vertexshadesareinterpolated

acrossthepolygon:-glShadeModel(GL_SMOOTH);•IfweuseglShadeModel(GL_FLAT);thecoloratthefirstvertexwilldeterminetheshadeofthewholepolygon

Flatshading•Normalissameineachpolygon;•Infiniteviewer;•Infinitelight;•Forflatshading,weonlyneedcomputethecolorofonepointinthispolygon.4647Pol

ygonNormals•Polygonshaveasinglenormal-ShadesattheverticesascomputedbythePhongmodelcanbealmostsame-Ide

nticalforadistantviewer(default)orifthereisnospecularcomponent-Infiniteviewerandlight•Considermodelofsp

here•WantdifferentnormalateachvertexeventhoughthisconceptisnotquitecorrectmathematicallyCharacteristic•It’sba

dforpolygonapproximatesmoothsurface.Thecolorinpolygonsisdifferent.48Viewofhuman•Machband•Howtoavoidthisband?Weshouldusesmoothshadin

g.4950SmoothShading•Wecansetanewnormalateachvertex•Easyforspheremodel-Ifcenteredatoriginn=p•Nowsmoothshadingworks•Notesilhouet

teedge51MeshShading•Thepreviousexampleisnotgeneralbecauseweknewthenormalateachvertexanalytically•Forpolygonalmodels,Gouraudproposedweusethe

averageofthenormalsaroundameshvertexn=(n1+n2+n3+n4)/|n1+n2+n3+n4|Datastructureforpolygon•Searchadjacentpolygonsfore

achvertex.5253ShadingmodelsforPolygons54Twointerpolatedshading•Gouraudshading-Cheapbutgivespoorhighlights•Phongsha

ding-Slightlymoreexpensive,butgiveshighqualityhighlightsFlatGouraudPhone55565758GouraudV.S.PhongGouraudV.S.Phong5960Gourau

dandPhongShading•GouraudShading-Findaveragenormalateachvertex(vertexnormals)-ApplymodifiedPhongmodelateachver

tex-Interpolatevertexshadesacrosseachpolygon•Phongshading-Findvertexnormals-Interpolatevertexnormalsacrossedges-Interpolateedge

normalsacrosspolygon-ApplymodifiedPhongmodelateachfragment61UnrepresentativevertexnormalsSpheresubdivision

6263Comparison•Ifthepolygonmeshapproximatessurfaceswithahighcurvatures,PhongshadingmaylooksmoothwhileGouraudshadin

gmayshowedges•PhongshadingrequiresmuchmoreworkthanGouraudshading-Untilrecentlynotavailableinrealtimesystems-Nowca

nbedoneusingfragmentshaders(seeChapter9)•Bothneeddatastructurestorepresentmeshessowecanobtainvertexnormals

小橙橙
小橙橙
文档分享,欢迎浏览!
  • 文档 4495
  • 被下载 8
  • 被收藏 0
相关资源
广告代码123
若发现您的权益受到侵害,请立即联系客服,我们会尽快为您处理。侵权客服QQ:395972555 (支持时间:9:00-21:00) 公众号
Powered by 太赞文库
×
确认删除?