第五章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

提交評論