MeshLab:使用我自己计算的法线渲染 obj 文件
我正在尝试编写一个带有顶点的 obj 文件。我正在计算代码中的顶点法线并写入该文件。当我尝试在 Meshlab 中渲染此文件时,它会正确读取顶点,但是当我转到“渲染 -> 显示顶点法线”时,它不会显示我计算的法线。相反,MeshLab 计算自己的法线并显示它们。
我不确定如何可视化我计算/写入文件的法线。我想稍后根据我计算的法线应用 Meshlab 着色器。
为了测试这一点,我创建了一个测试 obj 文件 -
vn 0.517350 0.517350 0.517350
v 0.500000 0.500000 0.500000
vn -0.333333 0.666667 0.666667
v -0.500000 0.500000 0.500000
vn 0.666667 -0.333333 0.666667
v 0.500000 -0.500000 0.500000
vn -0.666667 -0.666667 0.333333
v -0.500000 -0.500000 0.500000
f 1//1 2//2 3//3
f 4//4 3//3 2//2
这只是一个正方形。现在,如果我更改此文件中的法线值,当我选择“渲染->显示顶点法线”时,它仍然显示自己的顶点法线。 我怎样才能拥有自己的法线并应用适用于我的计算法线的着色器?请帮忙。
谢谢!!
I am trying to write a obj file with vertices. I am computing the vertex normals in my code and writing to this file as well. When I try to render this file in Meshlab it reads the vertices correctly, but when I go to 'Render->Show vertex normals', it is not showing the normals that I computed. Rather MeshLab computes its own normals and shows them.
I am not sure how I can visualize the normals that I computed/wrote to file. I want to apply Meshlab shader later based on my computed normals.
To test this I created a test obj file-
vn 0.517350 0.517350 0.517350
v 0.500000 0.500000 0.500000
vn -0.333333 0.666667 0.666667
v -0.500000 0.500000 0.500000
vn 0.666667 -0.333333 0.666667
v 0.500000 -0.500000 0.500000
vn -0.666667 -0.666667 0.333333
v -0.500000 -0.500000 0.500000
f 1//1 2//2 3//3
f 4//4 3//3 2//2
This is just one square. Now if I change the normal values in this file, it still shows its own vertex normals when I select 'Render->Show vertex normals'.
How can I have my own normals and apply shader that works on my computed normals?? Please help.
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
并非所有 OBJ 进口商都遵守常态。我发现这个旧错误似乎仍然存在,关于 MeshLab 如何忽略 OBJ 中的法线: http:// /sourceforge.net/p/meshlab/bugs/70/
您可能做的一切都是正确的,但问题可能不在您这边。
在处理网格交换时,由于各种软件的支持级别不同,网格交换可能会变得非常棘手,如果您经常这样做,那么使用多个 3D 应用程序来测试导出的数据会很方便。然后你可以更快地确定问题是在你这边还是他们那边。
如果您绝对需要对象在损坏的导入器上正确显示并且无法使用其他格式,则一种解决方法是手动取消焊接(复制)顶点以提供那些尖锐的折痕/硬边缘。这不会为您提供与任意指定法线一样多的自由度,但它允许您保留那些不连续的边界,其中区域不应平滑插值,而应有折痕。
Not all OBJ importers respect normals. I found this old bug which appears to still be open about how MeshLab's ignores normals in OBJs: http://sourceforge.net/p/meshlab/bugs/70/
You might be doing everything correctly but the issue may not be on your side.
When dealing with mesh interchange which can get quite hairy because of the different levels of support in various software, it's handy if you are doing it a lot to have multiple 3D applications to test your exported data against. Then you can more quickly figure out if the problem is on your side or theirs.
One workaround if you absolutely need the object to display correctly against a broken importer and can't use other formats is to manually unweld (duplicate) the vertices to give you those sharp creases/hard edges. That won't give you as much freedom as arbitrarily specifying normals, but it'll allow you to preserve those discontinuous boundaries where regions should not be smoothly interpolated and instead have a crease.
看起来今天(2019 年)这个问题已经在 meshlab 中解决了。
在下图中,您可以看到原始 .obj 文件(左)和一个更改法线方向的修改版本(右)。正常情况已如预期发生变化。
It seem than today (2019) the problem is solved in meshlab.
In the image below you can see your original .obj file (left), and one modified version changing the orientation of a normal (right). The normal has changed as expected.