高級(jí)計(jì)算機(jī)圖形學(xué)ACG04_第1頁(yè)
高級(jí)計(jì)算機(jī)圖形學(xué)ACG04_第2頁(yè)
高級(jí)計(jì)算機(jī)圖形學(xué)ACG04_第3頁(yè)
高級(jí)計(jì)算機(jī)圖形學(xué)ACG04_第4頁(yè)
高級(jí)計(jì)算機(jī)圖形學(xué)ACG04_第5頁(yè)
已閱讀5頁(yè),還剩114頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

AdvancedLightingandShading

Outline

?RadiometryandPhotometry,colorimetry

?BRDFtheory,implementingBRDFs

?Vertexshaders,pixelshadingandshadingLanguage

?MotionBlur,depthoffield,reflections,refractions,

shadows

RadiometryandPhotometry

?Radiometry

-Themeasurementofopticalradiation,whichis

electromagneticradiationwithinthefrequencyrangebetween

3xlOnand3xl016Hz

-includestheentireopticalradiationspectrum

?Photometry

-Themeasurementoflight,whichisdefinedas

electromagneticradiationwhichisdetectablebythehuman

eye

-Itisthusrestrictedtothewavelengthrangefromabout380to

780nm

-limitedtothevisiblespectrumasdefinedbytheresponseof

theeye

Photometry

?TheCIEphotometriccurve

Photopic

luminous

efficiency

Wavelength(nm)

Radiometry

?RadiantEnergy

-Q(measuredinjoules)

?RadiantFluxdi

FigurelaIrradiance

-Energyperunittimeisradiantflux(watt)

-①=dQ/dt

?RadiantFluxDensity

-Irradiance

?E=d①/dA

-Radiantexitance(alsocalledradiosity)

M=d(b/dA

dA

FigurelbRadiantexitance

Radiance

ds

projected

、aiea

?ProjectedareaXXX」

-rectilinearprojectionofasurfaceof

anyshapeontoaplane工

-Solidangle

?InCG,lightsandviewersare

oftentreatedaspoints.

?Measurementsintermofareasdof

notapply.

3

?4兀steradiansofsolidangleina卜二Z

sphere.\〃

duj

Radiance

Photometry

QUANTITYRADIOMETRICPHOTOMETRIC

powerwatt(W)lumen(Im)

powerperunitareaW/m2Im/in2=lux(lx)

powerperunitsolidangleW/srIm/sr=candela(cd)

powerperunitareaperunitsolidangleW/m2-srlm/jn2-sr=cd/m2=nit

Colorimetry

Colormatchingexperiment

?r=645nm

?g=526nm

?b=444nm

0

75

0

70

t

h

ig

50l

6e

rsit

teh

ew

om

0ne

6nath

nr

i

he

td

0ngn

5leu

ea

avn

wa

n

0a

5b

e

ip

r

0

5a

4f

o

m

u

0r

0ct

4e

p

86?4?2?0s

oooe

h

T

JQyodSIPEJ

RGBColorMatchingFunctions

?Showthethreecolorrequiredtomatchapurecolorat

thewavelength

-0,10

wavelength,nm

RGBColorMatchingFunctions

?Negativeweightsforvariouswavelengths.

?TheCIEproposedthreedifferenthypotheticallightsourcesthat

didnotusemonochromaticlight

1.40??

1.20--

1,00--

0.80

0.60--

0.40

0.20??

0.00L

350

wavelength,nm

Colorimetry

?TristimulusvaluesareweightsthatdefineacolorinCIEXYZ

space

?WhereC(X)isthespectralenergydistributionforwhateverlight

sourceischosen.

780

-X=j

380

780

-Y=jC(2)y(2)J2

_380

—780

Z=jC(2)z(2)M

380

CIEchromaticitydiagram

520

Y-x5401931CIEChromaticity

UniqueDiagram

X+Y+Zgreen

aboutUniqueyellow

here

Y

y-

X+Y+Z

z=l-x-y600

...0.2

UniqueUniqueredplots

blueabouthere

aboutThecomersofthistriangleis

hereapproximatelywherethephosphors

ofatypicalcolormonitorplot

00.20.40.60.8

X

BRDFTheory

?BRDF

-howlightinteractswithmatter

?Complicatedlight-matterdynamicsoccurs

?Dependsoncharacteristicsofboththelightandthematter

-E.g.,aroughopaquesurfacew川reflectlight

differentlythanasmoothreflectivesurface

BRDFTheory

?BRDF

-Viewer/lightpositiondependency(incoming/outgoingraysof

light)

-Differentwavelengths(colors)oflightmaybeabsorbed,

reflected,transmitteddifferently

-Positionalvariance-lightinteractsdifferentlywithdifferent

regionsofasurface,e.g.wood

?BRDFmustcapturethisviewandlightdependentnatureof

reflectedlight

BRDFTheory

?GeneralBRDFinfunctionalnotation

-3HD瑪電血&爆

-Xisusedtoindicatethelightswavelength

-0i,A:incominglightdirectioninsphericalcoordinates

-九0。outgoingreflecteddirectioninsphericalcoordinates

-uandvrepresentthesurfacepositionparameterizedin

texturespace.

BRDF泡曲

?Position-invariantBRDF

BRDF

L(九”))=于在。。,a:公L叫,勿)cos(q)

