Opengl Fullscreen Resolution Error

 ̄綄美尐妖づ 提交于 2019-12-07 07:26:25

Your problem has to do with sampling texels at the wrong position.

You want to sample at the center of each texel to avoid interpolation, but that does not happen if you naively use the range [0.0, 1.0]. This is because 0.0 is on the edge of your image, it is equally close to the center of the first texel as it is the center of the last texel on the other side of the texture (when using the default GL_REPEAT wrap mode).

The following diagram illustrates this problem on a 1D texture:

  http://i.msdn.microsoft.com/dynimg/IC83860.gif

You actually need to divide your coordinates into the range: [1.0 / (2.0 * N), 1.0 - 1.0 / (2.0 * N)]

This should be achievable if you re-write your coordinates this way:

(subx + 0.5)/texWidth, (suby + 0.5)/texHeight

Baiscally you just need a half-texel shift, and then your problem will go away.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!