- You
will need to change your Mesh file format (both text and binary) to
support tangents and bitangents
- You
will need to update your vertex declaration to support both tangents and
bitangents
- You
can use the semantics TANGENT and BINORMAL
- Tangents
and bitangents are transformed exactly the same way as normals, with the
rotation only (because they are vectors and not points)
- You
may add normal maps to all of your lit fragment shaders if you wish
- You
should probably create different vertex shaders for those that transform
tangents and bitangents and pass them on, but this isn't required
(Direct3D should still function correctly even if extra data is
interpolated but not used)
- YOU
STILL MUST HAVE A DIFFUSE TEXTURE
- This
means that you will be setting two textures into your fragment shaders
- This
also means that your Material will specify two image paths for both
textures that the Effect expects
- Normalize
each of the three interpolated vectors: The normal, the tangent, and the
bitangent
- Create
a so-called "TBN" rotation matrix, which is a float3x3 with the
tangent, then the bitangent, then the normal
- Note
that this order is important. You can think of each of these as x, y,
and z, respectively
- Sample
the normal map to get a float3 representing how the normal should be
modified. Since this came from a texture, each component will be in [0,1]
- Transform
the sample from [0,1] to [-1,1]:
- float3
normal_texture = ( normalMapSample * 2.0 ) - 1.0;
- Transform
the normal from normal space into world space using the TBN matrix:
- float3
normal_world = mul( normal_texture, rotation_textureToWorld );
- Now
you can use the normal in world space just as you have in previous
assignments to calculate lighting
- The
CADE machines should have this plugin installed. If for any reason you don't
think you have access to Photoshop and this plugin, let me know as early
as possible. (If you let me know Friday afternoon I will not be
sympathetic to your plight.)
- This
plugin uses "height" maps as its source
- White
is closer to the camera, black is further away
- Go
to Filter->NVIDIA Tools->NormalMapFilter
- None
of the "Invert" options should be selected
- You
can increase "Scale" to emphasize the effect
- "Height
Source" should be "Average RGB"
- A
left-handed normal map should look like the red is coming from the right,
and the green is coming from the bottom
- If
you find normal maps from other sources make sure that they match the
left-handed red/green convention. Most normal maps you find will probably
be right-handed and the green will look like it's coming from the top. You
will have to invert the green channel in your image editing program of
choice
Details
Exporting from Maya
- You
can use the functions MFnMesh::getTangents() and MFnMesh::getBinormals()
to get lists of tangents and bitangents
- You
can use the function MItMeshPolygon::tangentIndex() to get the index for
each vertex. Note that there is only one index that you should use for
both tangents and bitangents (in other words, there is no binormalIndex()
function)
Normal Mapping
- We
are glossing over a lot of important details in this assignment. If you
find that you can't get your normal mapping to look correct please email
the mailing list so we can figure things out. We made need to do a few
things in a more sophisticated manner if we run into problems that I
haven't anticipated
No comments:
Post a Comment