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

PPT
  • 阅读 81 次
  • 下载 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•Learntoshadeobjectssot

heirimagesappearthree-dimensional•Introducethetypesoflight-materialinteractions•Buildasimplereflectionmodel---thePhongmodel---thatcanbeusedwithre

altimegraphicshardwareSimpleLightingmodelWithSpecularlightingGouraudshadingWireframePolygonWhyweneedshading3WithshadowWithTexture4Wh

yweneedshading•SupposewebuildasceneusingmanypolygonsandcoloritwithglColor.Wegetsomethinglike•Whichisthebest?5Shading•Whydoestheimageofare

alspherelooklike•Light-materialinteractionscauseeachpointtohaveadifferentcolororshade•Needtoconsider-Lightsources-Mat

erialproperties-Locationofviewer-SurfaceorientationWhy?6Scattering•LightstrikesA-Somescattered-Someabsorbed•Someofscatteredlightst

rikesB-Somescattered-Someabsorbed•SomeofthisscatteredlightstrikesAandsoon7RenderingEquation•Theinfinitescattering

andabsorptionoflightcanbedescribedbytherenderingequation-Cannotbesolvedingeneralways-Raytracingisaspecialcasefor

perfectlyreflectingsurfaces•Renderingequationisglobalandincludes-Shadows-Multiplescatteringfromobjecttoobject8GlobalEffectstranslucentsurfaceshadowm

ultiplereflection9LocalvsGlobalRendering•Correctshadingrequiresaglobalcalculationinvolvingallobjectsandlightsou

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

imegraphics,wearehappyifthings“lookright”-Existmanytechniquesforapproximatingglobaleffects10Light-MaterialInter

action•Lightthatstrikesanobjectispartiallyabsorbedandpartiallyscattered(reflected)•Theamountreflecteddeterminesthecolorandbrightnessoftheobject-Asu

rfaceappearsredunderwhitelightbecausetheredcomponentofthelightisreflectedandtherestisabsorbed•Thereflectedlightisscatteredin

amannerthatdependsonthesmoothnessandorientationofthesurface11LightSourcesGenerallightsourcesaredifficulttoworkwithbecausewemustintegrate

lightcomingfromallpointsonthesourceLightcolor:I=[Ir,Ig,Ib],RGBmode,CMYmodeBGRYM

C11112SimpleLightSources•Pointsource-Modelwithpositionandcolor-Distantsource=infinitedistanceaway(parall

el)-I(p0)=[Ir(p0),Ig(p0),Ib(p0)]SimpleLightSources•Easytouse(incomputer)•Realisticispoor:•Imagecontrastishigh,somepartsarebrightandothersaredark;•

Inrealworld,thelightswillbelarge.•Wecanaddambientlighttosolvethisproblem.13umbrapenumbraSimpleLightSources•Spot

light-Restrictlightfromidealpointsource14Whyusecosfunction?SimpleLightSources•Infinitelight:Sunlight-Justknowthelightdirection;-Theintensit

yisconstant.•Ambientlight-Sameamountoflighteverywhereinscene-Canmodelcontributionofmanysourcesandreflectingsurfaces15Ia=[Iar,Iag,Iab]thesameval

ueateachpointonsurfaces16SurfaceTypes•Thesmootherasurface,themorereflectedlightisconcentratedinthedirectionaperfectmirrorwouldreflectedt

helight•AveryroughsurfacescatterslightinalldirectionssmoothsurfaceroughsurfaceSuchasmirrorsSuchasawalltranslucentsurfaceSuc

haswater17PhongModel•Asimplemodelthatcanbecomputedrapidly•Hasthreecomponents-Diffuse-Specular-Ambient•Usesfourvectors-Tolightsource-Toviewer-N

ormal-Perfectreflector18AmbientLight•Ambientlightistheresultofmultipleinteractionsbetween(large)lightsourcesandtheobjectsintheenvironment•Amountan

dcolordependonboththecolorofthelight(s)andthematerialpropertiesoftheobject•AddkaIatodiffuseandspeculartermsreflectioncoefintensityofamb

