标题: 'Normal Mapping'--法线贴图 [打印本页]
作者: 火柴盒 时间: 2008-4-25 11:40 标题: 'Normal Mapping'--法线贴图
'Normal Mapping'--法线贴图
'Normal Mapping'
by Misja Baas
原文链接:http://www.3dtotal.com/team/Tutorials_3/normal_mapping/normal_mapping01.asp
Normal mapping is a great way of showing more detail on a 3D model by simulating the way surface detail responds to light. It is a 2D effect so it will not change the shape of an object, but inside the profile outlines it can simulate a tremendous amount of extra detail. This is very useful for real time game engines where processing power is a limiting factor or animations where it’s render time that can be the limiting factor.
(法线贴图是一种显示三维模型更多细节的重要方法,它解算了模型表面因为灯光而产生的细节。这是一种2维的效果,所以它不会改变模型的形状,但是它计算了轮廓线以内的极大的额外细节。在处理能力受限的情况下,这对实时游戏引擎是非常有用的,另外当你渲染动画受到时间限制时,它也是及其有效的解决办法。)
Original and normal mapped object.(原始物体和法线贴图物体)
Normal mapping is not new but with the latest graphics cards it’s become more and more affordable. It’s very similar to bump mapping in that they both achieve the same effect.However, bump mapping simulates vertical offsets relative to the face direction it’s projected on, new directions are a result of the height differences between neighboring pixels. Normal mapping on the other hand uses colors to indicate directional offsets, making it far more efficient. It doesn’t use it’s neighbors to determine it’s angle, a single pixel is enough. The red channel in a normal map encodes the left-right axis of normal blue channel encodes vertical depth.
(法线贴图不是什么新事物,但依赖与最新的显卡,它正变得越来越重要。要达到上图的效果,通过凹凸贴图也是很容易的事。但是,凹凸贴图仅仅解算在它相对于面投射方向的垂直偏移,新的方向是两个相邻像素之间高度差异的结果。法线贴图使用颜色来表述在其他方向的偏移,这使它更有效。它无需使用它相邻的像素来测定它的角度,一个单一的像素就足够了。法线贴图中的红色通道编码了法线的左右轴,蓝色通道编码了垂直深度。)
This makes for a pretty interesting image that is, unfortunately, impossible to paint properly by hand (unlike bump maps). Which means you have to generate a normal map, this is done in several ways, you can bake it, render it or convert a height/bump map.
(这些创造了一幅漂亮的图片,但不幸的是你不大可能用手来绘制合适的图(跟凹凸贴图不同)。这意味着你不得不生成一张法线贴图,有好几种方法可以做到,你可以烘培它,渲染它,或是从一张凹凸贴图转换而来。)
作者: 火柴盒 时间: 2008-4-25 11:41
Baking: (烘培)
--------------------------------------------------------------------------------
Baking is the process of capturing the surface detail of the source object and transferring it to the target object, During the baking of a normal map the software will compare the two surfaces and determine which colors are needed where on the target surface to compensate for the difference in shape between the two objects.
(烘培是将源物体上的表面细节捕捉并转化到目标物体的过程。在烘培法线贴图的过程中,软件将比较两个表面,并测定目标表面哪里需要哪种颜色,以补偿两个物体形态间的差异。)
Source object and the target object partially enclosing it.
(源物体和目标物体要尽量靠近)
Baking is done by casting rays from the low poly surface (also called target since it will ultimately receive the normal map) onto the high poly surface (also called source) , the direction of the rays is determined by the vertex normals, they can be cast in both directions, forward and backwards. If you have a smooth surface (or one smoothing group) the normals are “averaged”, when you have a hard edged surface the normals point in the direction of the face normal, i.e. straight up from the face.
(烘培是通过从低多边形物体表面(也叫目标物体,因为它最终将接受法线贴图)投射光线到高多边形表面(即源物体)来进行的,光线的方向通过定点的法线来确定,他们能被投射到多个方向,向前或向后。如果你有一个平滑的表面(或是一个光滑组),法线将被平均化。当你有一个硬边缘的表面,法线方向是垂直于表面向上的。)
This is an important difference to be aware of when you start baking because when your edges are hard the vertex normals for one face point in a different direction than the vertex normals of it’s neighbors meaning you get “blind spots” in the projection.
(当你开始烘培时,需要意识到这是很重要的区别,当你的边是硬边是,对一个面而言,点的法线是指向不同的方向的,而不是指向它相邻的点的法线,这意味着在光线发射的过程中你得到了“盲点”。)
Another thing to be aware of is in order to bake a map properly every single polygon that is going to be included in the bake needs to have it’s own space in the UV layout. You cannot have overlapping UV’s since the software will not know which of the faces you want to be used in the calculation and instead will draw them all at once.
(另一个需要注意的是,为了烘培出一张完整的贴图,每一个在烘培中包含进来单一的多边形都必须有自己独立的UV。不能出现UV重叠,因为软件不知道哪个面是你想用在解算中的,因而会一次性的绘制出来。)
Since the target surface is one big, very complex projector you should treat every face on it as if it where an inverse UV projector, sucking up the image instead of projecting it. By looking through a face on the target mesh, as if it where a window, you should be able to see every polygon on your source mesh pointing more or less in your direction. If a source poly is perpendicular to you, or pointing away from you, it won’t be captured on the normal map. Another thing to take into account is that you need to see enough of each source poly so it can be given enough pixels to clearly define it on the normal map.
(因为目标表面是一个大的,非常复杂的放射体,你需要处理它上面的每一个面,例如在那些uv投影反转的地方,会使图像凹进去而不是凸起来。通过察看目标网格上的一个面,比如窗户那里的面,你将可以看到在你源网格的每一个多边形或多或少的指向你的方向。如果源多边形和你的目光垂直相交,或是指向远离你的方向,此时是无法捕捉到法线贴图的。还有一个需要考虑的是对每个源多边形你需要看的足够大,这样才能获取足够的像素在法线贴图上定义它。)
Check projection directions and visible surface detail.
(检察发射方向和表面细节的可见性。)
All in all baking is the most time consuming method but it will also give you the best results. It’s worth it!
(总之,烘培是最耗时的方法,但它将给最好的效果。这是值得的!)
作者: 火柴盒 时间: 2008-4-25 11:42
Rendering: (渲染)
--------------------------------------------------------------------------------
Another way of making a normal map is by rendering it.
(另一种制作法线贴图的方法是渲染它)
Rendering a normal map can be done by applying a normal material on a surface. This material will, during render time, color the surface relative to the camera you’re rendering from. This method does not use a source and target mesh and is in a way like making a texture map. You model your surface detail as you would paint it in Photoshop, top down, with only relatively small directional changes, any polys perpendicular to the camera will of course not be visible and there for require their own little bit of space in render, just like a texture map.
(通过给一个表面指定法线材质,你可以渲染一个法线贴图出来。这个材质将在渲染时,从你摄像机的角度彩色化表面。这种方法无需使用源物体和目标物体,它是一种类似于制作纹理贴图的方法。你模型上表面细节就像你在PS里画的,从上到下,仅仅有轻微的方向变化,任何垂直与摄像机的多边形将是不可见的,在渲染中那里需要有轻微的空间上变化,就想纹理贴图一样。)
Converting a height/bump map:
(转化一个高度/凹凸贴图)
--------------------------------------------------------------------------------
Converting a black and white image can be done in Photoshop using the Nvidia Photoshop plugin, this allows you to paint a black and white image and encode it into a normal map. This is in a way similar to the render method and not suited for complex shapes. You can however use this method to add extra detail to a baked normal map like surface textures, stitching, scars, pocks etc. if you can’t be bothered to model everything down to the last millimeter.
(转换一张黑白图像可以通过在PS中使用Nvidia的PS插件来实现,这允许你绘制一行黑白图像并将其编码为一张法线贴图。对渲染方法而言这是一个相当简单的办法,但不适用于复杂的形体。但是你可以用这种方式来给烘培的法线贴图添加一些额外的细节,如表面纹理,缝纫,伤痕,杂点等等,如果你厌倦于建造小至1mm的每个细小东东的话。)
Some bake software will allow you to slap a bump map for this kind of detail on your source mesh and bake that with it which gives a much more accurate result.
(一些烘培软件允许你在你的源物体上为了类似的细节赋予一个凹凸贴图,并带图烘培,这将得到一个更精确的多的结果。)
You have to wonder if the resolution of your normal map will be able to display this kind of detail at all though.
(你不得不惊讶于法线贴图能显示这类的细节。)
One thing to bear in mind is that whenever you make a change to your normal map in Photoshop you will need to run the “normalize only” option in the Nvidia plugin. You need to do this because a normal map needs to be mathematically correct in order to work properly (this has got something to do with the dot product of combined pixel values, all very boring tech stuff and too in depth for this chapter)
(你需要记住的一件事是,无论何时在ps中你修改了法线贴图,你需要在Nvidia插件中运行“normalize only”(仅规格化)选项。这样做的目的在于法线贴图需要被正确的计算以便正常发挥作用(这涉及到复合像素值的点乘,一些非常令人厌烦的技术,在此就不深究了)。)
Tangent, Object- and World space:
(相切,物体空间和世界空间)
--------------------------------------------------------------------------------
The surface detail or offsets simulated by a normal map are always relative to either the polygon it’s projected on (tangent space) or the object’s orientation (object space) or the world (world space).
(通过法线贴图计算出的表面细节和偏移是总是相对于多边形的投影方向或是物体的自身轴向(物体空间)或是世界(世界空间)的。)
作者: 火柴盒 时间: 2008-4-25 11:43
Tangent space: (相切空间)
--------------------------------------------------------------------------------
Tangent space is computationally the most expensive one for real time game engines but also the most flexible one. It looks at each target face’s direction as defined by it’s vertex normals and calculates the new lighting solution by offsetting it with the information from the normal map. This is the only type of normal mapping that you can use on deformable objects such as skinned or boned characters. It also allows you tile your map or re-use elements of your mesh on other places, rotating and twisting these as you see fit. This is a great way of freeing up more texture space on your normal map.
(对实时游戏引擎来说,相切空间应该算是最有价值的,但也是最灵活的。它通过顶点法线所定义的方向察看每个目标面,然后根据来自法线贴图的信息通过补偿它来计算新的灯光效果。这是惟一一种能被用与可边形物体的法线贴图类型,例如被蒙皮和绑定骨骼的角色。它也允许你重复你的贴图或是重新使用其他地方的网格元素,旋转,扭曲他们直到你觉得合适为止。这是一个在你的法线贴图里添加更多纹理空间的好方式。)
Object space: (物体空间)
--------------------------------------------------------------------------------
An object space normal map only looks at the orientation of the entire model it’s applied on to calculate the per pixel directions on it’s surface. This is great for non-deformable objects like, say, barrels and crates. It will allow you to duplicate elements on your mesh as long as you do not change their orientation.
(一个物体空间的法线贴图,仅从整个模型的自身朝向检视物体,并据此解算在它表面的每个像素的方向。它非常适合没有变形的物体,例如枪炮,或是箱子。它允许你复制网格上的元素,就像你没有改变他们的朝向一样。)
When an object space normal map tells a face it’s supposed to receive light coming from the left of the object it will always do so, even if the face is pointing away from the light source.
(当一个物体空间的法线贴图告诉一个面,它被期望接受来自物体左边的光线,它就会这样做,即使这个面实际是指向光源的。)
World space: (世界空间)
--------------------------------------------------------------------------------
World space normal maps are great for objects that don’t ever move or deform like, say, the world.
(世界空间法线贴图适用于那些既不移动也不变形的东西,比如世界环境)
Tangent space (left) and object space (right) normal maps of the same cube.
(同一个方盒子物体的相切空间(左)和物体空间(右)法线贴图)
作者: 火柴盒 时间: 2008-4-25 11:44
Putting it into practice: (实践一下)
--------------------------------------------------------------------------------
Since this is not a character modeling tutorial I will not go into the authoring process of modeling a high poly character, one tip I can give you however and that is to work in small parts when working on the high poly mesh. This way you can limit the amount of polys per object you are working on, making it all a lot less painfull when your total polycount is reaching the 500.000 mark. For normal map generating purposes you don’t even have to attach and weld the different sub components together, as long as they fit seamlessly you should be fine.
(因为这不是一个角色建模的教程,所以我将不描述建造高模的过程,但我可以给你一个小提示,这将对你建模时的一些小细节有所帮助。这样你可以将手中每个物体的多边形限制在一定数量,当你总的多边形数量达到50万时,场景就变的不可绘制了。考虑到生成法线贴图的目的,你甚至无需将几个构成组件合并焊接起来,就像它们本身是无缝的一样。)
started out with a rough version of the low poly in game model (low is rather relative since it’s aimed at next gen platforms and these can easily deal with 6000-8000 poly character models, in any way it’s lower than the source mesh, so low poly is still apt.).
(我以一个游戏模型中的粗糙的低多边形开始(低是相对而言的,因为它是被用于次世代平台的,它们能轻易处理6000-8000个多边形的角色模型,不管如何,它们都比源网格低,所以这里说低多边形依然是恰当的。)
Making a rough low poly version helps you to get started and will give you an idea of where your detail should go and how you are going to capture it in the baking process.
(制作一个低多边形的版本能帮你开始,你能从中了解你要的细节究竟在哪里,你要如何在烘培中获取它们。)
This is of course not a rule and every method is valid as long as the end result is good.
(这当然并不是一个规则,只要结果是好的,任何方法都是正确的。)
Then I subdivided the organic components such as arms and legs and started working into them, I used a poly proxy object/mesh smoothing on the trousers using zig zag patterns to create the creases. The arms where imported into Z-Brush 2 for some quick soft wrinkling. Z-Brush is great for organic stuff, it can however be a bit tricky to get
used to it.
(然后我细分了组织器官,例如手臂和腿,并开始处理它们。
The head I modeled entirely in Z-Brush2 using Z-spheres. I later remodeled the low poly version in Maya to make sure I get the right edgeloops for facial animations.
The hard surface detail I kept fairly low poly compared to the rest, there’s no point in making your objects unnessecarily heavy, it will only slow you down and it makes it harder to reshape them when you feel like it. And you will want to do that, since you will find yourself going back and forth between your source and target meshes.
Like I said earlier, cut your model up in smaller manageable parts, this way you can keep focused and organized.
When the high poly version was finally ready I remodeled the entire low poly model from scratch snapping it’s vertices directly on the high poly model, of course you need to make sure you place them strategically, this can be a bit challenging when you also need to worry about your target mesh’s layout for deformation later. Another good reason to rough it out first.
Finished low poly model, 6611 polys
When your low poly model is finally finished you need to properly unwrap it, assessing each component and giving it the right amount of texture space. I generally give the face a bit more resolution since it is the main focal point on any character, I also decided to tile the ammo belt boxes since the detail was so fine it needed extra space on the map to capture all the tiny details. I did this by only baking a few boxes and then re-attaching the remaining boxes and
map them to the normal map. Of course duplicating the boxes is also possible but was in this case not the
fastest solution.
Then it’s time to start baking, interestingly there aren’t that many normal map baking plugins out there. For Maya there’s Turtle’s Surface Transfer Editor (which I used and it’s great) and Maya’s own proprietary tool (which is next to useless) then there’s also Microwave which ,allegedly, is also pretty good. Max 7 comes with it’s own pretty accomplished normal mapping tools and then there’s a bunch stand alone normal mapping tools such as Cry Tek’s Polybump and ATI’s normal mapping tool.
(现在是时候开始烘培了,有趣的是并没有许多法线贴图烘培插件开发出来。对于maya,有海龟的表面变换编辑器(Surface Transfer Editor ,我一直都用它,和maya自带的工具(这个就用的少了),还有 Microwave ,这个效果也不错。max7开始,就自带了相当好的法线贴图工具,还有独立的法线贴图软件,比如Cry Tek’s Polybump 以及ATI的法线贴图工具。)
No doubt all the other big packages out there have their own solutions for this but since I have no experience with them I can’t recommend anything.
(毫无疑问,其他所有的大型三维软件包对此都有自己的解决方案,但是因为我对它们没什么了解,所以我就不推荐任何东西了。)
Anyway, back to baking: this is when the errors start to appear, look out for extreme and hard edged color differences, these can be fixed by painting them away in Photoshop (use the “normalize only” option in Nvidia’s Photoshop plugin
before saving) or pushing the target mesh in or outward a bit, globally or locally. Don’t worry too much about ruining your low poly objects shape, you can always fix this later when the normal map is finished, it may not be entirely
accurate but no one’s gonna notice. Besides you are an Artiste right? Whatever you made was intentional, even the unintentional.
Final tangent space normal map for the character.
(最终得到的角色的相切空间的法线贴图。)
作者: 火柴盒 时间: 2008-4-25 12:38
Low poly character (left) and high poly character models.
(低多边形角色(左)和高多边形角色模型)
来源:译文3D网
欢迎光临 论坛 (http://bbs.cgtime.org/) |
Powered by Discuz! 7.0.0 |