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

PPT
  • 阅读 68 次
  • 下载 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•Learntoshadeobjectssotheirim

agesappearthree-dimensional•Introducethetypesoflight-materialinteractions•Buildasimplereflectionmodel-

--thePhongmodel---thatcanbeusedwithrealtimegraphicshardwareSimpleLightingmodelWithSpecularlightingGouraudshadingWireframePoly

gonWhyweneedshading3WithshadowWithTexture4Whyweneedshading•Supposewebuildasceneusingmanypolygonsandc

oloritwithglColor.Wegetsomethinglike•Whichisthebest?5Shading•Whydoestheimageofarealspherelooklike•Light-materialinteracti

onscauseeachpointtohaveadifferentcolororshade•Needtoconsider-Lightsources-Materialproperties-Locationofviewer-Surfaceorientation

Why?6Scattering•LightstrikesA-Somescattered-Someabsorbed•SomeofscatteredlightstrikesB-Somescattered-Somea

bsorbed•SomeofthisscatteredlightstrikesAandsoon7RenderingEquation•Theinfinitescatteringandabsorptionoflightcanbedes

cribedbytherenderingequation-Cannotbesolvedingeneralways-Raytracingisaspecialcaseforperfectlyreflectingsurfaces•Renderingequationisglobalandinc

ludes-Shadows-Multiplescatteringfromobjecttoobject8GlobalEffectstranslucentsurfaceshadowmultiplerefle

ction9LocalvsGlobalRendering•Correctshadingrequiresaglobalcalculationinvolvingallobjectsandlightsources-Incompatiblewith

pipelinemodelwhichshadeseachpolygonindependently(localrendering)•However,incomputergraphics,especiallyrealtimegr

aphics,wearehappyifthings“lookright”-Existmanytechniquesforapproximatingglobaleffects10Light-MaterialInteraction•Lightthatstrikesanobjectispartiallya

bsorbedandpartiallyscattered(reflected)•Theamountreflecteddeterminesthecolorandbrightnessoftheobject-As

urfaceappearsredunderwhitelightbecausetheredcomponentofthelightisreflectedandtherestisabsorbed•Thereflectedlightisscatteredina

mannerthatdependsonthesmoothnessandorientationofthesurface11LightSourcesGenerallightsourcesaredifficulttoworkwithbeca

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

BGRYMC11112SimpleLightSources•Pointsource-Modelwithpositionandcolor-Distantsource=infinitedistanceaway(parallel)-I(p0)=[Ir(p0)

,Ig(p0),Ib(p0)]SimpleLightSources•Easytouse(incomputer)•Realisticispoor:•Imagecontrastishigh,somepartsarebrightandother

saredark;•Inrealworld,thelightswillbelarge.•Wecanaddambientlighttosolvethisproblem.13umbrapenumbraSimpleLightSources•Spo

tlight-Restrictlightfromidealpointsource14Whyusecosfunction?SimpleLightSources•Infinitelight:Sunlight-Justknowtheli

ghtdirection;-Theintensityisconstant.•Ambientlight-Sameamountoflighteverywhereinscene-Canmodelcontributionofmanysourcesandreflecting

surfaces15Ia=[Iar,Iag,Iab]thesamevalueateachpointonsurfaces16SurfaceTypes•Thesmootherasurface,themorereflectedlightisconcentratedinthedirectionaper

fectmirrorwouldreflectedthelight•Averyroughsurfacescatterslightinalldirectionssmoothsurfaceroughsurfac

eSuchasmirrorsSuchasawalltranslucentsurfaceSuchaswater17PhongModel•Asimplemodelthatcanbecomputedrapidly•Hasthre

ecomponents-Diffuse-Specular-Ambient•Usesfourvectors-Tolightsource-Toviewer-Normal-Perfectreflector18AmbientLight

•Ambientlightistheresultofmultipleinteractionsbetween(large)lightsourcesandtheobjectsintheenvironment

•Amountandcolordependonboththecolorofthelight(s)andthematerialpropertiesoftheobject•AddkaIatodiffuseandspeculartermsr

