Blender如何计算顶点法线? [英] How does Blender calculate vertex normals?

查看:747
本文介绍了Blender如何计算顶点法线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试计算各种游戏资产的顶点法线.我计算出的法线用于膨胀"模型(以在真实模型后面绘制,以产生粗轮廓).

I'm attempting to calculate vertex normals for various game assets. The normals I calculate are used for "inflating" the model (to draw behind the real model producing a thick outline).

我目前计算每张脸的法线并将它们平均化(有关Stack Overflow的其他几个问题也建议采用这种方法).但是,这不适用于像这样的尖角(相邻面孔的法线用橙色标记,我要计算的法线用绿色勾勒出轮廓).

I currently compute the normal for each face and average all of them (several other questions on Stack Overflow suggest this approach). However, this doesn't work for sharp corners like this one (adjacent faces' normals marked in orange, the normal I'm trying to calculate is outlined in green).

该对象看起来像一个小基座,我们在看左前角.有三个相邻的面(底面不可见;其法线指向正下方).

The object looks like a small pedestal and we're looking at the front-left corner. There are three adjoining faces (the bottom face isn't visible; its normal points straight down).

Blender计算出一个极好的法线,该法线正好位于三个面的法线的中间.似乎以某种方式计算出的法线相对于三个面法线中的每个法线具有最小的旋转.当对四边形进行不同三角剖分时,Blender的法线也不会改变.

Blender computes an excellent normal that lies squarely in the middle of the three faces' normals; it seems like it somehow calculates a normal that has minimum rotation to each of the three face normals. Blender's normal also doesn't change when the quads are triangulated differently.

平均人脸的法线会给我一个不同的法线,该法线在Z轴上稍微指向上方(-0.45,-0.89,+ 0.08).用这种方法充气模型不会产生良好的轮廓,因为轮廓的底面向上移动并且不会包围原始模型.

Averaging the faces' normals gives me a different normal that points slightly upward in the Z-axis (-0.45, -0.89, +0.08). Inflating my model this way doesn't produce a good outline because the bottom face of the outline is shifted up and doesn't enclose the original model.

我试图查看Blender源代码,但是找不到我想要的东西.如果有人可以指出我在Blender源代码中的算法,我也会接受.

I attempted to look at the Blender source code but couldn't find what I was looking for. If anyone can point me to the algorithm in the Blender source, I'd accept that also.

推荐答案

通过曲面法线所连接的面的角度对其进行加权.这是表面渲染的一种常见做法(请参见此处的讨论: http://www.bytehazard.com/code/vertnorm.html ),并确保您的底面的权重大于两个倾斜的侧面的权重.我不知道Blender是否做不同的事情,但是您应该尝试一下.

Weight the surface normals by the angle of the faces where they join. It is a common practice in surface rendering (see discussion here: http://www.bytehazard.com/code/vertnorm.html), and will ensure that your bottom face is weighted stronger than the two slanted side faces. I don't know if Blender does it differently, but you should give it a try.

这篇关于Blender如何计算顶点法线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