ientlightaIpaIak=19DiffuseReflection•Anidealdiffusesurfaceis,atthemicroscopiclevel,averyroughsurface.•Ch

alkisagoodapproximationtoanidealdiffusesurface.•Becauseofthemicroscopicvariationsinthesurface,anincomingrayoflightise

quallylikelytobereflectedinanydirectionoverthehemisphere.20LambertianSurface(朗伯面)•Perfectlydiffusereflector•Lightscatteredequallyin

alldirections•Amountoflightreflectedisproportionaltotheverticalcomponentofincominglight-reflectedlight~c

osqi-cosqi=l·nifvectorsnormalized-Therearealsothreecoefficients,kr,kb,kgthatshowhowmuchofeachcolorcomponenti

sreflected,relatedwiththematerials21Lambert'sCosineLaw•Lambert'slawdetermineshowmuchoftheincidentlightenergyisreflected.•Re

memberthattheamountofenergythatisreflectedinanyonedirectionisconstantinthismodel.Inotherwords,thereflectedintensity

isindependentoftheviewingdirection.IpdIpdcosqqCABdIpdIdkcosq=:,,ddrdgdbkkkk:pdIincidentlightintensity22Illuminationeffects•Shadedusingadiffuse-re

flectionmodel,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•Mostsurfacesareneitheridealdiffusersnorperfectlyspecula

r(idealreflectors)•Smoothsurfacesshowspecularhighlightsduetoincominglightbeingreflectedindirectionsconcentratedclosetot

hedirectionofaperfectreflectionspecularhighlight24IdealReflector•Normalisdeterminedbylocalorientation•Ang

leofincidence=angleofrelection•Thethreevectorsmustbecoplanarr=2(l·n)n-lrlHowtocomputer2cosincosinlnliv25ModelingSpecularRelec

tions•PhongproposedusingatermthatdroppedoffastheanglebetweentheviewerandtheidealreflectionincreasedfIr~ksIcosafshininesscoefabsorptioncoefincomin

gintensityreflectedintensitycos()frv26TheShininessCoefficient•Valuesofabetween100and200correspondtometals•Valuesbetween5and10givesurfacet

hatlooklikeplasticcosaff90-9027SpheresshadedusingphongilluminationmodelRefractlight•Snelllaw•ηt,ηiarethe

refractfactors2811(coscos)tiqqt=-lnRefractfactor2930DistanceTerms•Thelightfromapointsourcethatreachesasurfaceisinvers

elyproportionaltothesquareofthedistancebetweenthem•Wecanaddafactoroftheform1/(c1+c2dL+c3dL2)tothediffuseandspecularterms•Theconstantandlineartermss

oftentheeffectofthepointsource31Lightsourceattenuation(衰减)•I=Iaka+fattIlightkd(N.L)-fatt=1/dL2-fatt=(1/min((c1+c2dL+c3dL2),1));Distance11.3751.752.

1252.5C001.25.25.501032LightSources•InthePhongModel,weaddtheresultsfromeachlightsource•Eachlightsourcehasseparatediffuse,specular,andambienttermstoal

lowformaximumflexibilityeventhoughthisformdoesnothaveaphysicaljustification•Separatered,greenandbluecomponents•Hence,9coefficientsforeachp

ointsource-Idr,Idg,Idb,Isr,Isg,Isb,Iar,Iag,Iab33MaterialProperties•Materialpropertiesmatchlightsourceproperties-N

ineabsorbtioncoefficients•kdr,kdg,kdb,ksr,ksg,ksb,kar,kag,kab-Shininesscoefficienta34AddinguptheComponentsForeachlightsourceand

eachcolorcomponent,thePhongmodelcanbewritten(withoutthedistanceterms)asI=kdIdl·n+ksIs(v·r)a+kaIaForeachcolorcomp

onentweaddcontributionsfromallsourcesPhonglightmodel3536ModifiedPhongModel•ThespecularterminthePhongmodelisproblematicbecauseitrequir

esthecalculationofanewreflectionvectorandviewvectorforeachvertex•Blinnsuggestedanapproximationusingthehalfwayvector(分向量)

thatismoreefficient37CalculatingthereflectionvectorR=Ncosq+S=Ncosq+Ncosq-L=2N(N.L)-LCalculatingN.Hinst

