1 / 10

UW Extension Certificate Program in Game Development 2 nd quarter: Advanced Graphics

UW Extension Certificate Program in Game Development 2 nd quarter: Advanced Graphics. Lighting. Goals. Understand the general lighting problem Review the classic lighting equation. The lighting equation. Approximating the equation. The general problem is intractable

paul
Télécharger la présentation

UW Extension Certificate Program in Game Development 2 nd quarter: Advanced Graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. UW ExtensionCertificate Program inGame Development 2nd quarter:Advanced Graphics Lighting

  2. Goals • Understand the general lighting problem • 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=N•L • Non-reflective: no change with location of the viewer • Phong’s specular lighting model: I=(R•V)P • R=2(N•L)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 • typedefstruct _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 • typedefstruct _D3DMATERIAL9 { • D3DCOLORVALUE Diffuse; /* Diffuse color RGBA */ • D3DCOLORVALUE Ambient; /* Ambientcolor RGB */ • D3DCOLORVALUE Specular; /* Specular 'shininess' */ • D3DCOLORVALUE Emissive; /* Emissive color RGB */ • float Power; /* Sharpness if specular highlight */ • } D3DMATERIAL9; • typedefenum _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

More Related