第五章rendering计算机图形学课件_第1页
第五章rendering计算机图形学课件_第2页
第五章rendering计算机图形学课件_第3页
第五章rendering计算机图形学课件_第4页
第五章rendering计算机图形学课件_第5页
已阅读5页,还剩81页未读 继续免费阅读

下载本文档

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

文档简介

LightingandShadingComp236LectureNotesSpring2001.12/19/2022MarkHarris1LightingandShadingComp236LOverviewLasttime,wecoveredlight-matterinteraction.Now,applyittorendering.Outline:Lightingandshading.Lightingmodels.Shadingmethods..OverviewLasttime,wecovered2ThoseWeretheDays(Or:hownottomotivatea21stcenturycomputergraphicspaper.)“Intryingtoimprovethequalityofthesyntheticimages,wedonotexpecttobeabletodisplaytheobjectexactlyasitwouldappearinreality,withtexture,overcastshadows,etc.Wehopeonlytodisplayanimagethatapproximatestherealobjectcloselyenoughtoprovideacertaindegreeofrealism.”

–BuiTuongPhong,1975.ThoseWeretheDays(Or:howno3Lightingvs.ShadingCommonlymisusedterms.What’sthedifference?.Lightingvs.ShadingCommonlym4Lightingvs.ShadingCommonlymisusedterms.What’sthedifference?Lightingdesignatestheinteractionbetweenmaterialsandlightsources,asinlastlecture.Shadingistheprocessofdeterminingthecolorofapixel.Usuallydeterminedbylighting.Coulduseothermethods:randomcolor,NPR,etc..Lightingvs.ShadingCommonlym5LightingModelsWilldiscuss3:Lambert.Purelydiffusesurfaces.Phong.Addsperceptually-basedspecularterm.Torrance-sparrow:Providesaphysicalapproximation..LightingModelsWilldiscuss3:6LambertLightingModelSometimesmistakenlyattributedtoGouraud.Gourauddidn’tintroduceanewlightingmodel,justashadingmethod.UsedapproximationsfromWarnockandRomney.BothbasedonLambert’scosinelaw..LambertLightingModelSometime7Lambert’sCosineLawThereflectedluminousintensityinanydirectionfromaperfectlydiffusingsurfacevariesasthecosineoftheanglebetweenthedirectionofincidentlightandthenormalvectorofthesurface.Intuitively:cross-sectionalareaof

the“beam”intersectinganelement

ofsurfaceareaissmallerforgreater

angleswiththenormal..Lambert’sCosineLawThereflec8Lambert’sCosineLawIdeallydiffusesurfacesobeycosinelaw.OftencalledLambertiansurfaces.Id =kdIincident

cos

=kdIincident(N·L).kdisthediffusereflectance

ofthematerial.Wavelengthdependent,sousuallyspecifiedasacolor.IN.Lambert’sCosineLawIdeallydi9PhongLightingModelPhongaddsspecularhighlights.Hisoriginalformulaforthespecularterm:W(i)[coss

]nsistheanglebetweentheviewandspecularreflectiondirections.“W(i)isafunctionwhichgivestheratioofthespecularreflectedlightandtheincidentlightasafunctionofthetheincidentanglei.”Rangesfrom10to80percent.“nisapowerwhichmodelsthespecularreflectedlightforeachmaterial.”Rangesfrom1to10..PhongLightingModelPhongadds10PhongLightingModelMorerecentformulationsareslightlydifferent.ReplaceW(i)withaconstantks,independentoftheincidentdirection.Whatdowelosewhenwedothis?Is=ksIincident

cosn

=ksIincident(V·R)n.Vistheviewdirection.Risthespecularreflectiondirection.

.PhongLightingModelMorerecen11Blinn-PhongModelPopularvariationofPhongmodel.Usesthehalfwayvector,H.Is =ksIincident(N·H)n.H=L+V/|L+V|Whataretheadvantages?LNHV.Blinn-PhongModelPopularvaria12Blinn-PhongModelPopularvariationofPhongmodel.Usesthehalfwayvector,H.Is =ksIincident(N·H)n.H=L+V/|L+V|Fastertocomputethanreflectionvector.Stillview-dependentsinceHdependsonV.LNHV.Blinn-PhongModelPopularvaria13Blinn-PhongHighlightsDoesusingN.Hvs.R.Vaffecthighlights?Yes,thehighlights“spread”.Why?Isthisbad?.Blinn-PhongHighlightsDoesusi14Blinn-PhongHighlightsDoesusingN.Hvs.R.Vaffecthighlights?Yes,thehighlights“spread”.Why?Isthisbad?Notreally,fortworeasons.Canalwaysjustadjusttheexponent.PhongandBlinn-Phongarenotphysicallybased,soitdoesn’treallymatter!.Blinn-PhongHighlightsDoesusi15Torrance-SparrowModelIntroducedbyTorranceandSparrowin1967asatheoreticalmodel.IntroducedtoCGcommunitybyBlinnin1977.samepaperas“HalfwayVector”(Blinn-Phong).Attemptstoprovideamorephysicalmodelforspecularreflectionsfromrealsurfaces.Pointsoutthatintensityofspecularhighlightsisdependentontheincidentdirectionrelativetonormal.Phongattemptedtomodelthiswithw(i)factor?.Torrance-SparrowModelIntroduc16Torrance-SparrowModelBacktomicrofacets.Assumptions:Diffusecomponentcomesfrommultiplereflectionsbetweenfacetsandfrominternalscattering.SpecularcomponentofsurfacecomesfromfacetsorientedindirectionofH..Torrance-SparrowModelBackto17Torrance-SparrowModelIs=DGF/(N·V)Disthedistributionfunctionofthemicrofacetdirectionsonthesurface.Gistheamountthatfacetsshadowandmaskeachother.FistheFresnelreflectionlaw..Torrance-SparrowModelIs=DGF18D:MicroFacetDistributionT-SusedsimpleGaussiandistribution:D=e

-()2=deviationanglefromhalfwayvector,H.=standarddeviation.Largevalues=dull,smallvalues=shiny.D:MicroFacetDistributionT-S19DenominatorIntensityproportionaltonumberoffacetsinHdirection.So,mustaccountforfactthatobserverseesmoresurfaceareawhensurfaceistilted.Changeinareaproportionaltocosineoftiltangle.Hence,N·Vindenominator..DenominatorIntensityproportio20G:GeometricalAttenuationFactorRemembermicrofacetshadowingandmasking?Blinnderivesthisfactorforsymmetricalv-shapedgroovefacets.(Seepaper).shadowshadowMaskedLight.G:GeometricalAttenuationFac21F:FresnelReflectionFractionoflightincidentonafacetthatisactuallyreflectedratherthanabsorbed.Functionofangleofincidenceandindexofrefraction.F(,).Formetals(large),F(,)nearlyconstantat1.Fornon-metals(small),F(,)hasexponentialappearance.Nearzerofor=0,to1at=/2..F:FresnelReflectionFraction22ShadingHaveseensomemethodsforcomputinglighting.Givennormal,lightdirection,materialproperties.Non-diffusemodelsneedviewdirection.Nowexploremethodsofapplyingthatlighting(orothercolor)topixelsofrasterizedsurface..ShadingHaveseensomemethods23TypesofShadingInpolygonalrendering,thereare3maintypes:Flatshading.Gouraudshading.Phongshading.Theseroughlycorrespondto:Per-polygonshading.Per-vertexshading.Per-pixelshading..TypesofShadingInpolygonalr24FlatShadingFastandsimple.Computethecolorofapolygon.Usethatcoloroneverypixelofthepolygon..FlatShadingFastandsimple..25GouraudShadingStillprettyfastandsimple.Givesbettersenseofformthanflatshadingformanyapplications.BasicIdea:Computecolorateachvertex.Bi-linearlyinterpolatecolorforeachinteriorpixel..GouraudShadingStillprettyfa26GouraudShadingComputeSA,SB,SCfortriangleABC.Si=shadeofpointi.ForascanlineXY,computeSX,SYbylerping.e.g.tAB=|AX|/|AB|.SA=tAB*SA+(1-tAB)*SBComputeSPBylerpingbetweenSXandSY.scanlineABCSXXYSYPSP.GouraudShadingComputeSA,SB,27LinearInterpolationConcernsPerspectiveprojectioncomplicateslinearinterpolation.Relationshipbetweenscreenspacedistanceandeyespacedistanceisnonlinear.Therefore,relationshipbetween

interpolationinthetwospacesisalso

nonlinear.Thus,screenspacelinearinterpolation

ofcolors(andtexturecoordinates)

resultsinincorrectvalues.Note:potentialhomework/testproblem!

.LinearInterpolationConcernsP28Perspectively-correctInterpolationCouldinterpolateineyespace,thenprojecteveryinterpolatedpoint.Waytoomuchwork!Canweinterpolateinscreenspaceandcorrectforperspectivenonlinearity?Yes!.Perspectively-correctInterpol29Perspectively-correctInterpolationForadetailedderivation,see:/~hoff/techrep/persp/persp.htmlHere,weskiptothepunchline:Giventwoeyespacepoints,E1andE2.Canlerpineyespace:E(T)=E1(1-T)+E2(T).Tiseyespaceparameter,tisscreenspaceparameter.Toseerelationship,expressintermsofscreenspacet:E(t)=[(E1/Z1)*(1-t)+(E2/Z2)*t]/[(1/Z1)*(1-t)+(1/Z2)*t]

.Perspectively-correctInterpol30Perspectively-correctInterpolationE(t)=[(E1/Z1)*(1-t)+(E2/Z2)*t]/[(1/Z1)*(1-t)+(1/Z2)*t]E1/Z1,E2/Z2areprojectedpoints.BecauseZ1,Z2

aredepthscorrespondingtoE1,E2.Lookingclosely,canseethatinterpolationalonganeyespaceedge=interpolationalongprojectededgeinscreenspacedividedbytheinterpolationof1/Z..Perspectively-correctInterpol31GouraudExample.GouraudExample.32MachBandsGourauddiscusses“artifact”oflerping.Machbands:Causedbyinteractionofneighboringretinalneurons.Actsasasortofhigh-passfilter,accentuatingdiscontinuitiesinfirstderivative.Linearinterpolationcausesfirstderiv.Discontinuitiesatpolygonedges..MachBandsGourauddiscusses“a33MachBandsSimpleexamples.MachBandsSimpleexamples.34ImprovementsGouraudsuggestshigher-orderinterpolationwouldalleviatemachbanding.Butstressestheperformancecost.Probablynotworthit.Phongshadinghelpstheproblem..ImprovementsGouraudsuggestsh35PhongShadingPhongshadingisnotwhatcurrentgraphicshardwareimplements.APIs(D3D,OGL)employBlinn-PhonglightingandGouraudshading.Phongshadingapplieslightingcomputationper-pixel.Useslinearinterpolationofnormalvectors,ratherthancolors..PhongShadingPhongshadingis36PhongShadingInterpolationjustaswithcolorsinGouraudshading.InterpolatescanlineendpointnormalsNa,Nbfromendpointsofinterceptededges.InterpolatenormalNpateachpixelfromNa,Nb.NormalizeNp.(Interpolationofunitvectorsdoesnotpreservelength).Back-transformNp

toeyespace,computelighting..PhongShadingInterpolationjus37PhongShadingResultsaremuchimprovedoverGouraud.Hardertotelllow-fromhigh-polygonmodels.Stillsomeindicatorsandproblems:Silhouettestillhasalowtessellation.Sharedvs.Unsharedvertices.Machbanding.Yep,canstillgetfirstderivativediscontinuities..PhongShadingResultsaremuch38OtherTypesofPer-pixelShadingRaytracing.Doesn’tuseGouraudorPhongshading.Eachpixelusesownraytodeterminecolor.Canapplyarbitrarylightingmodel.Classical(Whitted)raytracingusesPhongmodel.Sinceraytracingdeterminescolorsbasedonintersections,don’thavetousepolygonalgeometry.Thus,canpotentiallyuseexactnormals,ratherthaninterpolation..OtherTypesofPer-pixelShadi39OtherTypesofPer-pixelShading.Newhardwareprovidesper-pixelcapabilities.E.G.NVIDIApixelshaders.Allow(somewhat)arbitraryprogramsoneachpixel.SonewhardwarecanimplementPhongshading.Also,vertexprograms.Allow(somewhat)arbitraryprogramsoneachvertex..OtherTypesofPer-pixelShadi40ReferencesGouraud,Phong,BlinnpapersIhandedout.AvailableinSeminalGraphics,ACMpress.Glassner,PrinciplesofDigitalImageSynthesis,volumetwo.Highlydetailedandlowlevel.MöllerandHaines,Real-TimeRendering.Agreatbook,withthebestbibliographyyoucanfind..ReferencesGouraud,Phong,Blin41ReferencesRogers,ProceduralElementsforComputerGraphics.Oneofmyfavorites.Foley,vandam,etal.ComputerGraphics,PrinciplesandPractice.Notthebesttreatment,butitcoverseverything..ReferencesRogers,ProceduralE42NextLecturePaulZimmonswillmesmerizeyouwith:

Texturemapping!.NextLecturePaulZimmonswill43LightingandShadingComp236LectureNotesSpring2001.12/19/2022MarkHarris44LightingandShadingComp236LOverviewLasttime,wecoveredlight-matterinteraction.Now,applyittorendering.Outline:Lightingandshading.Lightingmodels.Shadingmethods..OverviewLasttime,wecovered45ThoseWeretheDays(Or:hownottomotivatea21stcenturycomputergraphicspaper.)“Intryingtoimprovethequalityofthesyntheticimages,wedonotexpecttobeabletodisplaytheobjectexactlyasitwouldappearinreality,withtexture,overcastshadows,etc.Wehopeonlytodisplayanimagethatapproximatestherealobjectcloselyenoughtoprovideacertaindegreeofrealism.”

–BuiTuongPhong,1975.ThoseWeretheDays(Or:howno46Lightingvs.ShadingCommonlymisusedterms.What’sthedifference?.Lightingvs.ShadingCommonlym47Lightingvs.ShadingCommonlymisusedterms.What’sthedifference?Lightingdesignatestheinteractionbetweenmaterialsandlightsources,asinlastlecture.Shadingistheprocessofdeterminingthecolorofapixel.Usuallydeterminedbylighting.Coulduseothermethods:randomcolor,NPR,etc..Lightingvs.ShadingCommonlym48LightingModelsWilldiscuss3:Lambert.Purelydiffusesurfaces.Phong.Addsperceptually-basedspecularterm.Torrance-sparrow:Providesaphysicalapproximation..LightingModelsWilldiscuss3:49LambertLightingModelSometimesmistakenlyattributedtoGouraud.Gourauddidn’tintroduceanewlightingmodel,justashadingmethod.UsedapproximationsfromWarnockandRomney.BothbasedonLambert’scosinelaw..LambertLightingModelSometime50Lambert’sCosineLawThereflectedluminousintensityinanydirectionfromaperfectlydiffusingsurfacevariesasthecosineoftheanglebetweenthedirectionofincidentlightandthenormalvectorofthesurface.Intuitively:cross-sectionalareaof

the“beam”intersectinganelement

ofsurfaceareaissmallerforgreater

angleswiththenormal..Lambert’sCosineLawThereflec51Lambert’sCosineLawIdeallydiffusesurfacesobeycosinelaw.OftencalledLambertiansurfaces.Id =kdIincident

cos

=kdIincident(N·L).kdisthediffusereflectance

ofthematerial.Wavelengthdependent,sousuallyspecifiedasacolor.IN.Lambert’sCosineLawIdeallydi52PhongLightingModelPhongaddsspecularhighlights.Hisoriginalformulaforthespecularterm:W(i)[coss

]nsistheanglebetweentheviewandspecularreflectiondirections.“W(i)isafunctionwhichgivestheratioofthespecularreflectedlightandtheincidentlightasafunctionofthetheincidentanglei.”Rangesfrom10to80percent.“nisapowerwhichmodelsthespecularreflectedlightforeachmaterial.”Rangesfrom1to10..PhongLightingModelPhongadds53PhongLightingModelMorerecentformulationsareslightlydifferent.ReplaceW(i)withaconstantks,independentoftheincidentdirection.Whatdowelosewhenwedothis?Is=ksIincident

cosn

=ksIincident(V·R)n.Vistheviewdirection.Risthespecularreflectiondirection.

.PhongLightingModelMorerecen54Blinn-PhongModelPopularvariationofPhongmodel.Usesthehalfwayvector,H.Is =ksIincident(N·H)n.H=L+V/|L+V|Whataretheadvantages?LNHV.Blinn-PhongModelPopularvaria55Blinn-PhongModelPopularvariationofPhongmodel.Usesthehalfwayvector,H.Is =ksIincident(N·H)n.H=L+V/|L+V|Fastertocomputethanreflectionvector.Stillview-dependentsinceHdependsonV.LNHV.Blinn-PhongModelPopularvaria56Blinn-PhongHighlightsDoesusingN.Hvs.R.Vaffecthighlights?Yes,thehighlights“spread”.Why?Isthisbad?.Blinn-PhongHighlightsDoesusi57Blinn-PhongHighlightsDoesusingN.Hvs.R.Vaffecthighlights?Yes,thehighlights“spread”.Why?Isthisbad?Notreally,fortworeasons.Canalwaysjustadjusttheexponent.PhongandBlinn-Phongarenotphysicallybased,soitdoesn’treallymatter!.Blinn-PhongHighlightsDoesusi58Torrance-SparrowModelIntroducedbyTorranceandSparrowin1967asatheoreticalmodel.IntroducedtoCGcommunitybyBlinnin1977.samepaperas“HalfwayVector”(Blinn-Phong).Attemptstoprovideamorephysicalmodelforspecularreflectionsfromrealsurfaces.Pointsoutthatintensityofspecularhighlightsisdependentontheincidentdirectionrelativetonormal.Phongattemptedtomodelthiswithw(i)factor?.Torrance-SparrowModelIntroduc59Torrance-SparrowModelBacktomicrofacets.Assumptions:Diffusecomponentcomesfrommultiplereflectionsbetweenfacetsandfrominternalscattering.SpecularcomponentofsurfacecomesfromfacetsorientedindirectionofH..Torrance-SparrowModelBackto60Torrance-SparrowModelIs=DGF/(N·V)Disthedistributionfunctionofthemicrofacetdirectionsonthesurface.Gistheamountthatfacetsshadowandmaskeachother.FistheFresnelreflectionlaw..Torrance-SparrowModelIs=DGF61D:MicroFacetDistributionT-SusedsimpleGaussiandistribution:D=e

-()2=deviationanglefromhalfwayvector,H.=standarddeviation.Largevalues=dull,smallvalues=shiny.D:MicroFacetDistributionT-S62DenominatorIntensityproportionaltonumberoffacetsinHdirection.So,mustaccountforfactthatobserverseesmoresurfaceareawhensurfaceistilted.Changeinareaproportionaltocosineoftiltangle.Hence,N·Vindenominator..DenominatorIntensityproportio63G:GeometricalAttenuationFactorRemembermicrofacetshadowingandmasking?Blinnderivesthisfactorforsymmetricalv-shapedgroovefacets.(Seepaper).shadowshadowMaskedLight.G:GeometricalAttenuationFac64F:FresnelReflectionFractionoflightincidentonafacetthatisactuallyreflectedratherthanabsorbed.Functionofangleofincidenceandindexofrefraction.F(,).Formetals(large),F(,)nearlyconstantat1.Fornon-metals(small),F(,)hasexponentialappearance.Nearzerofor=0,to1at=/2..F:FresnelReflectionFraction65ShadingHaveseensomemethodsforcomputinglighting.Givennormal,lightdirection,materialproperties.Non-diffusemodelsneedviewdirection.Nowexploremethodsofapplyingthatlighting(orothercolor)topixelsofrasterizedsurface..ShadingHaveseensomemethods66TypesofShadingInpolygonalrendering,thereare3maintypes:Flatshading.Gouraudshading.Phongshading.Theseroughlycorrespondto:Per-polygonshading.Per-vertexshading.Per-pixelshading..TypesofShadingInpolygonalr67FlatShadingFastandsimple.Computethecolorofapolygon.Usethatcoloroneverypixelofthepolygon..FlatShadingFastandsimple..68GouraudShadingStillprettyfastandsimple.Givesbettersenseofformthanflatshadingformanyapplications.BasicIdea:Computecolorateachvertex.Bi-linearlyinterpolatecolorforeachinteriorpixel..GouraudShadingStillprettyfa69GouraudShadingComputeSA,SB,SCfortriangleABC.Si=shadeofpointi.ForascanlineXY,computeSX,SYbylerping.e.g.tAB=|AX|/|AB|.SA=tAB*SA+(1-tAB)*SBComputeSPBylerpingbetweenSXandSY.scanlineABCSXXYSYPSP.GouraudShadingComputeSA,SB,70LinearInterpolationConcernsPerspectiveprojectioncomplicateslinearinterpolation.Relationshipbetweenscreenspacedistanceandeyespacedistanceisnonlinear.Therefore,relationshipbetween

interpolationinthetwospacesisalso

nonlinear.Thus,screenspacelinearinterpolation

ofcolors(andtexturecoordinates)

resultsinincorrectvalues.Note:potentialhomework/testproblem!

.LinearInterpolationConcernsP71Perspectively-correctInterpolationCouldinterpolateineyespace,thenprojecteveryinterpolatedpoint.Waytoomuchwork!Canweinterpolateinscreenspaceandcorrectforperspectivenonlinearity?Yes!.Perspectively-correctInterpol72Perspectively-correctInterpolationForadetailedderivation,see:/~hoff/techrep/persp/persp.htmlHere,weskiptothepunchline:Giventwoeyespacepoints,E1andE2.Canlerpineyespace:E(T)=E1(1-T)+E2(T).Tiseyespaceparameter,tisscreenspaceparameter.Toseerelationship,expressintermsofscreenspacet:E(t)=[(E1/Z1)*(1-t)+(E2/Z2)*t]/[(1/Z1)*(1-t)+(1/Z2)*t]

.Perspectively-correctInterpol73Perspectively-correctInterpolationE(t)=[(E1/Z1)*(1-t)+(E2/Z2)*t]/[(1/Z1)*(1-t)+(1/Z2)*t]E1/Z1,E2/Z2areprojectedpoints.BecauseZ1,Z2

aredepthscorrespondingtoE1,E2.Lookingclosely,canseethatinterpolationalonganeyespaceedge=interpolationalongprojectededgeinscreenspacedividedbytheinterpolationof1/Z..Perspectively-correctInterpol74GouraudExample.GouraudExample.75MachBandsGourauddiscusses“artifact”oflerping.Machbands:Causedbyinteractionofneighboringretinalneurons.Actsasasortofhigh-passfilter,accentuatingdiscontinuitiesinfirstderivative.Linearinterpolationcausesfirstderiv.Discontinuitiesatpolygonedges..MachBandsGourauddiscusses“a76MachBandsSimpleexamples.MachBandsSimpleexamples.77ImprovementsGouraudsuggestshigher-orderinterpolationwouldalleviatemachbanding.Butstressestheperformancecost.Probablynotworthit.Phongshadinghelpstheproblem..ImprovementsGouraudsugge

温馨提示

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

评论

0/150

提交评论