我正在尝试将我的纹理移动到像素的中心,如此处所述OpenGL Texture Coordinates in Pixel Space但我正在努力这样做。我们试图以纹理为中心的像素还是在屏幕上?我们如何访问它们?这是我的顶点着色器:
"uniform mat4 " + ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX + ";\n" +
"attribute vec4 " + ShaderProgramConstants.ATTRIBUTE_POSITION + ";\n" +
"attribute vec4 " + ShaderProgramConstants.ATTRIBUTE_COLOR + ";\n" +
"attribute vec2 " + ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES + ";\n" +
"varying vec4 " + ShaderProgramConstants.VARYING_COLOR + ";\n" +
"varying vec2 " + ShaderProgramConstants.VARYING_TEXTURECOORDINATES + ";\n" +
"void main() {\n" +
" " + ShaderProgramConstants.VARYING_COLOR + " = " + ShaderProgramConstants.ATTRIBUTE_COLOR + ";\n" +
" " + ShaderProgramConstants.VARYING_TEXTURECOORDINATES + " = " + ShaderProgramConstants.ATTRIBUTE_TEXTURECOORDINATES + ";\n" +
" gl_Position = " + ShaderProgramConstants.UNIFORM_MODELVIEWPROJECTIONMATRIX + " * " + ShaderProgramConstants.ATTRIBUTE_POSITION + ";\n" +
"}"
我是开放 GL 的新手,刚刚开始研究顶点着色器,所以任何建议或提示将不胜感激。
编辑:我遇到的问题是,我的纹理中的像素在缩放时会变形。普通纹理看起来不错,但是当它们在 4x4 矩阵(模型视图矩阵)上使用 scaleM 命令缩放时,看起来随机行和列中有两列或两行相同的像素。