Difference between revisions of "Normal map"

From polycount
Jump to: navigation, search
(2D Workflow: wip)
(Older Tutorials: Jeff Ross fix)
(33 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Out of Date ==
 
The information on this page is a bit old, it needs to be updated. See these links for more current information:
 
 
** [http://www.polycount.com/forum/showthread.php?t=81154 Understanding averaged normals and ray projection/Who put waviness in my normal map?]
 
** [http://www.polycount.com/forum/showthread.php?t=107196 You're making me hard. Making sense of hard edges, uvs, normal maps and vertex counts]
 
** [http://www.polycount.com/forum/showthread.php?t=116899 Official handplane support thread - Now freeware!!]
 
** [http://www.polycount.com/forum/showthread.php?t=152467 The best kind of beveling ?]
 
** [http://farfarer.com/resources.htm RNM Normal Map Combiner], by [http://www.farfarer.com/ James "Farfarer" O'Hare]
 
** [http://vincentcallebaut.com/CombineNormal.html Combine Normal], by [http://vincentcallebaut.comVincent "Vincentt" Callebaut], [http://www.polycount.com/forum/showthread.php?t=131819 Combine normal maps script for Photoshop] Polycount Forum thread.
 
** [http://www.polycount.com/forum/showpost.php?p=2226864&postcount=51 Earthquake on separating smoothing groups in the UV]
 
** [http://www.polycount.com/forum/showpost.php?p=2225535&postcount=40 JedTheKrampus on offsetting Mirrored UVs]
 
** [http://www.polycount.com/forum/showthread.php?t=148303 Of Bit Depths, Banding and Normal Maps]
 
** [http://www.polycount.com/forum/showthread.php?t=147227 Skew you buddy! Making sense of skewed normal map details.]
 
** [http://www.polycount.com/forum/showthread.php?t=146667 A Practical Guide On Normal Mapping For Games]
 
** [http://www.polycount.com/forum/showthread.php?t=144715 Skewmesh Tutorial]
 
** [http://www.laurenscorijn.com/future-xoliulshader-support.html Future Xoliulshader support] = why Xoliulshader doesn't work properly in 3ds Max 2013/2014.
 
 
 
 
== What is a Normal Map? ==
 
== What is a Normal Map? ==
A normal map is an image that stores a line at each pixel. These lines are called "normals".  
+
A normal map is an image that stores a direction at each pixel. These directions are called [[VertexNormal|normals]].  
  
 
The [[Normal_Map_Technical_Details#RGB_Channels|red, green, and blue channels]] of the image are used to control the direction of each pixel's normal.  
 
The [[Normal_Map_Technical_Details#RGB_Channels|red, green, and blue channels]] of the image are used to control the direction of each pixel's normal.  
  
 
A normal map is commonly used to fake high-resolution details on a low-resolution model. Each pixel of the map stores the surface slope of the original high-res mesh at that point. This creates the illusion of more surface detail or better curvature. However, the silhouette of the model doesn't change.  
 
A normal map is commonly used to fake high-resolution details on a low-resolution model. Each pixel of the map stores the surface slope of the original high-res mesh at that point. This creates the illusion of more surface detail or better curvature. However, the silhouette of the model doesn't change.  
 +
 +
There are two basic methods to create normal maps. These methods can also be used together.
 +
# [[Normal_map#3D_Workflow|3D modeling and baking]]
 +
# [[Normal_map#2D_Workflow|2D painting and conversion]]
  
 
<gallery mode="packed" heights=250px>
 
<gallery mode="packed" heights=250px>
 
normalmap_stairs.jpg|A normal mapped model, the mesh without the map, and the normal map alone.<br>Image by [http://ericchadwick.com/ Eric Chadwick].
 
normalmap_stairs.jpg|A normal mapped model, the mesh without the map, and the normal map alone.<br>Image by [http://ericchadwick.com/ Eric Chadwick].
 
</gallery>
 
</gallery>
 
 
== 2D Workflow ==
 
Normal maps can be made in 2D painting software, without modeling in 3D. You can convert photo textures into normal maps, create node-based graphs to compile normal maps, or even hand-paint them with brushes.
 
 
Normal maps created in 2D work best when tiled across 3D models that have a uniform direction in [[Normal_Map_Technical_Details#Tangent_Basis|tangent space]], like terrains or walls. On these models the UVs are not rotated; they are all facing roughly in the same direction. To get seamless lighting, rotated UVs require [[Normal_Map_Technical_Details#UV_Coordinates|specific gradients in the normal map]], which can only be created properly by [[Texture Baking|baking a 3D model]].
 
 
(... work in progress ...)
 
 
<pre>
 
* 2D Normal Map Tools:
 
** Nvidia Photoshop Filter
 
** Crazy Bump
 
** NDO
 
** DDO
 
** Substance Designer
 
 
* Flat Color
 
* Blending Normal Maps Together
 
* Pre-Created Templates
 
* Re-Normalizing
 
* Ambient Occlusion into a Normal Map
 
* Back Lighting
 
</pre>
 
  
 
== 3D Workflow ==
 
== 3D Workflow ==
(... work in progress ...)
+
The 3D workflow varies for each artist. See the following links for more information. In time this info will be condensed onto the wiki.
  
<nowiki>
+
* [[Texture Baking]] has the step-by-step workflow for baking textures from a high-resolution model onto a lower-resolution model.
Summary.
+
* [http://www.polycount.com/forum/showthread.php?t=146667 A Practical Guide On Normal Mapping For Games] has a detailed survey of normal mapping workflows.
  
Breakout pages:
 
[[Normal Map Modeling]]
 
* High-Poly Modeling Tricks
 
** Sloped Extrusions
 
** Edge Thickness
 
** mental ray Round Corners Bump
 
** Floating Geometry
 
* Beveling
 
* Smoothing Groups & Hard Edges
 
* Mirroring
 
* LODs
 
</nowiki>
 
  
 +
=== High-Poly Modeling ===
 +
* [[DigitalSculpting]] and/or [[Subdivision Surface Modeling]] are the usual technique for building high-poly models for baking normal maps.
 +
* Optimize the high-resolution model to speed up bakes, to avoid running out of RAM while baking, and to keep 3d file sizes manageable. See [[Tools#Decimation_Software]].
 +
* If it's a [[DigitalSculpting|sculpt]] reduce the vertex count to a manageable file size before exporting. Sculpting tools like Zbrush create triangles smaller than the bake pixels, which will increase baking time significantly without actually improving the bake.
 +
* If it's a [[Subdivision Surface Modeling|subdivision surface]] choose an appropriate resolution. Use just enough subdivisions to get a smooth surface at the baking resolution, and no more.
 +
* [http://www.polycount.com/forum/showthread.php?t=155473 Speeding up highpoly hard surface workflow]
 +
* [http://www.polycount.com/forum/showthread.php?t=146280 Smooth Edge Shading - legitimate technique?] - using a shader trick to fake high-poly rounded edges.
 +
* [http://www.polycount.com/forum/showthread.php?t=71995 Tip-Zero Effort Beveling for normal maps] - the same trick.
  
== Tutorials ==
 
(... work in progress ...)
 
  
<nowiki>
+
=== Low-Poly Modeling ===
Warning about prevalence of misinformation.
+
* Use [[ReTopologyModeling]] to build the lower-resolution in-game model.
 +
* Good topology for baking: [[Normal_Map_Modeling#Low-Poly_Mesh]] and [http://www.polycount.com/forum/showthread.php?t=81154 Understanding averaged normals and ray projection/Who put waviness in my normal map?] and [http://www.polycount.com/forum/showthread.php?t=147227 Skew you buddy! Making sense of skewed normal map details].
 +
* Good topology for animation: [[Topology#Principles_of_Topology]].
 +
* [http://www.polycount.com/forum/showthread.php?t=152467 The best kind of beveling ?]
  
* Tutorials
 
* Related Pages
 
* 3D Tools
 
* 2D Tools
 
* Discussion
 
</nowiki>
 
  
 +
=== Texture Coordinates ===
 +
* Create good [[Texture Coordinates]] for your low-poly model.
 +
* For [[Normal_Map_Technical_Details#Tangent-Space_vs._Object-Space|tangent-space normal mapping]], split the UVs for every hard edge (where vertex normals are split, or different smoothing groups are used, same thing).
 +
* [http://www.polycount.com/forum/showthread.php?t=107196 You're making me hard. Making sense of hard edges, uvs, normal maps and vertex counts], and [http://www.polycount.com/forum/showpost.php?p=2226864&postcount=51 Earthquake on separating smoothing groups in the UV].
 +
* 3ds Max: [http://download.autodesk.com/us/3dsmax/2012help/index.html?url=files/GUID-9E98AEAC-F06F-4FAD-9091-DCD30AC9BB2-517.htm,topicNumber=d28e113220 Flatten by Smoothing Group] converts smoothing groups into UV islands. [http://www.polycount.com/forum/showpost.php?p=1332118&postcount=20 UV borders to hard edges] creates the correct hard edges, even on seams within shells.
 +
* Maya: [http://www.polycount.com/forum/showthread.php?p=2090450#post2090450 Maya MEL Script help needed (UV border edges)] converts hard edges into UV islands.
  
== Synched Workflow ==
 
To eliminate seams and shading artifacts, the game engine and the normal map [[Texture Baking|baking tool]] should use the same [[Normal_Map_Technical_Details#Tangent_Basis|tangent basis]].
 
  
When you export a model from your baking tool, it is best to choose a format like FBX which can store the tangents. Some games use this data to synch the normal maps to their renderer, so you get seamless shading.
+
=== Triangulation ===
 +
* See [[Texture Baking#Triangulation]], and [[Polygon Count#Polygons Vs. Triangles]].
 +
* Triangulate before mirroring, to prevent shading errors.
  
{| class="wikitable sortable" style="color:grey;"
 
|-
 
! Renderer !! Normal map baker
 
|-
 
| 3ds Max || 3ds Max, Handplane, ?
 
|-
 
| Blender || ?
 
|-
 
| Creation Engine || Handplane, ?
 
|-
 
| CryEngine || ?
 
|-
 
| Knald || ?
 
|-
 
| Marmoset Toolbag || 3ds Max, Maya, Xnormal, ?
 
|-
 
| Maya || Handplane, Maya, ?
 
|-
 
| Source || Handplane, Maya ([http://www.polycount.com/forum/showpost.php?p=2224653&postcount=28]), ?
 
|-
 
| Starcraft II || Handplane, ?
 
|-
 
| Substance Designer || ?
 
|-
 
| Unity([http://www.polycount.com/forum/showpost.php?p=2224781&postcount=29], [http://www.polycount.com/forum/showthread.php?p=2194353#post2194353]) || Handplane, Xnormal (via Asset Store), ?
 
|-
 
| Unreal Engine 4 || Handplane, Xnormal([http://www.polycount.com/forum/showpost.php?p=2224402&postcount=20]), ?
 
|-
 
| Xnormal || Xnormal, ?
 
|}
 
  
 +
=== Mirroring & Duplicating Parts ===
 +
* If creating symmetrical parts, mirror the model. See [[Normal Map Modeling#Mirroring]].
 +
* Duplicate any model parts which reuse the same UV; this ensures perfect UV overlap.
 +
* For using mirrored UVs, see [http://www.polycount.com/forum/showpost.php?p=2225535&postcount=40 JedTheKrampus on offsetting Mirrored UVs], [[Texture Baking#UV Coordinates]].
  
== Modeling the Low-Poly Mesh ==
 
The in-game mesh usually needs to be carefully optimized to create a good silhouette, define edge-loops for better deformation, and minimize extreme changes between the vertex normals for better shading (see [[#SmoothingGroupsAndHardEdges|Smoothing Groups & Hard Edges]]).
 
  
In order to create an optimized in-game mesh including a good silhouette and loops for deforming in animation, you can start with the 2nd subdivision level of your [[DigitalSculpting|digital sculpt]], or in some cases with the base mesh itself. Then you can just collapse edge loops or cut in new edges to add/remove detail as necessary. Or you can [[DigitalSculpting#OART|re-toplogize]] from scratch if that works better for you.
+
=== Baking Tools ===
 +
* [[Texture Baking]]
 +
* [http://www.polycount.com/forum/showthread.php?t=137579 Normal Map Bake Off: Xnormal vs 3Dsmax vs Substance Designer Bakes]
 +
* [http://www.polycount.com/forum/showthread.php?t=116899 Official handplane support thread - Now freeware!!]
 +
* [http://www.laurenscorijn.com/future-xoliulshader-support.html Future Xoliulshader support] = why Xoliulshader doesn't work properly in 3ds Max 2013/2014.
  
See [http://www.polycount.com/forum/showthread.php?t=107196 You're making me hard. Making sense of hard edges, uvs, normal maps and vertex counts] on the Polycount forum.
+
=== Projection Errors ===
 +
* Create an inflated copy of the low-resolution model, which encompasses the high-resolution model. See [[Texture Baking#Cages]]. Some tools create this automatically.
 +
* Interpenetrating or close-together parts can cause baking artifacts, because neighboring surfaces will capture parts of each other, see [[Texture Baking#Solving Intersections]]. To "explode" means to separate the non-welded surfaces, mesh elements, Zbrush subtools, etc. so there is ample space between them. Use the same separation for the highpoly model and the lowpoly model. After the bake, move the pieces back together.
 +
* If the modeling software has animation, you can keyframe the explode to easily reverse it after baking. Tools are also available, see [http://boards.polycount.net/showthread.php?t=62921 Explode script needed (for baking purposes)]. Elements can be tagged by some baking tools, so specific low-poly elements will only bake related high-poly elements, this avoids exploding (3ds Max can use Material IDs, etc.).
 +
* [http://www.polycount.com/forum/showthread.php?t=81154 Understanding averaged normals and ray projection/Who put waviness in my normal map?]
 +
* [http://www.polycount.com/forum/showthread.php?t=147227 Skew you buddy! Making sense of skewed normal map details.]
 +
* [http://www.polycount.com/forum/showthread.php?t=144715 Skewmesh tutorial for Max and Xnormal] by [http://www.exisinteractive.com/ PeterK] to prevent heavy distortions when baking with a cage, without the need to add extra supporting vertices.
 +
* [http://www.polycount.com/forum/showthread.php?t=148303 Of Bit Depths, Banding and Normal Maps].
  
<span id="UVC"></span><span id="UVCoordinates"></span>
 
=== UV Coordinates ===
 
Normal map baking tools only capture normals within the 0-1 UV square, any UV bits outside this area are ignored.
 
  
Only one copy of the forward-facing UVs should remain in the 0-1 UV square at baking time. If the mesh uses overlapping UVs, this will likely cause artifacts to appear in the baked map, since the baker will try render each UV shell into the map. Before baking, it's best to move all the overlaps and mirrored bits outside the 0-1 square.  
+
=== Editing Maps ===
 +
* Combine bakes if needed. See [[Ambient_occlusion_map#EarthQuake.27s_Baking_Method|Ambient occlusion map#EarthQuake's Baking Method]]
 +
* Add details from photos or other bakes. See [http://farfarer.com/resources.htm RNM Normal Map Combiner], and [http://vincentcallebaut.com/CombineNormal.html Combine Normal] ([http://www.polycount.com/forum/showthread.php?t=131819 Polycount Forum thread]).
 +
* Some errors can be painted out, but avoid this! Any painting must be repeated if the model is re-baked, and painting on a normal map can introduce more artifacts.
 +
* Swizzle. See [[Normal Map Technical Details#Common Swizzle Coordinates]].
 +
* Re-normalize. See [[Normal_map#Re-normalizing]].
 +
* Reduce to 8-bit. See [http://www.polycount.com/forum/showthread.php?t=148303 Of Bit Depths, Banding and Normal Maps].
  
[[image:Normalmap_uvcoord_offset.jpg|frame|none|The mirrored UVs (in red) are offset 1 unit before baking. <br>Image by [http://ericchadwick.com Eric Chadwick].]]
 
  
If you move all the overlaps and mirrored bits exactly 1 UV unit (any whole number will do), then you can leave them there after the bake and they will still be mapped correctly. You can move them back if you want, it doesn't matter to most game engines. Be aware that ZBrush does use UV offsets to manage mesh visibility, however this usually doesn't matter because the ZBrush cage mesh is often a different mesh than the in-game mesh used for baking.
+
== 2D Workflow ==
 +
Normal maps can be made in 2D painting software, without modeling in 3D. You can convert photo textures into normal maps, create node-based graphs to compile normal maps, or even hand-paint them with brushes.
  
You should avoid changing the UVs after baking the normal map, because rotating or mirroring UVs after baking will cause the normal map not to match the [[#TB|tangent basis]] anymore, which will likely cause lighting problems.  
+
Normal maps created in 2D work best when tiled across 3D models that have a uniform direction in [[Normal_Map_Technical_Details#Tangent_Basis|tangent space]], like terrains or walls. On these models the UVs are not rotated; they are all facing roughly in the same direction. To get seamless lighting, rotated UVs require [[Normal_Map_Technical_Details#UV_Coordinates|specific gradients in the normal map]], which can only be created properly by [[Texture Baking|baking a 3D model]].
  
In 3ds Max, W is a third texture coordinate. It's used for 3D procedural textures and for storing vertex color in UV channels (you need 3 axes for RGB, so UVW can store vertex color). Bake problems can be avoided by moving any overlapping UVs to -1 on the W axis, with the same results as moving them 1 unit on the U or V axes. The tool Render To Texture will always bake whatever UVs are the highest along the W axis. However using W can be messy... it's generally hidden unless you purposefully look for it (bad for team work), doesn't get preserved on export to other apps, and high W values can prevent selecting and/or welding UVs.  
+
A normal map baked from a high-poly mesh will often be better than one sampled from a texture, since you're rendering from a highly detailed surface. The normal map pixels will be recreating the surface angles of the high-poly mesh, resulting in a very believable look. A hybrid approach can be used by baking large and mid-level details from a high-poly mesh, and combining these with painted or photo-sourced "fine detail" for fabric weave, scratches, pores, etc.
  
<span id="M"></span><span id="Mirroring"></span>
+
Most image conversion tools assume the input is a heightmap, where black is low and white is high. If you try to convert a color texture that you've painted, the results are often very poor.
  
=== Mirroring ===
+
* [http://www.poopinmymouth.com/tutorial/normal_workflow_3.htm Normal map process tutorial] by [http://www.poopinmymouth.com/ Ben "poopinmymouth" Mathis] includes an example of painting out wavy lines in a baked normal map.
Normal maps can be mirrored across a model to create symmetrical details, and save UV space, which allows more detail in the normal map since the texture pixels are smaller on the model.  
+
  
With [[#OSNM|object-space]] maps, mirroring requires [http://boards.polycount.net/showthread.php?t=53986 specific shader support]. For [[#TSNM|tangent-space]] maps, mirroring typically creates a shading seam, but this can be reduced or hidden altogether, depending on the method used.
 
 
<span id="TMW"></span>
 
==== Typical Mirroring Workflow ====
 
# Delete the mesh half that will be mirrored.
 
# Arrange the UVs for the remaining model, filling the UV square.
 
# Mirror the model to create a "whole" mesh, welding the mesh vertices along the seam.
 
# Move the mirrored UVs exactly 1 unit (or any whole number) out of the 0-1 UV square.
 
# Bake the normal map.
 
 
Sometimes an artist will decide to delete half of a symmetrical model before baking.
 
 
This is a mistake however because often the vertex normals along the hole will bend towards the hole a bit; there are no faces on the other side to average the normals with. This will create a strong lighting seam in the normal map.
 
 
It's typically best to use the complete mirrored model to bake the normal map, not just the unique half.
 
 
To prevent the mirrored UVs from causing overlaps or baking errors, move the mirrored [[#UVC|UVs]] out of the 0-1 UV space, so only one copy of the non-mirrored UVs is left within the 0-1 square.
 
 
To avoid texel "leaks" between the UV shells, make sure there's enough [[#Edge_padding|Edge Padding]] around each shell, including along the edges of the normal map. None of the UV shells should be touching the edge of the 0-1 UV square, unless they're meant to tile with the other side of the map.
 
 
<span id="CM"></span>
 
 
==== Center Mirroring ====
 
If the mirror seam runs along the surface of a continuous mesh, like down the center of a human face for example, then it will probably create a lighting seam.
 
 
In Epic Games' [http://www.unrealtechnology.com/technology.php Unreal Engine 3] (UE3) their symmetrical models commonly use centered mirroring. Epic uses materials that mix a [[DetailMap]] with the normal maps; these seem to scatter the diffuse/specular lighting and help minimize the obviousness of the mirror seams. For their [[Light Map]]ped models they use [http://udn.epicgames.com/Three/LightMapUnwrapping.html a technique] that can almost completely hide the mirror seam.
 
 
[[image:Epic_MirroringCicada.jpg|frame|none| In UE3 a center mirror seam is reduced by using a detail normal map. <br> Image by "[http://epicgames.com Epic Games]"]]
 
 
'''''[http://www.zbrushcentral.com/showpost.php?p=573108&postcount=28 GOW2 normal map seams], [http://utforums.epicgames.com/showthread.php?p=27166791#post27166791 UDK normal map seams]'''''
 
 
<span id="OM"></span>
 
 
==== Offset Mirroring ====
 
Offset mirroring is a method where you move the mirror seam off to one side of the model, so the seam doesn't run exactly down the center. For example with a character's head, the UV seam can go down along the side of the head in front of the ear. The UV shell for the nearest ear can then be mirrored to use the area on the other side of the head.
 
 
This avoids the "Rorschach" effect and allows non-symmetrical details, but it still saves texture space because the two sides of the head can be mirrored (they're never seen at the same time anyhow).
 
 
Offset mirroring doesn't get rid of the seam, but it does move it off to a place where it can either be less obvious, or where it can be hidden in a natural seam on the model.
 
 
<span id="FCM"></span>
 
==== Flat Color Mirroring ====
 
[http://boards.polycount.net/showthread.php?t=51088 Tutorial for painting out seams on mirrored tangent-space normal maps] by [http://www.warbeast.de/ warby] solves seams by painting a flat set of normals along the seam, using neutral blue (128,128,255). However it only works along horizontal or vertical UV seams, not across any angled UVs. It also removes any details along the mirror seam, creating blank areas.
 
 
<span id="EM"></span>
 
==== Element Mirroring ====
 
The mirror seam can be avoided completely when it doesn't run directly through any mesh. For example if there's a detached mesh element that runs down the center of the model, this can be uniquely mapped, while the meshes on either side can be mirrors of each other. Whenever the mirrored parts don't share any vertex normals with the non-mirrored parts, there won't be any seams.
 
 
[[image:normalmap_mirrored-binocs-racer445.jpg|frame|none|The middle part (highlighted in red) uses unique non-mirrored UVs, allowing the mesh on the right to be mirrored without any seams. <br>Image by [http://http://racer445.com/ "racer445"]]]
 
 
<span id="SGAHE"></span>
 
 
=== Smoothing Groups & Hard Edges ===
 
Each vertex in a mesh has at least one vertex normal. Vertex normals are used to control the direction a triangle will be lit from; if the normal is facing the light the triangle will be fully lit, if facing away from the light the triangle won't be lit.
 
 
Each vertex however can have more than one vertex normal. When two triangles have different vertex normals along their shared edge, this creates a shading seam, called a ''hard edge'' in most modeling tools. 3ds Max uses ''Smoothing Groups'' to create hard/soft edges, Maya uses ''Harden Edge'' and ''Soften Edge''. These tools create hard and soft edges by splitting and combining the vertex normals.
 
 
[[image:BenMathis_SmoothingGroups_Excerpt.gif|frame|none|Hard edges occur where the vertices have multiple normals. <br>Image by [http://poopinmymouth.com Ben 'poopinmymouth' Mathis] ([http://poopinmymouth.com/process/tips/smoothing_groups.jpg tutorial here])]]
 
 
When a mesh uses all soft normals (a single smoothing group) the lighting has to be interpolated across the extreme differences between the vertex normals. If your renderer doesn't support the same [[#TangentBasis|tangent basis]] that the baker uses, this can produce extreme shading differences across the model, which creates shading artifacts. It is generally best to reduce these extremes when you can because a mismatched renderer can only do so much to counteract it.
 
 
Hard edges are usually best where the model already has a natural seam. For example, you can add a hard edge along the rim of a car's wheel well, to prevent the inside of the wheel well from distorting the shading for the outside of the car body. Mechanical models usually need hard edges where ever the surface bends more than about 45 degrees.
 
 
For most meshes, the best results usually come from adding hard edges where ever there are UV seams. There are no hard rules however, you must experiment with different approaches to find what works best in your game.
 
 
When you use object-space normal maps the vertex normal problem goes away since you're no longer relying on the crude vertex normals of the mesh. An object-space normal map completely ignores vertex normals. Object-space mapping allows you to use all soft edges and no bevels on the low-res mesh, without showing lighting errors.
 
 
<span id="HEDAT"></span>
 
==== Hard Edge Discussions & Tutorials ====
 
* [http://www.polycount.com/forum/showthread.php?p=2090450#post2090450 Maya MEL Script help needed (UV border edges)]
 
* [http://www.polycount.com/forum/showthread.php?t=107196 You're making me hard. Making sense of hard edges, uvs, normal maps and vertex counts]
 
* [http://www.polycount.com/forum/showthread.php?t=73593 Normal Maps: Can Somone Explain This "Black Edge" issue]
 
* [http://www.polycount.com/forum/showthread.php?t=73566 Normal Maps: Can someone explain normals, tangents and split UVs?]
 
* [http://www.polycount.com/forum/showthread.php?t=72861 3Point Shader Lite - Shader material editor and Quality Mode normalmaps for 3ds Max]
 
* [http://boards.polycount.net/showthread.php?t=68173 Why you should NOT trust 3ds Max's viewport normal-map display!]
 
* [http://www.game-artist.net/forums/support-tech-discussion/10503-xsi-normal-mapped-cube-looks-bad.html XSI - normal mapped cube looks bad]
 
* [http://www.game-artist.net/forums/support-tech-discussion/11924-weird-maya-normal-map-seam-artifact-problem-am-i-making-simple-mistake.html Weird Maya normal map seam/artifact problem]
 
* [http://boards.polycount.net/showthread.php?p=1080600 Seams in Normals when Creating Tiling Environment Trims and other Tiles]
 
* The tutorial [http://www.svartberg.com/tutorials/article_normalmaps/normalmaps.html Normalmaps for the Technical Game Modeler] by [http://www.svartberg.com Ariel Chai] shows how low-poly smoothing can affect the normal map.
 
* The tutorial: [http://wiki.polycount.net/3D_Tutorials/Modeling_High-Low_Poly_Models_for_Next_Gen_Games Modeling High/Low Poly Models for Next Gen Games] by [http://www.acetylenegames.com/artbymasa/ João "Masakari" Costa] shows how smoothing affects raycasting.
 
* The [http://tech-artists.org/wiki/Beveling Beveling section on the Tech-Artists.Org Wiki] discusses the breaking of normals and smoothing groups in general terms.
 
* The two-part article [http://www.ericchadwick.com/examples/provost/byf2.html#wts Beautiful, Yet Friendly] by [http://www.linkedin.com/in/gprovost Guillaume Provost] explains how smoothing groups and other mesh attributes cause vertices to be duplicated in the game. The vertex count is actually what matters in the game, not the triangle count.
 
* The Crysis documentation [http://doc.crymod.com/AssetCreation/PolyBumpReference.html PolyBump Reference] has a section towards the bottom that shows how smoothing affects their baked normal maps.
 
* The polycount thread [http://boards.polycount.net/showthread.php?t=60694 Toying around with normal map approaches] has a great discussion of how best to use smoothing groups and bevels for better shading.
 
 
<span id="UB"></span>
 
==== Using Bevels ====
 
Bevels/chamfers generally improve the silhouette of the model, and can also help reflect specular highlights better.
 
 
However bevels tend to produce long thin triangles, which slow down the in-game rendering of your model. Real-time renderers have trouble rendering long thin triangles because they create a lot of sub-pixel areas to render.
 
 
Bevels also balloon the vertex count, which can increase the transform cost and memory usage. Hard edges increase the vertex count too, but not when  the edge also shares a seam in UV space. For a good explanation of the vertex count issue, see [http://www.ericchadwick.com/examples/provost/byf2.html#wts Beautiful, Yet Friendly].
 
 
Using hard edges with matching UV shells tends to give better performance and better cosmetic results than using bevels. However there are differing opinions on this, see the Polycount thread "[http://boards.polycount.net/showthread.php?t=71760 Maya transfer maps help]".
 
 
<span id="EVN"></span>
 
==== Edited Vertex Normals ====
 
If you use bevels the shading will be improved by editing the vertex normals so the larger flat surfaces have perpendicular normals. The vertex normals are then forced to blend across the smaller bevel faces, instead of across the larger faces. See the Polycount thread [http://boards.polycount.net/showthread.php?t=66139 Superspecular soft edges tutorial chapter 1].
 
 
[[image:oliverio_bevel_normals.gif|frame|none|Bending normals on bevelled models. <br>From the tutorial [http://deadlineproof.com/model-shading-techniques-soft-edge-superspecular/ Shading techniques Superspecular soft edges]<br>Image by [http://deadlineproof.com/ Paolo Oliverio]]]
 
 
== Level of Detail Models ==
 
See [http://www.polycount.com/forum/showthread.php?p=1216945#post1216945 Problem if you're using 3point-style normals with an LOD].
 
 
<span id="MTHPM"></span>
 
 
== Modeling The High-Poly Mesh ==
 
[[Subdivision Surface Modeling]] and [[DigitalSculpting]] are the techniques most often used for modeling a normal map.
 
 
Some artists prefer to model the in-game mesh first, other artists prefer to model the high-res mesh first, and others start somewhere in the middle. The modeling order is ultimately a personal choice though, all three methods can produce excellent results:
 
* Build the in-game model, then up-res it and sculpt it.
 
* Build and sculpt a high resolution model, then build a new in-game model around that.
 
* Build a basemesh model, up-res and sculpt it, then step down a few levels of detail and use that as a base for building a better in-game mesh.
 
If the in-game mesh is started from one of the subdivision levels of the basemesh sculpt, various edge loops can be collapsed or new edges can be cut to add/remove detail as necessary.
 
 
<span id="SE"></span>
 
=== Sloped Extrusions ===
 
[[image:normal_slopes_hatred.jpg|frame|none|Extrusions on the high-poly model should be sloped to make a better normal map. <br>Image by [http://www.hatred.gameartisans.org/ Krzysztof "Hatred" Dolas].]]
 
 
=== Floating Geometry ===
 
[[image:FloatingGeo.jpg|frame|none|Normal map stores the direction the surface is facing rather than real depth information, thus allowing to save time using floating geometry. <br>To correctly bake AO with floating geo make it a separate object and turn off it's shadow casting. <br>Image by [http://artisaverb.info/ Andrew "d1ver" Maximov].]]
 
 
See also [[3DTutorials/Modeling High-Low Poly Models for Next Gen Games|Modeling High/Low Poly Models for Next Gen Games]] by [http://www.acetylenegames.com/artbymasa/ João "Masakari" Costa]
 
 
<span id="ET"></span>
 
 
=== Edge Thickness ===
 
[[image:normal_edge_thickness.jpg|frame|none|When creating edges of the Highpoly, sometimes you'll need to make them rounded than in real life to <br>work better at the size they will be seen.<br>Image by [http://racer445.com/Evan "racer445" Herbert]]]
 
 
<span id="MRF"></span><span id="MRRCB"></span>
 
 
=== mental ray Round Corners Bump ===
 
The mental ray renderer offers an automatic bevel rendering effect called Round Corners Bump that can be baked into a normal map. This is available in 3ds Max, Maya, and XSI. See [http://boards.polycount.net/showthread.php?t=71995 Zero Effort Beveling for normal maps] - by [http://boards.polycount.net/member.php?u=31662 Robert "r_fletch_r" Fletcher].
 
 
[http://jeffpatton.net/ Jeff Patton] posted about [http://jeffpatton.cgsociety.org/blog/archive/2007/10/ how to expose Round Corners Bump] in 3ds Max so you can use it in other materials.
 
 
[http://cryrid.com/art/ Michael "cryrid" Taylor] posted a tutorial about how to use [http://cryrid.com/images/temp/XSI/zeroeffort_bevels.jpg Round Corners in XSI].
 
 
XSI is able to bake a good normal map with it, but 3ds Max seems to bake it incorrectly, and Maya isn't able to bake the effect at all. Maybe Max might be able to bake it correctly, if the .mi shader is edited to use the correct coordinate space?
 
 
<span id="Baking"></span><span id="B"></span>
 
 
 
<span id="P"></span><span id="Painting"></span>
 
 
== Painting ==
 
Don't be afraid to edit normal maps in Photoshop. After all it is just a texture, so you can clone, blur, copy, blend all you want... as long as it looks good of course. Some understanding of [[#RGBChannels|the way colors work]] in normal maps will go a long way in helping you paint effectively.
 
 
A normal map sampled from a high-poly mesh will nearly always be better than one sampled from a texture, since you're actually grabbing "proper" normals from an accurate, highly detailed surface. That means your normal map's pixels will basically be recreating the surface angles of your high-poly mesh, resulting in a very believable look.
 
 
If you only convert an image into a normal-map, it can look very flat, and in some cases it can be completely wrong unless you're very careful about your value ranges. Most image conversion tools assume the input is a heightmap, where black is low and white is high. If you try to convert a diffuse texture that you've painted, the results are often very poor. Often the best results are obtained by baking the large and mid-level details from a high-poly mesh, and then combined with photo-sourced "fine detail" normals for surface details such as fabric weave, scratches and grain.
 
 
Sometimes creating a high poly surface takes more time than your budget allows. For character or significant environment assets then that is the best route, but for less significant environment surfaces working from a heightmap-based texture will provide a good enough result for a much less commitment in time.
 
 
* [http://crazybump.com/ CrazyBump] is a commercial normal map converter.
 
* [http://www.renderingsystems.com/support/showthread.php?tid=3 ShaderMap] is a commercial normal map converter.
 
* [http://www.pixplant.com/ PixPlant] is a commercial normal map converter.
 
* [http://boards.polycount.net/showthread.php?t=68860 NJob] is a free normal map converter.
 
* [http://developer.nvidia.com/nvidia-texture-tools-adobe-photoshop NVIDIA normalmap filter for Photoshop] is a free normal map converter.
 
* [http://xnormal.net Xnormal height-to-normals filter for Photoshop] is a free normal map converter.
 
* [http://www.poopinmymouth.com/tutorial/normal_workflow_3.htm Normal map process tutorial] by [http://www.poopinmymouth.com/ Ben "poopinmymouth" Mathis] includes an example of painting out wavy lines in a baked normal map.
 
  
 
=== Flat Color ===
 
=== Flat Color ===
Line 322: Line 105:
 
This is because most game pipelines use ''unsigned'' normal maps. For details see the Polycount forum thread [http://www.polycount.com/forum/showpost.php?p=771360&postcount=22 tutorial: fixing mirrored normal map seams].
 
This is because most game pipelines use ''unsigned'' normal maps. For details see the Polycount forum thread [http://www.polycount.com/forum/showpost.php?p=771360&postcount=22 tutorial: fixing mirrored normal map seams].
  
<span id="BNMT"></span>
 
  
 
=== Blending Normal Maps Together ===
 
=== Blending Normal Maps Together ===
Blending normal maps together is a quick way to add high-frequency detail like wrinkles, cracks, and the like. Fine details can be painted as a height map, then it can be converted into a normal map using one of the normal map tools. Then this "details" normal map can be blended with a geometry-derived normal map using one of the methods below.  
+
Blending normal maps together is a quick way to add high-frequency detail like wrinkles, cracks, and the like. Fine details can be painted as a height map, then it can be converted into a normal map. Then this "details" normal map can be blended with a geometry-derived normal map.
 +
 
 +
Another use is to blend a high-frequency detail normal map overtop a lower-frequency one, for example on terrains, to get small details closeup and larger details in the distance.
 +
 
 +
Re-oriented Normal Mapping (RNM) is probably the most accurate method, and can be done in real-time. The Photoshop script [http://vincentcallebaut.com/CombineNormal.html Combine Normal] by Vincent Callebaut uses this method, see the Polycount Forum thread [http://www.polycount.com/forum/showthread.php?t=131819 Combine normal maps script for Photoshop]. A full explanation is described on the page [http://blog.selfshadow.com/publications/blending-in-detail/ Blending in Detail - Self Shadow].
  
Here is a comparison of four of the blending methods. Note that in these examples the default values were used for CrazyBump (Intensity 50, Strength 33, Strength 33), but the tool allows each layer's strength to be adjusted individually for stronger or milder results. Each of the normal maps below were [[#Renormalizing|re-normalized]] after blending.
+
Below is a comparison of four other blending methods. Note that in these examples the default values were used for CrazyBump (Intensity 50, Strength 33, Strength 33), but the tool allows each layer's strength to be adjusted individually for stronger or milder results. Each of the normal maps below were [[#Renormalizing|re-normalized]] after blending.
  
{|class="wikitable"
+
{| border="1"
 
|[[image:nrmlmap_blending_methods_Maps.png]]
 
|[[image:nrmlmap_blending_methods_Maps.png]]
 
|[[image:nrmlmap_blending_methods_RTTNormalMapFX.png]]
 
|[[image:nrmlmap_blending_methods_RTTNormalMapFX.png]]
Line 343: Line 129:
 
# [[3DTutorials/Normal Map Deepening|Normal Map Deepening]] by [http://www.poopinmymouth.com/ Ben "poopinmymouth" Mathis] shows how to blend normal maps together using Overlay mode. [http://cgtextures.com/content.php?action=tutorial&name=normalmap CGTextures tutorial for the NVIDIA Photoshop filter] by [http://hirezstudios.com/ Scott Warren] also shows how to create normalmaps using multiple layers (Note: to work with the Overlay blend mode each layer's Output Level should be 128 instead of 255, you can use the Levels tool for this).
 
# [[3DTutorials/Normal Map Deepening|Normal Map Deepening]] by [http://www.poopinmymouth.com/ Ben "poopinmymouth" Mathis] shows how to blend normal maps together using Overlay mode. [http://cgtextures.com/content.php?action=tutorial&name=normalmap CGTextures tutorial for the NVIDIA Photoshop filter] by [http://hirezstudios.com/ Scott Warren] also shows how to create normalmaps using multiple layers (Note: to work with the Overlay blend mode each layer's Output Level should be 128 instead of 255, you can use the Levels tool for this).
  
The [http://boards.polycount.net/showthread.php?t=69615 Getting good height from Nvidia-filter normalizing grayscale height] thread on the Polycount forum has a discussion of different painting/blending options. Also see the [[#2DT|2D Tools]] section for painting and conversion tools.
+
The [http://boards.polycount.net/showthread.php?t=69615 Getting good height from Nvidia-filter normalizing grayscale height] thread on the Polycount forum has a discussion of different painting/blending options. Also see the [[Normal_map#2D_Normal_Map_Tools|2D Normal Map Tools]] section for painting and conversion tools.
  
<span id="PCT"></span>
 
  
 
=== Pre-Created Templates ===
 
=== Pre-Created Templates ===
Line 354: Line 139:
 
* See the section [[#BT|Baking Transparency]] for more template-rendering tools and tutorials.
 
* See the section [[#BT|Baking Transparency]] for more template-rendering tools and tutorials.
  
<span id="RN"></span><span id="Renormalizing"></span>
+
 
 
=== Re-normalizing ===
 
=== Re-normalizing ===
 
Re-normalizing means resetting the length of each normal in the map to 1.
 
Re-normalizing means resetting the length of each normal in the map to 1.
Line 366: Line 151:
 
Some shaders use [[#NormalMapCompression|compressed normal maps]]. Usually this means the blue channel is thrown away completely, so it's recalculated on-the-fly in the shader. However the shader has to re-normalize in order to recreate that data, so any custom normal lengths that were edited into the map will be ignored completely.  
 
Some shaders use [[#NormalMapCompression|compressed normal maps]]. Usually this means the blue channel is thrown away completely, so it's recalculated on-the-fly in the shader. However the shader has to re-normalize in order to recreate that data, so any custom normal lengths that were edited into the map will be ignored completely.  
  
<span id="AOIANM"></span><span id="AmbientOcclusionIntoANormalMap"></span>
 
  
 
=== Ambient Occlusion into a Normal Map ===
 
=== Ambient Occlusion into a Normal Map ===
Line 379: Line 163:
 
This trick doesn't work with any shaders that re-normalize, like 3ds Max's Hardware Shaders. The shader must be altered to actually use the lengths of your custom normals; most shaders just assume all normals are 1 in length because this makes the shader code simpler. Also this trick will not work with most of the common [[#NormalMapCompression|normal map compression formats]], which often discard the blue channel and recalculate it in the shader, which requires re-normalization.
 
This trick doesn't work with any shaders that re-normalize, like 3ds Max's Hardware Shaders. The shader must be altered to actually use the lengths of your custom normals; most shaders just assume all normals are 1 in length because this makes the shader code simpler. Also this trick will not work with most of the common [[#NormalMapCompression|normal map compression formats]], which often discard the blue channel and recalculate it in the shader, which requires re-normalization.
  
<span id="BLE"></span>
 
  
 
=== Back Lighting Example ===
 
=== Back Lighting Example ===
 
You can customize normal maps for some interesting effects. If you invert the blue channel of a tangent-space map, the normals will be pointing to the opposite side of the surface, which can simulate backlighting.
 
You can customize normal maps for some interesting effects. If you invert the blue channel of a tangent-space map, the normals will be pointing to the opposite side of the surface, which can simulate backlighting.
  
{|class="wikitable"
+
{| border="1"
 
|[[image:tree_front.jpg]]||[[image:tree_back.jpg]]
 
|[[image:tree_front.jpg]]||[[image:tree_back.jpg]]
 
|-
 
|-
Line 397: Line 180:
 
The tree leaves use a shader than adds together two diffuse maps, one using a regular tangent-space normal map, the other using the same normal map but with the blue channel inverted. This causes the diffuse map using the regular normal map to only get lit on the side facing the light (front view), while the diffuse map using the inverted normal map only gets lit on the opposite side of the leaves (back view). The leaf geometry is 2-sided but uses the same shader on both sides, so the effect works no matter the lighting angle. As an added bonus, because the tree is self-shadowing the leaves in shadow do not receive direct lighting, which means their backsides do not show the inverted normal map, so the fake subsurface scatter effect only appears where the light directly hits the leaves. This wouldn't work for a whole forest because of the computational cost of self-shadowing and double normal maps, but could be useful for a single "star" asset, or if LODs switched the distant trees to a model that uses a cheaper shader.
 
The tree leaves use a shader than adds together two diffuse maps, one using a regular tangent-space normal map, the other using the same normal map but with the blue channel inverted. This causes the diffuse map using the regular normal map to only get lit on the side facing the light (front view), while the diffuse map using the inverted normal map only gets lit on the opposite side of the leaves (back view). The leaf geometry is 2-sided but uses the same shader on both sides, so the effect works no matter the lighting angle. As an added bonus, because the tree is self-shadowing the leaves in shadow do not receive direct lighting, which means their backsides do not show the inverted normal map, so the fake subsurface scatter effect only appears where the light directly hits the leaves. This wouldn't work for a whole forest because of the computational cost of self-shadowing and double normal maps, but could be useful for a single "star" asset, or if LODs switched the distant trees to a model that uses a cheaper shader.
  
<span id="SAS"></span>
 
  
== Shaders and Seams ==
+
=== 2D Normal Map Tools ===
You need to use the right kind of shader to avoid seeing seams where UV breaks occur. It must be written to use the same [[#TangentBasis|tangent basis]] that was used during baking. If the shader doesn't, the lighting will either be inconsistent across UV borders or it will show smoothing errors from the low-poly vertex normals.
+
* [http://vincentcallebaut.com/CombineNormal.html Combine Normal] is a Photoshop script for Re-oriented Normal Mapping (RNM), see the Polycount Forum thread [http://www.polycount.com/forum/showthread.php?t=131819 Combine normal maps script for Photoshop], and the page [http://blog.selfshadow.com/publications/blending-in-detail/ Blending in Detail - Self Shadow].
 
+
* [http://crazybump.com/ CrazyBump] is a commercial normal map converter.
Xnormal generates accurate normals when displayed in Xnormal, and the SDK includes a method to write your own custom tangent space generator for the tool.
+
* [http://www.renderingsystems.com/support/showthread.php?tid=3 ShaderMap] is a commercial normal map converter.
 
+
* [http://www.pixplant.com/ PixPlant] is a commercial normal map converter.
<span id="3MS"></span>
+
* [http://boards.polycount.net/showthread.php?t=68860 NJob] is a free normal map converter.
=== 3ds Max Shaders ===
+
* [http://developer.nvidia.com/nvidia-texture-tools-adobe-photoshop NVIDIA normalmap filter for Photoshop] is a free normal map converter.
The "Render To Texture" tool in 3ds Max 2011 and older generates [[#TSNM|tangent-space]] normal maps that render correctly in the offline renderer (scanline) but do not render correctly in the realtime viewport with the 3ds Max shaders. Max is using a different [[#TangentBasis|tangent basis]] for each. This is readily apparent when creating non-organic hard surface normalmaps; smoothing errors appear in the viewport that do not appear when rendered.
+
* [http://xnormal.net Xnormal height-to-normals filter for Photoshop] is a free normal map converter.
 
+
* [[NDO]]
The errors can be fixed by using "Render To Texture" to bake a [[#TSNM|tangent-space]] or [[#OSNM|object-space]] map, and using the free [http://www.3pointstudios.com/3pointshader_about.shtml "3Point Shader"] by Christoph '[[CrazyButcher]]' Kubisch and Per 'perna' Abrahamsen. The shader uses the same tangent basis as the baking tool, so it produces nearly flawless results. It also works with old bakes.
+
* Filter Forge
 
+
* Substance Designer
You can get OK results in the Max viewport using a tangent-space map baked in Maya, loading it in a Standard material, and enabling "Show Hardware Map in Viewport". Another method is to use Render To Texture to bake an [[#OSNM|object-space]] map then use [[#CBS|Nspace]] to convert it into a tangent-space map then load that in a DirectX material and use the RTTNormalMap.fx shader.
+
 
+
Autodesk is aware of these issues, and plans to address them in an upcoming release. See these links for more information:
+
* Christoph "[[CrazyButcher]]" Kubisch and Per "perna" Abrahamsen designed a shader/modifier combination approach that fixes the viewport problem, see the Polycount forum post [http://boards.polycount.net/showthread.php?t=72861 3Point Shader Lite - Shader material editor and Quality Mode normalmaps for 3ds Max].
+
* Jean-Francois "jfyelle" Yelle, Autodesk Media & Entertainment Technical Product Manager, has [http://boards.polycount.net/showthread.php?p=1115812#post1115812 this post].
+
* Ben Cloward posted [http://boards.polycount.net/showthread.php?p=1100270#post1100270 workarounds and FX code].
+
* Christopher "cdiggins" Diggins, SDK writer for 3ds Max, shares some of the SDK code in his blog posts "[http://area.autodesk.com/blogs/chris/how_the_3ds_max_scanline_renderer_computes_tangent_and_binormal_vectors_for_normal_mapping How the 3ds Max Scanline Renderer Computes Tangent and Binormal Vectors for Normal Mapping]" and "[http://area.autodesk.com/blogs/chris/3ds_max_normal_map_baking_and_face_angle_weighting_the_plot_thickens 3ds Max Normal Map Baking and Face Angle Weighting: The Plot Thickens]".
+
 
+
[[image:nmtest_uv-splits_thumb.jpg|thumb|600px|none|Comparison of map baking methods in Maya and Max, and Ben Cloward's custom FX code.<br>Image by [http://www.bencloward.com/ Ben Cloward] and [http://www.linkedin.com/in/ericchadwick Eric Chadwick]]]
+
 
+
[[image:normalmapfix_3pointstudios_thumb.jpg|frame|none|3 Point Studios' normal map display fix for 3ds Max.<br>image by [http://www.3pointstudios.com 3 Point Studios]]]
+
 
+
{|class="wikitable"
+
|[[image:max2010_normalmap_workarounds.png|thumb|400px|none|]]
+
|[[image:max2010_normalmap_compare.png|thumb|400px|none|]]
+
|-
+
|Viewport methods in 3ds Max 2010.<br>Image by [http://www.linkedin.com/in/ericchadwick Eric Chadwick]
+
|More baking methods in 3ds Max 2010.<br> Image by [http://www.linkedin.com/in/ericchadwick Eric Chadwick]
+
|}
+
 
+
<span id="3MENT"></span>
+
 
+
=== 3ds Max Edit Normals Trick ===
+
After baking, if you add an Edit Normals modifier to your low-poly normalmapped model, this seems to "relax" the vertex normals for more accurate viewport shading. The modifier can be collapsed if desired.
+
 
+
<span id="MS"></span>
+
=== Maya Shaders ===
+
Maya seems to correctly generate normals to view in realtime, with the correct [[#TangentBasis|tangent basis]], with much less smoothing errors than 3ds Max.  
+
* [http://www.mentalwarp.com/~brice/shader.php BRDF shader] by [http://www.mentalwarp.com/~brice/ Brice Vandemoortele] and [http://www.kjapi.com/ Cedric Caillaud] (more info in [http://boards.polycount.net/showthread.php?t=49920 this Polycount thread]) '''Update:''' [http://boards.polycount.net/showthread.php?p=821862#post821862 New version here] with many updates, including object-space normal maps, relief mapping, self-shadowing, etc. Make sure you enable cgFX shaders in the Maya plugin manager, then you can create them in the same way you create a Lambert, Phong etc. Switch OFF high quality rendering in the viewports to see them correctly too.
+
* If you want to use the software renderer, use mental ray instead of Maya's software renderer because mental ray correctly interprets tangent space normals. The Maya renderer treats the normal map as a grayscale bump map, giving nasty results. Mental ray supports Maya's Phong shader just fine (amongst others), although it won't recognise a gloss map plugged into the "cosine power" slot. The slider still works though, if you don't mind having a uniform value for gloss. Spec maps work fine though. Just use the same set up as you would for viewport rendering. You'll need to have your textures saved as TGAs or similar for mental ray to work though. - from [http://boards.polycount.net/member.php?u=14235 CheeseOnToast]
+
 
+
== Links ==
+
 
+
=== Related Pages ===
+
* [[Curvature map]]
+
* [[DuDv map]]
+
* [[Flow map]]
+
* [[Normal map]]
+
* [[Radiosity normal map]]
+
* [[Vector displacement map]]
+
  
<span id="3DT"></span> <span id="Tools"></span> <span id="3DTools"></span>
 
=== 3D Tools ===
 
See [[:Category:Tools#A3D_Normal_Map_Software|Category:Tools#3D_Normal_Map_Software]]
 
  
<span id="2DT"></span><span id="2DTools"></span>
+
=== Older Tutorials ===
=== 2D Tools ===
+
A word of warning: There is a huge amount of misinformation about normal mapping on the web. It is best to assume all tutorials are incorrect, until you can verify the results yourself with your own tools and models.
See [[:Category:Tools#A2D_Normal_Map_Software|Category:Tools#2D_Normal_Map_Software]]
+
  
<span id="T"></span><span id="Tutorials"></span>
 
=== Tutorials ===
 
*  [http://www.polycount.com/forum/showthread.php?t=144715 Skewmesh tutorial for Max and Xnormal] by [http://www.exisinteractive.com/ PeterK] to prevent heavy distortions when baking with a cage, without the need to add extra supporting vertices.
 
* [http://www.polycount.com/forum/showthread.php?t=146667 A Practical Guide On Normal Mapping For Games] by [http://www.polycount.com/forum/member.php?u=56680 'SuperFranky']
 
 
* [http://area.autodesk.com/userdata/fckdata/239955/The%20Generation%20and%20Display%20of%20Normal%20Maps%20in%203ds%20Max.pdf The Generation and Display of Normal Maps in 3ds Max] (500kb PDF) <<BR>> Excellent whitepaper from Autodesk about normal mapping in 3ds Max and other apps.
 
* [http://area.autodesk.com/userdata/fckdata/239955/The%20Generation%20and%20Display%20of%20Normal%20Maps%20in%203ds%20Max.pdf The Generation and Display of Normal Maps in 3ds Max] (500kb PDF) <<BR>> Excellent whitepaper from Autodesk about normal mapping in 3ds Max and other apps.
 
* [http://www.katsbits.com/htm/tutorials/blender-baking-normal-maps-from-models.htm Renderbump and baking normal maps from high poly models using Blender 3D] by ''[http://www.katsbits.com/htm/about.htm "katsbits"]''<<BR>>Baking normal maps in Blender.
 
* [http://www.katsbits.com/htm/tutorials/blender-baking-normal-maps-from-models.htm Renderbump and baking normal maps from high poly models using Blender 3D] by ''[http://www.katsbits.com/htm/about.htm "katsbits"]''<<BR>>Baking normal maps in Blender.
Line 468: Line 202:
 
* [http://www.iddevnet.com/quake4/ArtReference_CreatingModels#head-3400c230e92ff7d57424b2a68f6e0ea75dee4afa Creating Models in Quake 4] by [http://www.ravensoft.com/ Raven Software] is a comprehensive guide to creating Quake 4 characters.
 
* [http://www.iddevnet.com/quake4/ArtReference_CreatingModels#head-3400c230e92ff7d57424b2a68f6e0ea75dee4afa Creating Models in Quake 4] by [http://www.ravensoft.com/ Raven Software] is a comprehensive guide to creating Quake 4 characters.
 
* [http://www.svartberg.com/tutorials/article_normalmaps/normalmaps.html Normalmaps for the Technical Game Modeler] by [http://www.svartberg.com Ariel Chai] shows how low-poly smoothing and UVs can affect normal maps in Doom 3.
 
* [http://www.svartberg.com/tutorials/article_normalmaps/normalmaps.html Normalmaps for the Technical Game Modeler] by [http://www.svartberg.com Ariel Chai] shows how low-poly smoothing and UVs can affect normal maps in Doom 3.
* [http://wiki.polycount.net/3D_Tutorials/Modeling_High-Low_Poly_Models_for_Next_Gen_Games Modeling High/Low Poly Models for Next Gen Games] by [http://www.acetylenegames.com/artbymasa/ João "Masakari" Costa] is an overview of modeling for normal maps.
+
* [[3DTutorials/Modeling_High-Low_Poly_Models_for_Next_Gen_Games]] by [http://www.acetylenegames.com/artbymasa/ João "Masakari" Costa] is an overview of modeling for normal maps.
 
* The [http://tech-artists.org/wiki/Beveling Beveling section on the Tech-Artists.Org Wiki] discusses how smoothing groups and bevels affect the topology of the low-poly model.
 
* The [http://tech-artists.org/wiki/Beveling Beveling section on the Tech-Artists.Org Wiki] discusses how smoothing groups and bevels affect the topology of the low-poly model.
 
* The two-part article [http://www.ericchadwick.com/examples/provost/byf2.html#wts Beautiful, Yet Friendly] by [http://www.linkedin.com/in/gprovost Guillaume Provost] explains how smoothing groups and other mesh attributes cause vertices to be duplicated in the game. The vertex count is actually what matters in-game, not the triangle or poly count.
 
* The two-part article [http://www.ericchadwick.com/examples/provost/byf2.html#wts Beautiful, Yet Friendly] by [http://www.linkedin.com/in/gprovost Guillaume Provost] explains how smoothing groups and other mesh attributes cause vertices to be duplicated in the game. The vertex count is actually what matters in-game, not the triangle or poly count.
 
* [http://www.poopinmymouth.com/tutorial/normal_workflow_2.htm Normal map workflow] by [http://www.poopinmymouth.com/ Ben "poopinmymouth" Mathis] demonstrates his normal mapping workflow in 3ds Max and Photoshop.
 
* [http://www.poopinmymouth.com/tutorial/normal_workflow_2.htm Normal map workflow] by [http://www.poopinmymouth.com/ Ben "poopinmymouth" Mathis] demonstrates his normal mapping workflow in 3ds Max and Photoshop.
* [http://dodownload.filefront.com/9086954//72f71c0147df53765045a22253c18361a29a6d532425842007ead644d39cbb85d0794ab560365cfa This video tutorial] by [http://www.custom-airbrush.com/ Jeff "airbrush" Ross] shows in Maya how to subdivide the low-poly mesh so it more closely matches the high-poly mesh, to help solve wavy lines in the bake.
+
* [https://www.dropbox.com/s/ej3ug1uhj3spig4/LowPoly_SmoothProxy_Baking_for_Cyl_Sph_Objects.swf?dl=0 This video tutorial] by [http://jeffross3dartist.com/ Jeff "airbrush" Ross] shows in Maya how to subdivide the low-poly mesh so it more closely matches the high-poly mesh, to help solve wavy lines in the bake.
 
* [http://www.bencloward.com/tutorials_normal_maps1.shtml Normal Mapping Tutorial] by [http://www.bencloward.com/ Ben Cloward] is a comprehensive tutorial about the entire normal map creation process.
 
* [http://www.bencloward.com/tutorials_normal_maps1.shtml Normal Mapping Tutorial] by [http://www.bencloward.com/ Ben Cloward] is a comprehensive tutorial about the entire normal map creation process.
 
* [http://www.pinwire.com/articles/26/1/Generating-High-Fidelity-Normal-Maps-with-3-D-Software.html Generating High Fidelity Normal Maps with 3-D Software] by [http://www.linkedin.com/pub/0/277/4AB Dave McCoy] shows how to use a special lighting setup to render normal maps (instead of baking them).
 
* [http://www.pinwire.com/articles/26/1/Generating-High-Fidelity-Normal-Maps-with-3-D-Software.html Generating High Fidelity Normal Maps with 3-D Software] by [http://www.linkedin.com/pub/0/277/4AB Dave McCoy] shows how to use a special lighting setup to render normal maps (instead of baking them).
Line 482: Line 216:
 
* [http://forums.cgsociety.org/showthread.php?f=46&t=373024 Hard Surface Texture Painting] by [http://stefan-morrell.cgsociety.org/gallery/ Stefan Morrell] is a good introduction to painting textures for metal surfaces.
 
* [http://forums.cgsociety.org/showthread.php?f=46&t=373024 Hard Surface Texture Painting] by [http://stefan-morrell.cgsociety.org/gallery/ Stefan Morrell] is a good introduction to painting textures for metal surfaces.
  
<span id="D"></span><span id="Discussion"></span>
+
== More Information ==
 
+
* [[Curvature map]]
=== Discussion ===
+
* [[DuDv map]]
[http://boards.polycount.net/showthread.php?p=820218 Discuss this page on the Polycount forums]. Suggestions welcome.
+
* [[Flow map]]
 +
* [[Normal Map Modeling]]
 +
* [[Normal Map Technical Details]]
 +
* [[Radiosity normal map]]
 +
* [[Texture Baking]]
 +
* [[Vector displacement map]]
  
Even though only one person has been editing this page so far, the information here was gathered from many different sources. We wish to thank all the contributors for their hard-earned knowledge. It is much appreciated!
 
  
 
----
 
----
 
[[Category:TextureTypes]] [[Category:Bump map]]
 
[[Category:TextureTypes]] [[Category:Bump map]]

Revision as of 14:22, 3 March 2016

What is a Normal Map?

A normal map is an image that stores a direction at each pixel. These directions are called normals.

The red, green, and blue channels of the image are used to control the direction of each pixel's normal.

A normal map is commonly used to fake high-resolution details on a low-resolution model. Each pixel of the map stores the surface slope of the original high-res mesh at that point. This creates the illusion of more surface detail or better curvature. However, the silhouette of the model doesn't change.

There are two basic methods to create normal maps. These methods can also be used together.

  1. 3D modeling and baking
  2. 2D painting and conversion

3D Workflow

The 3D workflow varies for each artist. See the following links for more information. In time this info will be condensed onto the wiki.


High-Poly Modeling


Low-Poly Modeling


Texture Coordinates


Triangulation


Mirroring & Duplicating Parts


Baking Tools

Projection Errors


Editing Maps


2D Workflow

Normal maps can be made in 2D painting software, without modeling in 3D. You can convert photo textures into normal maps, create node-based graphs to compile normal maps, or even hand-paint them with brushes.

Normal maps created in 2D work best when tiled across 3D models that have a uniform direction in tangent space, like terrains or walls. On these models the UVs are not rotated; they are all facing roughly in the same direction. To get seamless lighting, rotated UVs require specific gradients in the normal map, which can only be created properly by baking a 3D model.

A normal map baked from a high-poly mesh will often be better than one sampled from a texture, since you're rendering from a highly detailed surface. The normal map pixels will be recreating the surface angles of the high-poly mesh, resulting in a very believable look. A hybrid approach can be used by baking large and mid-level details from a high-poly mesh, and combining these with painted or photo-sourced "fine detail" for fabric weave, scratches, pores, etc.

Most image conversion tools assume the input is a heightmap, where black is low and white is high. If you try to convert a color texture that you've painted, the results are often very poor.


Flat Color

The color (128,128,255) creates normals that are completely perpendicular to the polygon, as long as the vertex normals are also perpendicular. Remember a normal map's per-pixel normals create offsets from the vertex normals. If you want an area in the normal map to be flat, so it creates no offsets from the vertex normals, then use the color (128,128,255).

This becomes especially obvious when mirroring a normal map and using a shader with a reflection ingredient. Reflection tends to accentuate the angles between the normals, so any errors become much more apparent.

Mirrored normal maps show a seam when (127,127,255) is used for the flat color; 128 is better.
Image by Eric Chadwick

In a purely logical way, 127 seems like it would be the halfway point between 0 and 255. However 128 is the color that actually works in practice. When a test is done comparing (127,127,255) versus (128,128,255) it becomes obvious that 127 creates a slightly bent normal, and 128 creates a flat one.

This is because most game pipelines use unsigned normal maps. For details see the Polycount forum thread tutorial: fixing mirrored normal map seams.


Blending Normal Maps Together

Blending normal maps together is a quick way to add high-frequency detail like wrinkles, cracks, and the like. Fine details can be painted as a height map, then it can be converted into a normal map. Then this "details" normal map can be blended with a geometry-derived normal map.

Another use is to blend a high-frequency detail normal map overtop a lower-frequency one, for example on terrains, to get small details closeup and larger details in the distance.

Re-oriented Normal Mapping (RNM) is probably the most accurate method, and can be done in real-time. The Photoshop script Combine Normal by Vincent Callebaut uses this method, see the Polycount Forum thread Combine normal maps script for Photoshop. A full explanation is described on the page Blending in Detail - Self Shadow.

Below is a comparison of four other blending methods. Note that in these examples the default values were used for CrazyBump (Intensity 50, Strength 33, Strength 33), but the tool allows each layer's strength to be adjusted individually for stronger or milder results. Each of the normal maps below were re-normalized after blending.

Nrmlmap blending methods Maps.png Nrmlmap blending methods RTTNormalMapFX.png
The blended normal maps.
Image by Eric Chadwick
Screenshot of the 3dsmax viewport, using the RTTNormalMap.fx shader.
Image by Eric Chadwick

The four blending methods used above:

  1. CrazyBump by Ryan Clark blends normal maps together using calculations in 3D space rather than just in 2D. This does probably the best job at preserving details, and each layer's strength settings can be tweaked individually.
  2. Combining Normal Maps in Photoshop by Rod Green blends normal maps together using Linear Dodge mode for the positive values and Difference mode for the negative values, along with a Photoshop Action to simplify the process. It's free, but the results may be less accurate than CrazyBump.
  3. Making of Varga by Paul "paultosca" Tosca blends normal maps together using Overlay mode for the red and green channels and Multiply mode for the blue channel. This gives a slightly stronger bump than the Overlay-only method. Leo "chronic" Covarrubias has a step-by-step tutorial for this method in CG Bootcamp Combine Normal Maps.
  4. Normal Map Deepening by Ben "poopinmymouth" Mathis shows how to blend normal maps together using Overlay mode. CGTextures tutorial for the NVIDIA Photoshop filter by Scott Warren also shows how to create normalmaps using multiple layers (Note: to work with the Overlay blend mode each layer's Output Level should be 128 instead of 255, you can use the Levels tool for this).

The Getting good height from Nvidia-filter normalizing grayscale height thread on the Polycount forum has a discussion of different painting/blending options. Also see the 2D Normal Map Tools section for painting and conversion tools.


Pre-Created Templates

A library of shapes can be developed and stored for later use, to save creation time for future normal maps. Things like screws, ports, pipes, and other doo-dads. These shapes can be stored as bitmaps with transparency so they can be layered into baked normal maps.


Re-normalizing

Re-normalizing means resetting the length of each normal in the map to 1.

A normal mapping shader takes the three color channels of a normal map and combines them to create the direction and length of each pixel's normal. These normals are then used to apply the scene lighting to the mesh. However if you edit normal maps by hand or if you blend multiple normal maps together this can cause those lengths to change. Most shaders expect the length of the normals to always be 1 (normalized), but some are written to re-normalize the normal map dynamically (for example, 3ds Max's Hardware Shaders do re-normalize).

If the normals in your normal map are not normalized, and your shader doesn't re-normalize them either, then you may see artifacts on the shaded surface... the specular highlight may speckle like crazy, the surface may get patches of odd shadowing, etc. To help you avoid this NVIDIA's normal map filter for Photoshop provides an easy way to re-normalize a map after editing; just use the Normalize Only option. Xnormal also comes with a Normalize filter for Photoshop.

The re-normalize option in the NVIDIA filter.
Image by Scott Warren

Some shaders use compressed normal maps. Usually this means the blue channel is thrown away completely, so it's recalculated on-the-fly in the shader. However the shader has to re-normalize in order to recreate that data, so any custom normal lengths that were edited into the map will be ignored completely.


Ambient Occlusion into a Normal Map

If the shader doesn't re-normalize the normal map, an Ambient Occlusion Map can actually be baked into the normal map. This will shorten the normals in the crevices of the surface, causing the surface to receive less light there. This works with both diffuse and specular, or any other pass that uses the normal map, like reflection.

However it's usually best to keep the AO as a separate map (or in an alpha channel) and multiply it against the ambient lighting only. This is usually done with a custom shader. If you multiply it against the diffuse map or normal map then it also occludes diffuse lighting which can make the model look dirty. Ambient occlusion is best when it occludes ambient lighting only, for example a diffusely convolved cubemap.

AO can be baked into a normal map, shortening the normals (lower left model).
Model by James Ku

To bake the AO into a normal map, adjust the levels of the AO layer first so the darks only go as low as 128 gray, then set the AO layer to Darken mode. This will shorten the normals in the normalmap, causing the surface to receive less light in the darker areas.

This trick doesn't work with any shaders that re-normalize, like 3ds Max's Hardware Shaders. The shader must be altered to actually use the lengths of your custom normals; most shaders just assume all normals are 1 in length because this makes the shader code simpler. Also this trick will not work with most of the common normal map compression formats, which often discard the blue channel and recalculate it in the shader, which requires re-normalization.


Back Lighting Example

You can customize normal maps for some interesting effects. If you invert the blue channel of a tangent-space map, the normals will be pointing to the opposite side of the surface, which can simulate backlighting.

Tree front.jpg Tree back.jpg
Tree simulating subsurface scattering (front view).
Image by Eric Chadwick
Tree simulating subsurface scattering (back view).
Image by Eric Chadwick
Tree maps.jpg
The maps used for the leaves. The 2nd diffuse was simply color-inverted, hue-shifted 180°, and saturated.
Image by Eric Chadwick

The tree leaves use a shader than adds together two diffuse maps, one using a regular tangent-space normal map, the other using the same normal map but with the blue channel inverted. This causes the diffuse map using the regular normal map to only get lit on the side facing the light (front view), while the diffuse map using the inverted normal map only gets lit on the opposite side of the leaves (back view). The leaf geometry is 2-sided but uses the same shader on both sides, so the effect works no matter the lighting angle. As an added bonus, because the tree is self-shadowing the leaves in shadow do not receive direct lighting, which means their backsides do not show the inverted normal map, so the fake subsurface scatter effect only appears where the light directly hits the leaves. This wouldn't work for a whole forest because of the computational cost of self-shadowing and double normal maps, but could be useful for a single "star" asset, or if LODs switched the distant trees to a model that uses a cheaper shader.


2D Normal Map Tools


Older Tutorials

A word of warning: There is a huge amount of misinformation about normal mapping on the web. It is best to assume all tutorials are incorrect, until you can verify the results yourself with your own tools and models.

More Information



Personal tools
Namespaces

Variants
Actions
Navigation
Tools