Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Windows 8 Game Development

You're reading from   Learning Windows 8 Game Development Windows 8 brings touchscreens to the tablet and PC. This book will show you how to develop games for both by following clear, hands-on examples. Takes your C++ skills into exciting areas of 3D development.

Arrow left icon
Product type Paperback
Published in Oct 2013
Publisher Packt
ISBN-13 9781849697446
Length 244 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Michael Quandt Michael Quandt
Author Profile Icon Michael Quandt
Michael Quandt
Arrow right icon
View More author details
Toc

Shaders

We need two more things before we can actually render a 3D object. The first, and most important one, is the set of shaders that we will use to define the look of the object and tell the GPU what to do.

A shader is a small program written in a custom language (in this case, the High Level Shader Language—HLSL) that describes how the different stages of the pipeline will operate to render to the screen. There are a few different types of shaders; however, we only really need to cover the vertex and pixel shaders before any 3D rendering can be done.

Vertex shaders

The first shader that we will look at is the vertex shader. This shader is responsible for taking the vertices from our buffer and making sure they are in the right place relative to the virtual camera in the world.

A common vertex shader looks like the following:

cbuffer WVP : register(b0)
{
matrix World;
matrix View;
matrix Projection;
};

float3 main(float3 inputPos : POSITION) : POSITION
{
  float4 pos = float4(inputPos...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £16.99/month. Cancel anytime