eflectioncoefintensityofambientlightaIpaIak=19DiffuseReflection•Anidealdiffusesurfaceis,atthemicroscopiclevel,averyroughsurface.•Chalki

sagoodapproximationtoanidealdiffusesurface.•Becauseofthemicroscopicvariationsinthesurface,anincomingrayoflightisequallyli

kelytobereflectedinanydirectionoverthehemisphere.20LambertianSurface(朗伯面)•Perfectlydiffusereflector•Lightscatteredequallyinalldirections•Amoun

toflightreflectedisproportionaltotheverticalcomponentofincominglight-reflectedlight~cosqi-cosqi=l·nifvectorsnormalized-Therea

realsothreecoefficients,kr,kb,kgthatshowhowmuchofeachcolorcomponentisreflected,relatedwiththematerials21Lambert'sCosin

eLaw•Lambert'slawdetermineshowmuchoftheincidentlightenergyisreflected.•Rememberthattheamountofenergythatisreflected

inanyonedirectionisconstantinthismodel.Inotherwords,thereflectedintensityisindependentoftheviewingdirection.IpdIpdcosqqCABdIpdIdkcosq=:,,dd

rdgdbkkkk: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•Mosts

urfacesareneitheridealdiffusersnorperfectlyspecular(idealreflectors)•Smoothsurfacesshowspecularhighlightsduetoincominglightbe

ingreflectedindirectionsconcentratedclosetothedirectionofaperfectreflectionspecularhighlight24IdealReflector•Normalisdeterminedbylocalorientatio

n•Angleofincidence=angleofrelection•Thethreevectorsmustbecoplanarr=2(l·n)n-lrlHowtocomputer2cosincos

inlnliv25ModelingSpecularRelections•PhongproposedusingatermthatdroppedoffastheanglebetweentheviewerandtheidealreflectionincreasedfIr~ksIcosafs

hininesscoefabsorptioncoefincomingintensityreflectedintensitycos()frv26TheShininessCoefficient•Valuesofabetween100and200correspondtometals•Va

luesbetween5and10givesurfacethatlooklikeplasticcosaff90-9027SpheresshadedusingphongilluminationmodelRefractlight•Snell

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

naltothesquareofthedistancebetweenthem•Wecanaddafactoroftheform1/(c1+c2dL+c3dL2)tothediffuseandspecularterms•Thec

onstantandlineartermssoftentheeffectofthepointsource31Lightsourceattenuation(衰减)•I=Iaka+fattIlightkd(N.L)-fatt=1/dL2-fatt=(1/mi

n((c1+c2dL+c3dL2),1));Distance11.3751.752.1252.5C001.25.25.501032LightSources•InthePhongModel,weaddtheresultsf

romeachlightsource•Eachlightsourcehasseparatediffuse,specular,andambienttermstoallowformaximumflexibili

tyeventhoughthisformdoesnothaveaphysicaljustification•Separatered,greenandbluecomponents•Hence,9coefficientsfor

eachpointsource-Idr,Idg,Idb,Isr,Isg,Isb,Iar,Iag,Iab33MaterialProperties•Materialpropertiesmatchlightsourceproperties-Nin

eabsorbtioncoefficients•kdr,kdg,kdb,ksr,ksg,ksb,kar,kag,kab-Shininesscoefficienta34AddinguptheComponentsForeachlightsourceandeachcolo

rcomponent,thePhongmodelcanbewritten(withoutthedistanceterms)asI=kdIdl·n+ksIs(v·r)a+kaIaForeachcolorcomponent

weaddcontributionsfromallsourcesPhonglightmodel3536ModifiedPhongModel•ThespecularterminthePhongmodelisproblematicbecauseitrequiresthe

calculationofanewreflectionvectorandviewvectorforeachvertex•Blinnsuggestedanapproximationusingthehalfwayvector(分向量)thatismoreefficient37Calculati

ngthereflectionvectorR=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•bischosentomatchshineness•Notethathalfwayangleishalfofanglebetweenrandvifvec

