аЯрЁБс>ўџ <>ўџџџ;џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџьЅС7 №ПоbjbjUU %87|7|ьёџџџџџџl(0008h„D(…Адддддддд$5 Up*ддддд*hдд?hhhдддhдhœhдШ ˆfA–ХТ(0дU0…Хд”Хh((й Illumination Models Deepak Gautam 1. Introduction 2. How To 3. Closing words 1. Introduction This document is going to explain to you how a direct light model works, that’s is how light interacts with diferent surfaces, how is light reflected, etc etc. Some of the models are based on the research I conducted at Staffordshire University between 2002. 2. How To How does a surface interacts with light? This depends on an huge amount of factors, such as surface normal, lights relative directions,observers position, surface roughness, etc etc. Doing this in real-time involves creating an reasonable aproximation. There are basically 3 components that we must know (there are lot’s of components, but lets keep them to a minimum for now). Consider white light for now (achromatic light): Ambient Lighting: Consider a room without light sources. What do you see? Well.. nothing everything is black.. Ambient lighting is used to add an uniform light glow into a scene. Diffuse scattering: this happens when light penetrates the surface and it’s re-radiated uniformly. Specular reflections: this is view dependent, and its basically light being reflected over the surface from the light source. Lets see how this stuff is computed. The ambient lighting term is easy, it has the value that you or the artist want. Diffuse term is computed using what’s called the Lambert’s Law that tells that the amount of light being reflected is : L= normalized light direction N= normalized surface normal Diffuse= max(L.N, 0) Specular term has some ways to be computed, the most known model is the phong model , it envolves computing a reflection vector: Eye= normalized camera position N= normalized surface normal S= normalized light direction Reflection= -S+2*(S. N)*N Specular= (max(Reflection.Eye, 0))^n There is a nice variation of the phong model, that is used in Open GL API engines. It simplifies the general model by, computing a Halfway vector: Eye= normalized camera position N= normalized surface normal S= normalized light direction Half = Eye+S Renormalize half vector, then: Specular= (max(half.N,0))^n That’s it, now you know how to compute each individual light component. Now what to do with this stuff? Sum up everything. SurfaceColor= Ambient+Diffuse+Specular Ahh, wasn’t that easy! Now, how to add color you ask, and i say, eassyyyyy, we have the components light intensity, so we just have to multiply (modulate) color. (Color is defined in RGB space in this case) SurfaceColor= Ambient*AmbientColor+Diffuse*DiffuseColor+Specular*SpecularColor Now this let’s you have some nice ilumination, but what if you wanna have textured models ?? I say again, eaaaasyyy ! Just modulate the diffuse and the ambient term by the texture color (we dont modulate specular because it is light being reflected). The texture is usually called Decal texture. SurfaceColor= (Ambient*AmbientColor+Diffuse*DiffuseColor)*Decal+Specular*SpecularColor And that’s it, a nice and simple light model that you can use wherever you want to. Now lets see how to handle diferent light sources. There are 2 basic light sources types: Omni/point lights: light is scattered 360 degrees, that is in all directions. Spot/Directional lights: light is scattered only in one direction. Its really easy to handle both, for directional light sources, you just need your light directionvector. For omni/point light sources you will have to compute a vector from your light position into all geometry vertices/triangles. There’s a diference in directional lights, these are considered to be at infinity, and dont have any type of light attenuation. Omni lights must handle (or not, do has you wish) light attenuation with distance. Spot lights are a bit more involved, and you must handle (or not, again do has you wish) light attenuation with distance, and light attenuation within spotlight cuttoff angle. For the distance attenuation case is easy, just compute the light position distance to the vertice in question, and modulate light intensity with something like this: Atten= 1/ (kc+ klD+kq(D^2) ) Where the k’s are coeficients and D is light distance to the vertice. The attenuation within spotlight cuttoff angle is also easy, just modulate light intensity by a factor of (cos(B))^E, where B is the angle between light direction and a line that goes from light position into the current vertice, and E is a choosen exponent. You know the math’s behind this, let me explain how you will use them. The most obvious way is to compute this stuff per-face. This is what’s called flat shading. It looks really ugly.. A better way to compute this, is doing per-vertex and interpolating values across your triangles. This is what’s called Gouraud Shading. Im hoping that by now you already know what are vertex normals. But just in case you don’t know how these are computed. A vertex normal is just an average of all normals of triangles that share the same vertex. This is sometimes not enough, but its enough to get you started. In the old days you would compute this stuff on your cpu, now with vertex shaders it’s a bit stupid doing that.. Just compute your lighting in a vertex shader. Computing lighting this way is a bit artificial btw. Every surface has it’s how properties, by example clothes reflect light in a diferent way than metal. This is aproximated by using what’s called surface Materials. They’re just some coeficients (0..1) that you use to define material properties, how much does this surface reflects light, how much light does this surface absorves, etc etc. (btw: these are usually called, ambient reflection coeficient, diffuse reflection coeficient, specular reflection coeficient) SurfaceColor=(Amb*AmbColor*MatAmb+Dif*DifColor*MatDif)*Decal+Spec*SpecColor*MatSpec And there you have, a nice aproximation of how light interacts with surfaces. Im going to give you some nice tips now. You don’t have to exponentiate your specular component. You can do an aproximation, and save a lot off useless computation. This aproximation was suggested by Schlick (94). Computer Graphics: Using Open GL1997. Let D be your specular component, and E be your specular exponent. Schlick suggested to replace D^E with D/(E-E*D+D). 3. Closing words Newer games such as Splinter Cell demonstrate how Illumination models can be generated to create almost photo-realistic graphics. Remember that ilumination models are the basis of every game. Allways, and i mean allways, compute this stuff in a vertex shader! References Computer Graphics: Principle and Practice Computer Graphics: Using OpenGl Credits Proffessor Claude C Chilebushi – Lead researcher Realtime Computer Graphics and Gaming Technologies Staffordshire University. John Carmack for making such amazing light models! For real! Illumination Models Realtime Computer Graphics Deepak Gautam 2001  +-Fprsƒ‰•DWј [qЧ  œ 6 7 9 Ь эоЬНЎЁ€€n€n€n€_€_RCB*CJOJQJ^JaJphB*CJOJQJaJphB* CJOJQJ^JaJph#5B*CJOJQJ\^JaJphB*CJOJQJ^JaJph#5B* CJOJQJ\^JaJphB*CJOJQJaJphB*CJOJQJ^JaJphB*CJOJQJ^JaJph#5B* CJOJQJ\^JaJphB* CJOJQJ^JaJph#5B* CJ(OJQJ\^JaJ(ph +,-./0123456789:;<љљљљљљљљљїѕљљљљљљљљљљљљљљљљљ7$8$H$ьнўў<=>?@ABCDEFV`qrsƒ„‰Š‹•–ПР•–DEљљљљљљљљљљљљљљљљљљљљљљљљљљљљљ7$8$H$Ežј[В Ч Ш Щ Ъ ш    œ  Н к ј  7 8 9 Ь Э э ( 5 6 љљљљљљљљљљљљљљљљљљљїїљљљљљљљ7$8$H$Ь 5 U r №  ч 8aЙh{ЖЯ/„…}в–ЈЏАЬЭйк#$№с№с№с№с№сЯсЯсРЙ№сЊс№сšс‹с|lс_RB*CJOJQJaJphB*CJOJQJaJph5B*CJOJQJ\aJphB*CJOJQJ^JaJphџB*CJOJQJ^JaJphџ5B* CJOJQJ\aJphB*CJOJQJ^JaJph CJOJQJB*CJOJQJ^JaJph#5B*CJOJQJ\^JaJphB*CJOJQJ^JaJphB* CJOJQJ^JaJph 6 U V r s Л М м н №   / ч ш 78•–abЙКAhЖљњХHљљљљљљљљљљљљљљљљљљљљљљљљљљљљљ7$8$H$H./ux…МНzвгЉMNўe|}бв !JKЧљљїљљљљљљљљљљљљљљљљљљљљљљљљљ7$8$H$a”•–ЇЈjkЏАБВГДЕЖЗИЙКЛМНОПРСТУљљљљљљљљљљљљљљљљљљљљљљљљљљљљљ7$8$H$УФХЦЧШЩЪЫЬЭЮйк$%&./­ЎыьZ[лмнљљљљљљљљљљљљљїљљљљљѕѕѕѕѓѕёѕѕ7$8$H$$%&./ъыо№чзШЛзB*CJOJQJaJphB*CJOJQJ^JaJph5B*CJOJQJ\aJphCJOJQJaJB*CJOJQJ^JaJphно§#0PАа/ Ар=!А"А# $ %А i8@ёџ8 NormalCJ_HaJmH sH tH `@` Heading 1$$7$8$@&H$a$#5B* CJ(OJQJ\^JaJ(ph`@` Heading 2$$7$8$@&H$a$#5B* CJOJQJ\^JaJ(phP`P Heading 3$7$8$@&H$B*CJOJQJaJph<A@ђџЁ< Default Paragraph Font,@ђ, Header  ЦрР!, @, Footer  ЦрР!о 8џџџџ +,-./0123456789:;<=>?@ABCDEFV`qrsƒ„‰Š‹•–ПР•–DEžј[ВЧШЩЪшœНкј789ЬЭэ (56UVrsЛМмн№  / ч ш 7 8 • – a b Й К A h Ж љ њ Х H./ux…МНzвгЉMNўe|}бв !JKЧa”•–ЇЈjkЏАБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮйк$%&./­ЎыьZ[лп˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€0€€0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€š0€š0€š0€š0€š0€š0€š0€š0€€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€€š0€€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€š0€€š0€š0€š0€š0€š0€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€š0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€(0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€˜0€€š@0€€š@€€˜@0€€ oo№№№ѓЬ $о<E6 HУнон **$ˆч ш “”•$%ыььY[кпџџCIAJ:\dgnew\games\lightmodels.docCIAOC:\WINDOWS\Application Data\Microsoft\Word\AutoRecovery save of lightmodels.asdCIAOC:\WINDOWS\Application Data\Microsoft\Word\AutoRecovery save of lightmodels.asdџ@€**ˆ•d  **о@џџUnknownџџџџџџџџџџџџG‡:џTimes New Roman5€Symbol3& ‡:џArialCF‡ŸComic Sans MS?& ‡ŸVerdana Ref? Tahoma,Bold5& ‡:џTahoma"1ˆ№аhзеqіеqх3 /Y№ ДД0C2ƒ№џџIllumination Models Deepak GautamCIAўџ р…ŸђљOhЋ‘+'Гй0x˜ДРиф№  4 @ LX`hpфIllumination ModelslluDeepak GautamodeepeepNormalGCIA19Microsoft Word 9.0@4т0@ЂЏн‘ХТ@U2–ХТх3ўџ еЭеœ.“—+,љЎ0ќ hp|„Œ” œЄЌД М мфi/ C  Illumination Models Title ўџџџ !"#$%&'()*ўџџџ,-./012ўџџџ456789:ўџџџ§џџџ=ўџџџўџџџўџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџRoot Entryџџџџџџџџ РFˆfA–ХТ?€1TableџџџџџџџџџџџџХWordDocumentџџџџџџџџ%8SummaryInformation(џџџџ+DocumentSummaryInformation8џџџџџџџџџџџџ3CompObjџџџџjObjectPoolџџџџџџџџџџџџˆfA–ХТˆfA–ХТџџџџџџџџџџџџўџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџўџ џџџџ РFMicrosoft Word Document MSWordDocWord.Document.8є9Вq