梯度和记忆
我正在使用 OpenGL 创建一个绘图应用程序。我创建了一种生成渐变纹理的算法。然后我将它们映射到我的多边形上,效果非常好。我意识到这需要多少内存。创建 1000 个渐变大约需要 800MB,这太多了。是否有纹理的替代方法,或者压缩纹理的方法,或者将渐变映射到不占用太多内存的多边形的另一种方法?
谢谢
我的多边形是凹的,我使用 GLUTesselator,它们是多色的并且是点对点的
I'm creating a drawing application with OpenGL. I'v created an algorithm that generates gradient textures. I then map these to my polygons and this works quite well. What I realized is how much memory this requires. Creating 1000 gradients takes about 800MB and that's way too much. Is there an alternative to textures, or a way to compress them, or another way to map gradients to polygons that doesn't use up as much memory?
Thanks
My polygons are concave, I use GLUTesselator, and they are multicolored and point to point
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的...渐变在 OpenGL 中非常容易实现;你根本不需要纹理。在这里凭记忆工作...您只需执行以下操作:
如果更改顶点的颜色,它只会在这两点之间创建渐变。
Yes... gradients are super easy to do in OpenGL; you don't need textures at all. Working from memory here... you'd just do something like this:
If you change the color of a vertex, it just creates a gradient between those two points.
您还可以尝试在片段着色器内按程序生成渐变。
如果您采用纹理压缩路径,则可以使用glCompressedTexImage2D,压缩纹理格式是通过GL扩展提供的,常见的是S3TC/DXT1。
You can also try generating gradients procedurally inside a fragment shader.
If you go via the texture compression path, you can use glCompressedTexImage2D, compressed texture formats are provided via GL extensions, a common one is S3TC/DXT1.