torsarecoplanar•ResultingmodelisknownasthemodifiedPhongorBlinnlightingmodel-SpecifiedinOpenGLstandard39ExampleOnlydifferencesintheseteapotsa

retheparametersinthemodifiedPhongmodel40ComputationofVectors•landvarespecifiedbytheapplication•Cancomputerrfromlandn•Problemisdet

erminingn•Forsimplesurfaces,itcanbedeterminedbuthowwedeterminendiffersdependingonunderlyingrepresentationofsurface•OpenG

Lleavesdeterminationofnormaltoapplication-ExceptionforGLUquadricsandBeziersurfaces(Chapter11)41PlaneNormals•Equationofpla

ne:ax+by+cz+d=0•FromChapter4weknowthatplaneisdeterminedbythreepointsp0,p2,p3ornormalnandp0•Normalcanbeobtainedbyn=(p2-p0)×(p1-p0)p1p0p242NormaltoS

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

minedbyvectors•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-P

arametericpolynomialsurfaces•Beziersurfacepatches(Chapter11)45PolygonalShading•Shadingcalculationsaredoneforeachvertex-Vertexc

olorsbecomevertexshades•Bydefault,vertexshadesareinterpolatedacrossthepolygon:-glShadeModel(GL_SMOOTH);•IfweuseglShadeModel(GL_FLAT);thec

oloratthefirstvertexwilldeterminetheshadeofthewholepolygonFlatshading•Normalissameineachpolygon;•Infiniteviewer;•Infinitelight;•Forflats

hading,weonlyneedcomputethecolorofonepointinthispolygon.4647PolygonNormals•Polygonshaveasinglenormal-Sha

desattheverticesascomputedbythePhongmodelcanbealmostsame-Identicalforadistantviewer(default)orifthereisnospecularcomp

onent-Infiniteviewerandlight•Considermodelofsphere•WantdifferentnormalateachvertexeventhoughthisconceptisnotquitecorrectmathematicallyCharacteristic•

It’sbadforpolygonapproximatesmoothsurface.Thecolorinpolygonsisdifferent.48Viewofhuman•Machband•Howtoavoidthisb

and?Weshouldusesmoothshading.4950SmoothShading•Wecansetanewnormalateachvertex•Easyforspheremodel-Ifcentereda

toriginn=p•Nowsmoothshadingworks•Notesilhouetteedge51MeshShading•Thepreviousexampleisnotgeneralbecauseweknewthenormalateachvertexanalytical

ly•Forpolygonalmodels,Gouraudproposedweusetheaverageofthenormalsaroundameshvertexn=(n1+n2+n3+n4)/|n1+n2+n3+n4|Datas

tructureforpolygon•Searchadjacentpolygonsforeachvertex.5253ShadingmodelsforPolygons54Twointerpolatedshading•Gouraudshading-Cheapbutgivesp

oorhighlights•Phongshading-Slightlymoreexpensive,butgiveshighqualityhighlightsFlatGouraudPhone55565758GouraudV.S.PhongGouraud

V.S.Phong5960GouraudandPhongShading•GouraudShading-Findaveragenormalateachvertex(vertexnormals)-ApplymodifiedPhongmodelateachvertex-Interpolat

evertexshadesacrosseachpolygon•Phongshading-Findvertexnormals-Interpolatevertexnormalsacrossedges-Interpolateedgenormalsacrossp

olygon-ApplymodifiedPhongmodelateachfragment61UnrepresentativevertexnormalsSpheresubdivision6263Comparison•Ifthepolygonmesha

pproximatessurfaceswithahighcurvatures,PhongshadingmaylooksmoothwhileGouraudshadingmayshowedges•Phong

shadingrequiresmuchmoreworkthanGouraudshading-Untilrecentlynotavailableinrealtimesystems-Nowcanbedoneusingfragmentshaders(seeChapter9)•Bothnee

ddatastructurestorepresentmeshessowecanobtainvertexnormals

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