Feb23 - Introduction to HLSL Shaders in XNA Game Design...

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

View Full Document Right Arrow Icon
Introduction to HLSL Shaders in XNA Game Design Experience Modified from Jim Whitehead’s slides Creative Commons Attribution 3.0 (Except copyrighted images and example Shader) creativecommons.org/licenses/by/3.0
Background image of page 1

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

View Full DocumentRight Arrow Icon
What is a Shader? • Recall that all 3D drawing in XNA uses a Shader Have been using BasicEffect shader so far • But, more generally, what is a shader? Today, gaming computers have both a CPU, and a GPU • CPU is on motherboard, GPU is on graphics card – CPU is an unspecialized computer • GPU is a computer specialized for 3D graphics – Advantage: faster 3D graphics, more effects, larger scenes A Shader is a small program that runs on the GPU • Written in a Shader language (HLSL, Cg, GLSL) • XNA supports only the HLSL shader language
Background image of page 2
Shader Languages Currently 3 major shader languages Cg (Nvidia) HLSL (Microsoft) Derived from Cg GLSL (OpenGL) Main influences are C language pre-existing Shader languages developed in university and industry HLSL (Microsoft, 2002?) GLSL (OpenGL ARB, 2003) ARB Vertex/Fragment (OpenGL ARB, 2002) Source: http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter01.html (Modified with information on HLSL and GLSL)
Background image of page 3

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

View Full DocumentRight Arrow Icon
Brief history Initially, computers did not have specialized graphics hardware In mid-90’s 3D acceleration hardware appeared • OpenGL typically provided better support DirectX 7 (1999) introduced support for hardware T&L • Transform and lighting • Moved vertex transformations and lighting computations from CPU to GPU • Improved game graphics, but at a cost: lighting and display calculations hard-wired into cards • Led to games having similar look In 2002, first consumer-level programmable GPUs became available • Led to development of Cg, HLSL, and GLSL shader languages • Benefit: can have game-specific custom graphics programs running on GPU • Games can have very distinctive visuals
Background image of page 4
• Shaders (GPU programs) are specialized into 3 different types: Vertex shaders • Executed once per vertex in a scene. • Transforms 3D position in space to 2D coordinate on screen • Can manipulate position, color, texture coordinates • Cannot add new vertices Geometry shaders • Can add/remove vertices from a mesh • Can procedurally generate geometry, or add detail to shapes Pixel shaders (fragment shaders) • Calculates the color of individual pixels • Used for lighting, texturing, bump mapping, etc. • Executed once per pixel per geometric primitive
Background image of page 5

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

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

Page1 / 20

Feb23 - Introduction to HLSL Shaders in XNA Game Design...

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

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