带 DXT5 压缩纹理的 Alpha 通道
我在 OS X 上使用 OpenGL 编写了一个测试程序,该程序加载 PNG,使用 libsquish (http://code.google.com/p/libsquish/) 将其在内存中压缩为 DXT5,并为平面提供纹理。
当我上传包含 Alpha 通道的图像,但没有像素具有除完全不透明以外的 Alpha 值时,它会正确显示: https://i.sstatic.net/WlRcD.png
给定相同的图像,但黑色部分被透明替换,这是我得到的输出:https://i.sstatic.net/wOPqA.png
代码不漂亮,它是一个抛出的错误概念证明:
- C++ 源代码:http://pastebin.com/m0RqpgUS
- 顶点着色器:http://pastebin.com/QyaWCaTk
- 片段着色器:http://pastebin.com/KEuFJ83C
- 测试图像:http://dl.dropbox.com/u/4597377/images.zip
任何想法?
I've written a test program using OpenGL on OS X that loads a PNG, compresses it in memory to DXT5 using libsquish (http://code.google.com/p/libsquish/), and textures a plane.
When I upload an image that contains an alpha channel, but no pixels have alpha values other than fully opaque, it displays correctly: https://i.sstatic.net/WlRcD.png
Given the same image but the black part is replaced with transparency, this is the output I get: https://i.sstatic.net/wOPqA.png
The code is not pretty, it is a thrown together proof of concept:
- The C++ source: http://pastebin.com/m0RqpgUS
- The vertex shader: http://pastebin.com/QyaWCaTk
- The fragment shader: http://pastebin.com/KEuFJ83C
- The test images: http://dl.dropbox.com/u/4597377/images.zip
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
原来我忘记了这一点:
Turns out I forgot this: