1 / 16

Lighten Up! Lighting a 3D World with HLSL

Lighten Up! Lighting a 3D World with HLSL. Matt Christian http://www.insidegamer.org matt@insidegamer.org. Who am I?. Current Student University of Wisconsin – Stout Applied Mathematics and Computer Science: Software Development Associate Degree in Computer Programming

lila-martin
Download Presentation

Lighten Up! Lighting a 3D World with HLSL

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. Lighten Up!Lighting a 3D World with HLSL Matt Christian http://www.insidegamer.org matt@insidegamer.org

  2. Who am I? • Current Student • University of Wisconsin – Stout • Applied Mathematics and Computer Science: Software Development • Associate Degree in Computer Programming • Northcentral Technical College • Avid Gamer / Game Programmer • Gamer since age 5 • Worked with XNA, DirectX, VB (yes I wrote a game in VB 6.0)

  3. Microsoft HLSL • High Level Shader Language (HLSL) • Developed for DirectX but used in all traditional graphical APIs • DirectX 8.0 • C-style language used to manipulate graphics • Vertex Shaders • Pixel Shaders • Geometry Shaders (not covered)

  4. Why Use Shaders? • Make things pretty! • More Realistic • Shaders make use of graphics hardware and allow the CPU to be free of the majority of graphical calculations done on the GPU • “Fixed” pipeline (lighting without shaders) is being phased out • XNA’s BasicEffect

  5. Vertex Shaders • Manipulate vertices • Position, color, etc…

  6. Pixel Shaders • Manipulate each pixel • Lighting, bump mapping, post-processing

  7. Rendering Pipeline • How are shaders processed?

  8. 3D Transformations • World Transformation • Transform from model coordinates to 3D world coordinates (position, rotation, scale) • View Transformation • Transform the world to align with the camera or ‘eye’ viewing the world • Projection Transformation • Convert 3D objects to 2D screen space • World*View*Projection Transformation Matrix

  9. The Point Light - Basics • A point light is a light source sending light out from the center • 2D: Circle • 3D: Sphere • Examples • Sun • Light bulb • Almost any light

  10. Steps for Our Shader • Determine all transformations • Have light travel in a specific direction • Light contacts surface • Light surface based on distance and brightness • Blend light color with surface color/ material

  11. Light - Brightness • Brightness of a surface is determined by the angle of the light versus the normal of the surface (note:Surface Normal ) • Direct light (light directed at normal) yields a brighter surface • Perpendicular light and normal yields no light applied • Illumination = cos(theta) * brightness • Where theta is the angle between the surface normal and direction of the light • Cos(90) = 0

  12. Light – Attenuation & Falloff • Attenuation is the speed at which a light’s intensity decreases (further away receives less intense light) • While Attenuation deals with distance, a light’s falloff is the loss of intensity from the center of a light source (this slide has a falloff)

  13. DirectX and Materials • General Idea of a Material • Clear layer sitting on top of an object (may be colored) defining how a surface reflects light • Light on Surface = Illumination * Material Info * Attenuation • Material Info includes: • Diffuse – Non-shiny, reflective light (concrete) • Ambient – Reflective ambient light (all-world light) • Specular – Shiny, reflective light (apple) • Emissive – Light the object emits (crystal)

  14. Code & Demo • Effect File (.fx) • DirectX 9.0c

  15. Questions? • HLSL • DirectX • Gaming

  16. More Information • http://freespace.virgin.net/hugo.elias/graphics/x_main.htm • Very helpful site on light and perceiving light • http://msdn2.microsoft.com/en-us/library/bb509561(VS.85).aspx • MSDN HLSL Documentation • http://www.insidegamer.org/projects.aspx • My projects website, contains some shader writings • http://www.geekswithblogs.net/CodeBlog • My blog

More Related