L3)=/3,M)乙3)(〃四)

Blinn5sformofPhonghighlighting

L(%)=①"(①)(皿)4=((〃3”

、/、h)%

p"。例)

?ThePhongspeculartermisabitodd

-itsBRDFcancelsoutthereflectanceequation'scosinetermfrom

theangleofincidence.

-Phonghighlightingmodelisadhocandignorestheeffectofthe

projectedarea

BRDFTheory

?2importantproperties

-Reciprocity

BRDF<R,a,,,4)=BRDF入(9。0。,亂曲)

-Conservationofenergy

Q

SomeBRDFModelingConcept

?Micro-facets(Cook-Torranceetal.)

-heightcorrelation(HTSGBRDFmodel)

?Fresnelreflectance

?Anisotropyandisotropic

Micro-facets

?Micro-facets

-Thesurfaceconsistsofalargenumberofsmallflat“micro

mirrors”(facets)

-Facetsreflectlightonlyinthespeculardirection

-Diffusereflectionasinterreflectionofseveralfacets.

Micro-facets

-Ontheleft,themicro-facetcan“see”indirectionskland

k2,soitcontributestotheBRDF.

-Ontheright,directionk2isblockedandthemicro-facet

doesnotcontribute.

Fresnelreflectance

?Whenadielectricislookedatalongagrazingangle,ifis

morereflective.

?Incomparison,metalsvaryrelativelylittle.

1

o8

?

o6

?

o4

?

o2

?

0

0102030405060708090

angleofincidence

Fresnelreflectance

