1 / 20

Practical Course – Shader Gallery C# / DirectX WS 06/07

Practical Course – Shader Gallery C# / DirectX WS 06/07. Assignment 3. Move. Create. Reset. Lost. Destroy. Render. Important DirectX “Methods”. private void OnCreateDevice( object sender, DeviceEventArgs e); private void OnResetDevice( object sender, DeviceEventArgs e);

Download Presentation

Practical Course – Shader Gallery C# / DirectX WS 06/07

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. Practical Course – Shader Gallery C# / DirectX WS 06/07 Assignment 3

  2. Move Create Reset Lost Destroy Render Important DirectX “Methods” private void OnCreateDevice(object sender, DeviceEventArgs e); private void OnResetDevice(object sender, DeviceEventArgs e); public void OnFrameMove(Device device, double appTime, float elapsedTime) public void OnFrameRender(Device device, double appTime, float elapsedTime) private void OnLostDevice(object sender, EventArgs e); private void OnDestroyDevice(object sender, EventArgs e); Managed/Sysmem Default Default Managed/Sysmem Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  3. User / Driver Vertex Stage Pixel Stage Texture 0 Texture 1 Texture 2 Texture 3 Pipeline Transform & Lighting Rasterizer Texturing Blending/Ops Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  4. Objects in 3D world Geometry subsystem 2D primitives Raster subsystem Color image Rendering pipeline Object coordinates Modelling transform affine World coordinates Model-View-Transformation Viewing transform affine Eye coordinates Normalizing transform Normalized (Clip-)coord. clipping 2D Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  5. Lighting - Light sources • Directional (parallel) lights • E.g. sun • One homogeneous vector • Point lights • Same intensity in all directions • One homogeneous point • Spot lights • Limited set of directions • Point + direction + cutoff angle Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  6. Light sources • Area lights • Light sources with a finite area • Can be considered a continuum of point lights • Not available in interactive rendering systems Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  7. Light sources • Geometry • Positions and directions need to be specified in the same coordinate system as the scene geometry • Choose camera space coordinates for illumination calculations • Points and directions undergo normal model/view transformations Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  8. Ambient light • Incoming light component that is identical everywhere in the scene • No direction • Hack for replacing true global illumination, i.e. light bouncing off from other objects Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  9. Diffuse Light - Lambert’s Cosine Law • The reflected luminous intensity in any direction from a perfectly diffusing surface varies as the cosine of the angle between the direction of incident light and the normal vector of the surface. • Intuitively: cross-sectional area of the “beam” intersecting an elementof surface area is smaller for greater angles with the normal. Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  10. N I  Lambert’s Cosine Law • Ideally diffuse surfaces obey cosine law. • Often called Lambertian surfaces. • Id = kd Iincidentcos  = kd Iincident (N·L). • kd is the diffuse reflectanceof the material. • Wavelength dependent, so usually specified as a color. Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  11. Specular Light - Phong Lighting Model • Phong adds specular highlights. • His original formula for the specular term: • W(i)[cos s]n • s is the angle between the view and specular reflection directions. • “W(i) is a function which gives the ratio of the specular reflected light and the incident light as a function of the the incident angle i.” • Ranges from 10 to 80 percent. • “n is a power which models the specular reflected light for each material.” • Ranges from 1 to 10. Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  12. Phong Lighting Model • More recent formulations are slightly different. • Replace W(i) with a constant ks, independent of the incident direction. • What do we lose when we do this? • Is= ks Iincidentcosn = ks Iincident (V·R)n. • V is the view direction. • R is the specular reflection direction. Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  13. The Phong model Phong Bui-Tuong (1975):Use cosine power as heuristic n v rl l Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  14. Materials • Computing the reflection direction rl of l • n and l are unit length n (n▪l)▪n l rl=2(n▪l)▪n-l -l Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  15. Phong lighting cosn • For specular component • Extended highlights • Perfect mirroring only in direction rl • Rapid decay • Model using cosna (perfect n  ) a n eye rl l v J J a Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  16. The Blinn-Phong model • Using the halfway vector n h eye rl b l v J J a Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  17. Shading Specular Ambient Diffuse Ka = 0.1 Kd = 0.5 Ks = 0.4 Phong Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  18. One application for alpha blending Transparency Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  19. Transparency with alpha Idea: 4 3 2 1 Over Operator: Colordst := (1-Alphasrc)*Colordst+ Alphasrc*Colorsrc Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

  20. Depth Peeling … You‘ll need (for the minimum version): CullMode = CW; // = Clockwise; CullMode = CCW; // = Counterclockwise; You‘ll need (for the cool version): ColorWriteEnable = 0; /ColorWriteEnable = 15; // = all ZFunc = GreaterEqual; / ZFunc = Less; / ZFunc = Equal; device.Clear(ClearFlags.ZBuffer, Color.Black, 0.0f, 0); Kai Bürger & Polina Kondratieva – Computer Graphics and Visualization Group

More Related