eadofR.V,inwhichH=(L+V)/|L+V|2*b=a38Usingthehalfwayangle•Replace(v·r)aby(n·h)b•bischosentomatchshineness•Notethathalfwayangleishalfofan

glebetweenrandvifvectorsarecoplanar•ResultingmodelisknownasthemodifiedPhongorBlinnlightingmodel-SpecifiedinOpenGLstandard39E

xampleOnlydifferencesintheseteapotsaretheparametersinthemodifiedPhongmodel40ComputationofVectors•landvarespecifiedbyth

eapplication•Cancomputerrfromlandn•Problemisdeterminingn•Forsimplesurfaces,itcanbedeterminedbuthowwedeterminendiffersdependingonunde

rlyingrepresentationofsurface•OpenGLleavesdeterminationofnormaltoapplication-ExceptionforGLUquadricsandBeziersurfaces(Chapte

r11)41PlaneNormals•Equationofplane:ax+by+cz+d=0•FromChapter4weknowthatplaneisdeterminedbythreepointsp0,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•Tangentplanedeterminedbyvectors•Normalg

ivenbycrossproductx=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•Beziersurfacepatches(Chapte

r11)45PolygonalShading•Shadingcalculationsaredoneforeachvertex-Vertexcolorsbecomevertexshades•Bydefault,vertexshadesareinterpolatedacrossthe

polygon:-glShadeModel(GL_SMOOTH);•IfweuseglShadeModel(GL_FLAT);thecoloratthefirstvertexwilldeterminetheshadeofthew

holepolygonFlatshading•Normalissameineachpolygon;•Infiniteviewer;•Infinitelight;•Forflatshading,weonlyneedcomputethecolorofonepointinthis

polygon.4647PolygonNormals•Polygonshaveasinglenormal-ShadesattheverticesascomputedbythePhongmodelcanbealmostsame-Identicalforadistan

tviewer(default)orifthereisnospecularcomponent-Infiniteviewerandlight•Considermodelofsphere•Wantdifferentnormalateachvertexeventhoughthisconcepti

snotquitecorrectmathematicallyCharacteristic•It’sbadforpolygonapproximatesmoothsurface.Thecolorinpolygonsisdifferent.48Viewo

fhuman•Machband•Howtoavoidthisband?Weshouldusesmoothshading.4950SmoothShading•Wecansetanewnormalateachvert

ex•Easyforspheremodel-Ifcenteredatoriginn=p•Nowsmoothshadingworks•Notesilhouetteedge51MeshShading•Thepr

eviousexampleisnotgeneralbecauseweknewthenormalateachvertexanalytically•Forpolygonalmodels,Gouraudpro

posedweusetheaverageofthenormalsaroundameshvertexn=(n1+n2+n3+n4)/|n1+n2+n3+n4|Datastructureforpolygon•Searchadjacentpolygonsforeachvertex.5253Shadi

ngmodelsforPolygons54Twointerpolatedshading•Gouraudshading-Cheapbutgivespoorhighlights•Phongshading-Slightlymoreexpensive,butgivesh

ighqualityhighlightsFlatGouraudPhone55565758GouraudV.S.PhongGouraudV.S.Phong5960GouraudandPhongShading•GouraudShading-Findaveragenormal

ateachvertex(vertexnormals)-ApplymodifiedPhongmodelateachvertex-Interpolatevertexshadesacrosseachpolygon•Phong

shading-Findvertexnormals-Interpolatevertexnormalsacrossedges-Interpolateedgenormalsacrosspolygon-ApplymodifiedPhongmodelateachfragment6

1UnrepresentativevertexnormalsSpheresubdivision6263Comparison•Ifthepolygonmeshapproximatessurfaceswithahighcurvatures,P

hongshadingmaylooksmoothwhileGouraudshadingmayshowedges•PhongshadingrequiresmuchmoreworkthanGouraudshading-Untilrecentl

ynotavailableinrealtimesystems-Nowcanbedoneusingfragmentshaders(seeChapter9)•Bothneeddatastructurestor

epresentmeshessowecanobtainvertexnormals

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