ios - Texture lookup in vertex shader behaves differently on iPad device vs iPad simulator - OpenGL ES 2.0 -


i have vertex shader in texture lookup determine gl_position. using part of gpu particle simulation system, particle positions stored in texture.

it seems that: vec4 texturevalue = texture2d(datatexture, vec2(1.0, 1.0)); behaves differently on simulator ipad device. on simulator, texture lookup succeeds (the value @ location 0.5, 0.5) , particle appears there. however, on ipad texture lookup returning 0.0, 0.0.

i have tried both textures of format gl_float , gl_unsigned_byte.

has else experienced this? glsl es spec says texture lookups can done in both vertex , fragment shaders, don't see problem is.

i using latest gm beta of ios sdk 4.2

i tested well. using ios 4.3, can texture lookup on vertex shader on both device , simulator. there bit of strangeness though (which maybe why it's not "official" szu mentioned). on actual device (i tested on ipad 2) have lookup on fragment shader on vertex shader. is, if not using on fragment shader, you'll still have reference in way. here's trivial example i'm passing in texture , using red pixel reposition y value of vertex little bit:

/////fragment shader uniform sampler2d tex; //necessary though not used  void main() {   vec4 notused = texture2d(tex, vec2(0.0,0.0)); //necessary though not used   gl_fragcolor = vec4(1.0,1.0,1.0,1.0); }  /////vertex shader attribute vec4 position; attribute vec2 texcoord;    uniform sampler2d tex;   void main() {   float offset = texture2d(tex, texcoord).x;   offset = (offset - 0.5) * 2.0; //map 0->1 -1 +1   float posx = position.x;   float posy = position.y + offset/8.0;    gl_position = vec4(posx, posy, 0.0, 1.0);   } 

i have fuller write-up of @ http://www.mat.ucsb.edu/a.forbes/blog/?p=453


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -