OpenGL轮廓和折痕渲染
我想用OpenGL渲染大纲 +折痕,但这并不是我想要的。有人可以帮我解决这个问题吗? 到目前为止,大纲是这样渲染的。
此刻我正在做的是: 弗里斯特我这样做:
GL.Enable(EnableCap.PolygonOffsetFill);
GL.PolygonOffset(0, -1f);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
GL.DepthFunc(DepthFunction.Lequal);
GL.DrawArrays(PrimitiveType.Triangles, 0, verticesList.Count);
GL.Disable(EnableCap.PolygonOffsetFill);
然后我再次呈现这样的渲染:
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
GL.LineWidth(5f);
GL.DepthFunc(DepthFunction.Less);
GL.DrawArrays(PrimitiveType.Triangles, 0, verticesList.Count);
我也想渲染那些绿线:
填充形状上的线框看起来像:
提前致谢!
I want to render the outlines + creases with opengl but it's not going as I wish. Can someone, please help me to solve this problem?
So far the outline it's rendered like this.
At this moment what I'm doing is:
Frist I do this:
GL.Enable(EnableCap.PolygonOffsetFill);
GL.PolygonOffset(0, -1f);
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
GL.DepthFunc(DepthFunction.Lequal);
GL.DrawArrays(PrimitiveType.Triangles, 0, verticesList.Count);
GL.Disable(EnableCap.PolygonOffsetFill);
Then I render again like this:
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
GL.LineWidth(5f);
GL.DepthFunc(DepthFunction.Less);
GL.DrawArrays(PrimitiveType.Triangles, 0, verticesList.Count);
I want to render those green lines as well:
The wireframe over the filled shape looks like this:
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@rabbid76是对的。
但是有很多方法可以实现它:
大纲:
大纲可以通过OpenGL中的另一个通行证渲染器(您会在此找到许多教程)
折痕
您所说的“折痕”也称为“尖锐边缘”,您可能需要在不同的网格上渲染它们。
如果您可以访问网格拓扑(这意味着不同的面/顶点/边缘之间的连接),则很容易进行。
为此,您可以:
(我从未测试过第二种方法,这似乎有点过分杀伤,但最终只会有一个网格)
这将是第一个实现的结果:
@Rabbid76 is right.
there are many ways to achieve it though :
Outlines :
The outline can be renderer via another pass in OpenGL (you'll find many tutorial on this)
Creases
What you call "crease" is also known as "sharp edges" and you may need to render them on different mesh.
It is quite easy to go about it if you have access to your mesh topology (meaning the connectivity between your different faces/vertices/edges).
For that you could either :
(I never tested this second method, it would seem a little overkill, but you'll end up with only one mesh)
this would be a result for the first implementation :
您无法使用
gl.polygonmode(材料face.frontandback,polygonmode.line);
来实现此目标。polygonmode.line
模式不会呈现网格的轮廓,而是构图的大纲(三角形)。没有任何功能会立即为您提供您想要的东西。如果要在坚固的网格上绘制这些线,则需要禁用深度测试并使用线原始。您可以为此几何使用相同的顶点坐标,但是必须以不同的顺序绘制它们。 OpenGL只是图形驱动程序实现的低级API,可让您访问GPU,但这不是渲染,游戏或CAD引擎。您必须实现引擎,并且可以使用OpenGL进行操作。You cannot achieve this with
GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
. ThePolygonMode.Line
mode does not render the outlines of the mesh, but the outlines of the primitives (triangles). There is no feature that will give you what you want right away. If you want to draw these lines on a solid mesh, you need to disable the depth test and create a separate geometry with Line primitives. You can use the same vertex coordinates for this geometry, but you must draw them in a different order. OpenGL is just a low-level API implemented by the graphics driver that gives you access to the GPU, but it's not a render, game, or CAD engine. You have to implement the engine and you can do it with OpenGL.