I have a vertex shader in which I do a texture lookup to determine gl_Position. I am using this as part of a GPU particle simulation system, where particle positions are stored in a texture.
It seems that: vec4 textureValue = texture2D(dataTexture, vec2(1.0, 1.0)); behaves differently on the simulator than the iPad device. On the simulator, the texture lookup succeeds (the value at that location is 0.5, 0.5) and my particle appears there. However, on the iPad itself the texture lookup is constantly returning 0.0, 0.0.
I have tried both textures of the format GL_FLOAT and GL_UNSIGNED_BYTE.
Has anyone else experienced this? The GLSL ES spec says that texture lookups can be done in both the vertex and fragment shaders, so I don’t see what the problem is.
I am using the latest GM Beta of iOS SDK 4.2
I just tested this as well. Using iOS 4.3, you can do a texture lookup on the vertex shader on both the device and the simulator. There is a bit of strangeness though (which is maybe why it’s not “official” as szu mentioned). On the actual device (I tested on the iPad 2) you have to do a lookup on the fragment shader as well as on the vertex shader. That is, if you are not actually using it on the fragment shader, you’ll still have to reference it in some way. Here’s a trivial example where I’m passing in a texture and using the red pixel to reposition the y value of the vertex by a little bit:
I have a slightly fuller write-up of this at http://www.mat.ucsb.edu/a.forbes/blog/?p=453