使用 OpenGL 的多边形渐变

发布于 2024-08-30 20:51:34 字数 92 浏览 1 评论 0原文

我想知道如果我正在制作多边形,如何创建具有多个停止点和方向的渐变。现在我正在通过更改顶点的颜色来创建渐变,但这有限制。还有其他方法可以做到这一点吗?

谢谢

I'm wondering how I could create a gradient wuth multiple stops and a direction if I'm making polygons. Right now I'm creating gradients by changing the color of the verticies but this is limiting. Is there another way to do this?

Thanks

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

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

发布评论

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

评论(3

不气馁 2024-09-06 20:51:34

您可能拥有的一种选择是渲染一个带有纹理渐变的简单多边形,然后使用该多边形来纹理化您的实际多边形。

然后,您可以旋转源多边形,并且任何带有其图像纹理的物体也会旋转其渐变,而不会改变实际的几何形状。

One option you may have is to render a simple polygon with a gradient to a texture, which you then use to texture your actual polygon.

Then you can rotate the source polygon and anything textured with its image will have its gradient rotate as well, without the actual geometry changing.

独木成林 2024-09-06 20:51:34

最灵活的方法可能是使用所需的渐变创建纹理,然后将其应用到几何体。

The most flexible way is probably to create a texture with the gradient you want, and then apply that to your geometry.

巷雨优美回忆 2024-09-06 20:51:34

如果您使用着色器,您可以将顶点世界位置传递到顶点着色器中,它们将插入到片段着色器中,因此对于每个片段,您将获得它在世界空间中的位置(当然您可以使用任何空间)。然后只需选择任何传递函数来将该值更改为颜色即可。您可以使用 b 样条线或片段着色器中的任何内容来创建任何类型的复杂算法。

If you're using a shader, you can pass your vertex world positions into your vertex shader and they'll interpolate to your fragment shader, so for every fragment, you'll get where it is in world-space (of course you can use any space). Then it's just a matter of choosing whatever transfer function to change that value to a color. You can make any kind of elaborate algorithm using b-splines or whatever in your fragment shader.

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