OpenGL 纹理图像模糊
我正在尝试创建一个代表海拔的 mipmap 纹理图像。图像必须为 940 x 618。我意识到我的纹理的宽度和高度必须为 2 的幂。到目前为止,我已尝试逐步完成正方形中的所有纹理(例如 64 x 64 或 128 x 128,甚至 512 x 512),但图像仍然模糊。知道如何更好地纹理这种尺寸的图像吗?
I am trying to create a mipmapped textured image that represents elevation. The image must be 940 x 618. I realize that my texture must have a width and height of a power of 2. As of now I have tried to incrementally go through doing all my texturing in squares (eg 64 x 64, or 128 x 128, even 512 x 512), but the image still comes out blurry. Any idea of how to better texture an image of this size?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 1024x1024 纹理并将图像放入图像 940x618 的一部分中。然后使用值 940.0/1024.0 和 618.0/1024.0 作为最大纹理坐标,或缩放
TEXTURE_MATRIX
。这将为您的像素进行 1:1 映射。您可能还需要将模型移动半个像素以获得完美拟合,这取决于您的模型设置和视图。这是我为 Mac 制作的屏幕保护程序中使用的技术。 http://memention.com/void/ 它抓取屏幕内容并将其用作某些 3D 上的纹理效果,我真的想要像素完美契合。
Use a 1024x1024 texture and put your image in just a part of the image, 940x618. Then use the values 940.0/1024.0 and 618.0/1024.0 for the max texture coordinates, or scale the
TEXTURE_MATRIX
. This will make a 1:1 mapping for your pixels. You might also need to shift the model half a pixel to get a perfect fit, this depends on your model setup and view.This is the technic I used in this screensaver I made for the Mac. http://memention.com/void/ It grabs the screen contents and uses it as a texture on some 3D effects and I really wanted a pixel perfect fit.
据我所知,现代技术并不要求你使用 2 的幂作为你的维度。但请注意,如果此代码在较旧的计算机上运行,您将会遇到一些问题。你的机器有多少年了?
As far as I know, modern technologies do not require you to use a power of 2 for your dimensions. Just know however, that if this code is run an older machine, you'll have some problems. How old is your machine?
纹理可能未按 1:1 映射,并且您有 GL_LINEAR 或 GL_NEAREST 过滤。尝试更高分辨率的纹理、mipmap 和 1:1 屏幕映射。
The texture is probably not mapped 1:1, and you have GL_LINEAR or GL_NEAREST filtering. Try higher resolution texture, mipmapping, and 1:1 screen mapping.
使用 940x618 大小的纹理(如果这确实是其所应用的表面的大小)并将纹理的缩小/放大设置为使用 GL_LINEAR。这应该会给你你想要的结果。
Use a 940x618 sized texture (if this is truly the size of the surface it's applied to) and set the texture's minification/magnification to use GL_LINEAR. That should give you the results you're after.