如何在 WPF 3D 中使用顶点处的值对网格着色?

发布于 2024-08-31 09:53:12 字数 360 浏览 3 评论 0原文

我们有一个球体,我们想要以 3D 方式显示它,并给定一个依赖于球坐标的函数。

使用 (theta, phi) 中的规则网格对球体进行三角测量,但这会在两极附近产生许多小三角形。为了减少极点处的三角形数量,我们更改了网格生成以在表面上生成更均匀大小的三角形。

第一种三角测量方法的优点是我们可以轻松创建纹理并将其覆盖在表面上。似乎在 WPF 中不可能像在 OpenGL 或 Direct3D 中那样为顶点分配颜色。

使用第二种三角测量方法,如何生成纹理和设置纹理坐标并不明显,因为顶点不再与网格对齐。

也许可以创建一个包含每个顶点颜色的线性纹理,但这将如何影响着色呢?通过应用每个顶点着色,它仍然会像人们所期望的那样在三角形表面上平滑地渲染吗?

We've got a sphere which we want to display in 3D and color given a function that depends on spherical coordinates.

The sphere was triangulated using a regular grid in (theta, phi), but this produced a lot of small triangles near the poles. In an attempt to reduce the number triangles at the poles, we've changed out mesh generation to produce more evenly sized triangles over the surface.

The first triangulation method had the advantage that we could easily create a texture and drape it over the surface. It seems that in WPF it isn't possible to assign colors to vertices the way one would go about in OpenGL or Direct3D.

With the second triangulation method it isn't apparent how to go about generating the texture and setting the texture coordinates, since the vertices aren't aligned to a grid any more.

Maybe it would be possible to create a linear texture containing a color for each vertex, but then how will that effect the coloring? Will it still render smoothly over the triangle surfaces as one would expect by applying per vertex coloring?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

糖果控 2024-09-07 09:53:12

我已经将算法转换为使用线性纹理,这实际上只是对颜色图的查找。这似乎很有效,并且是比前一个更好的解决方案。我现在只创建 256 x 1 的固定纹理,而不是创建大小为 ThetaSamples * PhiSamples 的纹理。

I've converted the algorithm to use a linear texture which is really just a lookup into the colormap. This seems to work great and is a much better solution than the previous one. Instead of creating a texture of size ThetaSamples * PhiSamples, I'm now only creating a fixed texture of 256 x 1.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文