Presentation is loading. Please wait.

Presentation is loading. Please wait.

UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Lighting.

Similar presentations


Presentation on theme: "UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Lighting."— Presentation transcript:

1 UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Lighting

2 Goals 1. Understand the general lighting problem 2. Review the classic lighting equation

3 The lighting equation

4 Approximating the equation  The general problem is intractable  We must construct approximate models  Models for light sources and for materials (reflection)  Multiple light sources are used simultaneously  Each light’s contribution calculated in isolation  Multiple models are used simultaneously  Each model handles just one aspect of light transfer  Apply all models to all lights  Add the results to combine them

5 The classic reflection models  Have been used for many years  Lambert’s diffuse lighting model: I=NL  Non-reflective: no change with location of the viewer  Phong’s specular lighting model: I=(RV) P  R=2(NL)N - L  Reflective: changes as the viewer changes location  Specular model tends to be optional I=observed light intensity L=direction to the light N=surface normal V=direction to the viewer R=reflection vector P=specular power L, N, V, R are normalized

6 The classic light source models  Each model returns:  How much light is received (RGB light intensity)  The L, used by the reflection model  Ambient light is just a constant RGB  Models light coming from everywhere (white noise)  Reflection model not applied (there’s no L)  Directional light has a constant RGB and L  Models the sun – light coming from very far away  Point and spot light use formulas for RGB and L

7 D3D lights  typedef struct _D3DLIGHT9 {  D3DLIGHTTYPE Type; /* Type of light source */  D3DCOLORVALUE Diffuse; /* Diffuse color of light */  D3DCOLORVALUE Specular; /* Specular color of light */  D3DCOLORVALUE Ambient; /* Ambient color of light */  D3DVECTOR Position; /* Position in world space */  D3DVECTOR Direction; /* Direction in world space */  float Range; /* Cutoff range */  float Falloff; /* Falloff */  float Attenuation0; /* Constant attenuation */  float Attenuation1; /* Linear attenuation */  float Attenuation2; /* Quadratic attenuation */  float Theta; /* Inner angle of spotlight cone */  float Phi; /* Outer angle of spotlight cone */  } D3DLIGHT9;

8 Material properties  The reflection models used are a material property  The specular power is also a material property  Coefficients are material properties, too  Ambient, diffuse, specular and emissive  Emissive is just added to the rest  Part of the material is applied in the pixel shader  The texture is just an ambient/diffuse coefficient!  Specular (and emissive) are added there, too

9 D3D materials  typedef struct _D3DMATERIAL9 {  D3DCOLORVALUE Diffuse; /* Diffuse color RGBA */  D3DCOLORVALUE Ambient; /* Ambient color RGB */  D3DCOLORVALUE Specular; /* Specular 'shininess' */  D3DCOLORVALUE Emissive; /* Emissive color RGB */  float Power; /* Sharpness if specular highlight */  } D3DMATERIAL9;  typedef enum _D3DMATERIALCOLORSOURCE  {  D3DMCS_MATERIAL = 0, // Color from material is used  D3DMCS_COLOR1 = 1, // Diffuse vertex color is used  D3DMCS_COLOR2 = 2, // Specular vertex color is used  D3DMCS_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum  } D3DMATERIALCOLORSOURCE;

10 Implementation notes  Many 3D accelerators since the late 90’s have included hardware to perform all of this  D3D calls it the “fixed-function pipeline”  It’s completely removed in D3D10  All of this must be done in shaders!  More flexibility = more work


Download ppt "UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Lighting."

Similar presentations


Ads by Google