Friday, March 8, 2013

Graphics Assignment 8

This week's assignment was on Normal maps. Basically the idea behind this concept is that we take the normal per vertex of the normal texture and multiply it with TBN ( Tangent, Binormal and normal) matrix in the fragment shader. TBN is a 3x3 matrix in that specific order that is, Tangent's xyz coordinate as first row, Binnormal's xyz as the second row and the Normal's xyz as the third row. We take the Tangents and Binormals per vertex of the mesh from Maya while exporting. 
  
  The tangent and binormal in model space are passed to the vertex shader. Tangent and Binormal in world space are calculated by multiplying with ModelToWorldTransformation, the similar way we did for calculating normals. Now, the TBN in world space are passed on to fragment shader. In fragment shader, another sampler is used to sample for the normal Map. That sample is multiplied with TBN matrix which gives out normal of the texture in world space. So, I am converting texture normal in the texture space to texture normal in the world space, which gives me the cool effect of bumpyness without having to deal with the complex geometry of the model.

Changes in MayaExporter:

  I now include tangents and bitangents in the text file while exporting the model from Maya.
  
 I have changed the Maya's right hand convention to left hand as Directx is left hand-

  •   By changing the z coordinates of the position, normal, tangent and binormal
  •   By negating the binormal xyz
  •   By changing the order of  indices, that is, the winding order
  •   By changing the V coordinate of the UV's to V=1-V
Mesh Movement: WASD QE
Light Movement: IJKL
Camera Movement: NUM8,4,2,6



No comments:

Post a Comment