您可以按如下方式计算两条边之间的角度:
given: edge vectors E and F for a given face of your vertex,
E_normalized = normalize(E)
F_normalized = normalize(F)
cross_normal = cross(E_normalized, F_normalized)
sin_theta = length( cross_normal )
cos_theta = dot(E_normalized, F_normalized)
results:
face normal = normalize(cross_normal)
face angle theta = atan2(sin_theta, cos_theta)
Run Code Online (Sandbox Code Playgroud)
然后,相应地对法线进行加权:
total_vector = vec(0,0,0)
for(each face adjacent to a particular vertex):
[compute normal and theta as above]
total_vector += normal * theta
return normalize(total_vector)
Run Code Online (Sandbox Code Playgroud)
为了实时优化,我首先会进行分析,看看到底是什么导致速度变慢。我猜想atan2()每个顶点计算几次可能会很昂贵,但对此进行改进确实需要找到角度加权法线的替代品。
| 归档时间: |
|
| 查看次数: |
420 次 |
| 最近记录: |