10_DXProgramming_2

10_DXProgramming_2 - DirectX Programming #2 Hyunna Lee...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
DirectX Programming #2 Hyunna Lee Computer Graphics, 2009 Fall
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Shading } Calculating intensity for each pixel based on } Object descriptions } Optical features for surface } Viewing parameters
Background image of page 2
Normal } For shading, you have to specify the vertex normal struct CUSTOMVERTEX { D3DXVECTOR3 position; // The 3D position for the vertex D3DXVECTOR3 normal; // The surface normal for the vertex }; #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Material } Defines characteristics of the quad of a geometric object } Color } Diffuse } Ambient } Specular } Emission } Glossiness } Power (of exponent term)
Background image of page 4
Per-vertex colors } We have used per-vertex color already } D3DFVF_DIFFUSE : diffuse color } Either per-vertex information or material based information can be used as shading factors } D3DMCS_MATERIAL : material color } D3DMCS_COLOR1 : per-vertex diffuse color (D3DFVF_DIFFUSE) } D3DMCS_COLOR2 : per-vertex specular color (D3DFVF_SPECULAR)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Light Type } Point light } Position and color } Light bulb without lampshade } Directional light } Color and direction } Sunray
Background image of page 6
Light Type } Spotlight } Position, color, and direction } Cone shape illumination area } Theta, phi, falloff, attenuation0/1/2
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Using Lights } Light configuration } Attach light to the device } Enable lighting D3DXVECTOR3 vecDir; D3DLIGHT9 light ; ZeroMemory( &light, sizeof( D3DLIGHT9 ) ); light.Type = D3DLIGHT_DIRECTIONAL ; light.Diffuse.r = light.Diffuse.g = light.Diffuse.b = 1.0f; light.Direction = D3DXVECTOR3(1.0f, 2.0f, 3.0f); g_pd3dDevice-> SetLight light ); g_pd3dDevice-> LightEnable ( 0, TRUE ); g_pd3dDevice->SetRenderState( D3DRS_LIGHTING , TRUE );
Background image of page 8
Shading Model } Three shading model } Flat shading : D3DSHADE_FLAT } Gouraud shading : D3DSHADE_GOURAUD } The default shading model is D3DSHADE_GOURAUD } Phong shading : D3DSHADE_PHONG } D3D9 does not support implicit Phong shading } Setting the shading model to D3D_SHADE_PHONG will lead unpredictable behavior g_pd3dDevice-> SetRenderState( D3DRS_SHADEMODE , D3DSHADE_FLAT );
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Shading Model } Phong reflection model } Ambient light } The result of multiple reflections from walls and objects } Modeled as a constant } Diffuse reflection } Specular reflection
Background image of page 10
Shading Model } Flat shading } Shades each polygon } Based on the angle between the polygon's surface normal and the direction of the light source } Color } The intensity of the light source
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/29/2010 for the course CSE 4190.411 taught by Professor Shinyeonggil during the Fall '08 term at Seoul National.

Page1 / 32

10_DXProgramming_2 - DirectX Programming #2 Hyunna Lee...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online