O'Reilly logo

Character Animation with Direct3D® by Carl Granberg

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Normal Mapping Shader

The shader code takes all that theory you’ve been reading about, as well as the prepared meshes, and outputs something that looks a lot better than what you’ve seen so far. In this chapter I have implemented normal mapping for the morphing meshes and the Face class. You should have little trouble, though, porting it to the skinned mesh shader yourself. After adding the tangent and the binormal to the vertex declaration of the base mesh in the Face class, the full vertex declaration of the Face class looks like the following:

//Face Vertex Format D3DVERTEXELEMENT9 faceVertexDecl[] = { //1st Stream: Base Mesh {0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0}, {0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required