高级计算机图形学ACG04_第1页
高级计算机图形学ACG04_第2页
高级计算机图形学ACG04_第3页
高级计算机图形学ACG04_第4页
高级计算机图形学ACG04_第5页
已阅读5页,还剩114页未读 继续免费阅读

下载本文档

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

文档简介

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

评论

0/150

提交评论