2

我正在尝试将几何着色器移植回 OpenGL 2.1 (GLSL 1.2) 顶点着色器。在替换了编译器抱怨的所有代码后,它给了我另一个错误:

顶点着色器纹理采样器太多

所以我向 GL 查询了允许的最大值,这就是我得到的:

GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:0 GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB:0

这可能意味着顶点着色器中不允许使用纹理。

这只是我的硬件/驱动程序的限制还是 OpenGL2.1/GLSL1.2 要求的?

4

1 回答 1

5

Having successfully used vertex texturing on OpenGL 2.1 hardware, I can confirm that this is a mere hardware/driver limitation. Those constants wouldn't make much sense if OpenGL 2.1/GLSL 1.20 would completely disallow the possiblity of vertex textures in the first place.

EDIT: As a more objective proof of the above, the OpenGL Shading Language 1.10 Specification (corresponding to OpenGL 2.0) says in section 8.7 Texture Lookup Functions:

Texture lookup functions are available to both vertex and fragment shaders.

And the OpenGL 2.0 Specification itself says in section 2.15.4 Vertex Shaders - Shader Execution:

Vertex shaders have the ability to do a lookup into a texture map, if supported by the GL implementation. The maximum number of texture image units available to a vertex shader is MAX_VERTEX_TEXTURE_IMAGE_UNITS; a maximum number of zero indicates that the GL implemenation does not support texture accesses in vertex shaders.

于 2012-11-28T13:18:47.267 回答