1(g*j+[c(g+C)-l]2>

2

5(g-C)2[[c(g-C)+l]?

c=vh____

g=+C2-1

Anisotropy

ImprovementonBRDF

?BRDFassumeslightentersandleavesasurfaceatthe

samepoint,whichisn5ttrueinreallife

?Bi-directionScatteringSurfaceReflectionDistribution

Functions(BSSRDF)

妥添

\

\

\4

XAJ/

<1

ution-function

BRDFandBSSRDF

ImplementingBRDFs

?Factorization

-BRDFisa4Dfunction

?usea4Dlookuptable(i.e.a4Dtexture)tostorethe

BRDF

?atrun-timedoaper-pixeltexturelookuptocomputethe

lightingequationabove.

-ConvertaBRDFintoasetoftwo-dimensionaltextures

Factorization

?Factorization

-Firstphase-preprocess

?SeparatetheBRDFintotwo2Dfunctionsrepresentedas

apairoftexturemaps

-Secondphase

?ReconstructingtheBRDFandcomputationoftheBRDF

lightingequation

Factorization-Decomposition

?Factorization幾

-Findp,q/(co,,%卜Zp/g)%.(q)

?SVDj=i

-Singularvaluedecomposition

-Optimal

-expensiveintimeandspace

?ND

-Normalizeddecomposition

-simple

Example

?FactorizationofaBRDFforgold

-Thetwotexturesareaccessedwiththeincominglightand

outgoingviewdirections

-Multiplytexturestogetherateachpixeltogeneratetheteapofs

illumination

Drawbackoffactorization

?Drawbacks

-Foreachlightsourceinthescene,atleasttwotextureaccess

areneeded.

-Theradiancecoiningfromarealight,thesky,orother

surroundingobjectscannotbecaptured.

anansotropicsurface

aphotomicrographshowingasimilar

(brushedmetal).

surface

directionalityofthedetail

Outline

?RadiometryandPhotometry,colorimetry

?BRDFtheory,implementingBRDFs

?Vertexshaders,pixelshadingandshadingLanguage

?MotionBlur,depthoffield,reflections,refractions,

shadows,global川umination

VertexDataTessellationData

Geometry

Stage

Rasterizer

Stage

Shader

?Vertexshaderwastoreplacehardwaretransformand

lighting(T&L)unit

-Developersgainmorecontroloverthelightingmodel

ofvertices.

?Specialeffectsandobjectdeformations

?PixelShaderwastoreplaceTexturingStages

-Developerscanmanipulateeachpixelsdirectly

?makinghandcraftedphongshadingandotherper-

pixeleffectspossible.

-Canmodifythez-depthvalue

-Maketextureaccessingandmanipulationeveneasier:

?Accesstoupto16textures.

?Manipulationoftexturecoordinates,likescaling

andoffsetting.

?ShadingLanguages

-Assembly-likelanguages.

VertexShader

?HardwareT&LversusVertexShader:

-HardwareT&L

?ThetaskofT&Lofverticeswasoffloadedtographic

hardware

-freeCPUforothertasks.

?Thedrawback

-itforcedtheuseofbasichard-wiredGouraud/Phong

lightingmodel.

-VertexShader

?Hardware-assistedandprogrammableversionof

HardwareT&Lstage.

?V.ScanemulateallofthefunctionalityoftheHardware

T&L,andwithoptimizationsitcanevenbefasterthanthe

hard-wiredpath.

VertexShader

?Thefirstversion(DX8)ofvertexshaderspecification:

-Upto128steps.

-17differentinstructions.

-Noexplicitflowcontrolinstructions.

-4Typesofmemory

?Per-vertexinput.

?Per-vertexoutput.

?Temp.registers.

?Constantmemory.

VertexShader

?Memory

-Dataarestoredas“Vectors",whichconsistofonetofour

elements(aelementisasigned32-bitfloatingpoint).

-Constantmemoryisread-onlytotheshader,andholdsthe

samedataforallverticesprocessed.(Ex.Lightattributes).

-Thevertex5shomogeneousclippositionmustalwaysbe

output,otherthingslikediffuseandspecularcolors,texture

coordinates,fogandpointsizecanalsobeoutput.

VertexShader

-Objectdeformation.

?Deformorevendefine

theobjecfsverticesby

V.S.

-Pagecurls,heathaze,

waterripples.

?Byusingtheentire

framebuffer'scontents

asatextureonamesh.

PixelShader

?PixelShader

-storedas"vector"

-Threesetsofinputs:

?Theinterpolated/lampeddiffuseandspecularcolorsand

alphas.

?8constantsregisters

?4ormoretexturecoordinates.

-These“texturecoordinates"actuallycanrepresent

anything.

?E.g.lightvector(x,y,z),halfangle(x,y,z)orplanar

coordinates(x,y).

Pixelshader

>rgbaoutput

——Az-depthoutput

PixelShader

jm.."」h"「二一’:

;????一?

'Hi*凝f闌

!MilttSWW

WOWWWWr

、4,_:A,,、f—t.*_I_11__」;

w?wwww

Texture1

Texture2

PixelShader

?Textureaddressinginstructions

-Performdependenttextureread

?"texldrxtx”:

-rxisregisterx,txistexturecoordinatesx.

-Accessspecifictextureusingtxastexturecoordinates,

andstorethefetchedvalueinrx.

-Theselectionoftexturebeingaccessedisdetermined

bythenumberofregister.

-Specialusesofdependenttextureread:

?Normalization:accessanormalizingcubemap,the

normalizedvalueoftxisstoredinrx.

?Powerfunction:accessapowerfunction

PixelShader

Implementsuccessiverenderingpasses

-Thebestway

?useP.S's"phase”command.

-"Rendertoatexture55

?storeintermediateresultsintextures,andaccessthemas

texturesinsuccessivepasses.

?Mainproblem:limitedprecisionoftexture.

-Usebackbuffersor“pixelbuffers"

?whenthegraphichardwaredonotsupportthe"renderto

atexture"feature,wecanonlystoreintermediateresults

inbuffersinhost/CPU.

PixelShader

?ImplementphongshadingbyP.S.

-Formula:c=(nJ+a)*d+(n.h)Ashi*g

?c:finalcolor.-ShallbeoutputtedinrO.

?n:pixelnormal.-Storedinbumpednormalmap.

?I:lightdirection.-Storedintex.coordinatet1.

?a:ambientconstant.-Storedconstantc7.

?d:diffusecolor-Storedindiffusemap.

?h:half-anglevector.-Storedint2.

?shi:shininessconstant.-Storedinshininessmap.

?g:glossconstant.-Storedinglossmap.

PixelShader

?ImplementphongshadingbyP.S.

-Texturespreparation:

?Diffusemap/glossmapissettobeassociatedwithrO.

?Bumpednormalmap/shininessmapistobeassociated

withr1.

?Normalizingmapistobeassociatedwithr2.

?Powerfunctionmapistobeassociatedwithr3.

-Registerpreparation:

?to:surfacelocation.

?t1:lightvector.

?t2:half-anglevector.

?c7:ambientconstant.

PixelShader

?ImplementphongshadingbyP.S.

-texIdrl,tO//Accessnormal/shininessmapNbysurfacelocation

andstorefetchedvalueinrl

texIdr2,tl//StorenormalizedvalueoflightvectorLinr2

texcrdr3.rgb,t2//Carryhalf^anglevaluedirectlyintor3.

dp3_satr5.xyz,rl_bx2,r2_bx2//Calculate(n.l)andstoretheresult

inr5;

dp3_satr2.xyz,rl_bx2,r3//Calculaten.handstoretheresultinr2

movr2.y,rl.a//Carryshininess(alphaofrl)intor2,nowr2hasn.h

inxandshininessiny

PixelShader

一phase//Becausewewanttoperformtextureinstructionsagain,

startsecondphase.

texIdrO,tO//Accessdiffuse/glossmapbysurfacelocationand

storefetchedvalueinrO

texIdr3,r2//Byaccessingthepowerfunctionmap,store

(n.h)Ashininessvalueinr3

addr4.rgb,r5,c7//Calculate(n.l+a)andstoretheresultinr4

mulrO.rgb,rO,r4//Calculate(n.l+a)*dandstoretheresultinr4

+mul_x2rO.a,rO.a,r3.a//Calculateg*(n.h)Ashininessandstorethe

resultinrO.a

addrO.rgb,rO,rO.a//Calculate(n.h+a)*d+g*n.h)Ashininess

andstoreitinrO

nVIDIA'sRegisterCombiner

?nVIDIA5sRegisterCombiner

-Customableper-pixelshadingand

multitexturing.

-Per-pixelphongshading.

-Bumpmapping

-Modulatespecularlightingwithtexturemap.

ShadingLanguage

?Thebenefitsofusinghigherlevelshadinglanguage

-Easeofuse.

?Easytowrite.

?Easytomaintain

-Portability.

-Optimization.

?Theshadinglanguagecompilercanperformoptimization

onthegeneratedcodes.

-Infact,thesebenefitscanapplytoanyhighlevel

programminglanguages,likeCoverassemblycodes.

ShadingLanguage

?ExamplesofShadingLanguages:

-Cooks"ShadeTree"

?Expressiontreeofshadingoperations.

-"QuakeIIIArena"scriptinglanguage.

-The“RenderMan“specificationofashadinglanguage.

-Stanfordreal-timeshadinglanguage(RTSL)

-DX95sHighLevelShadingLanguage(HLSL):

ShadeTree

finalcolorfloatka=0.5,ks=0.5;

floatroughness=0.1;

.卜floatintensity;

colorcopper=(0.8,0.3,0.1);

intensity=ka*ambient()+

、ks*specular(normal,viewer,roughness);

final_color=intensity*copper;

copper/丁

color

*

?/,\

specular

weightofambientweightof.function

specular僅黑

ambient

component/\

component

normalviewersurfaceroughness

ShaderlanguageusedinTM

Outline

?RadiometryandPhotometry,colorimetry

?BRDFtheory,implementingBRDFs

?Vertexshaders,pixelshadingandshadingLanguage

?MotionBlur,depthoffield,reflections,refractions,

shadows,global川umination

MotionBlur

?Modelandrenderthebluritself

-Usetheaccumulationbuffer

?Addinfollowingnframe

?Lowerstheframerate

?Cleverway:subtractoutthefirst

sceneandaddinthelast

MotionBlur

?Twopassesvertexshaders

-Firstpass:normallyrender

-Secondpass:usevectorshader

?N:normalvector

?M:motionvector

?N-M:<0outputpreviousposition,elsecurrentposition

?Misusedtomodulatethealphacomponent

MotionBlur

Visualizationofthe

velocitybuffer

Blurringeffect

DepthofField

?Useaccumulationbuffer

-Varytheviewpointandkeepfocuspointfixed

?Layer-basedsystems:blurparticularlayer

-Usefilteringtechniquestoblur

-Usepixelshadertointerpolateforeachpixel

viewer

focalpoint

Reflections

?Environmentmapping

-Assumethatreflectedobjectsarefar

?PlanarReflections

?GlossyEffects

?ReflectionsfromCurvedReflectors

Reflections—PlanarReflections

?Lawofreflection:

-angleofincidence=angleofreflection

1.Createacopyoftheobject

2.Transformitintothereflectedposition

3.Lightsourceshavetobetransformedaswell

4.Rendertheobject

5.Renderrestofthescene

Reflections—PlanarReflections

?R:reflectingplane

?n:reflectingplanenormal

?Scalingmatrix=S(1,-1,1)whenn=(0,1,0)andRgoes

throughtheorigin

F=R(n,(0,1,0))T(-p),p:somepointonR

M=F1S(1,-1,1)7F

ReflectionsPlanarReflections

X

withstencilbuffer

PlanarReflectionsProblems

1.Reflectedgeometryappearatplaceswherethereisnoreflector

geometry

-Solvedbyusingstencilbuffer

2.Backfacecullingisturnedon,thereflectedobjectswillappear

tohavefrontfacecullingturnedon

-Solvedbyturningofffacecullingorswitchtofrontface

culling

3.Objectsbehindthereflectorplaneshouldnotbereflected

一Puteachverticesintoplaneequation

-Ifvaluev0,itisbehindtheplane

一Trianglesintersectingtheplaneneedtobeclipped

-Useauser-definedclippingplane

Reflections—GlossyEffects

?Fogthereflectedobjects

-Fadetheobjectstoblackasthedistancefromthemirror

increases

?Fuzzyreflectionandfrostedglass

一Useaccumulationandstencilbuffers

Fogthereflectedobjects

Fuzzyreflectionandfrostedglass

FuzzyreflectionFuzzyrefraction

a

Refraction

?SnelPsLaw

Refractions

Anotherway

1.Generateacubicenvironmentmapfromeye5spositionand

includeonlyrefractedobjects

2.Rendertherefractionobject,accesstheEMbythe

refractiondirection

Shadows

PlanarShadows

?ProjectionShadows

yvx—lxvy

=Px=

4匕一〃匕,

P=

zly~vy

仕-I00、

0000

M=

0-IzIy0

J-I0fyy

PlanarShadows

/lx1[d+n.1/

/\P=1(””-1)

//\\n.(v-1)

n;(nA+d-l/i-In,一1四一3

\\//\AAxAy

\\M=加”』+"一也-4%一/)”

n?l+d-5-lzd

飛n?l.

兀:irx+d=0

PlanarShadows

?Render

1.Applythematrixtotheobjects

2.Rendertheprojectedobjectwithadarkcolor

-Toavoidrenderingbeneaththereceiver,weshouldadd

somebiastotheprojectedplane

-Ordrawtheplanefirst,anddrawtheshadowwithZ-buffer

off

-Usestencilbuffertoavoiddrawingshadowsoutsidethe

plane

SoftShadows

?Wheneveralightsourcehasanarea,softshadows

appear

?Sampleseveralpointsinthelightarea,rendertothe

accumulationbuffer.

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論